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

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


The following commit has been merged in the upstream branch:
commit 520cd87d219648ff4dfbd184f4f484bfec6076d3
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Wed Dec 6 13:32:16 2006 +1100

    New object GfsVariablePosition
    
    For implementation of "reduced gravity".
    
    darcs-hash:20061206023216-d4795-96bf4ec5427beadceb9ed5303e2e2c03b2f5ba1f.gz

diff --git a/src/tension.c b/src/tension.c
index 0c2cfbc..cb6fa9e 100644
--- a/src/tension.c
+++ b/src/tension.c
@@ -277,10 +277,13 @@ static void gfs_source_tension_write (GtsObject * o, FILE * fp)
 static gdouble gfs_source_tension_stability (GfsSourceGeneric * s,
 					     GfsSimulation * sim)
 {
-  if (GFS_IS_VARIABLE_CURVATURE (GFS_SOURCE_TENSION (s)->k))
+  if (GFS_IS_VARIABLE_POSITION (GFS_SOURCE_TENSION (s)->k))
+    /* reduced gravity */
+    return sqrt (ftt_level_size (gfs_domain_depth (GFS_DOMAIN (sim)))/
+		 fabs (GFS_SOURCE_TENSION_GENERIC (s)->sigma));
+  else 
+    /* surface tension */
     return gfs_source_tension_generic_stability (s, sim);
-  else
-    return G_MAXDOUBLE;
 }
 
 static void gfs_source_tension_class_init (GfsSourceGenericClass * klass)
@@ -497,3 +500,117 @@ GfsVariableClass * gfs_variable_curvature_class (void)
 
   return klass;
 }
+
+/* GfsVariablePosition: object */
+
+static void variable_position_read (GtsObject ** o, GtsFile * fp)
+{
+  GfsVariablePosition * v = GFS_VARIABLE_POSITION (*o);
+
+  (* GTS_OBJECT_CLASS (gfs_variable_position_class ())->parent_class->read) (o, fp);
+  if (fp->type == GTS_ERROR)
+    return;
+
+  if (fp->type != GTS_STRING) {
+    gts_file_error (fp, "expecting a string (component)");
+    return;
+  }
+  if (!strcmp (fp->token->str, "x"))
+    v->c = FTT_X;
+  else if (!strcmp (fp->token->str, "y"))
+    v->c = FTT_Y;
+#if !FTT_2D
+  else if (!strcmp (fp->token->str, "z"))
+    v->c = FTT_Z;
+#endif /* 3D */
+  else {
+    gts_file_error (fp, "`%s' is not a valid component", fp->token->str);
+    return;
+  }
+  if (GFS_VARIABLE1 (v)->description)
+    g_free (GFS_VARIABLE1 (v)->description);
+  GFS_VARIABLE1 (v)->description = g_strjoin (" ", fp->token->str,
+					      "coordinate of the interface defined by tracer",
+					      GFS_VARIABLE_CURVATURE (v)->f->name, NULL);
+  gts_file_next_token (fp);  
+}
+
+static void variable_position_write (GtsObject * o, FILE * fp)
+{
+  GfsVariablePosition * v = GFS_VARIABLE_POSITION (o);
+
+  (* GTS_OBJECT_CLASS (gfs_variable_position_class ())->parent_class->write) (o, fp);
+
+  fprintf (fp, " %s", v->c == FTT_X ? "x" : v->c == FTT_Y ? "y" : "z");
+}
+
+static void position (FttCell * cell, GfsVariable * v)
+{
+  FttVector p;
+
+  if (gfs_vof_center (cell, GFS_VARIABLE_CURVATURE (v)->f, &p))
+    GFS_VARIABLE (cell, v->i) = (&p.x)[GFS_VARIABLE_POSITION (v)->c];
+  else
+    GFS_VARIABLE (cell, v->i) = G_MAXDOUBLE;
+}
+
+static void variable_position_event_half (GfsEvent * event, GfsSimulation * sim)
+{
+  GfsDomain * domain = GFS_DOMAIN (sim);
+
+  gfs_domain_timer_start (domain, "variable_position");
+
+  gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
+			    (FttCellTraverseFunc) position, event);
+  gfs_domain_cell_traverse (domain, FTT_POST_ORDER, FTT_TRAVERSE_NON_LEAFS, -1,
+			    (FttCellTraverseFunc) GFS_VARIABLE1 (event)->fine_coarse, event);
+  gfs_domain_bc (domain, FTT_TRAVERSE_LEAFS, -1, GFS_VARIABLE1 (event));
+
+  gfs_domain_timer_stop (domain, "variable_position");
+}
+
+static gboolean variable_position_event (GfsEvent * event, GfsSimulation * sim)
+{
+  if ((* GFS_EVENT_CLASS (GTS_OBJECT_CLASS (gfs_variable_class ())->parent_class)->event)
+      (event, sim)) {
+    if (!GFS_VARIABLE_CURVATURE (event)->first_done) {
+      variable_position_event_half (event, sim);
+      GFS_VARIABLE_CURVATURE (event)->first_done = TRUE;
+    }
+    return TRUE;
+  }
+  return FALSE;
+}
+
+static void variable_position_class_init (GtsObjectClass * klass)
+{
+  klass->read = variable_position_read;
+  klass->write = variable_position_write;
+  GFS_EVENT_CLASS (klass)->event = variable_position_event;
+  GFS_EVENT_CLASS (klass)->event_half = variable_position_event_half;
+}
+
+static void variable_position_init (GfsVariable * v)
+{
+}
+
+GfsVariableClass * gfs_variable_position_class (void)
+{
+  static GfsVariableClass * klass = NULL;
+
+  if (klass == NULL) {
+    GtsObjectClassInfo gfs_variable_position_info = {
+      "GfsVariablePosition",
+      sizeof (GfsVariablePosition),
+      sizeof (GfsVariableClass),
+      (GtsObjectClassInitFunc) variable_position_class_init,
+      (GtsObjectInitFunc) variable_position_init,
+      (GtsArgSetFunc) NULL,
+      (GtsArgGetFunc) NULL
+    };
+    klass = gts_object_class_new (GTS_OBJECT_CLASS (gfs_variable_curvature_class ()), 
+				  &gfs_variable_position_info);
+  }
+
+  return klass;
+}
diff --git a/src/tension.h b/src/tension.h
index 79f92a8..27cb7ce 100644
--- a/src/tension.h
+++ b/src/tension.h
@@ -112,6 +112,26 @@ struct _GfsVariableCurvature {
 
 GfsVariableClass * gfs_variable_curvature_class  (void);
 
+/* GfsVariablePosition: header */
+
+typedef struct _GfsVariablePosition                GfsVariablePosition;
+
+struct _GfsVariablePosition {
+  /*< private >*/
+  GfsVariableCurvature parent;
+
+  /*< public >*/
+  FttComponent c;
+};
+
+#define GFS_VARIABLE_POSITION(obj)            GTS_OBJECT_CAST (obj,\
+					           GfsVariablePosition,\
+					           gfs_variable_position_class ())
+#define GFS_IS_VARIABLE_POSITION(obj)         (gts_object_is_from_class (obj,\
+					     gfs_variable_position_class ()))
+
+GfsVariableClass * gfs_variable_position_class  (void);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/src/vof.c b/src/vof.c
index fe5c85b..fb63306 100644
--- a/src/vof.c
+++ b/src/vof.c
@@ -893,6 +893,37 @@ guint gfs_vof_facet (FttCell * cell, GfsVariable * v, FttVector * p, FttVector *
 }
 
 /**
+ * gfs_vof_center:
+ * @cell: a #FttCell.
+ * @v: a #GfsVariable.
+ * @p: a #FttVector.
+ * @m: a #FttVector.
+ *
+ * Fills @p with the (approximate) coordinates of the center
+ * of mass of the VOF-reconstructed interface facet defined by @v.
+ *
+ * Returns: %TRUE if the cell contains the interface, %FALSE otherwise.
+ */
+gboolean gfs_vof_center (FttCell * cell, GfsVariable * v, FttVector * p)
+{
+  g_return_val_if_fail (cell != NULL, FALSE);
+  g_return_val_if_fail (v != NULL, FALSE);
+  g_return_val_if_fail (p != NULL, 0);
+
+  FttVector m, q[6];
+  guint i, nv = gfs_vof_facet (cell, v, q, &m);
+  if (nv > 0) {
+    p->x = p->y = p->z = 0.;
+    for (i = 0; i < nv; i++) {
+      p->x += q[i].x; p->y += q[i].y; p->z += q[i].z;
+    }
+    p->x /= nv; p->y /= nv; p->z /= nv;
+    return TRUE;
+  }
+  return FALSE;
+}
+
+/**
  * gfs_vof_interpolate:
  * @cell: a #FttCell containing location @p.
  * @p: the center of the virtual cell.
diff --git a/src/vof.h b/src/vof.h
index 68f7143..014009e 100644
--- a/src/vof.h
+++ b/src/vof.h
@@ -70,6 +70,9 @@ guint    gfs_vof_facet             (FttCell * cell,
 				    GfsVariable * v,
 				    FttVector * p,
 				    FttVector * m);
+gboolean gfs_vof_center            (FttCell * cell, 
+				    GfsVariable * v, 
+				    FttVector * p);
 gdouble  gfs_vof_interpolate       (FttCell * cell,
 				    FttVector * p,
 				    guint level,

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list