From a6542ff07f3fc6f403be6acefbf6dcf524aa9aff Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <schaller@strw.leidenuniv.nl> Date: Mon, 17 Dec 2018 13:43:41 +0100 Subject: [PATCH] Correctly reset the do_limiter flags when rebuilding. --- examples/SedovBlast_1D/sedov.yml | 2 +- src/cell.c | 22 ++++++++++++++++++---- src/engine_marktasks.c | 11 ++--------- src/runner.c | 9 +++++++++ src/space.c | 8 +++++++- 5 files changed, 37 insertions(+), 15 deletions(-) diff --git a/examples/SedovBlast_1D/sedov.yml b/examples/SedovBlast_1D/sedov.yml index 16b5cf9bc5..b4252581d6 100644 --- a/examples/SedovBlast_1D/sedov.yml +++ b/examples/SedovBlast_1D/sedov.yml @@ -21,7 +21,7 @@ Snapshots: # Parameters governing the conserved quantities statistics Statistics: - delta_time: 1e-2 # Time between statistics output + delta_time: 1e-3 # Time between statistics output # Parameters for the hydrodynamics scheme SPH: diff --git a/src/cell.c b/src/cell.c index e3ac72519f..0c8d81289c 100644 --- a/src/cell.c +++ b/src/cell.c @@ -1633,7 +1633,10 @@ void cell_activate_drift_part(struct cell *c, struct scheduler *s) { for (struct cell *parent = c->parent; parent != NULL && !parent->hydro.do_sub_drift; parent = parent->parent) { + + /* Mark this cell for drifting */ parent->hydro.do_sub_drift = 1; + if (parent == c->hydro.super) { #ifdef SWIFT_DEBUG_CHECKS if (parent->hydro.drift == NULL) @@ -1705,19 +1708,30 @@ void cell_activate_limiter(struct cell *c, struct scheduler *s) { /* If this cell is already marked for drift, quit early. */ if (c->hydro.do_limiter) return; - /* Mark this cell for drifting. */ + /* Mark this cell for limiting. */ c->hydro.do_limiter = 1; /* Set the do_sub_limiter all the way up and activate the super limiter if this has not yet been done. */ if (c == c->super) { +#ifdef SWIFT_DEBUG_CHECKS + if (c->timestep_limiter == NULL) + error("Trying to activate un-existing c->timestep_limiter"); +#endif scheduler_activate(s, c->timestep_limiter); } else { for (struct cell *parent = c->parent; parent != NULL && !parent->hydro.do_sub_limiter; parent = parent->parent) { + + /* Mark this cell for limiting */ parent->hydro.do_sub_limiter = 1; + if (parent == c->super) { +#ifdef SWIFT_DEBUG_CHECKS + if (parent->timestep_limiter == NULL) + error("Trying to activate un-existing parent->timestep_limiter"); +#endif scheduler_activate(s, parent->timestep_limiter); break; } @@ -2791,7 +2805,7 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { /* Activate hydro drift */ if (t->type == task_type_self) { if (ci_nodeID == nodeID) cell_activate_drift_part(ci, s); - if (ci->nodeID == nodeID && with_limiter) cell_activate_limiter(ci, s); + if (ci_nodeID == nodeID && with_limiter) cell_activate_limiter(ci, s); } /* Set the correct sorting flags and activate hydro drifts */ @@ -2807,8 +2821,8 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) { if (cj_nodeID == nodeID) cell_activate_drift_part(cj, s); /* Activate the limiter tasks. */ - if (ci->nodeID == nodeID && with_limiter) cell_activate_limiter(ci, s); - if (cj->nodeID == nodeID && with_limiter) cell_activate_limiter(cj, s); + if (ci_nodeID == nodeID && with_limiter) cell_activate_limiter(ci, s); + if (cj_nodeID == nodeID && with_limiter) cell_activate_limiter(cj, s); /* Check the sorts and activate them if needed. */ cell_activate_hydro_sorts(ci, t->flags, s); diff --git a/src/engine_marktasks.c b/src/engine_marktasks.c index d9b1a4cd34..3a26dbb2f4 100644 --- a/src/engine_marktasks.c +++ b/src/engine_marktasks.c @@ -241,10 +241,8 @@ void engine_marktasks_mapper(void *map_data, int num_elements, if (cj_nodeID == nodeID) cell_activate_drift_part(cj, s); /* And the limiter */ - if (ci->nodeID == nodeID && with_limiter) - cell_activate_limiter(ci, s); - if (cj->nodeID == nodeID && with_limiter) - cell_activate_limiter(cj, s); + if (ci_nodeID == nodeID && with_limiter) cell_activate_limiter(ci, s); + if (cj_nodeID == nodeID && with_limiter) cell_activate_limiter(cj, s); /* Check the sorts and activate them if needed. */ cell_activate_hydro_sorts(ci, t->flags, s); @@ -580,11 +578,6 @@ void engine_marktasks_mapper(void *map_data, int num_elements, scheduler_activate(s, t); } - /* Time-step limiter? */ - else if (t->type == task_type_timestep) { - if (cell_is_active_hydro(t->ci, e)) scheduler_activate(s, t); - } - /* Subgrid tasks */ else if (t_type == task_type_cooling) { if (cell_is_active_hydro(t->ci, e) || cell_is_active_gravity(t->ci, e)) diff --git a/src/runner.c b/src/runner.c index 01df46ed6e..330c9cbc2f 100644 --- a/src/runner.c +++ b/src/runner.c @@ -2349,6 +2349,15 @@ void runner_do_limiter(struct runner *r, struct cell *c, int force, int timer) { /* Limit irrespective of cell flags? */ force |= c->hydro.do_limiter; + /* Early abort? */ + if (c->hydro.count == 0) { + + /* Clear the limiter flags. */ + c->hydro.do_limiter = 0; + c->hydro.do_sub_limiter = 0; + return; + } + /* Loop over the progeny ? */ if (c->split && (force || c->hydro.do_sub_limiter)) { for (int k = 0; k < 8; k++) { diff --git a/src/space.c b/src/space.c index 40cbd10688..0b3caac788 100644 --- a/src/space.c +++ b/src/space.c @@ -245,6 +245,8 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements, c->stars.do_sub_sort = 0; c->grav.do_sub_drift = 0; c->hydro.do_sub_drift = 0; + c->hydro.do_sub_limiter = 0; + c->hydro.do_limiter = 0; c->hydro.ti_end_min = -1; c->hydro.ti_end_max = -1; c->grav.ti_end_min = -1; @@ -2677,6 +2679,8 @@ void space_split_recursive(struct space *s, struct cell *c, cp->stars.do_sub_sort = 0; cp->grav.do_sub_drift = 0; cp->hydro.do_sub_drift = 0; + cp->hydro.do_sub_limiter = 0; + cp->hydro.do_limiter = 0; #ifdef WITH_MPI cp->mpi.tag = -1; #endif // WITH_MPI @@ -4282,7 +4286,9 @@ void space_check_limiter_mapper(void *map_data, int nr_parts, /* Verify that all limited particles have been treated */ for (int k = 0; k < nr_parts; k++) { - if (parts[k].wakeup == time_bin_awake) error("Particle still woken up!"); + if (parts[k].wakeup == time_bin_awake) + error("Particle still woken up! id=%lld", parts[k].id); + if (parts[k].gpart != NULL) if (parts[k].time_bin != parts[k].gpart->time_bin) error("Gpart not on the same time-bin as part"); -- GitLab