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

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


The following commit has been merged in the upstream branch:
commit 00c4becc77ea69ebb341cbd785e3db50fcf00937
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Mon Jun 9 07:55:16 2008 +1000

    GfsAdaptGradient has been generalised to functions
    
    darcs-hash:20080608215516-d4795-0d2c13a8431620120eb15481fef33f01f0153b61.gz

diff --git a/src/adaptive.c b/src/adaptive.c
index cd3518c..043de87 100644
--- a/src/adaptive.c
+++ b/src/adaptive.c
@@ -444,43 +444,54 @@ GfsEventClass * gfs_adapt_function_class (void)
 
 /* GfsAdaptGradient: Object */
 
-static void gfs_adapt_gradient_read (GtsObject ** o, GtsFile * fp)
+static void gfs_adapt_gradient_destroy (GtsObject * o)
 {
-  GfsVariable * v;
-  GfsDomain * domain;
+  if (GFS_ADAPT_GRADIENT (o)->v && !gfs_function_get_variable (GFS_ADAPT_FUNCTION (o)->f))
+    gts_object_destroy (GTS_OBJECT (GFS_ADAPT_GRADIENT (o)->v));
 
-  if (GTS_OBJECT_CLASS (gfs_adapt_gradient_class ())->parent_class->read)
-    (* GTS_OBJECT_CLASS (gfs_adapt_gradient_class ())->parent_class->read) 
-      (o, fp);
+  (* GTS_OBJECT_CLASS (gfs_adapt_gradient_class ())->parent_class->destroy) (o);
+}
+
+static void gfs_adapt_gradient_read (GtsObject ** o, GtsFile * fp)
+{
+  (* GTS_OBJECT_CLASS (gfs_adapt_gradient_class ())->parent_class->read) (o, fp);
   if (fp->type == GTS_ERROR)
     return;
 
-  if (fp->type != GTS_STRING) {
-    gts_file_error (fp, "expecting a string (variable name)");
-    return;
-  }
-  domain = GFS_DOMAIN (gfs_object_simulation (*o));
-  v = gfs_variable_from_name (domain->variables, fp->token->str);
-  if (v == NULL) {
-    gts_file_error (fp, "unknown variable `%s'", fp->token->str);
-    return;
-  }
-  GFS_ADAPT_GRADIENT (*o)->v = v;
-  gts_file_next_token (fp);
+  GFS_ADAPT_GRADIENT (*o)->v = gfs_function_get_variable (GFS_ADAPT_FUNCTION (*o)->f);
+  if (GFS_ADAPT_GRADIENT (*o)->v == NULL)
+    GFS_ADAPT_GRADIENT (*o)->v = gfs_temporary_variable (GFS_DOMAIN (gfs_object_simulation (*o)));
 }
 
-static void gfs_adapt_gradient_write (GtsObject * o, FILE * fp)
+static void update_f (FttCell * cell, GfsAdaptFunction * a)
 {
-  if (GTS_OBJECT_CLASS (gfs_adapt_gradient_class ())->parent_class->write)
-    (* GTS_OBJECT_CLASS (gfs_adapt_gradient_class ())->parent_class->write) 
-      (o, fp);
-  fprintf (fp, " %s ", GFS_ADAPT_GRADIENT (o)->v->name);
+  GFS_VALUE (cell, GFS_ADAPT_GRADIENT (a)->v) = gfs_function_value (a->f, cell);
+}
+
+static gboolean gfs_adapt_gradient_event (GfsEvent * event, 
+					  GfsSimulation * sim)
+{
+  if ((* GFS_EVENT_CLASS (GTS_OBJECT_CLASS (gfs_adapt_gradient_class ())->parent_class)->event) 
+      (event, sim)) {
+    if (!gfs_function_get_variable (GFS_ADAPT_FUNCTION (event)->f)) {
+      gfs_domain_cell_traverse (GFS_DOMAIN (sim), FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
+				(FttCellTraverseFunc) update_f, event);
+      GfsVariable * v = GFS_ADAPT_GRADIENT (event)->v;
+      gfs_domain_cell_traverse (GFS_DOMAIN (sim),
+				FTT_POST_ORDER, FTT_TRAVERSE_NON_LEAFS, -1,
+				(FttCellTraverseFunc) v->fine_coarse, v);
+      gfs_domain_bc (GFS_DOMAIN (sim), FTT_TRAVERSE_ALL, -1, v);
+    }
+    return TRUE;
+  }
+  return FALSE;
 }
 
 static void gfs_adapt_gradient_class_init (GfsEventClass * klass)
 {
+  GTS_OBJECT_CLASS (klass)->destroy = gfs_adapt_gradient_destroy;
   GTS_OBJECT_CLASS (klass)->read = gfs_adapt_gradient_read;
-  GTS_OBJECT_CLASS (klass)->write = gfs_adapt_gradient_write;
+  klass->event = gfs_adapt_gradient_event;
 }
 
 static gdouble gradient_cost (FttCell * cell, GfsAdaptGradient * a)
@@ -517,7 +528,7 @@ GfsEventClass * gfs_adapt_gradient_class (void)
       (GtsArgSetFunc) NULL,
       (GtsArgGetFunc) NULL
     };
-    klass = gts_object_class_new (GTS_OBJECT_CLASS (gfs_adapt_class ()),
+    klass = gts_object_class_new (GTS_OBJECT_CLASS (gfs_adapt_function_class ()),
 				  &gfs_adapt_gradient_info);
   }
 
diff --git a/src/adaptive.h b/src/adaptive.h
index e84ea0c..6d4fc43 100644
--- a/src/adaptive.h
+++ b/src/adaptive.h
@@ -114,7 +114,7 @@ typedef struct _GfsAdaptGradient         GfsAdaptGradient;
 
 struct _GfsAdaptGradient {
   /*< private >*/
-  GfsAdapt parent;
+  GfsAdaptFunction parent;
 
   /*< public >*/
   GfsVariable * v;

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list