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

Stephane Popinet popinet at users.sf.net
Tue Nov 24 12:24:50 UTC 2009


The following commit has been merged in the upstream branch:
commit 7a52ae7f1877a1a001e6fe73ab8266a6fc09bf8d
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Mon Jul 27 10:35:18 2009 +1000

    GfsOutputSolidForce can take an optional weight argument
    
    darcs-hash:20090727003518-d4795-7b90e146e643724e24283669eb3368ccd6e6fa27.gz

diff --git a/src/domain.c b/src/domain.c
index 3eb7e1f..86e5990 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -3065,14 +3065,15 @@ static void add_pressure_force (FttCell * cell, gpointer * data)
   gdouble * m = data[1];
   gdouble * r = &GFS_STATE (cell)->solid->ca.x;
   GfsVariable * p = data[2];
+  gdouble weight = data[3] ? gfs_function_value (data[3], cell) : 1.;
   FttVector ff, mm;
   FttComponent c;
 
   gfs_pressure_force (cell, p, &ff);
   gts_vector_cross (&mm.x, r, &ff.x);
   for (c = 0; c < 3; c++) {
-    f[c] += (&ff.x)[c];
-    m[c] += (&mm.x)[c];
+    f[c] += weight*(&ff.x)[c];
+    m[c] += weight*(&mm.x)[c];
   }
 }
 
@@ -3098,6 +3099,7 @@ static void add_viscous_force (FttCell * cell, gpointer * data)
   gdouble * m = data[1];
   GfsVariable * v = data[2];
   GfsSourceDiffusion * d = data[3];
+  gdouble weight = data[4] ? gfs_function_value (data[4], cell) : 1.;
   gdouble D;
   GfsSolidVector * s = GFS_STATE (cell)->solid;
   gdouble * r = &s->ca.x;
@@ -3149,8 +3151,8 @@ static void add_viscous_force (FttCell * cell, gpointer * data)
 #endif /* 3D */
   gts_vector_cross (&mm.x, r, &ff.x);
   for (c = 0; c < 3; c++) {
-    f[c] += (&ff.x)[c];
-    m[c] += (&mm.x)[c];
+    f[c] += weight*(&ff.x)[c];
+    m[c] += weight*(&mm.x)[c];
   }
 }
 
@@ -3161,10 +3163,11 @@ static void add_viscous_force (FttCell * cell, gpointer * data)
  * @vf: a #FttVector.
  * @pm: a #FttVector.
  * @vm: a #FttVector.
+ * @weight: an optional weight.
  *
  * Fills @pf and @vf (resp. @pm and @vm) with the components of the
  * net pressure and viscous forces (resp. pressure and viscous
- * moments) applied by the fluid on the solid surface embbeded in
+ * moments) applied by the fluid on the solid surface embedded in
  * @domain.
  *
  * The reference point for the moments is the origin of the coordinate system.
@@ -3173,11 +3176,12 @@ void gfs_domain_solid_force (GfsDomain * domain,
 			     FttVector * pf,
 			     FttVector * vf,
 			     FttVector * pm,
-			     FttVector * vm)
+			     FttVector * vm,
+			     GfsFunction * weight)
 {
   FttComponent c;
   GfsVariable ** v;
-  gpointer data[3];
+  gpointer data[4];
 
   g_return_if_fail (domain != NULL);
   g_return_if_fail (pf != NULL);
@@ -3193,6 +3197,7 @@ void gfs_domain_solid_force (GfsDomain * domain,
   data[0] = pf;
   data[1] = pm;
   data[2] = gfs_variable_from_name (domain->variables, "P");
+  data[3] = weight;
   gfs_domain_traverse_mixed (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS,
 			     (FttCellTraverseFunc) add_pressure_force, data);
 
@@ -3203,13 +3208,14 @@ void gfs_domain_solid_force (GfsDomain * domain,
     GfsSourceDiffusion * D = source_diffusion (v[c]);
 
     if (D) {
-      gpointer data[4];
+      gpointer data[5];
 
       gfs_domain_surface_bc (domain, v[c]);
       data[0] = vf;
       data[1] = vm;
       data[2] = v[c];
       data[3] = D;
+      data[4] = weight;
       gfs_domain_traverse_mixed (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS,
 				 (FttCellTraverseFunc) add_viscous_force, data);
     }
diff --git a/src/domain.h b/src/domain.h
index 7b80e0d..356a464 100644
--- a/src/domain.h
+++ b/src/domain.h
@@ -276,7 +276,8 @@ void         gfs_domain_solid_force           (GfsDomain * domain,
 					       FttVector * pf,
 					       FttVector * vf,
 					       FttVector * pm,
-					       FttVector * vm);
+					       FttVector * vm,
+					       GfsFunction * weight);
 guint        gfs_domain_tag_droplets          (GfsDomain * domain,
 					       GfsVariable * c,
 					       GfsVariable * tag);
diff --git a/src/output.c b/src/output.c
index a335ee2..52c91d6 100644
--- a/src/output.c
+++ b/src/output.c
@@ -989,6 +989,37 @@ GfsOutputClass * gfs_output_balance_class (void)
 
 /* GfsOutputSolidForce: Object */
 
+static void gfs_output_solid_force_destroy (GtsObject * object)
+{
+  if (GFS_OUTPUT_SOLID_FORCE (object)->weight)
+    gts_object_destroy (GTS_OBJECT (GFS_OUTPUT_SOLID_FORCE (object)->weight));
+
+  (* GTS_OBJECT_CLASS (gfs_output_solid_force_class ())->parent_class->destroy) (object);
+}
+
+static void gfs_output_solid_force_read (GtsObject ** o, GtsFile * fp)
+{
+  GfsOutputSolidForce * l = GFS_OUTPUT_SOLID_FORCE (*o);
+
+  (* GTS_OBJECT_CLASS (gfs_output_solid_force_class ())->parent_class->read) (o, fp);
+  if (fp->type == GTS_ERROR)
+    return;
+
+  if (fp->type != '\n') {
+    if (!l->weight)
+      l->weight = gfs_function_new (gfs_function_class (), 0.);
+    gfs_function_read (l->weight, gfs_object_simulation (l), fp);
+  }
+}
+
+static void gfs_output_solid_force_write (GtsObject * o, FILE * fp)
+{
+  GfsOutputSolidForce * l = GFS_OUTPUT_SOLID_FORCE (o);
+  (* GTS_OBJECT_CLASS (gfs_output_solid_force_class ())->parent_class->write) (o, fp);
+  if (l->weight)
+    gfs_function_write (l->weight, fp);
+}
+
 static gboolean gfs_output_solid_force_event (GfsEvent * event, 
 					      GfsSimulation * sim)
 {
@@ -1004,7 +1035,7 @@ static gboolean gfs_output_solid_force_event (GfsEvent * event,
       fputs ("# 1: T (2,3,4): Pressure force (5,6,7): Viscous force "
 	     "(8,9,10): Pressure moment (11,12,13): Viscous moment\n", fp);
     
-    gfs_domain_solid_force (domain, &pf, &vf, &pm, &vm);
+    gfs_domain_solid_force (domain, &pf, &vf, &pm, &vm, GFS_OUTPUT_SOLID_FORCE (event)->weight);
     fprintf (fp, "%g %g %g %g %g %g %g %g %g %g %g %g %g\n",
 	     sim->time.t,
 	     pf.x*Ln, pf.y*Ln, pf.z*Ln,
@@ -1018,6 +1049,9 @@ static gboolean gfs_output_solid_force_event (GfsEvent * event,
 
 static void gfs_output_solid_force_class_init (GfsOutputClass * klass)
 {
+  GTS_OBJECT_CLASS (klass)->read = gfs_output_solid_force_read;
+  GTS_OBJECT_CLASS (klass)->write = gfs_output_solid_force_write;
+  GTS_OBJECT_CLASS (klass)->destroy = gfs_output_solid_force_destroy;
   GFS_EVENT_CLASS (klass)->event = gfs_output_solid_force_event;
 }
 
@@ -1028,7 +1062,7 @@ GfsOutputClass * gfs_output_solid_force_class (void)
   if (klass == NULL) {
     GtsObjectClassInfo gfs_output_solid_force_info = {
       "GfsOutputSolidForce",
-      sizeof (GfsOutput),
+      sizeof (GfsOutputSolidForce),
       sizeof (GfsOutputClass),
       (GtsObjectClassInitFunc) gfs_output_solid_force_class_init,
       (GtsObjectInitFunc) NULL,
diff --git a/src/output.h b/src/output.h
index 06bb3ea..c5be861 100644
--- a/src/output.h
+++ b/src/output.h
@@ -120,6 +120,20 @@ GfsOutputClass * gfs_output_balance_class  (void);
 
 /* GfsOutputSolidForce: Header */
 
+typedef struct _GfsOutputSolidForce         GfsOutputSolidForce;
+
+struct _GfsOutputSolidForce {
+  /*< private >*/
+  GfsOutput parent;
+
+  /*< public >*/
+  GfsFunction * weight;
+};
+
+#define GFS_OUTPUT_SOLID_FORCE(obj)            GTS_OBJECT_CAST (obj,\
+					         GfsOutputSolidForce,\
+					         gfs_output_solid_force_class ())
+
 GfsOutputClass * gfs_output_solid_force_class (void);
 
 /* GfsOutputLocation: Header */

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list