[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203
Stephane Popinet
popinet at users.sf.net
Fri May 15 02:53:09 UTC 2009
The following commit has been merged in the upstream branch:
commit 9cd097151acd83aee7355e83888da9ac96e6974b
Author: Stephane Popinet <popinet at users.sf.net>
Date: Tue Mar 14 14:15:46 2006 +1100
New function gfs_solid_is_thin()
darcs-hash:20060314031546-d4795-0847fc49f3fce08cf7611b5f24af93e9e812a082.gz
diff --git a/doc/figures/thin.fig b/doc/figures/thin.fig
new file mode 100644
index 0000000..8b88477
--- /dev/null
+++ b/doc/figures/thin.fig
@@ -0,0 +1,151 @@
+#FIG 3.2 Produced by xfig version 3.2.5-alpha5
+Landscape
+Center
+Metric
+A4
+100.00
+Single
+-2
+1200 2
+2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 3600 450 4500 450 4500 1350 3600 1350 3600 450
+2 2 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 4950 450 5850 450 5850 1350 4950 1350 4950 450
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 4050 450 3600 900
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 5400 450 5400 1350
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 3600 3600 3825 3150
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 4275 3150 4500 3600
+2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 3600 5850 4500 5850 4500 6750 3600 6750 3600 5850
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
+ 3375 6075 3825 6300 3375 6525
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 3600 1800 4500 1800 4500 2700 3600 2700 3600 1800
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4050 1800 3600 2250
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4500 2250 4050 2700
+2 2 0 2 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 3600 3150 4500 3150 4500 4050 3600 4050 3600 3150
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 6300 3150 7200 3150 7200 4050 6300 4050 6300 3150
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 6300 3600 7200 3600
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 6750 3150 7200 3375
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 7650 3150 8550 3150 8550 4050 7650 4050 7650 3150
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 7650 3600 8100 3150
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 8775 3375 8325 3600
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 8325 3600 8775 3825
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 3600 4500 4500 4500 4500 5400 3600 5400 3600 4500
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4500 5175 4275 5400
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4500 4725 3825 5400
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 3600 4950 4050 4500
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 4950 4500 5850 4500 5850 5400 4950 5400 4950 4500
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 5850 4725 5400 4500
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4950 4950 5175 5400
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 5625 5400 5850 5175
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 3600 7200 4500 7200 4500 8100 3600 8100 3600 7200
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 3600 7875 4500 7875
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 3600 7425 4500 7425
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 4950 7200 5850 7200 5850 8100 4950 8100 4950 7200
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4950 7425 5175 7200
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4950 7875 5625 7200
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 6300 7200 7200 7200 7200 8100 6300 8100 6300 7200
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 3
+ 6525 6975 6750 7425 6975 6975
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 3
+ 6525 8325 6750 7875 6975 8325
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 3600 8550 4500 8550 4500 9450 3600 9450 3600 8550
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 3600 9000 4500 9000
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 3600 8775 3825 8550
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4275 8550 4500 8775
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4950 9000 5400 8550
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4950 8775 5175 8550
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 4950 8550 5850 8550 5850 9450 4950 9450 4950 8550
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 3
+ 5175 9675 5400 9225 5625 9675
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 6300 8550 7200 8550 7200 9450 6300 9450 6300 8550
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 3
+ 6525 8325 6750 8775 6975 8325
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 3
+ 6525 9675 6750 9225 6975 9675
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 3
+ 7425 8775 6975 9000 7425 9225
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 3600 9900 4500 9900 4500 10800 3600 10800 3600 9900
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 3600 10125 3825 9900
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 3825 10800 3600 10575
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4500 10575 4275 10800
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4275 9900 4500 10125
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 4950 9900 5850 9900 5850 10800 4950 10800 4950 9900
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 5400 9900 4950 10350
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4950 10125 5175 9900
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 5850 10350 5400 10800
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 5850 10575 5625 10800
+2 2 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 6300 9900 7200 9900 7200 10800 6300 10800 6300 9900
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 3
+ 6525 9675 6750 10125 6975 9675
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 3
+ 6075 10125 6525 10350 6075 10575
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 3
+ 6525 11025 6750 10575 6975 11025
+2 1 0 2 4 7 50 -1 -1 0.000 0 0 7 0 0 3
+ 7425 10125 6975 10350 7425 10575
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2
+ 4950 3600 5850 3600
+2 2 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 5
+ 4950 3150 5850 3150 5850 4050 4950 4050 4950 3150
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 3
+ 5175 2925 5400 3375 5625 2925
+4 0 0 50 -1 16 20 0.0000 4 255 2685 450 675 odd = 2 even = 0: \001
+4 0 0 50 -1 16 20 0.0000 4 255 2595 450 2025 odd = 4 even = 0:\001
+4 0 0 50 -1 16 20 0.0000 4 255 2595 450 3375 odd = 2 even = 1:\001
+4 0 0 50 -1 16 20 0.0000 4 255 2595 450 4725 odd = 2 even = 2:\001
+4 0 0 50 -1 16 20 0.0000 4 255 2595 450 6075 odd = 0 even = 1:\001
+4 0 0 50 -1 16 20 0.0000 4 255 2595 450 7425 odd = 0 even = 2:\001
+4 0 0 50 -1 16 20 0.0000 4 255 2595 450 8775 odd = 0 even = 3:\001
+4 0 0 50 -1 16 20 0.0000 4 255 2595 450 10125 odd = 0 even = 4:\001
+4 0 4 50 -1 16 20 0.0000 4 255 1200 9450 6075 red: thin\001
+4 0 0 50 -1 16 20 0.0000 4 255 1665 9450 6525 black: thick\001
diff --git a/src/solid.c b/src/solid.c
index b2abda9..b1726f7 100644
--- a/src/solid.c
+++ b/src/solid.c
@@ -221,6 +221,42 @@ static void triangle_face_intersection (GtsTriangle * t, CellFace * f)
}
}
+static void face_new (CellFace * f, FttCell * cell, GtsSurface * s, FttVector * h)
+{
+ FttVector p;
+
+ ftt_cell_pos (cell, &p);
+ f->p[0].x = p.x - h->x/2.; f->p[0].y = p.y - h->y/2.; f->p[0].z = 0.;
+ f->p[1].x = p.x + h->x/2.; f->p[1].y = p.y - h->y/2.; f->p[1].z = 0.;
+ f->p[2].x = p.x + h->x/2.; f->p[2].y = p.y + h->y/2.; f->p[2].z = 0.;
+ f->p[3].x = p.x - h->x/2.; f->p[3].y = p.y + h->y/2.; f->p[3].z = 0.;
+ f->x[0] = f->x[1] = f->x[2] = f->x[3] = 0.;
+ f->n[0] = f->n[1] = f->n[2] = f->n[3] = 0;
+ f->inside[0] = f->inside[1] = f->inside[2] = f->inside[3] = 0;
+
+ gts_surface_foreach_face (s, (GtsFunc) triangle_face_intersection, f);
+}
+
+static gboolean solid_face_is_thin (CellFace * f)
+{
+ guint odd = 0, even = 0, i;
+
+ for (i = 0; i < 4; i++)
+ if (f->n[i]) {
+ if (f->n[i] % 2 != 0)
+ odd++;
+ else
+ even++;
+ }
+ if (odd == 2 && even == 1) {
+ for (i = 0; i < 4; i++)
+ if (f->n[i] % 2 != 0 && f->n[(i + 2) % 4] % 2 != 0)
+ return FALSE;
+ return TRUE;
+ }
+ return (odd > 2 || even > 1);
+}
+
/**
* gfs_set_2D_solid_fractions_from_surface:
* @cell: a #FttCell.
@@ -233,26 +269,15 @@ void gfs_set_2D_solid_fractions_from_surface (FttCell * cell,
{
GfsSolidVector * solid;
FttVector h;
- FttVector p;
CellFace f;
guint i, n1 = 0;
g_return_if_fail (cell != NULL);
g_return_if_fail (s != NULL);
- solid = GFS_STATE (cell)->solid;
- ftt_cell_pos (cell, &p);
h.x = h.y = ftt_cell_size (cell);
- f.p[0].x = p.x - h.x/2.; f.p[0].y = p.y - h.y/2.; f.p[0].z = 0.;
- f.p[1].x = p.x + h.x/2.; f.p[1].y = p.y - h.y/2.; f.p[1].z = 0.;
- f.p[2].x = p.x + h.x/2.; f.p[2].y = p.y + h.y/2.; f.p[2].z = 0.;
- f.p[3].x = p.x - h.x/2.; f.p[3].y = p.y + h.y/2.; f.p[3].z = 0.;
- f.x[0] = f.x[1] = f.x[2] = f.x[3] = 0.;
- f.n[0] = f.n[1] = f.n[2] = f.n[3] = 0;
- f.inside[0] = f.inside[1] = f.inside[2] = f.inside[3] = 0;
-
- gts_surface_foreach_face (s, (GtsFunc) triangle_face_intersection, &f);
-
+ face_new (&f, cell, s, &h);
+
for (i = 0; i < 4; i++)
if (f.n[i] % 2 != 0) {
f.x[i] /= f.n[i];
@@ -261,6 +286,7 @@ void gfs_set_2D_solid_fractions_from_surface (FttCell * cell,
else
f.n[i] = 0;
+ solid = GFS_STATE (cell)->solid;
switch (n1) {
case 0:
if (solid) {
@@ -281,7 +307,33 @@ void gfs_set_2D_solid_fractions_from_surface (FttCell * cell,
}
#if FTT_2D /* 2D */
+
# define set_solid_fractions_from_surface gfs_set_2D_solid_fractions_from_surface
+
+/**
+ * gfs_solid_is_thin:
+ * @cell: a #FttCell.
+ * @s: a #GtsSurface.
+ *
+ * @s is "thin" relative to @cell if the miminum distance between
+ * non-connected faces of @s cutting @cell is smaller than the size of
+ * @cell (see doc/figures/thin.fig).
+ *
+ * Returns: %TRUE if @s is a thin surface, %FALSE otherwise.
+ */
+gboolean gfs_solid_is_thin (FttCell * cell, GtsSurface * s)
+{
+ CellFace f;
+ FttVector h;
+
+ g_return_val_if_fail (cell != NULL, FALSE);
+ g_return_val_if_fail (s != NULL, FALSE);
+
+ h.x = h.y = ftt_cell_size (cell);
+ face_new (&f, cell, s, &h);
+ return solid_face_is_thin (&f);
+}
+
#else /* 2D3 or 3D */
#include "isocube.h"
@@ -357,7 +409,7 @@ static guint topology (CellCube * cube)
gboolean used[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
for (l = 0; l < 12; l++) {
- guint nv = 0, e = l, cut = cube->n[e];
+ guint nv = 0, e = l, cut = cube->n[e] % 2;
while (cut && !used[e]) {
guint m = 0, * ne = connect[e][cube->inside[e] > 0];
@@ -367,7 +419,7 @@ static guint topology (CellCube * cube)
cut = 0;
while (m < 3 && !cut) {
e = ne[m++];
- cut = cube->n[e];
+ cut = cube->n[e] % 2;
}
}
if (nv > 2)
@@ -376,6 +428,24 @@ static guint topology (CellCube * cube)
return nl;
}
+static void cube_new (CellCube * cube, FttCell * cell, GtsSurface * s, FttVector * o, FttVector * h)
+{
+ guint i;
+
+ for (i = 0; i < FTT_DIMENSION; i++)
+ (&o->x)[i] -= (&h->x)[i]/2.;
+ for (i = 0; i < 12; i++) {
+ cube->x[i] = 0.; cube->n[i] = 0; cube->inside[i] = 0;
+ }
+ for (i = 0; i < 8; i++) { /* for each vertex of the cube */
+ cube->p[i].x = o->x + h->x*vertex[i].x;
+ cube->p[i].y = o->y + h->y*vertex[i].y;
+ cube->p[i].z = o->z + h->z*vertex[i].z;
+ }
+
+ gts_surface_foreach_face (s, (GtsFunc) triangle_cube_intersection, cube);
+}
+
static void set_solid_fractions_from_surface3D (FttCell * cell, GtsSurface * s)
{
GfsSolidVector * solid = GFS_STATE (cell)->solid;
@@ -387,18 +457,7 @@ static void set_solid_fractions_from_surface3D (FttCell * cell, GtsSurface * s)
ftt_cell_pos (cell, &o);
cell_size (cell, &h);
- for (i = 0; i < FTT_DIMENSION; i++)
- (&o.x)[i] -= (&h.x)[i]/2.;
- for (i = 0; i < 12; i++) {
- cube.x[i] = 0.; cube.n[i] = 0; cube.inside[i] = 0;
- }
- for (i = 0; i < 8; i++) { /* for each vertex of the cube */
- cube.p[i].x = o.x + h.x*vertex[i].x;
- cube.p[i].y = o.y + h.y*vertex[i].y;
- cube.p[i].z = o.z + h.z*vertex[i].z;
- }
-
- gts_surface_foreach_face (s, (GtsFunc) triangle_cube_intersection, &cube);
+ cube_new (&cube, cell, s, &o, &h);
for (i = 0; i < 12; i++) /* for each edge of the cube */
if (cube.n[i] % 2 != 0) { /* only for odd number of intersections */
@@ -532,7 +591,43 @@ static void set_solid_fractions_from_surface3D (FttCell * cell, GtsSurface * s)
}
}
+/**
+ * gfs_solid_is_thin:
+ * @cell: a #FttCell.
+ * @s: a #GtsSurface.
+ *
+ * @s is "thin" relative to @cell if the miminum distance between
+ * non-connected faces of @s cutting @cell is smaller than the size of
+ * @cell (see doc/figures/thin.fig).
+ *
+ * Returns: %TRUE if @s is a thin surface, %FALSE otherwise.
+ */
+gboolean gfs_solid_is_thin (FttCell * cell, GtsSurface * s)
+{
+ CellCube cube;
+ FttVector o, h;
+ guint i;
+
+ g_return_val_if_fail (cell != NULL, FALSE);
+ g_return_val_if_fail (s != NULL, FALSE);
+
+ ftt_cell_pos (cell, &o);
+ cell_size (cell, &h);
+ cube_new (&cube, cell, s, &o, &h);
+ for (i = 0; i < FTT_NEIGHBORS; i++) {
+ CellFace f;
+ guint j;
+
+ for (j = 0; j < 4; j++)
+ f.n[j] = cube.n[face[i][j][0]];
+ if (solid_face_is_thin (&f))
+ return TRUE;
+ }
+ return (topology (&cube) > 1);
+}
+
# define set_solid_fractions_from_surface set_solid_fractions_from_surface3D
+
#endif /* 2D3 or 3D */
static gdouble solid_sa (GfsSolidVector * s)
diff --git a/src/solid.h b/src/solid.h
index 9c19cbb..d1648ec 100644
--- a/src/solid.h
+++ b/src/solid.h
@@ -29,6 +29,8 @@ extern "C" {
#endif /* __cplusplus */
void gfs_cell_fluid (FttCell * cell);
+gboolean gfs_solid_is_thin (FttCell * cell,
+ GtsSurface * s);
void gfs_set_2D_solid_fractions_from_surface (FttCell * cell,
GtsSurface * s);
void gfs_domain_init_solid_fractions (GfsDomain * domain,
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list