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

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


The following commit has been merged in the upstream branch:
commit f6dae73a61f536178f46f8e21a5147793937c9d2
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Mon Jul 6 08:14:36 2009 +1000

    Box positions set in the parameter file are preserved
    
    darcs-hash:20090705221436-d4795-2c5ff55404317ef692c8b4ca038de6e3cfae4d32.gz

diff --git a/src/boundary.c b/src/boundary.c
index e9d0167..b7cb5fd 100644
--- a/src/boundary.c
+++ b/src/boundary.c
@@ -1427,8 +1427,7 @@ GfsGEdgeClass * gfs_gedge_class (void)
  *
  * Links the two boxes connected by @edge. The boxes are set as their
  * respective neighbors in the direction defined by @edge (note that
- * their relative positions are not set, call
- * gfs_box_set_relative_pos() if necessary).
+ * their relative positions are not set).
  */
 void gfs_gedge_link_boxes (GfsGEdge * edge)
 {
@@ -1707,6 +1706,8 @@ static void gfs_box_read (GtsObject ** o, GtsFile * fp)
 	ftt_cell_set_pos (GFS_BOUNDARY (b->neighbor[d])->root, &bpos);
       }
   }
+  else /* position is not set */
+    FTT_ROOT_CELL (b->root)->pos.x = G_MAXDOUBLE;
 
   /* updates weight of domain */
   GTS_WGRAPH (domain)->weight += gts_gnode_weight (GTS_GNODE (b)) - weight;
@@ -1779,93 +1780,3 @@ GfsBox * gfs_box_new (GfsBoxClass * klass)
   return object;
 }
 
-static void box_set_pos (GfsBox * box, FttVector * pos, 
-			 GHashTable * set,
-			 FttDirection dold)
-{
-  FttVector p;
-  static FttDirection id[FTT_NEIGHBORS][FTT_NEIGHBORS] = 
-#if FTT_2D
-  {
-    {0,1,2,3},
-    {1,0,3,2},
-    {2,3,1,0},
-    {3,2,0,1},
-  };
-#else  /* 3D */
-  {
-    {0,1,2,3,5,4},
-    {1,0,3,2,4,5},
-    {2,3,1,0,5,4},
-    {3,2,0,1,4,5},
-    {4,5,2,3,0,1},
-    {5,4,3,2,1,0}
-  };
-#endif /* 3D */
-  FttDirection i;
-  gdouble size;
-
-  if (g_hash_table_lookup (set, box))
-    return;
-  g_hash_table_insert (set, box, box);
-
-  size = ftt_cell_size (box->root);
-  ftt_cell_set_pos (box->root, pos);
-  for (i = 0; i < FTT_NEIGHBORS; i++) {
-    FttDirection d = id[dold][i];
-    
-    p.x = pos->x + rpos[d].x*size;
-    p.y = pos->y + rpos[d].y*size;
-    p.z = pos->z + rpos[d].z*size;
-    if (GFS_IS_BOX (box->neighbor[d]))
-      box_set_pos (GFS_BOX (box->neighbor[d]), &p, set, d);
-    else if (GFS_IS_BOUNDARY (box->neighbor[d]))
-      ftt_cell_set_pos (GFS_BOUNDARY (box->neighbor[d])->root, &p);
-  }
-}
-
-/**
- * gfs_box_set_pos:
- * @box: a #GfsBox.
- * @pos: the new position of the center of the box.
- *
- * Recursively sets the position of the center of @box and of its
- * neighbors.  
- */
-void gfs_box_set_pos (GfsBox * box, FttVector * pos)
-{
-  GHashTable * set;
-
-  g_return_if_fail (box != NULL);
-  g_return_if_fail (pos != NULL);
-
-  set = g_hash_table_new (NULL, NULL);
-  box_set_pos (box, pos, set, FTT_RIGHT);
-  g_hash_table_destroy (set);
-}
-
-/**
- * gfs_box_set_relative_pos:
- * @box: a #GfsBox.
- * @reference: a reference #GfsBox.
- * @d: the direction in which @box is found relative to @reference.
- *
- * Recursively sets the position of the center of @box and of its
- * neighbors relative to the position of @reference in direction @d.
- */
-void gfs_box_set_relative_pos (GfsBox * box, GfsBox * reference, FttDirection d)
-{
-  FttVector pos;
-  gdouble size;
-
-  g_return_if_fail (box != NULL);
-  g_return_if_fail (reference != NULL);
-  g_return_if_fail (d >= 0 && d < FTT_NEIGHBORS);
-
-  ftt_cell_pos (reference->root, &pos);
-  size = ftt_cell_size (reference->root);
-  pos.x += rpos[d].x*size;
-  pos.y += rpos[d].y*size;
-  pos.z += rpos[d].z*size;
-  gfs_box_set_pos (box, &pos);
-}
diff --git a/src/boundary.h b/src/boundary.h
index b057295..677bed1 100644
--- a/src/boundary.h
+++ b/src/boundary.h
@@ -318,11 +318,6 @@ struct _GfsBoxClass {
      
 GfsBoxClass *    gfs_box_class                (void);
 GfsBox *         gfs_box_new                  (GfsBoxClass * klass);
-void             gfs_box_set_pos              (GfsBox * box, 
-					       FttVector * pos);
-void             gfs_box_set_relative_pos     (GfsBox * box, 
-					       GfsBox * reference, 
-					       FttDirection d);
 
 static inline
 GfsDomain * gfs_box_domain (GfsBox * box)
diff --git a/src/domain.c b/src/domain.c
index c6bbd45..8bc9e13 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -159,10 +159,58 @@ static void domain_read (GtsObject ** o, GtsFile * fp)
   }
 }
 
+static void box_set_pos (GfsBox * box, FttVector * pos, 
+			 FttDirection dold)
+{
+  FttVector p;
+  static FttVector rpos[FTT_NEIGHBORS] = {
+#if FTT_2D
+    {1.,0.,0.}, {-1.,0.,0.}, {0.,1.,0.}, {0.,-1.,0.}
+#else  /* FTT_3D */
+    {1.,0.,0.}, {-1.,0.,0.}, {0.,1.,0.}, {0.,-1.,0.}, {0.,0.,1.}, {0.,0.,-1.}
+#endif /* FTT_3D */
+  };  
+  static FttDirection id[FTT_NEIGHBORS][FTT_NEIGHBORS] = {
+#if FTT_2D
+    {0,1,2,3},
+    {1,0,3,2},
+    {2,3,1,0},
+    {3,2,0,1},
+#else  /* 3D */
+    {0,1,2,3,5,4},
+    {1,0,3,2,4,5},
+    {2,3,1,0,5,4},
+    {3,2,0,1,4,5},
+    {4,5,2,3,0,1},
+    {5,4,3,2,1,0}
+#endif /* 3D */
+  };
+
+  ftt_cell_pos (box->root, &p);
+  if (p.x != G_MAXDOUBLE) /* position already set */
+    return;
+
+  FttDirection i;
+  gdouble size;
+  size = ftt_cell_size (box->root);
+  ftt_cell_set_pos (box->root, pos);
+  for (i = 0; i < FTT_NEIGHBORS; i++) {
+    FttDirection d = id[dold][i];
+    
+    p.x = pos->x + rpos[d].x*size;
+    p.y = pos->y + rpos[d].y*size;
+    p.z = pos->z + rpos[d].z*size;
+    if (GFS_IS_BOX (box->neighbor[d]))
+      box_set_pos (GFS_BOX (box->neighbor[d]), &p, d);
+    else if (GFS_IS_BOUNDARY (box->neighbor[d]))
+      ftt_cell_set_pos (GFS_BOUNDARY (box->neighbor[d])->root, &p);
+  }
+}
+
 static void set_ref_pos (GfsBox * box, FttVector * pos)
 {
   if (box->id == 1)
-    gfs_box_set_pos (box, pos);
+    box_set_pos (box, pos, FTT_RIGHT);
 }
 
 #ifdef HAVE_MPI

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list