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

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


The following commit has been merged in the upstream branch:
commit 0bd1c5257789983ea1aa8ed358d89c84c5355fa0
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Sat Jan 12 16:52:58 2008 +1100

    Timestep is set properly to guarantee CFL condition
    
    This should fix CFL problems when using the VOF scheme.
    
    darcs-hash:20080112055258-d4795-90bdb6900bd99045ae0b1be2f2efe91058315444.gz

diff --git a/src/event.c b/src/event.c
index 1a5c4d8..f66a039 100644
--- a/src/event.c
+++ b/src/event.c
@@ -25,6 +25,40 @@
 #include "solid.h"
 #include "output.h"
 
+/**
+ * gfs_event_next:
+ * @event: a #GfsEvent.
+ * @sim: a #GfsSimulation.
+ *
+ * Returns: the next physical time at which @event will be realised.
+ */
+gdouble gfs_event_next (GfsEvent * event, GfsSimulation * sim)
+{
+  g_return_val_if_fail (event != NULL, G_MAXDOUBLE);
+  g_return_val_if_fail (sim != NULL, G_MAXDOUBLE);
+
+  if (sim->time.t < event->t)
+    return event->t;
+  if (event->t >= event->end ||
+      event->i >= event->iend ||
+      sim->time.t > event->end || 
+      sim->time.i > event->iend)
+    return G_MAXDOUBLE;
+  if (event->end_event)
+    return G_MAXDOUBLE;
+  if (sim->time.t >= event->t) {
+    if (event->istep < G_MAXINT) {
+      if (event->n == 0)
+	return G_MAXDOUBLE;
+    }
+    else
+      return event->start + (event->n + 1)*event->step;
+  }
+  if (sim->time.i >= event->i && event->step < G_MAXDOUBLE && event->n == 0)
+    return sim->time.t + event->step;
+  return G_MAXDOUBLE;
+}
+
 static gboolean gfs_event_event (GfsEvent * event, GfsSimulation * sim)
 {
   if (event->t >= event->end ||
diff --git a/src/event.h b/src/event.h
index 712b050..06dea2a 100644
--- a/src/event.h
+++ b/src/event.h
@@ -73,6 +73,8 @@ void            gfs_event_init        (GfsEvent * event,
 				       GfsSimulation * sim);
 void            gfs_event_do          (GfsEvent * event, 
 				       GfsSimulation * sim);
+gdouble         gfs_event_next        (GfsEvent * event, 
+				       GfsSimulation * sim);
 void            gfs_event_half_do     (GfsEvent * event, 
 				       GfsSimulation * sim);
 #define         gfs_event_is_repetitive(e) ((e)->step < G_MAXDOUBLE || (e)->istep < G_MAXINT)
diff --git a/src/simulation.c b/src/simulation.c
index ad022a4..6c3f5fc 100644
--- a/src/simulation.c
+++ b/src/simulation.c
@@ -359,6 +359,7 @@ static void simulation_run (GfsSimulation * sim)
 				&sim->approx_projection_params,
 				&sim->advection_params,
 				p, sim->physical_params.alpha, res);
+    gfs_simulation_set_timestep (sim);
     advance_tracers (domain, sim->advection_params.dt/2.);
   }
   while (sim->time.t < sim->time.end &&
@@ -368,8 +369,6 @@ static void simulation_run (GfsSimulation * sim)
 
     gts_container_foreach (GTS_CONTAINER (sim->events), (GtsFunc) gfs_event_do, sim);
 
-    gfs_simulation_set_timestep (sim);
-
     gfs_predicted_face_velocities (domain, FTT_DIMENSION, &sim->advection_params);
     
     gfs_variables_swap (p, pmac);
@@ -405,19 +404,19 @@ static void simulation_run (GfsSimulation * sim)
    				&sim->approx_projection_params, 
     				&sim->advection_params, p, sim->physical_params.alpha, res);
 
-    advance_tracers (domain, sim->advection_params.dt);
-
     sim->time.t = sim->tnext;
     sim->time.i++;
 
+    gfs_simulation_set_timestep (sim);
+    advance_tracers (domain, sim->advection_params.dt);
+
     gts_range_add_value (&domain->timestep, gfs_clock_elapsed (domain->timer) - 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);
+  gts_container_foreach (GTS_CONTAINER (sim->events), (GtsFunc) gts_object_destroy, NULL);
 }
 
 static void gfs_simulation_class_init (GfsSimulationClass * klass)
@@ -1036,9 +1035,9 @@ void gfs_simulation_set_timestep (GfsSimulation * sim)
   gdouble tnext = G_MAXINT;
   i = sim->events->items;
   while (i) {
-    GfsEvent * event = i->data;
-    if (t < event->t && event->t < tnext)
-      tnext = event->t + 1e-9;
+    gdouble next = gfs_event_next (i->data, sim);
+    if (t < next && next < tnext)
+      tnext = next + 1e-9;
     i = i->next;
   }
   if (sim->time.end < tnext)
@@ -1310,8 +1309,6 @@ static void advection_run (GfsSimulation * sim)
 
     gts_container_foreach (GTS_CONTAINER (sim->events), (GtsFunc) gfs_event_do, sim);
 
-    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);
@@ -1320,6 +1317,8 @@ static void advection_run (GfsSimulation * sim)
 			      (FttFaceTraverseFunc) gfs_face_interpolated_normal_velocity,
 			      gfs_domain_velocity (domain));
 
+    gfs_simulation_set_timestep (sim);
+
     advance_tracers (domain, sim->advection_params.dt);
 
     gts_container_foreach (GTS_CONTAINER (sim->events), (GtsFunc) gfs_event_half_do, sim);
diff --git a/src/vof.c b/src/vof.c
index 73d5c1d..db497c8 100644
--- a/src/vof.c
+++ b/src/vof.c
@@ -1063,7 +1063,7 @@ static void variable_tracer_vof_init (GfsVariable * v)
   v->coarse_fine = vof_coarse_fine;
   v->fine_coarse = vof_fine_coarse;
   //  v->face_value = gfs_vof_face_value;
-  GFS_VARIABLE_TRACER (v)->advection.cfl = 0.45;
+  GFS_VARIABLE_TRACER (v)->advection.cfl = 0.5;
 }
 
 GfsVariableClass * gfs_variable_tracer_vof_class (void)

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list