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

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


The following commit has been merged in the upstream branch:
commit 1870b163d04f48cd888f91f0fa26a724e1abd288
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Fri Mar 16 15:13:03 2007 +1100

    "Permanent" cells cannot be coarsened
    
    At the moment this is used to prevent coarsening of the initial
    embedded solid surface: a first step towards adaptivity of embedded
    solid surfaces.
    
    darcs-hash:20070316041303-d4795-fc0a3caeb29aaaadaa95cb0ec0b02e176865f829.gz

diff --git a/src/adaptive.c b/src/adaptive.c
index 42aa371..ca485cd 100644
--- a/src/adaptive.c
+++ b/src/adaptive.c
@@ -67,11 +67,11 @@ void gfs_cell_fine_init (FttCell * parent, GfsDomain * domain)
   g_return_if_fail (!FTT_CELL_IS_LEAF (parent));
   g_return_if_fail (domain != NULL);
 
-  /* refinement of mixed cell is not implemented (yet) */
-  g_assert (GFS_CELL_IS_BOUNDARY (parent) || GFS_IS_FLUID (parent));
-
   gfs_cell_init (parent, domain);
 
+  /* fixme: refinement of mixed cell is not implemented (yet) */
+  g_assert (GFS_CELL_IS_BOUNDARY (parent) || GFS_IS_FLUID (parent));
+
   i = domain->variables;
   while (i) {
     GfsVariable * v = i->data;
@@ -647,41 +647,38 @@ static gdouble refine_cost (FttCell * cell, GfsSimulation * sim)
 
 static void compute_cost (FttCell * cell, AdaptParams * p)
 {
-  p->nc++;
-  if (!GFS_IS_MIXED (cell)) {
-    gdouble cost = refine_cost (cell, p->sim);
-
-    GFS_VARIABLE (cell, p->hcoarsev->i) = GFS_VARIABLE (cell, p->hfinev->i) = 0.;
-    if (FTT_CELL_IS_LEAF (cell)) {
-      CELL_COST (cell) = cost;
-    }
-    else {
-      FttCellChildren child;
-      FttCellNeighbors n;
-      guint i, level = ftt_cell_level (cell);
-      FttCell * parent;
-      gdouble cmax = 0.;
-
-      ftt_cell_children (cell, &child);
-      for (i = 0; i < FTT_CELLS; i++)
-	if (child.c[i] && CELL_COST (child.c[i]) > cmax)
-	  cmax = CELL_COST (child.c[i]);
-      if (cmax > cost) cost = cmax;
-      if (cost > CELL_COST (cell)) CELL_COST (cell) = cost;
-
-      ftt_cell_neighbors (cell, &n);
-      for (i = 0; i < FTT_NEIGHBORS; i++)
-	if (n.c[i] && ftt_cell_level (n.c[i]) == level && 
-	    (parent = ftt_cell_parent (n.c[i])) &&
-	    cmax > CELL_COST (parent))
-	  CELL_COST (parent) = cmax;
-    }
+  gdouble cost = refine_cost (cell, p->sim);
+
+  GFS_VARIABLE (cell, p->hcoarsev->i) = GFS_VARIABLE (cell, p->hfinev->i) = 0.;
+  if (FTT_CELL_IS_LEAF (cell))
+    CELL_COST (cell) = cost;
+  else {
+    FttCellChildren child;
+    FttCellNeighbors n;
+    guint i, level = ftt_cell_level (cell);
+    FttCell * parent;
+    gdouble cmax = 0.;
+
+    ftt_cell_children (cell, &child);
+    for (i = 0; i < FTT_CELLS; i++)
+      if (child.c[i] && CELL_COST (child.c[i]) > cmax)
+	cmax = CELL_COST (child.c[i]);
+    if (cmax > cost) cost = cmax;
+    if (cost > CELL_COST (cell)) CELL_COST (cell) = cost;
+
+    ftt_cell_neighbors (cell, &n);
+    for (i = 0; i < FTT_NEIGHBORS; i++)
+      if (n.c[i] && ftt_cell_level (n.c[i]) == level && 
+	  (parent = ftt_cell_parent (n.c[i])) &&
+	  cmax > CELL_COST (parent))
+	CELL_COST (parent) = cmax;
   }
+  p->nc++;
 }
 
 static void store_cost (FttCell * cell, AdaptParams * p)
 {
-  GFS_VARIABLE (cell, p->c->i) = GFS_IS_MIXED (cell) ? 0. : CELL_COST (cell);
+  GFS_VARIABLE (cell, p->c->i) = CELL_COST (cell);
 }
 
 static guint minlevel (FttCell * cell, GfsSimulation * sim)
@@ -718,26 +715,23 @@ static guint maxlevel (FttCell * cell, GfsSimulation * sim)
 
 static void fill_heaps (FttCell * cell, AdaptParams * p)
 {
-  /* refinement of solid cells not implemented (yet) */
-  if (!GFS_IS_MIXED (cell)) {
-    guint level = ftt_cell_level (cell);
-    FttCell * parent = ftt_cell_parent (cell);
-
-    if (level < maxlevel (cell, p->sim))
-      GFS_DOUBLE_TO_POINTER (GFS_VARIABLE (cell, p->hcoarsev->i)) = 
-	gts_eheap_insert_with_key (p->hcoarse, cell, - CELL_COST (cell));
-    if (parent && !GFS_IS_MIXED (parent) && GFS_VARIABLE (parent, p->hfinev->i) == 0. &&
-	level > minlevel (parent, p->sim))
-      GFS_DOUBLE_TO_POINTER (GFS_VARIABLE (parent, p->hfinev->i)) = 
-	gts_eheap_insert_with_key (p->hfine, parent, CELL_COST (parent));
-  }
+  guint level = ftt_cell_level (cell);
+  FttCell * parent = ftt_cell_parent (cell);
+  
+  if (level < maxlevel (cell, p->sim))
+    GFS_DOUBLE_TO_POINTER (GFS_VARIABLE (cell, p->hcoarsev->i)) = 
+      gts_eheap_insert_with_key (p->hcoarse, cell, - CELL_COST (cell));
+  if (parent && !GFS_CELL_IS_PERMANENT (parent) && GFS_VARIABLE (parent, p->hfinev->i) == 0. &&
+      level > minlevel (parent, p->sim))
+    GFS_DOUBLE_TO_POINTER (GFS_VARIABLE (parent, p->hfinev->i)) = 
+      gts_eheap_insert_with_key (p->hfine, parent, CELL_COST (parent));
 }
 
 static gboolean fine_cell_coarsenable (FttCell * cell, AdaptParams * p)
 {
   if (GFS_CELL_IS_BOUNDARY (cell))
     return TRUE;
-  if (GFS_IS_MIXED (cell))
+  if (GFS_CELL_IS_PERMANENT (cell))
     return FALSE;
   if (CELL_COST (cell) >= -p->clim)
     return FALSE;
@@ -878,8 +872,6 @@ static gboolean coarsen_cell (FttCell * cell, AdaptLocalParams * p)
 {
   if (GFS_CELL_IS_BOUNDARY (cell))
     return TRUE;
-  if (GFS_IS_MIXED (cell))
-    return FALSE;
   return COARSENABLE (cell, p);
 }
 
@@ -922,25 +914,24 @@ static void refine_cell_mark (FttCell * cell, AdaptLocalParams * p)
 {
   p->nc++;
   REFINABLE (cell, p) = FALSE;
-  COARSENABLE (cell, p) = TRUE;
-  if (!GFS_IS_MIXED (cell)) {
-    guint level = ftt_cell_level (cell);
-    GSList * i = p->sim->adapts->items;
-    while (i) {
-      GfsAdapt * a = i->data;
-      if (a->active) {
-	if (level < gfs_function_value (a->maxlevel, cell) &&
-	    (* a->cost) (cell, a) > a->cmax) {
-	  REFINABLE (cell, p) = TRUE;
-	  COARSENABLE (cell, p) = FALSE;
-	  return;
-	}
-	if (level < gfs_function_value (a->minlevel, cell) ||
-	    (* a->cost) (cell, a) > a->cmax/4.)
-	  COARSENABLE (cell, p) = FALSE;
+  COARSENABLE (cell, p) = !GFS_CELL_IS_PERMANENT (cell);
+
+  guint level = ftt_cell_level (cell);
+  GSList * i = p->sim->adapts->items;
+  while (i) {
+    GfsAdapt * a = i->data;
+    if (a->active) {
+      if (level < gfs_function_value (a->maxlevel, cell) &&
+	  (* a->cost) (cell, a) > a->cmax) {
+	REFINABLE (cell, p) = TRUE;
+	COARSENABLE (cell, p) = FALSE;
+	return;
       }
-      i = i->next;
+      if (level < gfs_function_value (a->minlevel, cell) ||
+	  (* a->cost) (cell, a) > a->cmax/4.)
+	COARSENABLE (cell, p) = FALSE;
     }
+    i = i->next;
   }
 }
 
diff --git a/src/fluid.h b/src/fluid.h
index 0bf20f8..2a77ce3 100644
--- a/src/fluid.h
+++ b/src/fluid.h
@@ -62,7 +62,8 @@ typedef enum {
   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 */
+  GFS_FLAG_PERMANENT         = 1 << (FTT_FLAG_USER + 4),
+  GFS_FLAG_USER =                    FTT_FLAG_USER + 5 /* user flags start here */
 } GfsFlags;
 
 #define GFS_STATE(cell)               ((GfsStateVector *) (cell)->data)
@@ -86,6 +87,7 @@ typedef enum {
 #define GFS_IS_MIXED(cell)      ((cell) != NULL &&\
                                  GFS_STATE (cell)->solid != NULL)
 #define GFS_CELL_IS_BOUNDARY(cell) (((cell)->flags & GFS_FLAG_BOUNDARY) != 0)
+#define GFS_CELL_IS_PERMANENT(cell) (((cell)->flags & GFS_FLAG_PERMANENT) != 0)
 #define GFS_CELL_IS_GRADIENT_BOUNDARY(cell) (((cell)->flags & GFS_FLAG_GRADIENT_BOUNDARY) != 0)
 
 FttCellFace           gfs_cell_face                 (FttCell * cell,
diff --git a/src/simulation.c b/src/simulation.c
index b69f222..1ab26c8 100644
--- a/src/simulation.c
+++ b/src/simulation.c
@@ -896,6 +896,11 @@ static void is_diffusion (GfsSource * s, gboolean * diffusion)
   *diffusion = (GFS_IS_SOURCE_DIFFUSION (s) != NULL);
 }
 
+static void set_permanent (FttCell * cell)
+{
+  cell->flags |= GFS_FLAG_PERMANENT;
+}
+
 /**
  * gfs_simulation_refine:
  * @sim: a #GfsSimulation.
@@ -940,6 +945,8 @@ void gfs_simulation_refine (GfsSimulation * sim)
 						 (FttCellCleanupFunc) gfs_cell_cleanup, NULL, 
 						 NULL);
     gfs_domain_match (domain);
+    gfs_domain_traverse_mixed (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS,
+			       (FttCellTraverseFunc) set_permanent, NULL);
     gfs_domain_timer_stop (domain, "solid_fractions");
   }
   gts_container_foreach (GTS_CONTAINER (sim), (GtsFunc) check_solid_fractions, &nf);

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list