From c58eb6e4ddc619eb858c5e6a6c8e6c111d2ad3b2 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Wed, 27 Jan 2016 17:58:57 +0000 Subject: [PATCH] Propagate time-stepping policy all the way to the kick task --- src/engine.c | 4 ++++ src/runner.c | 20 ++++---------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/engine.c b/src/engine.c index 174ce93810..b5035598e4 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2166,6 +2166,10 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, /* Print policy */ engine_policy(e); + /* Deal with timestep */ + if(e->policy & engine_policy_fixdt) + e->dt_min = e->dt_max; + /* Construct types for MPI communications */ #ifdef WITH_MPI part_create_mpi_type(&e->part_mpi_type); diff --git a/src/runner.c b/src/runner.c index 4440c3ac7d..b4b25586de 100644 --- a/src/runner.c +++ b/src/runner.c @@ -856,7 +856,7 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) { current_dt = 0.0f; float t_start, t_end, t_end_min = FLT_MAX, t_end_max = 0., dt; float dt_timeline; - float h_max, dx_max;//, dt_min, dt_max; + float h_max, dx_max; double ekin = 0.0, epot = 0.0; float mom[3] = {0.0f, 0.0f, 0.0f}, ang[3] = {0.0f, 0.0f, 0.0f}; float m, x[3], v_full[3]; @@ -869,8 +869,6 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) { if (!c->split) { /* Init the min/max counters. */ - //dt_min = FLT_MAX; - //dt_max = 0.0f; h_max = 0.0f; dx_max = 0.0f; @@ -901,18 +899,18 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) { /* Limit timestep increase */ if (current_dt > 0.0f) new_dt = fminf(new_dt, 2.0f * current_dt); - + /* Limit timestep within the allowed range */ new_dt = fminf(new_dt, global_dt_max); new_dt = fmaxf(new_dt, global_dt_min); - + /* Put this timestep on the time line */ dt_timeline = dt_max_timeline; while (new_dt < dt_timeline) dt_timeline /= 2.; /* Now we have a time step, proceed with the kick */ new_dt = dt_timeline; - + /* Compute the time step for this kick */ t_start = 0.5f * (p->t_begin + p->t_end); t_end = p->t_end + 0.5f * new_dt; @@ -967,8 +965,6 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) { else { /* Init everything. */ - //dt_min = FLT_MAX; - //dt_max = 0.0f; h_max = 0.0f; dx_max = 0.0f; updated = 0; @@ -1017,13 +1013,6 @@ void runner_dokick(struct runner *r, struct cell *c, int timer) { c->t_end_min = t_end_min; c->t_end_max = t_end_max; - // assert(t_end_min > 0.); - - if (t_end_min == 0.) { - message("oO"); - abort(); - } - if (timer) { #ifdef TIMER_VERBOSE message("runner %02i: %i parts at depth %i took %.3f ms.", r->id, c->count, @@ -1112,7 +1101,6 @@ void *runner_main(void *data) { error("Unknown task subtype."); break; case task_type_init: - //message("init"); runner_doinit(r, ci); break; case task_type_ghost: -- GitLab