[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203
Stephane Popinet
popinet at users.sf.net
Fri May 15 02:53:18 UTC 2009
The following commit has been merged in the upstream branch:
commit c3a8244b9b4ccfffbb0341daede180417d98598f
Author: Stephane Popinet <popinet at users.sf.net>
Date: Wed Oct 11 14:08:25 2006 +1000
Fixed stupid timestep calculation (thanks to Chris Johnson for the bug report)
darcs-hash:20061011040825-d4795-63774aa49646c3a286453c970203e482c9557271.gz
diff --git a/src/simulation.c b/src/simulation.c
index 7499026..b38fb9b 100644
--- a/src/simulation.c
+++ b/src/simulation.c
@@ -998,7 +998,6 @@ static gdouble min_cfl (GfsSimulation * sim)
void gfs_simulation_set_timestep (GfsSimulation * sim)
{
gdouble t, cfl;
- GSList * i;
g_return_if_fail (sim != NULL);
@@ -1009,23 +1008,29 @@ void gfs_simulation_set_timestep (GfsSimulation * sim)
sim->advection_params.dt = G_MAXDOUBLE;
if (sim->advection_params.dt > sim->time.dtmax)
sim->advection_params.dt = sim->time.dtmax;
- sim->tnext = t + sim->advection_params.dt;
- i = sim->events->items;
+ gdouble tnext = G_MAXDOUBLE;
+ GSList * i = sim->events->items;
while (i) {
GfsEvent * event = i->data;
- GSList * next = i->next;
-
- if (t < event->t && sim->tnext > event->t - 1e-9) {
- sim->advection_params.dt = event->t - t;
- sim->tnext = event->t;
- }
- i = next;
+ if (t < event->t && event->t < tnext)
+ tnext = event->t;
+ i = i->next;
}
- if (sim->tnext > sim->time.end - 1e-9) {
- sim->advection_params.dt = sim->time.end - t;
- sim->tnext = sim->time.end;
+ if (sim->time.end < tnext)
+ tnext = sim->time.end;
+
+ if (tnext < G_MAXDOUBLE) {
+ gdouble n = ceil ((tnext - t)/sim->advection_params.dt);
+ sim->advection_params.dt = n > 0. ? (tnext - t)/n : 0.;
+ if (n == 1.)
+ sim->tnext = tnext;
+ else
+ sim->tnext = t + sim->advection_params.dt;
}
+ else
+ sim->tnext = t + sim->advection_params.dt;
+
if (sim->advection_params.dt < 1e-9)
sim->advection_params.dt = 1e-9;
}
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list