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

Stephane Popinet popinet at users.sf.net
Fri May 15 02:54:51 UTC 2009


The following commit has been merged in the upstream branch:
commit bfda174a46e97c3a74ca251ed72fcae9de828bc3
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Fri Nov 9 15:34:30 2007 +1100

    cell_init() is now a method of GfsDomain
    
    This simplifies applying a consistent initialisation when creating
    children cells, in particular for the complicated initialisation
    occuring when refining interface cells between direction-sweeps during
    VOF advection.
    
    darcs-hash:20071109043430-d4795-8f15de4cf621c9fa852939a4f43f6dc16d9ffda7.gz

diff --git a/src/adaptive.c b/src/adaptive.c
index 5752ca4..094a405 100644
--- a/src/adaptive.c
+++ b/src/adaptive.c
@@ -52,35 +52,6 @@ void gfs_cell_coarse_init (FttCell * cell, GfsDomain * domain)
   }
 }
 
-/**
- * gfs_cell_fine_init:
- * @parent: a #FttCell.
- * @domain: a #GfsDomain containing @parent.
- *
- * Initialises the children of @parent.
- */
-void gfs_cell_fine_init (FttCell * parent, GfsDomain * domain)
-{
-  GSList * i;
-
-  g_return_if_fail (parent != NULL);
-  g_return_if_fail (!FTT_CELL_IS_LEAF (parent));
-  g_return_if_fail (domain != NULL);
-
-  gfs_cell_init (parent, domain);
-
-  if (!GFS_CELL_IS_BOUNDARY (parent) && GFS_IS_MIXED (parent))
-    gfs_solid_coarse_fine (parent);
-
-  i = domain->variables;
-  while (i) {
-    GfsVariable * v = i->data;
-  
-    (* v->coarse_fine) (parent, v);
-    i = i->next;
-  }
-}
-
 /* GfsAdapt: Object */
 
 typedef struct {
@@ -598,37 +569,31 @@ GfsEventClass * gfs_adapt_curvature_class (void)
   return klass;
 }
 
-static void refine_cell_corner (FttCell * cell, gpointer * adata)
+static void refine_cell_corner (FttCell * cell, GfsDomain * domain)
 {
   if (ftt_refine_corner (cell))
-    ftt_cell_refine_single (cell, adata[0], adata[1]);
+    ftt_cell_refine_single (cell, domain->cell_init, domain->cell_init_data);
 }
 
 /**
  * @domain: a #GfsDomain.
  * @depth: the depth of @domain.
- * @init: a #FttCellInitFunc.
- * @data: user data to pass to @init.
  *
  * Force the grading of the tree hierarchy of domain, matches the
  * boundaries, recomputes merged cells and applies the boundary
  * conditions for all variables.
  */
-void gfs_domain_reshape (GfsDomain * domain, guint depth, FttCellInitFunc init, gpointer data)
+void gfs_domain_reshape (GfsDomain * domain, guint depth)
 {
-  gpointer adata[2];
   gint l;
 
   g_return_if_fail (domain != NULL);
-  g_return_if_fail (init != NULL);
 
-  adata[0] = init;
-  adata[1] = data;
   for (l = depth - 2; l >= 0; l--)
     gfs_domain_cell_traverse (domain,
 			      FTT_PRE_ORDER, FTT_TRAVERSE_LEVEL, l,
 			      (FttCellTraverseFunc) refine_cell_corner,
-			      adata);
+			      domain);
   gfs_domain_match (domain);
   gfs_set_merged (domain);
   GSList * i = domain->variables;
@@ -798,9 +763,10 @@ static void fine_cell_cleanup (FttCell * cell, AdaptParams * p)
 static void cell_fine_init (FttCell * cell, AdaptParams * p)
 {
   FttCellChildren child;
+  GfsDomain * domain = GFS_DOMAIN (p->sim);
   guint n;
 
-  gfs_cell_fine_init (cell, GFS_DOMAIN (p->sim));
+  (* domain->cell_init) (cell, domain->cell_init_data);
   ftt_cell_children (cell, &child);
   for (n = 0; n < FTT_CELLS; n++)
     if (child.c[n])
@@ -933,7 +899,8 @@ static void coarsen_box (GfsBox * box, AdaptLocalParams * p)
 
 static void local_cell_fine_init (FttCell * parent,  AdaptLocalParams * p)
 {
-  gfs_cell_fine_init (parent, GFS_DOMAIN (p->sim));
+  GfsDomain * domain = GFS_DOMAIN (p->sim);
+  (* domain->cell_init) (parent, domain->cell_init_data);
   if (!GFS_CELL_IS_BOUNDARY (parent)) {
     p->s->created += FTT_CELLS;
     p->nc += FTT_CELLS;
@@ -1050,7 +1017,7 @@ void gfs_simulation_adapt (GfsSimulation * simulation)
     else
       adapt_local (simulation, &depth, &simulation->adapts_stats);
 
-    gfs_domain_reshape (domain, depth, (FttCellInitFunc) gfs_cell_fine_init, domain);
+    gfs_domain_reshape (domain, depth);
   }
 
   gfs_domain_timer_stop (domain, "adapt");
diff --git a/src/adaptive.h b/src/adaptive.h
index d3f52c2..e84ea0c 100644
--- a/src/adaptive.h
+++ b/src/adaptive.h
@@ -29,15 +29,11 @@ extern "C" {
 
 void          gfs_cell_coarse_init          (FttCell * cell,
 					     GfsDomain * domain);
-void          gfs_cell_fine_init            (FttCell * cell,
-					     GfsDomain * domain);
 void          gfs_adapt_stats_init          (GfsAdaptStats * s);
 void          gfs_adapt_stats_update        (GfsAdaptStats * s);
 void          gfs_simulation_adapt          (GfsSimulation * simulation);
 void          gfs_domain_reshape            (GfsDomain * domain,
-					     guint depth,
-					     FttCellInitFunc init, 
-					     gpointer data);
+					     guint depth);
 
 /* GfsAdapt: Header */
 
diff --git a/src/boundary.c b/src/boundary.c
index 1534bd6..74d8ea2 100644
--- a/src/boundary.c
+++ b/src/boundary.c
@@ -488,8 +488,8 @@ static void match (FttCell * cell, GfsBoundary * boundary)
       GFS_STATE (cell)->solid = NULL;
     }      
     if (FTT_CELL_IS_LEAF (cell) && !FTT_CELL_IS_LEAF (neighbor)) {
-      ftt_cell_refine_single (cell, (FttCellInitFunc) gfs_cell_fine_init,
-			      gfs_box_domain (boundary->box));
+      GfsDomain * domain = gfs_box_domain (boundary->box);
+      ftt_cell_refine_single (cell, domain->cell_init, domain->cell_init_data);
       boundary->changed = TRUE;
     }
   }
@@ -1111,9 +1111,9 @@ static void match_update (FttCell * cell,
       FttCell * neighbor = ftt_cell_neighbor (cell, GFS_BOUNDARY (boundary)->d);
 
       g_assert (neighbor);
-      ftt_cell_refine_single (cell, (FttCellInitFunc) gfs_cell_fine_init, domain);
+      ftt_cell_refine_single (cell, domain->cell_init, domain->cell_init_data);
       if (FTT_CELL_IS_LEAF (neighbor))
-	ftt_cell_refine_single (neighbor, (FttCellInitFunc) gfs_cell_fine_init, domain);
+	ftt_cell_refine_single (neighbor, domain->cell_init, domain->cell_init_data);
       /* what about solid fractions? */
       GFS_BOUNDARY (boundary)->changed = TRUE;
     }
diff --git a/src/domain.c b/src/domain.c
index 2f7b49a..81b343d 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -330,6 +330,9 @@ static void domain_init (GfsDomain * domain)
 
   domain->variables_io = NULL;
   domain->max_depth_write = -1;
+
+  domain->cell_init = (FttCellInitFunc) gfs_cell_fine_init;
+  domain->cell_init_data = domain;
 }
 
 GfsDomainClass * gfs_domain_class (void)
@@ -2281,6 +2284,35 @@ void gfs_cell_reinit (FttCell * cell, GfsDomain * domain)
 }
 
 /**
+ * gfs_cell_fine_init:
+ * @parent: a #FttCell.
+ * @domain: a #GfsDomain containing @parent.
+ *
+ * Initialises the children of @parent.
+ */
+void gfs_cell_fine_init (FttCell * parent, GfsDomain * domain)
+{
+  GSList * i;
+
+  g_return_if_fail (parent != NULL);
+  g_return_if_fail (!FTT_CELL_IS_LEAF (parent));
+  g_return_if_fail (domain != NULL);
+
+  gfs_cell_init (parent, domain);
+
+  if (!GFS_CELL_IS_BOUNDARY (parent) && GFS_IS_MIXED (parent))
+    gfs_solid_coarse_fine (parent);
+
+  i = domain->variables;
+  while (i) {
+    GfsVariable * v = i->data;
+  
+    (* v->coarse_fine) (parent, v);
+    i = i->next;
+  }
+}
+
+/**
  * gfs_cell_copy:
  * @from: a #FttCell to copy attributes from.
  * @to: a #FttCell to copy attributes to.
diff --git a/src/domain.h b/src/domain.h
index 166bd5c..67e754f 100644
--- a/src/domain.h
+++ b/src/domain.h
@@ -63,8 +63,10 @@ struct _GfsDomain {
 
   GSList * variables_io;
   gboolean binary;
-
   gint max_depth_write;
+
+  FttCellInitFunc cell_init;
+  gpointer cell_init_data;
 };
 
 struct _GfsDomainClass {
@@ -215,6 +217,8 @@ void         gfs_cell_init                    (FttCell * cell,
 					       GfsDomain * domain);
 void         gfs_cell_reinit                  (FttCell * cell, 
 					       GfsDomain * domain);
+void         gfs_cell_fine_init               (FttCell * cell,
+					       GfsDomain * domain);
 void         gfs_cell_copy                    (const FttCell * from, 
 					       FttCell * to,
 					       GfsDomain * domain);
diff --git a/src/refine.c b/src/refine.c
index f19b943..8862312 100644
--- a/src/refine.c
+++ b/src/refine.c
@@ -207,7 +207,7 @@ static void refine_cut_cell (FttCell * cell, GfsSurface * s, RefineCut * p)
   GTS_OBJECT (s)->reserved = p->surface;
   GFS_REFINE_SOLID (p->refine)->v->data = s;
   if (ftt_cell_level (cell) < gfs_function_value (p->refine->maxlevel, cell))
-    ftt_cell_refine_single (cell, (FttCellInitFunc) gfs_cell_fine_init, p->domain);
+    ftt_cell_refine_single (cell, p->domain->cell_init, p->domain->cell_init_data);
   GFS_REFINE_SOLID (p->refine)->v->data = NULL;
 }
 
@@ -215,7 +215,7 @@ static void refine_implicit_cell (FttCell * cell, RefineCut * p)
 {
   guint maxlevel = gfs_function_value (p->refine->maxlevel, cell);
   if (ftt_cell_level (cell) < maxlevel && gfs_cell_is_cut (cell, p->surface, FALSE, maxlevel))
-    ftt_cell_refine_single (cell, (FttCellInitFunc) gfs_cell_fine_init, p->domain);
+    ftt_cell_refine_single (cell, p->domain->cell_init, p->domain->cell_init_data);
 }
 
 static void gfs_refine_solid_refine (GfsRefine * refine, GfsSimulation * sim)
diff --git a/src/simulation.c b/src/simulation.c
index a80c39b..5a7a189 100644
--- a/src/simulation.c
+++ b/src/simulation.c
@@ -794,7 +794,7 @@ void gfs_simulation_init (GfsSimulation * sim)
 static void refine_cell_corner (FttCell * cell, GfsDomain * domain)
 {
   if (ftt_refine_corner (cell))
-    ftt_cell_refine_single (cell, (FttCellInitFunc) gfs_cell_fine_init, domain);
+    ftt_cell_refine_single (cell, domain->cell_init, domain->cell_init_data);
 }
 
 static void check_face (FttCellFace * f, guint * nf)

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list