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

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


The following commit has been merged in the upstream branch:
commit 09388e6393b7602e1f1aaf877205284637fa475f
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Fri Dec 21 12:53:02 2007 +1100

    gfs_domain_cfl takes MAC velocities into account
    
    darcs-hash:20071221015302-d4795-b7744087c1a9de4ccf7b39e5de6fc06ce2bd0ada.gz

diff --git a/src/domain.c b/src/domain.c
index 81b343d..12847d5 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -2177,28 +2177,41 @@ guint gfs_domain_size (GfsDomain * domain,
   return n;
 }
 
-static void minimum_cfl (FttCell * cell, gpointer * data)
+typedef struct {
+  gdouble cfl;
+  GfsVariable ** v;
+} CflData;
+
+static void minimum_mac_cfl (FttCellFace * face, gdouble * cfl)
+{
+  gdouble un = GFS_STATE (face->cell)->f[face->d].un;
+  if (un != 0.) {
+    gdouble cflu = ftt_cell_size (face->cell)/fabs (un);
+    if (cflu*cflu < *cfl)
+      *cfl = cflu*cflu;
+  }
+}
+
+static void minimum_cfl (FttCell * cell, CflData * p)
 {
-  gdouble * cfl = data[0];
-  GfsVariable ** v = data[1];
   gdouble size = ftt_cell_size (cell);
   FttComponent c;
 
   for (c = 0; c < FTT_DIMENSION; c++) {
-    if (GFS_VARIABLE (cell, v[c]->i) != 0.) {
-      gdouble cflu = size/fabs (GFS_VARIABLE (cell, v[c]->i));
+    if (GFS_VARIABLE (cell, p->v[c]->i) != 0.) {
+      gdouble cflu = size/fabs (GFS_VARIABLE (cell, p->v[c]->i));
 
-      if (cflu*cflu < *cfl)
-	*cfl = cflu*cflu;
+      if (cflu*cflu < p->cfl)
+	p->cfl = cflu*cflu;
     }
-    if (v[c]->sources) {
-      gdouble g = gfs_variable_mac_source (v[c], cell);
+    if (p->v[c]->sources) {
+      gdouble g = gfs_variable_mac_source (p->v[c], cell);
 
       if (g != 0.) {
 	gdouble cflg = 2.*size/fabs (g);
 
-	if (cflg < *cfl)
-	  *cfl = cflg;
+	if (cflg < p->cfl)
+	  p->cfl = cflg;
       }
     }
   }
@@ -2219,24 +2232,25 @@ gdouble gfs_domain_cfl (GfsDomain * domain,
 			FttTraverseFlags flags,
 			gint max_depth)
 {
-  gdouble cfl = 1.;
-  gpointer data[2];
+  CflData p;
 
   g_return_val_if_fail (domain != NULL, 0.);
 
-  data[0] = &cfl;
-  data[1] = gfs_domain_velocity (domain);
+  p.cfl = 1.;
+  gfs_domain_face_traverse (domain, FTT_XYZ, FTT_PRE_ORDER, flags, max_depth, 
+			    (FttFaceTraverseFunc) minimum_mac_cfl, &p.cfl);
+  p.v = gfs_domain_velocity (domain);
   gfs_domain_cell_traverse (domain, FTT_PRE_ORDER, flags, max_depth, 
-			    (FttCellTraverseFunc) minimum_cfl, data);
+			    (FttCellTraverseFunc) minimum_cfl, &p);
 #ifdef HAVE_MPI
   if (domain->pid >= 0) {
     gdouble gcfl;
 
-    MPI_Allreduce (&cfl, &gcfl, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
-    cfl = gcfl;
+    MPI_Allreduce (&p.cfl, &gcfl, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
+    p.cfl = gcfl;
   }
 #endif /* HAVE_MPI */
-  return sqrt (cfl);
+  return sqrt (p.cfl);
 }
 
 /**

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list