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

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


The following commit has been merged in the upstream branch:
commit 1df82667ce1a3e4d32fc566b49d782add90bea74
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Thu Oct 29 14:55:08 2009 +1100

    OutputScalarSum, OutputScalarNorm etc... take metric into account
    
    darcs-hash:20091029035508-d4795-7a12291304f1216cd506ae4ed51341a8d20b5d3a.gz

diff --git a/src/domain.c b/src/domain.c
index 2704105..ee147ac 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -1860,7 +1860,7 @@ static void add_norm (const FttCell * cell, gpointer * data)
   GfsNorm * n = data[0];
   GfsVariable * v = data[1];
 
-  gfs_norm_add (n, GFS_VARIABLE (cell, v->i), gfs_cell_volume (cell));
+  gfs_norm_add (n, GFS_VALUE (cell, v), gfs_cell_volume (cell, v->domain));
 }
 
 static void add_norm_weighted (FttCell * cell, gpointer * data)
@@ -1869,7 +1869,8 @@ static void add_norm_weighted (FttCell * cell, gpointer * data)
   GfsVariable * v = data[1];
   GfsFunction * w = data[2];
 
-  gfs_norm_add (n, GFS_VARIABLE (cell, v->i), gfs_cell_volume (cell)*gfs_function_value (w, cell));
+  gfs_norm_add (n, GFS_VALUE (cell, v), gfs_cell_volume (cell, v->domain)*
+		gfs_function_value (w, cell));
 }
 
 #ifdef HAVE_MPI
@@ -2034,7 +2035,7 @@ static void add_norm_velocity (FttCell * cell, gpointer * data)
   GfsVariable ** u = data[0];
   GfsNorm * n = data[1];
   
-  gfs_norm_add (n, gfs_vector_norm (cell, u), gfs_cell_volume (cell));
+  gfs_norm_add (n, gfs_vector_norm (cell, u), gfs_cell_volume (cell, u[0]->domain));
 }
 
 /**
diff --git a/src/domain.h b/src/domain.h
index f7cd455..1133baf 100644
--- a/src/domain.h
+++ b/src/domain.h
@@ -408,6 +408,20 @@ gdouble gfs_domain_solid_metric (const GfsDomain * domain, const FttCell * cell)
   return 1.;
 }
 
+/**
+ * gfs_cell_volume:
+ * @cell: a #FttCell.
+ * @domain: a #GfsDomain.
+ *
+ * Returns: the volume of @cell.
+ */
+static inline
+gdouble gfs_cell_volume (const FttCell * cell, const GfsDomain * domain)
+{
+  double v = ftt_cell_volume (cell)*(GFS_IS_MIXED (cell) ? GFS_STATE (cell)->solid->a : 1.);
+  return domain->cell_metric ? (* domain->cell_metric) (domain, cell)*v : v;
+}
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/src/fluid.c b/src/fluid.c
index 8ffdd94..227c8f7 100644
--- a/src/fluid.c
+++ b/src/fluid.c
@@ -1820,7 +1820,7 @@ static void add_norm (const FttCell * cell, gpointer * data)
   GfsNorm * n = data[0];
   GfsVariable * v = data[1];
 
-  gfs_norm_add (n, GFS_VARIABLE (cell, v->i), gfs_cell_volume (cell));
+  gfs_norm_add (n, GFS_VALUE (cell, v), gfs_cell_volume (cell, v->domain));
 }
 
 /**
diff --git a/src/fluid.h b/src/fluid.h
index c77990c..019e7d0 100644
--- a/src/fluid.h
+++ b/src/fluid.h
@@ -191,9 +191,6 @@ GtsRange              gfs_stats_variable             (FttCell * root,
 						      FttTraverseFlags flags,
 						      gint max_depth);
 
-#define               gfs_cell_volume(cell)   (ftt_cell_volume (cell)*(GFS_IS_MIXED (cell) ?\
-					       GFS_STATE (cell)->solid->a : 1.))
-
 typedef struct _GfsNorm GfsNorm;
 
 struct _GfsNorm {
diff --git a/src/output.c b/src/output.c
index bb725b0..630a1cc 100644
--- a/src/output.c
+++ b/src/output.c
@@ -1996,11 +1996,11 @@ GfsOutputClass * gfs_output_scalar_stats_class (void)
 
 static void add (FttCell * cell, gpointer * data)
 {
-  gdouble vol = gfs_cell_volume (cell);
   GfsVariable * v = data[0];
+  gdouble vol = gfs_cell_volume (cell, v->domain);
   gdouble * sum = data[1];
 
-  *sum += vol*GFS_VARIABLE (cell, v->i);
+  *sum += vol*GFS_VALUE (cell, v);
 }
 
 static gboolean gfs_output_scalar_sum_event (GfsEvent * event, 
@@ -2291,7 +2291,7 @@ static void gfs_output_scalar_histogram_write (GtsObject * o, FILE * fp)
 static void update_histogram (FttCell * cell, GfsOutputScalar * h)
 {
   GfsOutputScalarHistogram * hi = GFS_OUTPUT_SCALAR_HISTOGRAM (h);
-  gdouble v = GFS_VARIABLE (cell, h->v->i);
+  gdouble v = GFS_VALUE (cell, h->v);
   gint i = (v - h->min)/(h->max - h->min)*hi->n;
 
   if (i >= 0 && i < hi->n) {
@@ -2300,7 +2300,7 @@ static void update_histogram (FttCell * cell, GfsOutputScalar * h)
     if (hi->wf)
       w *= gfs_function_value (hi->wf, cell);
     else
-      w *= gfs_cell_volume (cell);
+      w *= gfs_cell_volume (cell, h->v->domain);
 
     hi->W += w;
     hi->w[i] += w;
@@ -2813,8 +2813,8 @@ static void compute_correlation (FttCell * cell, gpointer * data)
   gdouble v, ref, w;
 
   ref = gfs_function_value (GFS_OUTPUT_ERROR_NORM (o)->s, cell);
-  v = GFS_VARIABLE (cell, o->v->i) - *bias;
-  w = gfs_cell_volume (cell);
+  v = GFS_VALUE (cell, o->v) - *bias;
+  w = gfs_cell_volume (cell, o->v->domain);
   *sumref += ref*ref*w;
   *sum += v*ref*w;
 }
diff --git a/src/source.c b/src/source.c
index 6efd8f6..358bbf3 100644
--- a/src/source.c
+++ b/src/source.c
@@ -435,7 +435,7 @@ typedef struct {
 
 static void sum (FttCell * cell, Sum * s)
 {
-  gdouble vol = gfs_cell_volume (cell);
+  gdouble vol = gfs_cell_volume (cell, s->v->domain);
   s->s += vol*GFS_VALUE (cell, s->v);
   s->sv += vol;
 }
@@ -637,7 +637,8 @@ static void source_flux_write (GtsObject * o, FILE * fp)
 
 static void add (FttCell * cell, GfsSourceFlux * s)
 {
-  s->s += gfs_cell_volume (cell)*gfs_function_value (s->fraction, cell);
+  s->s += gfs_cell_volume (cell, GFS_DOMAIN (gfs_object_simulation (s)))*
+    gfs_function_value (s->fraction, cell);
 }
 
 static gboolean source_flux_event (GfsEvent * event, GfsSimulation * sim)
diff --git a/test/axiadvection/axiadvection.gfs b/test/axiadvection/axiadvection.gfs
index a8b61fb..ed25c0c 100644
--- a/test/axiadvection/axiadvection.gfs
+++ b/test/axiadvection/axiadvection.gfs
@@ -32,8 +32,8 @@
     InitFraction T (- ellipse (0, 0.3, 0.1, 0.1))
     InitFraction T1 (- ellipse (0, 0.3, 0.1, 0.1))
     AdaptGradient { istep = 1 } { cmax = 1e-3 minlevel = 4 maxlevel = (x < 0.25 ? 6 : 7) } T1
-    OutputScalarSum { istep = 1 end = 0.8 } srt { v = y*T }
-    OutputScalarSum { istep = 1 end = 0.8 } srt1 { v = y*T1 }
+    OutputScalarSum { istep = 1 end = 0.8 } srt { v = T }
+    OutputScalarSum { istep = 1 end = 0.8 } srt1 { v = T1 }
     OutputSimulation { step = 0.2 } stdout
     EventScript { step = 0.2 } {
 	echo "Save stdout { format = Gnuplot }"
diff --git a/test/axiadvection/solid/solid.gfs b/test/axiadvection/solid/solid.gfs
index 50e8b8c..fa29083 100644
--- a/test/axiadvection/solid/solid.gfs
+++ b/test/axiadvection/solid/solid.gfs
@@ -21,8 +21,8 @@
     InitFraction T (- ellipse (-0.2, 0., 0.05, 0.05))
     InitFraction T1 (- ellipse (-0.2, 0., 0.05, 0.05))
     AdaptGradient { istep = 1 } { cmax = 1e-3 minlevel = 4 maxlevel = (x < 0. ? 7 : 8) } T1
-    OutputScalarSum { istep = 1 } srt { v = y*T }
-    OutputScalarSum { istep = 1 } srt1 { v = y*T1 }
+    OutputScalarSum { istep = 1 } srt { v = T }
+    OutputScalarSum { istep = 1 } srt1 { v = T1 }
 }
 GfsBox {
     left = Boundary {

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list