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

Stephane Popinet popinet at users.sourceforge.net
Fri May 15 02:51:19 UTC 2009


The following commit has been merged in the upstream branch:
commit 3aee5f3d6e49566e8a614428c97381eb97ae1dad
Author: Stephane Popinet <popinet at users.sourceforge.net>
Date:   Mon Nov 1 10:06:09 2004 +1100

    Domain traversal for painting algorithm (gerris--mainline--0.7--patch-14)
    
    gerris--mainline--0.7--patch-14
    Keywords:
    
    The previous "box" traversal did not work for the painting algorithm
    (which does not know box boundaries).
    
    Traversing the whole domain rather than each box fixes the problem.
    
    Also, the painting algorithm used to also traverse boundary cells. A
    check has been added to avoid that.
    
    darcs-hash:20041031230609-aabb8-0c48c9fe96d13f39d0b5efd17847d44087bbd3d7.gz

diff --git a/src/domain.c b/src/domain.c
index 5ca50b2..957af17 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -833,6 +833,51 @@ void gfs_domain_traverse_mixed (GfsDomain * domain,
   gts_container_foreach (GTS_CONTAINER (domain), (GtsFunc) traverse_mixed, datum);
 }
 
+static void traverse_cut (GfsBox * box, gpointer * datum)
+{
+  FttCellTraverseCutFunc func = (FttCellTraverseCutFunc) datum[0];
+  gpointer data = datum[1];
+  FttTraverseType * order = datum[2];
+  FttTraverseFlags * flags = datum[3];
+  GtsSurface * s = datum[4];
+
+  gfs_cell_traverse_cut (box->root, s, *order, *flags, func, data);
+}
+
+/**
+ * gfs_domain_traverse_cut:
+ * @domain: a #GfsDomain.
+ * @s: a #GtsSurface.
+ * @order: the order in which the cells are visited - %FTT_PRE_ORDER,
+ * %FTT_POST_ORDER. 
+ * @flags: which types of children are to be visited.
+ * @func: the function to call for each visited #FttCell.
+ * @data: user data to pass to @func.
+ *
+ * Calls @func for each cell of @domain cut by @s.
+ */
+void gfs_domain_traverse_cut (GfsDomain * domain,
+			      GtsSurface * s,
+			      FttTraverseType order,
+			      FttTraverseFlags flags,
+			      FttCellTraverseCutFunc func,
+			      gpointer data)
+{
+  gpointer datum[5];
+
+  datum[0] = func;
+  datum[1] = data;
+  datum[2] = &order;
+  datum[3] = &flags;
+  datum[4] = s;
+
+  g_return_if_fail (domain != NULL);
+  g_return_if_fail (s != NULL);
+  g_return_if_fail (func != NULL);
+
+  gts_container_foreach (GTS_CONTAINER (domain), (GtsFunc) traverse_cut, datum);
+}
+
 static void box_depth (GfsBox * box, guint * depth)
 {
   guint d = ftt_cell_depth (box->root);
diff --git a/src/domain.h b/src/domain.h
index f99c0a0..6cc3880 100644
--- a/src/domain.h
+++ b/src/domain.h
@@ -102,6 +102,12 @@ void         gfs_domain_traverse_mixed        (GfsDomain * domain,
 					       FttTraverseFlags flags,
 					       FttCellTraverseFunc func,
 					       gpointer data);
+void         gfs_domain_traverse_cut          (GfsDomain * domain,
+					       GtsSurface * s,
+					       FttTraverseType order,
+					       FttTraverseFlags flags,
+					       FttCellTraverseCutFunc func,
+					       gpointer data);
 void         gfs_domain_face_traverse         (GfsDomain * domain,
 					       FttComponent c,
 					       FttTraverseType order,
diff --git a/src/simulation.c b/src/simulation.c
index 62b1752..f802d8e 100644
--- a/src/simulation.c
+++ b/src/simulation.c
@@ -731,22 +731,6 @@ GfsSimulation * gfs_simulation_new (GfsSimulationClass * klass)
   return object;
 }
 
-static void box_init_solid_fractions (GfsBox * box, GfsSimulation * sim)
-{
-  gfs_cell_init_solid_fractions (box->root, sim->surface, TRUE, 
-				 (FttCellCleanupFunc) gfs_cell_cleanup, NULL);
-  if (FTT_CELL_IS_DESTROYED (box->root)) {
-    FttVector p;
-
-    ftt_cell_pos (box->root, &p);
-    g_warning ("%s centered at (%g,%g,%g) is entirely filled by a solid.\n"
-	       "Aborting...\n", 
-	       GTS_OBJECT (box)->klass->info.name,
-	       p.x, p.y, p.z);
-    exit (1);
-  }
-}
-
 static void refine_cell_corner (FttCell * cell, GfsDomain * domain)
 {
   if (ftt_refine_corner (cell))
@@ -816,7 +800,8 @@ void gfs_simulation_refine (GfsSimulation * sim)
 
   if (sim->surface) {
     gfs_domain_timer_start (domain, "solid_fractions");
-    gts_container_foreach (GTS_CONTAINER (sim), (GtsFunc) box_init_solid_fractions, sim);
+    gfs_domain_init_solid_fractions (domain, sim->surface, TRUE,
+				     (FttCellCleanupFunc) gfs_cell_cleanup, NULL);
     gfs_domain_match (domain);
     gfs_domain_timer_stop (domain, "solid_fractions");
   }
diff --git a/src/solid.c b/src/solid.c
index d1cec31..6645576 100644
--- a/src/solid.c
+++ b/src/solid.c
@@ -505,7 +505,7 @@ static void paint_leaf (GtsFifo * fifo, gdouble a)
     
     ftt_cell_neighbors (cell, &n);
     for (i = 0; i < FTT_NEIGHBORS; i++)
-      if (n.c[i])
+      if (n.c[i] && !GFS_CELL_IS_BOUNDARY (n.c[i]))
 	push_leaf (fifo, n.c[i], i, a);
   }
 }
@@ -521,7 +521,8 @@ static void paint_mixed_leaf (FttCell * cell)
     fifo = gts_fifo_new ();
     for (i = 0; i < FTT_NEIGHBORS; i++)
       if ((solid->s[i] == 0. || solid->s[i] == 1.) &&
-	  (n = ftt_cell_neighbor (cell, i))) {
+	  (n = ftt_cell_neighbor (cell, i)) &&
+	  !GFS_CELL_IS_BOUNDARY (n)) {
 	push_leaf (fifo, n, i, solid->s[i] + 1.);
 	paint_leaf (fifo, solid->s[i] + 1.);
       }
@@ -529,33 +530,15 @@ static void paint_mixed_leaf (FttCell * cell)
   }
 }
 
-
 typedef struct {
   gboolean destroy_solid;
   FttCellCleanupFunc cleanup;
   gpointer data;
 } InitSolidParams;
 
-#if (!FTT_2D)
-#if USE_OLD
-static void init_solid_fractions (FttCell * cell, GtsSurface * s, InitSolidParams * p)
-{
-  GNode * stree;
-
-  stree = gts_bb_tree_surface (s);
-  set_solid_fractions_from_surface (cell, s, stree, p->is_open);
-  gts_bb_tree_destroy (stree, TRUE);
-}
-#endif
-#endif /* 3D */
-
 static void solid_fractions_from_children (FttCell * cell, InitSolidParams * p)
 {
-  if (FTT_CELL_IS_LEAF (cell)) {
-    if (p->destroy_solid && GFS_STATE (cell)->div == 1.)
-      ftt_cell_destroy (cell, p->cleanup, p->data);
-  }
-  else {
+  if (!FTT_CELL_IS_LEAF (cell)) {
     FttCellChildren child;
     guint i;
     
@@ -563,56 +546,63 @@ static void solid_fractions_from_children (FttCell * cell, InitSolidParams * p)
     for (i = 0; i < FTT_CELLS; i++)
       if (child.c[i])
 	solid_fractions_from_children (child.c[i], p);
-    if (FTT_CELL_IS_LEAF (cell)) {
+    if (FTT_CELL_IS_LEAF (cell))
       /* all the children have been destroyed i.e. the cell is solid */
-      if (FTT_CELL_IS_ROOT (cell))
-	g_log (G_LOG_DOMAIN,
-	       G_LOG_LEVEL_ERROR,
-	       "root cell is entirely outside of the fluid domain\n"
-	       "the solid surface orientation may be incorrect\n");
-      else
-	ftt_cell_destroy (cell, p->cleanup, p->data);
+      GFS_STATE (cell)->div = 1.;
+    else {
+      gfs_cell_init_solid_fractions_from_children (cell);
+      GFS_STATE (cell)->div = 0.;
     }
+  }
+  if (GFS_STATE (cell)->div == 1.) {
+    if (FTT_CELL_IS_ROOT (cell))
+      g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR,
+	     "root cell is entirely outside of the fluid domain\n"
+	     "the solid surface orientation may be incorrect\n");
     else
-      gfs_cell_init_solid_fractions_from_children (cell);
+      ftt_cell_destroy (cell, p->cleanup, p->data);
   }
 }
 
+static void foreach_box (GfsBox * box, InitSolidParams * p)
+{
+  solid_fractions_from_children (box->root, p);
+}
+
 /**
- * gfs_cell_init_solid_fractions:
- * @root: the root #FttCell of the cell tree.
+ * gfs_domain_init_solid_fractions:
+ * @domain: a #GfsDomain.
  * @s: an orientable surface defining the solid boundary.
  * @destroy_solid: controls what to do with solid cells.
  * @cleanup: a #FttCellCleanupFunc or %NULL.
  * @data: user data to pass to @cleanup.
  *
- * Initializes the solid fractions of all the cells of the cell tree
- * starting at @root.
+ * Initializes the solid fractions of all the cells of @domain.
  *
  * If @destroy_solid is set to %TRUE, the cells entirely contained in
  * the solid are destroyed using @cleanup as cleanup function.  
  */
-void gfs_cell_init_solid_fractions (FttCell * root,
-				    GtsSurface * s,
-				    gboolean destroy_solid,
-				    FttCellCleanupFunc cleanup,
-				    gpointer data)
+void gfs_domain_init_solid_fractions (GfsDomain * domain,
+				      GtsSurface * s,
+				      gboolean destroy_solid,
+				      FttCellCleanupFunc cleanup,
+				      gpointer data)
 {
   InitSolidParams p;
 
-  g_return_if_fail (root != NULL);
+  g_return_if_fail (domain != NULL);
   g_return_if_fail (s != NULL);
 
+  gfs_domain_traverse_cut (domain, s, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS,
+			   (FttCellTraverseCutFunc) set_solid_fractions_from_surface, NULL);
+  gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
+			    (FttCellTraverseFunc) gfs_cell_reset, gfs_div);
+  gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
+			    (FttCellTraverseFunc) paint_mixed_leaf, NULL);
   p.destroy_solid = destroy_solid;
   p.cleanup = cleanup;
   p.data = data;
-  gfs_cell_traverse_cut (root, s, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS,
-			 (FttCellTraverseCutFunc) set_solid_fractions_from_surface, NULL);
-  ftt_cell_traverse (root, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
-		     (FttCellTraverseFunc) gfs_cell_reset, gfs_div);
-  ftt_cell_traverse (root, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
-		     (FttCellTraverseFunc) paint_mixed_leaf, NULL);
-  solid_fractions_from_children (root, &p);
+  gts_container_foreach (GTS_CONTAINER (domain), (GtsFunc) foreach_box, &p);
 }
 
 static gboolean check_area_fractions (const FttCell * root)
diff --git a/src/solid.h b/src/solid.h
index 2985369..51b0492 100644
--- a/src/solid.h
+++ b/src/solid.h
@@ -22,30 +22,30 @@
 
 #include <gts.h>
 
-#include "fluid.h"
+#include "domain.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
 void         gfs_cell_fluid                              (FttCell * cell);
-void         gfs_cell_init_solid_fractions        (FttCell * root, 
-						   GtsSurface * s,
-						   gboolean destroy_solid,
-						   FttCellCleanupFunc cleanup,
-						   gpointer data);
+void         gfs_domain_init_solid_fractions             (GfsDomain * domain,
+							  GtsSurface * s,
+							  gboolean destroy_solid,
+							  FttCellCleanupFunc cleanup,
+							  gpointer data);
 void         gfs_cell_init_solid_fractions_from_children (FttCell * cell);
 gboolean     gfs_cell_check_solid_fractions              (FttCell * root);
-gboolean     gfs_refine_mixed                       (const FttCell * cell);
-void         gfs_cell_init_fraction                 (FttCell * root, 
-						     GtsSurface * s,
-						     GNode * stree,
-						     gboolean is_open,
-						     GfsVariable * c);
-void         gfs_cell_cm                            (const FttCell * cell, 
-						     FttVector * cm);
-void         gfs_face_ca                            (const FttCellFace * face, 
-						     FttVector * ca);
+gboolean     gfs_refine_mixed                            (const FttCell * cell);
+void         gfs_cell_init_fraction                      (FttCell * root, 
+							  GtsSurface * s,
+							  GNode * stree,
+							  gboolean is_open,
+							  GfsVariable * c);
+void         gfs_cell_cm                                 (const FttCell * cell, 
+							  FttVector * cm);
+void         gfs_face_ca                                 (const FttCellFace * face, 
+							  FttVector * ca);
 
 #ifdef __cplusplus
 }

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list