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

Stephane Popinet s.popinet at niwa.co.nz
Fri May 15 02:51:39 UTC 2009


The following commit has been merged in the upstream branch:
commit c6e7c60bc986459f5d8381e53fe4b8563a01b565
Author: Stephane Popinet <s.popinet at niwa.co.nz>
Date:   Fri Feb 11 17:13:08 2005 +1100

    New GfsAdaptFunction class
    
    Which uses the new GfsFunction to allow users to specify adaptive criteria
    based on the values of local variables.
    
    This can be used for example to refine around an interface depending on the local
    value of the surface tension.
    
    darcs-hash:20050211061308-fbd8f-7e8574f3f621d5a35c4b001e695cd5ad99abd31c.gz

diff --git a/src/adaptive.c b/src/adaptive.c
index 423ddee..2f71c9d 100644
--- a/src/adaptive.c
+++ b/src/adaptive.c
@@ -21,6 +21,7 @@
 #include <math.h>
 
 #include "adaptive.h"
+#include "solid.h"
 
 #include "graphic.h"
 
@@ -409,6 +410,72 @@ GfsEventClass * gfs_adapt_streamline_curvature_class (void)
   return klass;
 }
 
+/* GfsAdaptFunction: Object */
+
+static void gfs_adapt_function_destroy (GtsObject * o)
+{
+  gts_object_destroy (GTS_OBJECT (GFS_ADAPT_FUNCTION (o)->f));
+
+  (* GTS_OBJECT_CLASS (gfs_adapt_function_class ())->parent_class->destroy) (o);
+}
+
+static void gfs_adapt_function_read (GtsObject ** o, GtsFile * fp)
+{
+  (* GTS_OBJECT_CLASS (gfs_adapt_function_class ())->parent_class->read) (o, fp);
+  if (fp->type == GTS_ERROR)
+    return;
+
+  gfs_object_simulation (GFS_ADAPT_FUNCTION (*o)->f) = gfs_object_simulation (*o);
+  gfs_function_read (GFS_ADAPT_FUNCTION (*o)->f, fp);
+}
+
+static void gfs_adapt_function_write (GtsObject * o, FILE * fp)
+{
+  (* GTS_OBJECT_CLASS (gfs_adapt_function_class ())->parent_class->write) (o, fp);
+  gfs_function_write (GFS_ADAPT_FUNCTION (o)->f, fp);
+}
+
+static void gfs_adapt_function_class_init (GtsObjectClass * klass)
+{
+  klass->destroy = gfs_adapt_function_destroy;  
+  klass->read = gfs_adapt_function_read;
+  klass->write = gfs_adapt_function_write;
+}
+
+static gdouble function_cost (FttCell * cell, GfsAdaptFunction * a)
+{
+  FttVector p;
+  gfs_cell_cm (cell, &p);
+  return gfs_function_value (a->f, cell, &p, gfs_object_simulation (a)->time.t);
+}
+
+static void gfs_adapt_function_init (GfsAdaptFunction * object)
+{
+  object->f = gfs_function_new (gfs_function_class (), 0.);
+  GFS_ADAPT (object)->cost = (GtsKeyFunc) function_cost;
+}
+
+GfsEventClass * gfs_adapt_function_class (void)
+{
+  static GfsEventClass * klass = NULL;
+
+  if (klass == NULL) {
+    GtsObjectClassInfo gfs_adapt_function_info = {
+      "GfsAdaptFunction",
+      sizeof (GfsAdaptFunction),
+      sizeof (GfsEventClass),
+      (GtsObjectClassInitFunc) gfs_adapt_function_class_init,
+      (GtsObjectInitFunc) gfs_adapt_function_init,
+      (GtsArgSetFunc) NULL,
+      (GtsArgGetFunc) NULL
+    };
+    klass = gts_object_class_new (GTS_OBJECT_CLASS (gfs_adapt_class ()),
+				  &gfs_adapt_function_info);
+  }
+
+  return klass;
+}
+
 /* GfsAdaptGradient: Object */
 
 static void gfs_adapt_gradient_read (GtsObject ** o, GtsFile * fp)
diff --git a/src/adaptive.h b/src/adaptive.h
index a2ad1c3..c61d991 100644
--- a/src/adaptive.h
+++ b/src/adaptive.h
@@ -88,6 +88,26 @@ GfsEventClass * gfs_adapt_vorticity_class  (void);
 
 GfsEventClass * gfs_adapt_streamline_curvature_class  (void);
  
+/* GfsAdaptFunction: Header */
+
+typedef struct _GfsAdaptFunction         GfsAdaptFunction;
+
+struct _GfsAdaptFunction {
+  /*< private >*/
+  GfsAdapt parent;
+
+  /*< public >*/
+  GfsFunction * f;
+};
+
+#define GFS_ADAPT_FUNCTION(obj)            GTS_OBJECT_CAST (obj,\
+					         GfsAdaptFunction,\
+					         gfs_adapt_function_class ())
+#define GFS_IS_ADAPT_FUNCTION(obj)         (gts_object_is_from_class (obj,\
+						 gfs_adapt_function_class ()))
+
+GfsEventClass * gfs_adapt_function_class  (void);
+
 /* GfsAdaptGradient: Header */
 
 typedef struct _GfsAdaptGradient         GfsAdaptGradient;
diff --git a/src/init.c b/src/init.c
index 8421874..4b592c1 100644
--- a/src/init.c
+++ b/src/init.c
@@ -252,6 +252,7 @@ void gfs_init (int * argc, char *** argv)
     gfs_adapt_class ();
       gfs_adapt_vorticity_class ();
       gfs_adapt_streamline_curvature_class ();
+      gfs_adapt_function_class ();
       gfs_adapt_gradient_class ();
         gfs_adapt_curvature_class ();
       gfs_adapt_not_box_class ();

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list