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

Stephane Popinet popinet at users.sf.net
Fri May 15 02:53:03 UTC 2009


The following commit has been merged in the upstream branch:
commit 5d007995f7b78a4ce9fa58a0858ca70005ceeb18
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Sat Jan 28 04:43:49 2006 +1100

    Generalised gfs_correct_normal_velocities() for CSF surface tension
    
    darcs-hash:20060127174349-d4795-6bb40608516505920e9c7095bc74262e03441ce7.gz

diff --git a/src/ocean.c b/src/ocean.c
index 76f2935..847a02c 100644
--- a/src/ocean.c
+++ b/src/ocean.c
@@ -134,7 +134,7 @@ static void gfs_correct_normal_velocities_weighted (GfsDomain * domain,
 						    gboolean weighted)
 {
   if (!weighted)
-    gfs_correct_normal_velocities (domain, dimension, p, g, dt);
+    gfs_correct_normal_velocities (domain, dimension, p, g, dt, NULL);
   else {
     gpointer data[3];
     FttComponent c;
@@ -688,7 +688,7 @@ static void ocean_run (GfsSimulation * sim)
 
     gfs_domain_timer_start (domain, "correct_normal_velocities");
     gfs_poisson_coefficients (domain, NULL);
-    gfs_correct_normal_velocities (domain, 2, p, g, sim->advection_params.dt/2.);
+    gfs_correct_normal_velocities (domain, 2, p, g, sim->advection_params.dt/2., NULL);
     gfs_domain_cell_traverse_boundary (domain, FTT_BACK,
 				       FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
 				       (FttCellTraverseFunc) compute_w, 
diff --git a/src/timestep.c b/src/timestep.c
index a2c6700..096b4c4 100644
--- a/src/timestep.c
+++ b/src/timestep.c
@@ -39,10 +39,8 @@ static void correct_normal_velocity (FttCellFace * face,
 {
   GfsGradient g;
   gdouble dp;
-  FttFaceType type;
   GfsStateVector * s;
-  GfsVariable * p = data[0];
-  GfsVariable ** gv = data[1];
+  GfsVariable * p = data[0], ** gv = data[1], * w = data[3];
   gdouble * dt = data[2];
   FttComponent c;
 
@@ -50,11 +48,12 @@ static void correct_normal_velocity (FttCellFace * face,
     return;
 
   s = GFS_STATE (face->cell);
-  type = ftt_face_type (face);
   c = face->d/2;
 
   gfs_face_weighted_gradient (face, &g, p->i, -1);
   dp = (g.b - g.a*GFS_VARIABLE (face->cell, p->i))/ftt_cell_size (face->cell);
+  if (w)
+    dp *= gfs_face_interpolated_value (face, w->i);
   if (!FTT_FACE_DIRECT (face))
     dp = - dp;
 
@@ -62,12 +61,14 @@ static void correct_normal_velocity (FttCellFace * face,
     dp /= s->solid->s[face->d];
 
   GFS_FACE_NORMAL_VELOCITY_LEFT (face) -= dp*(*dt);
-  GFS_VARIABLE (face->cell, gv[c]->i) += dp;
+  if (gv)
+    GFS_VARIABLE (face->cell, gv[c]->i) += dp;
 
-  if (type == FTT_FINE_COARSE)
+  if (ftt_face_type (face) == FTT_FINE_COARSE)
     dp *= GFS_FACE_FRACTION_LEFT (face)/(GFS_FACE_FRACTION_RIGHT (face)*FTT_CELLS/2);
   GFS_FACE_NORMAL_VELOCITY_RIGHT (face) -= dp*(*dt);
-  GFS_VARIABLE (face->neighbor, gv[c]->i) += dp;
+  if (gv)
+    GFS_VARIABLE (face->neighbor, gv[c]->i) += dp;
 }
 
 static void scale_gradients (FttCell * cell, gpointer * data)
@@ -91,46 +92,53 @@ static void scale_gradients (FttCell * cell, gpointer * data)
  * @domain: a #GfsDomain.
  * @dimension: the number of dimensions (2 or 3).
  * @p: the pressure field.
- * @g: where to store the pressure gradient.
+ * @g: where to store the pressure gradient or %NULL.
  * @dt: the timestep.
+ * @w: an optional weight to apply to the correction.
  *
  * Corrects the normal velocity field of @domain using @p and and @dt.
  *
- * Also allocates the @g variables and fills them with the centered gradient of @p.
+ * Also allocates the @g variables (if @g is not %NULL) and fills them
+ * with the centered gradient of @p.
  */
 void gfs_correct_normal_velocities (GfsDomain * domain,
 				    guint dimension,
 				    GfsVariable * p,
 				    GfsVariable ** g,
-				    gdouble dt)
+				    gdouble dt,
+				    GfsVariable * w)
 {
-  gpointer data[3];
+  gpointer data[4];
   FttComponent c;
 
   g_return_if_fail (domain != NULL);
   g_return_if_fail (p != NULL);
-  g_return_if_fail (g != NULL);
 
-  for (c = 0; c < dimension; c++) {
-    g[c] = gfs_temporary_variable (domain);
-    gfs_variable_set_vector (g[c], c);
+  if (g) {
+    for (c = 0; c < dimension; c++) {
+      g[c] = gfs_temporary_variable (domain);
+      gfs_variable_set_vector (g[c], c);
+    }
+    data[0] = g;
+    data[1] = &dimension;
+    gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
+			      (FttCellTraverseFunc) reset_gradients, data);
   }
-  data[0] = g;
-  data[1] = &dimension;
-  gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
-			    (FttCellTraverseFunc) reset_gradients, data);
   data[0] = p;
   data[1] = g;
   data[2] = &dt;
+  data[3] = w;
   gfs_domain_face_traverse (domain, dimension == 2 ? FTT_XY : FTT_XYZ,
 			    FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
 			    (FttFaceTraverseFunc) correct_normal_velocity, data);
-  data[0] = g;
-  data[1] = &dimension;
-  gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
-			    (FttCellTraverseFunc) scale_gradients, data);
-  for (c = 0; c < dimension; c++)
-    gfs_domain_bc (domain, FTT_TRAVERSE_LEAFS, -1, g[c]);
+  if (g) {
+    data[0] = g;
+    data[1] = &dimension;
+    gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
+			      (FttCellTraverseFunc) scale_gradients, data);
+    for (c = 0; c < dimension; c++)
+      gfs_domain_bc (domain, FTT_TRAVERSE_LEAFS, -1, g[c]);
+  }
 }
 
 static void scale_divergence (FttCell * cell, gpointer * data)
@@ -236,7 +244,7 @@ void gfs_mac_projection (GfsDomain * domain,
   gts_object_destroy (GTS_OBJECT (dia));
   gts_object_destroy (GTS_OBJECT (res));
 
-  gfs_correct_normal_velocities (domain, FTT_DIMENSION, p, g, apar->dt);
+  gfs_correct_normal_velocities (domain, FTT_DIMENSION, p, g, apar->dt, NULL);
 
 #if 0
   {
@@ -409,7 +417,7 @@ void gfs_approximate_projection (GfsDomain * domain,
   if (!res)
     gts_object_destroy (GTS_OBJECT (res1));
 
-  gfs_correct_normal_velocities (domain, FTT_DIMENSION, p, g, apar->dt);
+  gfs_correct_normal_velocities (domain, FTT_DIMENSION, p, g, apar->dt, NULL);
   gfs_correct_centered_velocities (domain, FTT_DIMENSION, g, apar->dt);
 
   gfs_domain_timer_stop (domain, "approximate_projection");
diff --git a/src/timestep.h b/src/timestep.h
index b13e2c8..d692c57 100644
--- a/src/timestep.h
+++ b/src/timestep.h
@@ -32,7 +32,8 @@ void          gfs_correct_normal_velocities   (GfsDomain * domain,
 					       guint dimension,
 					       GfsVariable * p,
 					       GfsVariable ** g,
-					       gdouble dt);
+					       gdouble dt,
+					       GfsVariable * w);
 void          gfs_mac_projection              (GfsDomain * domain,
 					       GfsMultilevelParams * par,
 					       GfsAdvectionParams * apar,

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list