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

Stephane Popinet stephane.popinet at paradise.net.nz
Fri May 15 02:51:33 UTC 2009


The following commit has been merged in the upstream branch:
commit ce4b00bd937f0f523d079d185b4b4c5c0b78da28
Author: Stephane Popinet <stephane.popinet at paradise.net.nz>
Date:   Sun Jan 30 14:27:38 2005 +1100

    New GfsAdvection simulation class
    
    darcs-hash:20050130032738-fa380-d5168d304adde4548be7c78b6b5b4800de58ade7.gz

diff --git a/src/init.c b/src/init.c
index 2ce49c3..8421874 100644
--- a/src/init.c
+++ b/src/init.c
@@ -214,6 +214,7 @@ void gfs_init (int * argc, char *** argv)
   /* Instantiates classes before reading any domain or simulation file */
   gfs_simulation_class ();
     gfs_ocean_class ();
+    gfs_advection_class ();
 
   gfs_variable_class ();
     gfs_variable_tracer_class ();
diff --git a/src/simulation.c b/src/simulation.c
index 7c28f2c..df06124 100644
--- a/src/simulation.c
+++ b/src/simulation.c
@@ -1036,3 +1036,114 @@ void gfs_simulation_run (GfsSimulation * sim)
   (* GFS_SIMULATION_CLASS (GTS_OBJECT (sim)->klass)->run) (sim);
   g_timer_stop (GFS_DOMAIN (sim)->timer);
 }
+
+/* GfsAdvection: Object */
+
+static void advection_run (GfsSimulation * sim)
+{
+  GfsVariable * v;
+  GfsDomain * domain;
+
+  domain = GFS_DOMAIN (sim);
+
+  gfs_simulation_refine (sim);
+
+  gts_container_foreach (GTS_CONTAINER (sim->events), (GtsFunc) gfs_event_init, sim);
+  gts_container_foreach (GTS_CONTAINER (sim->adapts), (GtsFunc) gfs_event_init, sim);
+
+  gfs_set_merged (domain);
+  v = domain->variables;
+  while (v) {
+    gfs_event_init (GFS_EVENT (v), sim);
+    gfs_domain_bc (domain, FTT_TRAVERSE_LEAFS, -1, v);
+    v = v->next;
+  }
+
+  while (sim->time.t < sim->time.end &&
+	 sim->time.i < sim->time.iend) {
+    gdouble tstart;
+
+    v = domain->variables;
+    while (v) {
+      gfs_event_do (GFS_EVENT (v), sim);
+      v = v->next;
+    }
+    gfs_domain_cell_traverse (domain,
+			      FTT_POST_ORDER, FTT_TRAVERSE_NON_LEAFS, -1,
+			      (FttCellTraverseFunc) gfs_cell_coarse_init, domain);
+    gts_container_foreach (GTS_CONTAINER (sim->events), (GtsFunc) gfs_event_do, sim);
+
+    tstart = g_timer_elapsed (domain->timer, NULL);
+
+    gfs_simulation_set_timestep (sim);
+
+    gfs_domain_face_traverse (domain, FTT_XYZ,
+			      FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
+			      (FttFaceTraverseFunc) gfs_face_reset_normal_velocity,
+			      NULL);
+    gfs_domain_face_traverse (domain, FTT_XYZ,
+			      FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,
+			      (FttFaceTraverseFunc) gfs_face_interpolated_normal_velocity, NULL);
+
+    v = domain->variables;
+    while (v) {
+      if (GFS_IS_VARIABLE_TRACER (v)) {
+	GfsVariableTracer * t = GFS_VARIABLE_TRACER (v);
+
+	t->advection.dt = sim->advection_params.dt;
+	switch (t->advection.scheme) {
+	case GFS_GODUNOV:
+	  gfs_tracer_advection_diffusion (domain, &t->advection, &t->diffusion, NULL);
+	  break;
+	case GFS_VOF:
+	  gfs_tracer_vof_advection (domain, &t->advection, NULL);
+	  gfs_domain_variable_centered_sources (domain, v, v, t->advection.dt);
+	  break;
+	case GFS_NONE:
+	  break;
+	}
+      }
+      v = v->next;
+    }
+
+    gts_container_foreach (GTS_CONTAINER (sim->events), (GtsFunc) gfs_event_half_do, sim);
+
+    gfs_simulation_adapt (sim, NULL);
+
+    sim->time.t = sim->tnext;
+    sim->time.i++;
+
+    gts_range_add_value (&domain->timestep, g_timer_elapsed (domain->timer, NULL) - tstart);
+    gts_range_update (&domain->timestep);
+    gts_range_add_value (&domain->size, gfs_domain_size (domain, FTT_TRAVERSE_LEAFS, -1));
+    gts_range_update (&domain->size);
+  }
+  gts_container_foreach (GTS_CONTAINER (sim->events), (GtsFunc) gfs_event_do, sim);  
+  gts_container_foreach (GTS_CONTAINER (sim->events),
+			 (GtsFunc) gts_object_destroy, NULL);
+}
+
+static void gfs_advection_class_init (GfsSimulationClass * klass)
+{
+  klass->run = advection_run;
+}
+
+GfsSimulationClass * gfs_advection_class (void)
+{
+  static GfsSimulationClass * klass = NULL;
+
+  if (klass == NULL) {
+    GtsObjectClassInfo gfs_advection_info = {
+      "GfsAdvection",
+      sizeof (GfsSimulation),
+      sizeof (GfsSimulationClass),
+      (GtsObjectClassInitFunc) gfs_advection_class_init,
+      (GtsObjectInitFunc) NULL,
+      (GtsArgSetFunc) NULL,
+      (GtsArgGetFunc) NULL
+    };
+    klass = gts_object_class_new (GTS_OBJECT_CLASS (gfs_simulation_class ()), &gfs_advection_info);
+  }
+
+  return klass;
+}
diff --git a/src/simulation.h b/src/simulation.h
index 69203cb..90c613e 100644
--- a/src/simulation.h
+++ b/src/simulation.h
@@ -117,7 +117,11 @@ void                 gfs_physical_params_write   (GfsPhysicalParams * p,
 void                 gfs_physical_params_read    (GfsPhysicalParams * p,
 						  GtsFile * fp);
 void                 gfs_simulation_run          (GfsSimulation * sim);
-#define              gfs_object_simulation(o)    GFS_SIMULATION(GTS_OBJECT (o)->reserved)
+#define              gfs_object_simulation(o)     GFS_SIMULATION(GTS_OBJECT (o)->reserved)
+
+/* GfsAdvection: Header */
+
+GfsSimulationClass * gfs_advection_class          (void);
 
 #ifdef __cplusplus
 }

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list