[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203

Stephane Popinet s.popinet at niwa.co.nz
Fri May 15 02:52:23 UTC 2009


The following commit has been merged in the upstream branch:
commit 3f4e04e10906ee5e758267d0d69a5b9c19a9f11f
Author: Stephane Popinet <s.popinet at niwa.co.nz>
Date:   Tue Aug 2 13:50:33 2005 +1000

    Introduced a new GFS_FLAG_GRADIENT_BOUNDARY cell flag to fix Flather ocean bc
    
    The Flather ocean bc do not like the centered pressure gradient
    interpolation used to correct the centered velocities. To revert to
    the old "upwind" gradient interpolation a new flag has been
    introduced. This flag is set automatically by the Flather bc.
    
    darcs-hash:20050802035033-fbd8f-4bd5bbb72a9e2deff919bd3fa3238bdb4bd6ae89.gz

diff --git a/src/boundary.c b/src/boundary.c
index 608e3cd..8001935 100644
--- a/src/boundary.c
+++ b/src/boundary.c
@@ -333,9 +333,12 @@ static void gfs_boundary_destroy (GtsObject * object)
 static void match (FttCell * cell, GfsBoundary * boundary)
 {
   FttCell * neighbor = ftt_cell_neighbor (cell, boundary->d);
+  FttCell * parent = ftt_cell_parent (cell);
   guint level = ftt_cell_level (cell);
 
   cell->flags |= GFS_FLAG_BOUNDARY;
+  if (parent && GFS_CELL_IS_GRADIENT_BOUNDARY (parent))
+    cell->flags |= GFS_FLAG_GRADIENT_BOUNDARY;
   if (neighbor == NULL || ftt_cell_level (neighbor) < level) {
     if (FTT_CELL_IS_ROOT (cell))
       g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR,
diff --git a/src/fluid.h b/src/fluid.h
index 1ad41f0..924528d 100644
--- a/src/fluid.h
+++ b/src/fluid.h
@@ -58,10 +58,11 @@ struct _GfsSolidVector {
 };
 
 typedef enum {
-  GFS_FLAG_USED =      1 <<  FTT_FLAG_USER,
-  GFS_FLAG_BOUNDARY  = 1 << (FTT_FLAG_USER + 1),
-  GFS_FLAG_DIRICHLET = 1 << (FTT_FLAG_USER + 2),
-  GFS_FLAG_USER =            FTT_FLAG_USER + 3 /* user flags start here */
+  GFS_FLAG_USED =              1 <<  FTT_FLAG_USER,
+  GFS_FLAG_BOUNDARY          = 1 << (FTT_FLAG_USER + 1),
+  GFS_FLAG_DIRICHLET         = 1 << (FTT_FLAG_USER + 2),
+  GFS_FLAG_GRADIENT_BOUNDARY = 1 << (FTT_FLAG_USER + 3),
+  GFS_FLAG_USER =                    FTT_FLAG_USER + 4 /* user flags start here */
 } GfsFlags;
 
 #define GFS_STATE(cell)               ((GfsStateVector *) (cell)->data)
@@ -87,6 +88,7 @@ typedef enum {
 #define GFS_IS_SMALL(cell)      (GFS_IS_MIXED (cell) &&\
                                  GFS_STATE (cell)->solid->a < 0.5)
 #define GFS_CELL_IS_BOUNDARY(cell) (((cell)->flags & GFS_FLAG_BOUNDARY) != 0)
+#define GFS_CELL_IS_GRADIENT_BOUNDARY(cell) (((cell)->flags & GFS_FLAG_GRADIENT_BOUNDARY) != 0)
 
 void                  gfs_cell_cleanup              (FttCell * cell);
 void                  gfs_cell_reset                (FttCell * cell, 
diff --git a/src/ocean.c b/src/ocean.c
index 99e531d..05408b1 100644
--- a/src/ocean.c
+++ b/src/ocean.c
@@ -814,6 +814,11 @@ static void bc_flather_write (GtsObject * o, FILE * fp)
     gfs_function_write (bc->val, fp);
 }
 
+static void set_gradient_boundary (FttCell * cell)
+{
+  cell->flags |= GFS_FLAG_GRADIENT_BOUNDARY;
+}
+
 static void bc_flather_read (GtsObject ** o, GtsFile * fp)
 {
   GfsBcFlather * bc = GFS_BC_FLATHER (*o);
@@ -846,6 +851,9 @@ static void bc_flather_read (GtsObject ** o, GtsFile * fp)
   if (bc->val == NULL)
     bc->val = gfs_function_new (gfs_function_class (), 0.);
   gfs_function_read (bc->val, gfs_box_domain (GFS_BC (bc)->b->box), fp);
+
+  ftt_cell_traverse (GFS_BC (bc)->b->root, FTT_PRE_ORDER, FTT_TRAVERSE_ALL, -1,
+		     (FttCellTraverseFunc) set_gradient_boundary, NULL);
 }
 
 static void bc_flather_destroy (GtsObject * o)
@@ -885,18 +893,20 @@ static gdouble flather_value (FttCellFace * f, GfsBc * b)
 
 static void flather (FttCellFace * f, GfsBc * b)
 {
+  g_assert (GFS_CELL_IS_GRADIENT_BOUNDARY (f->cell));
   GFS_VARIABLE (f->cell, b->v->i) = 2.*flather_value (f, b) - GFS_VARIABLE (f->neighbor, b->v->i);
 }
 
 static void homogeneous_flather (FttCellFace * f, GfsBc * b)
 {
+  g_assert (GFS_CELL_IS_GRADIENT_BOUNDARY (f->cell));
   GFS_VARIABLE (f->cell, b->v->i) = - GFS_VARIABLE (f->neighbor, b->v->i);
 }
 
 static void face_flather (FttCellFace * f, GfsBc * b)
 {
-  GFS_STATE (f->cell)->f[f->d].v =
-    GFS_STATE (f->neighbor)->f[FTT_OPPOSITE_DIRECTION (f->d)].v = flather_value (f, b);
+  g_assert (GFS_CELL_IS_GRADIENT_BOUNDARY (f->cell));
+  GFS_STATE (f->cell)->f[f->d].v = flather_value (f, b);
 }
 
 static void gfs_bc_flather_class_init (GtsObjectClass * klass)
diff --git a/src/timestep.c b/src/timestep.c
index f660ccd..7757d45 100644
--- a/src/timestep.c
+++ b/src/timestep.c
@@ -170,8 +170,8 @@ static void scale_gradients (FttCell * cell, gpointer * data)
     ftt_cell_neighbors (cell, &n);
     for (c = 0; c < *dimension; c++) {
       FttCell * c1 = n.c[2*c], * c2 = n.c[2*c + 1];
-      
-      if (c1 && c2)
+
+      if (c1 && c2 && !GFS_CELL_IS_GRADIENT_BOUNDARY (c1) && !GFS_CELL_IS_GRADIENT_BOUNDARY (c2))
 	GFS_VARIABLE (cell, g[c]->i) /= 2.;
     }
   }

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list