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

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


The following commit has been merged in the upstream branch:
commit e44a670221e86c73116287a48ec3b51663f7a566
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Fri Sep 14 08:10:22 2007 +1000

    Domain traversal should now be deterministic
    
    ...as well as the rest of Gerris. This was not the case before because of the
    "randomization" effect of using hash tables indexed on pointers to store the
    graph nodes (i.e. the GfsBoxes). This was a pain for debugging and also caused
    boxes to "jump around" when visualising periodic domains with several boxes.
    
    darcs-hash:20070913221022-d4795-36ac6586e2760575d4ebbaa140d075ea7e644ca7.gz

diff --git a/src/domain.c b/src/domain.c
index 4fd74c3..c74fe72 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -262,12 +262,36 @@ static void domain_destroy (GtsObject * o)
   (* GTS_OBJECT_CLASS (gfs_domain_class ())->parent_class->destroy) (o);
 }
 
+static void add_item (gpointer item, GPtrArray * a)
+{
+  g_ptr_array_add (a, item);
+}
+
+static gint compare_boxes (const GfsBox ** b1, const GfsBox ** b2)
+{
+  return (*b1)->id < (*b2)->id ? -1 : 1;
+}
+
+static void domain_foreach (GtsContainer * c, 
+			    GtsFunc func, 
+			    gpointer data)
+{
+  GPtrArray * a = g_ptr_array_new ();
+  (* GTS_CONTAINER_CLASS (GTS_OBJECT_CLASS (gfs_domain_class ())->parent_class)->foreach)
+    (c, (GtsFunc) add_item, a);
+  g_ptr_array_sort (a, (GCompareFunc) compare_boxes);
+  g_ptr_array_foreach (a, (GFunc) func, data);
+  g_ptr_array_free (a, TRUE);
+}
+
 static void domain_class_init (GfsDomainClass * klass)
 {
   GTS_OBJECT_CLASS (klass)->read = domain_read;
   GTS_OBJECT_CLASS (klass)->write = domain_write;
   GTS_OBJECT_CLASS (klass)->destroy = domain_destroy;
 
+  GTS_CONTAINER_CLASS (klass)->foreach = domain_foreach;
+
   klass->post_read = domain_post_read;
 }
 
diff --git a/src/simulation.c b/src/simulation.c
index 93d7b34..a80c39b 100644
--- a/src/simulation.c
+++ b/src/simulation.c
@@ -752,8 +752,8 @@ GfsSimulation * gfs_simulation_new (GfsSimulationClass * klass)
   GfsSimulation * object;
 
   object = GFS_SIMULATION (gts_graph_new (GTS_GRAPH_CLASS (klass),
-					 GTS_GNODE_CLASS (gfs_box_class ()),
-					 GTS_GEDGE_CLASS (gfs_gedge_class ())));
+					  GTS_GNODE_CLASS (gfs_box_class ()),
+					  GTS_GEDGE_CLASS (gfs_gedge_class ())));
 
   return object;
 }

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list