[SCM] Gerris Flow Solver branch, upstream, updated. e8f73a07832050124d2b8bf6c6f35b33180e65a8
Stephane Popinet
popinet at users.sf.net
Tue Nov 24 12:24:45 UTC 2009
The following commit has been merged in the upstream branch:
commit ac9b957b52aa64f77938ba3258961f6862622aa1
Author: Stephane Popinet <popinet at users.sf.net>
Date: Thu Jul 23 07:37:38 2009 +1000
New interface for gfs_domain_locate() and gfs_domain_boundary_locate()
darcs-hash:20090722213738-d4795-692316b04a7c467a1d8fb3243902ca53acf99020.gz
diff --git a/modules/terrain.mod b/modules/terrain.mod
index ad37860..ccb0a4e 100644
--- a/modules/terrain.mod
+++ b/modules/terrain.mod
@@ -648,7 +648,7 @@ static gdouble corner_value (GfsRefineTerrain * t, FttVector * p, gdouble eps, g
for (j = -1; j <= 1; j += 2) {
FttVector q;
q.x = p->x + eps*i; q.y = p->y + eps*j; q.z = p->z;
- FttCell * cell = gfs_domain_locate (domain, q, level);
+ FttCell * cell = gfs_domain_locate (domain, q, level, NULL);
if (cell) {
if (ftt_cell_level (cell) < level)
return 0.;
@@ -805,7 +805,7 @@ static gboolean refine_terrain_from_boundary (FttCell * cell, GfsRefineTerrain *
gdouble h = ftt_cell_size (cell)/2., zmin = p.z - h, zmax = p.z + h;
p.z = t->front;
GfsDomain * domain = GFS_DOMAIN (gfs_object_simulation (t));
- FttCell * boundary = gfs_domain_locate (domain, p, ftt_cell_level (cell));
+ FttCell * boundary = gfs_domain_locate (domain, p, ftt_cell_level (cell), NULL);
g_assert (boundary);
if (GFS_VALUE (boundary, t->min) > zmax || GFS_VALUE (boundary, t->max) < zmin)
return FALSE;
@@ -827,7 +827,7 @@ static void init_terrain_from_boundary (FttCell * cell, GfsRefineTerrain * t)
ftt_cell_pos (cell, &p);
p.z = t->front;
GfsDomain * domain = GFS_DOMAIN (gfs_object_simulation (t));
- FttCell * boundary = gfs_domain_locate (domain, p, -1);
+ FttCell * boundary = gfs_domain_locate (domain, p, -1, NULL);
g_assert (boundary);
g_assert (ftt_cell_level (cell) == ftt_cell_level (boundary));
guint i;
diff --git a/src/domain.c b/src/domain.c
index 4bd3540..89b225f 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -2247,6 +2247,7 @@ void gfs_domain_split (GfsDomain * domain, gboolean one_box_per_pe)
* @domain: a #GfsDomain.
* @target: position of the point to look for.
* @max_depth: maximum depth to consider (-1 means no restriction, see below for -2).
+ * @where: a pointer to a #GfsBox or %NULL.
*
* Locates the cell of @domain containing @target. This is done
* efficiently in log(n) operations by using the topology of the cell
@@ -2256,16 +2257,25 @@ void gfs_domain_split (GfsDomain * domain, gboolean one_box_per_pe)
* returned. This cell is not necessarily a leaf-cell in contrast to
* the case where @max_depth is set to -1.
*
+ * If @where is not %NULL it is filled with the #GfsBox containing the
+ * cell.
+ *
* Returns: a #FttCell of @domain containing (boundary included) the
* point defined by @target or %NULL if @target is not contained in
* any cell of @domain.
*/
FttCell * gfs_domain_locate (GfsDomain * domain,
FttVector target,
- gint max_depth)
+ gint max_depth,
+ GfsBox ** where)
{
GtsObject * b = locate_array_locate (domain->array, &target);
- return GFS_IS_BOX (b) ? ftt_cell_locate (GFS_BOX (b)->root, target, max_depth) : NULL;
+ if (GFS_IS_BOX (b)) {
+ if (where)
+ *where = GFS_BOX (b);
+ return ftt_cell_locate (GFS_BOX (b)->root, target, max_depth);
+ }
+ return NULL;
}
/**
@@ -2273,18 +2283,25 @@ FttCell * gfs_domain_locate (GfsDomain * domain,
* @domain: a #GfsDomain.
* @target: position of the point to look for.
* @max_depth: maximum depth to consider (-1 means no restriction).
+ * @where: a pointer to a #GtsObject.
*
* Locates the cell of @domain or of its boundary containing @target.
*
+ * If @where is not %NULL it is filled with the #GtsObject (either a
+ * #GfsBox or a #GfsBoundary) containing the cell.
+ *
* Returns: a #FttCell of @domain or of its boundary containing the
* point defined by @target or %NULL if @target is not contained in
* any cell of @domain or of its boundary.
*/
FttCell * gfs_domain_boundary_locate (GfsDomain * domain,
FttVector target,
- gint max_depth)
+ gint max_depth,
+ GtsObject ** where)
{
GtsObject * b = locate_array_locate (domain->array, &target);
+ if (where)
+ *where = b;
if (GFS_IS_BOX (b))
return ftt_cell_locate (GFS_BOX (b)->root, target, max_depth);
else if (GFS_IS_BOUNDARY (b)) {
@@ -2385,13 +2402,13 @@ void gfs_domain_advect_point (GfsDomain * domain,
g_return_if_fail (p != NULL);
p0 = p1 = *p;
- cell = gfs_domain_locate (domain, p0, -1);
+ cell = gfs_domain_locate (domain, p0, -1, NULL);
if (cell == NULL)
return;
u = gfs_domain_velocity (domain);
for (c = 0; c < FTT_DIMENSION; c++)
(&p1.x)[c] += dt*gfs_interpolate (cell, p0, u[c])/2.;
- cell = gfs_domain_locate (domain, p1, -1);
+ cell = gfs_domain_locate (domain, p1, -1, NULL);
if (cell == NULL)
return;
for (c = 0; c < FTT_DIMENSION; c++)
@@ -3758,7 +3775,7 @@ static void box_combine_traverse (GfsBox * box, gpointer * data)
FttCell * locate;
ftt_cell_pos (box->root, &p);
- locate = gfs_domain_locate (data[0], p, ftt_cell_level (box->root));
+ locate = gfs_domain_locate (data[0], p, ftt_cell_level (box->root), NULL);
if (locate == NULL) {
if (data[3])
ftt_cell_traverse (box->root, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1, data[3], data[4]);
diff --git a/src/domain.h b/src/domain.h
index 1834c98..5591734 100644
--- a/src/domain.h
+++ b/src/domain.h
@@ -210,10 +210,12 @@ void gfs_domain_split (GfsDomain * domain,
gboolean one_box_per_pe);
FttCell * gfs_domain_locate (GfsDomain * domain,
FttVector target,
- gint max_depth);
+ gint max_depth,
+ GfsBox ** where);
FttCell * gfs_domain_boundary_locate (GfsDomain * domain,
FttVector target,
- gint max_depth);
+ gint max_depth,
+ GtsObject ** where);
gdouble gfs_domain_cell_point_distance2 (GfsDomain * domain,
GtsPoint * p,
gdouble (* distance2) (FttCell *,
diff --git a/src/graphic.c b/src/graphic.c
index ec4bc90..520fd6b 100644
--- a/src/graphic.c
+++ b/src/graphic.c
@@ -366,7 +366,7 @@ static void iso_func (gdouble ** a, GtsCartesianGrid g, guint k,
p.z = g.z;
for (i = 0, p.x = g.x; i < g.nx; i++, p.x += g.dx)
for (j = 0, p.y = g.y; j < g.ny; j++, p.y += g.dy) {
- FttCell * cell = gfs_domain_locate (domain, p, *level);
+ FttCell * cell = gfs_domain_locate (domain, p, *level, NULL);
if (cell == NULL)
a[i][j] = 0.;
@@ -1130,7 +1130,7 @@ static GtsColor variable_color (GtsObject * o)
pos.y = p->y;
pos.z = p->z;
- cell = gfs_domain_locate (domain, pos, -1);
+ cell = gfs_domain_locate (domain, pos, -1, NULL);
if (cell) {
val = gfs_interpolate (cell, pos, v);
c = colormap_color (colormap, (val - *min)/(*max - *min));
@@ -1736,7 +1736,7 @@ static GList * grow_curve (GfsDomain * domain,
#endif /* 2D */
p1 = p2 = p;
- while ((cell = gfs_domain_locate (domain, p, -1)) != NULL &&
+ while ((cell = gfs_domain_locate (domain, p, -1, NULL)) != NULL &&
circumcircle_radius (p1, p2, p) > ftt_cell_size (cell) &&
nmax--) {
gdouble h = delta*ftt_cell_size (cell);
@@ -1771,7 +1771,7 @@ static GList * grow_curve (GfsDomain * domain,
nu = 2.*sqrt (nu);
for (c = 0; c < FTT_DIMENSION; c++)
(&p1.x)[c] += h*(&u.x)[c]/nu;
- cell1 = gfs_domain_locate (domain, p1, -1);
+ cell1 = gfs_domain_locate (domain, p1, -1, NULL);
if (!cell1)
break;
nu = interpolated_velocity (cell1, p1, U, direction, &u);
@@ -1801,7 +1801,7 @@ static GList * grow_curve (GfsDomain * domain,
break;
}
if (oldp && (p2.x != oldp->x || p2.y != oldp->y || p2.z != oldp->z)) {
- cell = gfs_domain_locate (domain, p2, -1);
+ cell = gfs_domain_locate (domain, p2, -1, NULL);
if (cell) {
oldp = gts_point_new (path_class, p2.x, p2.y, p2.z);
if (var)
diff --git a/src/moving.c b/src/moving.c
index 3dad7c1..a0c2ba4 100644
--- a/src/moving.c
+++ b/src/moving.c
@@ -644,7 +644,7 @@ static void simulation_moving_set_timestep (GfsSimulation * sim)
static void move_vertex (GtsPoint * p, SolidInfo * par)
{
FttVector pos = *((FttVector *) &p->x);
- FttCell * cell = gfs_domain_locate (GFS_DOMAIN (par->sim), pos, -2);
+ FttCell * cell = gfs_domain_locate (GFS_DOMAIN (par->sim), pos, -2, NULL);
if (cell) {
gdouble dt = par->sim->advection_params.dt;
FttComponent c;
diff --git a/src/output.c b/src/output.c
index a2156ae..a335ee2 100644
--- a/src/output.c
+++ b/src/output.c
@@ -1177,7 +1177,7 @@ static gboolean gfs_output_location_event (GfsEvent * event,
for (i = 0; i < location->p->len; i++) {
FttVector p = g_array_index (location->p, FttVector, i), pm = p;
gfs_simulation_map (sim, &pm);
- FttCell * cell = gfs_domain_locate (domain, pm, -1);
+ FttCell * cell = gfs_domain_locate (domain, pm, -1, NULL);
if (cell != NULL) {
GSList * i = domain->variables;
diff --git a/src/tension.c b/src/tension.c
index d2ed61d..75bd505 100644
--- a/src/tension.c
+++ b/src/tension.c
@@ -655,7 +655,7 @@ static void interface_curvature (FttCell * cell, gpointer * data)
target = NULL;
}
if (!target)
- target = gfs_domain_locate (v->domain, p, -1);
+ target = gfs_domain_locate (v->domain, p, -1, NULL);
GFS_VARIABLE (cell, v->i) = gfs_interpolate (target, p, nv[FTT_DIMENSION]);
}
}
diff --git a/src/unstructured.c b/src/unstructured.c
index 926053d..eb21db8 100644
--- a/src/unstructured.c
+++ b/src/unstructured.c
@@ -101,7 +101,7 @@ static void allocate_vertices (FttCell * cell, AllocParams * par)
FttComponent c;
for (c = 0; c < FTT_DIMENSION; c++)
(&q.x)[c] = (&p.x)[c] - dx[j][c]*h;
- FttCell * n = gfs_domain_locate (par->domain, q, par->max_depth);
+ FttCell * n = gfs_domain_locate (par->domain, q, par->max_depth, NULL);
if (n) {
guint k;
for (k = 0; k < j && n; k++)
diff --git a/src/vof.c b/src/vof.c
index a886352..857d491 100644
--- a/src/vof.c
+++ b/src/vof.c
@@ -805,7 +805,7 @@ static void stencil (FttCell * cell, GfsVariable * v, gdouble F(3,3,3))
if (x != 0 || y != 0 || z != 0) {
FttVector o;
o.x = p.x + h*x; o.y = p.y + h*y; o.z = p.z + h*z;
- FttCell * neighbor = gfs_domain_boundary_locate (v->domain, o, level);
+ FttCell * neighbor = gfs_domain_boundary_locate (v->domain, o, level, NULL);
if (neighbor)
F(x + 1, y + 1, z + 1) =
gfs_vof_interpolate (neighbor, &o, level, GFS_VARIABLE_TRACER_VOF (v));
@@ -1747,7 +1747,7 @@ static gdouble fraction (FttVector * p,
guint level,
GfsVariable * v)
{
- FttCell * cell = gfs_domain_boundary_locate (v->domain, *p, level);
+ FttCell * cell = gfs_domain_boundary_locate (v->domain, *p, level, NULL);
if (cell)
return gfs_vof_interpolate (cell, p, level, GFS_VARIABLE_TRACER_VOF (v));
else /* fixme: boundary conditions? */
@@ -2171,7 +2171,7 @@ static void fit_from_fractions (FttCell * cell, GfsVariable * v, ParabolaFit * f
if (x != 0 || y != 0 || z != 0) {
FttVector o;
o.x = p.x + h*x; o.y = p.y + h*y; o.z = p.z + h*z;
- FttCell * neighbor = gfs_domain_boundary_locate (v->domain, o, level);
+ FttCell * neighbor = gfs_domain_boundary_locate (v->domain, o, level, NULL);
if (neighbor)
add_vof_center (neighbor, &o, level, &p, GFS_VARIABLE_TRACER_VOF (v),
fit, 1.);
diff --git a/tools/gfs2oogl.c b/tools/gfs2oogl.c
index 62e59a3..62fe314 100644
--- a/tools/gfs2oogl.c
+++ b/tools/gfs2oogl.c
@@ -68,14 +68,14 @@ static gdouble local_size_ratio (GtsSegment * s, GfsDomain * domain)
p.x = p1->x;
p.y = p1->y;
p.z = p1->z;
- cell = gfs_domain_locate (domain, p, -1);
+ cell = gfs_domain_locate (domain, p, -1, NULL);
if (cell)
size = ftt_cell_size (cell);
p.x = p2->x;
p.y = p2->y;
p.z = p2->z;
- cell = gfs_domain_locate (domain, p, -1);
+ cell = gfs_domain_locate (domain, p, -1, NULL);
if (cell) {
gdouble s = ftt_cell_size (cell);
@@ -392,7 +392,7 @@ static gboolean advect (GfsDomain * domain,
ph = *p;
for (c = 0; c < 2/*FTT_DIMENSION*/; c++)
((gdouble *) &ph)[c] += h*((gdouble *) &u)[c]/(2.*nu);
- cell = gfs_domain_locate (domain, ph, -1);
+ cell = gfs_domain_locate (domain, ph, -1, NULL);
if (cell != NULL) {
nu = 0.;
for (c = 0; c < 2/*FTT_DIMENSION*/; c++) {
@@ -424,7 +424,7 @@ static InsertStatus grow_streamline (GfsDomain * domain,
gint direction,
GSList ** stream)
{
- FttCell * cell = gfs_domain_locate (domain, p, -1);
+ FttCell * cell = gfs_domain_locate (domain, p, -1, NULL);
GtsVertex * v, * vstart = NULL;
gdouble s = 0.;
InsertStatus status = cell ? INSERTED : OFFSIDE;
@@ -444,7 +444,7 @@ static InsertStatus grow_streamline (GfsDomain * domain,
case ALREADY_THERE:
if (advect (domain, cell, &p, ds, direction)) {
s += ds;
- cell = gfs_domain_locate (domain, p, -1);
+ cell = gfs_domain_locate (domain, p, -1, NULL);
if (cell == NULL)
status = OFFSIDE;
}
@@ -533,7 +533,7 @@ static gboolean seed (GSList * i,
if (d > 1e-6) {
v->x = p.x = (p1->x + p2->x)/2. - (p2->y - p1->y)*dsep/d;
v->y = p.y = (p1->y + p2->y)/2. + (p2->x - p1->x)*dsep/d;
- if (gfs_domain_locate (domain, p, -1) &&
+ if (gfs_domain_locate (domain, p, -1, NULL) &&
closest_grid_is_insertable (grid, v, dsep, 0.) == INSERTED) {
GSList * s = streamline (domain, grid, p, dmin, 0.25, closed);
@@ -545,7 +545,7 @@ static gboolean seed (GSList * i,
}
v->x = p.x = (p1->x + p2->x)/2. + (p2->y - p1->y)*dsep/d;
v->y = p.y = (p1->y + p2->y)/2. - (p2->x - p1->x)*dsep/d;
- if (gfs_domain_locate (domain, p, -1) &&
+ if (gfs_domain_locate (domain, p, -1, NULL) &&
closest_grid_is_insertable (grid, v, dsep, 0.) == INSERTED) {
GSList * s = streamline (domain, grid, p, dmin, 0.25, closed);
@@ -575,7 +575,7 @@ static void cell_center (FttCell * cell, gpointer * data)
ftt_cell_pos (cell, &pos);
pos.z = 0.;
v = gts_point_new (gts_point_class (), pos.x, pos.y, pos.z);
- if (gfs_domain_locate (domain, pos, -1) &&
+ if (gfs_domain_locate (domain, pos, -1, NULL) &&
closest_grid_is_insertable (grid, v, 0., 0.) == INSERTED)
*p = pos;
gts_object_destroy (GTS_OBJECT (v));
@@ -1087,7 +1087,7 @@ int main (int argc, char * argv[])
if (var)
while (fscanf (profile, "%lf %lf %lf", &p.x, &p.y, &p.z) == 3) {
- FttCell * cell = gfs_domain_locate (domain, p, -1);
+ FttCell * cell = gfs_domain_locate (domain, p, -1, NULL);
if (cell)
printf ("%g %g %g %g\n", p.x, p.y, p.z, gfs_interpolate (cell, p, var));
}
@@ -1104,7 +1104,7 @@ int main (int argc, char * argv[])
}
printf ("\n");
while (fscanf (profile, "%lf %lf %lf", &p.x, &p.y, &p.z) == 3) {
- FttCell * cell = gfs_domain_locate (domain, p, -1);
+ FttCell * cell = gfs_domain_locate (domain, p, -1, NULL);
if (cell) {
printf ("%g %g %g ", p.x, p.y, p.z);
j = domain->variables;
diff --git a/tools/gfscompare.c b/tools/gfscompare.c
index fd737f6..2f89a2c 100644
--- a/tools/gfscompare.c
+++ b/tools/gfscompare.c
@@ -179,10 +179,10 @@ static gboolean difference_tree (FttCell * cell,
ftt_cell_pos (cell, &pos);
pos.x += period;
- locate = gfs_domain_locate (ref, pos, level);
+ locate = gfs_domain_locate (ref, pos, level, NULL);
if (locate == NULL) {
pos.x -= 2.*period;
- locate = gfs_domain_locate (ref, pos, level);
+ locate = gfs_domain_locate (ref, pos, level, NULL);
}
if (locate == NULL) {
fprintf (stderr, "gfscompare: the files are not comparable\n");
@@ -291,7 +291,7 @@ static void difference_centered (FttCell * cell, gpointer * data)
FttCell * locate;
gfs_cell_cm (cell, &p);
- locate = gfs_domain_locate (ref, p, -1);
+ locate = gfs_domain_locate (ref, p, -1, NULL);
if (locate == NULL || ftt_cell_level (locate) < ftt_cell_level (cell)) {
fprintf (stderr, "gfscompare: the files are not comparable\n");
exit (1);
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list