Commit cfff9c73 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Better level for the time-step limiter task to make sure the gravity and hydro...

Better level for the time-step limiter task to make sure the gravity and hydro steps are synchronized.
parent 3f71118e
......@@ -2718,15 +2718,16 @@ void cell_activate_limiter(struct cell *c, struct scheduler *s) {
/* Set the do_sub_limiter all the way up and activate the super limiter
if this has not yet been done. */
if (c == c->hydro.super) {
if (c == c->super) {
#ifdef SWIFT_DEBUG_CHECKS
if (c->hydro.limiter_out == NULL)
error("Trying to activate un-existing c->timestep_limiter");
if (c->hydro.timestep_limiter == NULL)
if (c->timestep_limiter == NULL)
error("Trying to activate un-existing c->timestep_limiter");
#endif
scheduler_activate(s, c->hydro.limiter_out);
scheduler_activate(s, c->hydro.timestep_limiter);
if (c == c->hydro.super) {
scheduler_activate(s, c->hydro.limiter_in);
scheduler_activate(s, c->hydro.limiter_out);
}
scheduler_activate(s, c->timestep_limiter);
} else {
for (struct cell *parent = c->parent;
parent != NULL &&
......@@ -2735,15 +2736,16 @@ void cell_activate_limiter(struct cell *c, struct scheduler *s) {
/* Mark this cell for limiting */
cell_set_flag(parent, cell_flag_do_hydro_sub_limiter);
if (parent == c->hydro.super) {
if (parent == c->super) {
#ifdef SWIFT_DEBUG_CHECKS
if (parent->hydro.timestep_limiter == NULL)
error("Trying to activate un-existing parent->timestep_limiter");
if (parent->hydro.limiter_out == NULL)
if (parent->timestep_limiter == NULL)
error("Trying to activate un-existing parent->timestep_limiter");
#endif
scheduler_activate(s, parent->hydro.limiter_out);
scheduler_activate(s, parent->hydro.timestep_limiter);
if (parent == c->hydro.super) {
scheduler_activate(s, parent->hydro.limiter_in);
scheduler_activate(s, parent->hydro.limiter_out);
}
scheduler_activate(s, parent->timestep_limiter);
break;
}
}
......@@ -3559,9 +3561,6 @@ int cell_unskip_hydro_tasks(struct cell *c, struct scheduler *s) {
if (c->kick1 != NULL) scheduler_activate(s, c->kick1);
if (c->kick2 != NULL) scheduler_activate(s, c->kick2);
if (c->timestep != NULL) scheduler_activate(s, c->timestep);
if (c->hydro.limiter_in != NULL) scheduler_activate(s, c->hydro.limiter_in);
if (c->hydro.limiter_out != NULL)
scheduler_activate(s, c->hydro.limiter_out);
if (c->hydro.end_force != NULL) scheduler_activate(s, c->hydro.end_force);
if (c->hydro.cooling != NULL) scheduler_activate(s, c->hydro.cooling);
#ifdef WITH_LOGGER
......
......@@ -366,9 +366,6 @@ struct cell {
/*! Dependency implicit task for the time-step limiter (in->limiter->out)*/
struct task *limiter_out;
/*! The task to limit the time-step of inactive particles */
struct task *timestep_limiter;
/*! Dependency implicit task for the ghost (in->ghost->out)*/
struct task *ghost_in;
......@@ -764,6 +761,9 @@ struct cell {
/*! The task to compute time-steps */
struct task *timestep;
/*! The task to limit the time-step of inactive particles */
struct task *timestep_limiter;
#ifdef WITH_LOGGER
/*! The logger task */
struct task *logger;
......
......@@ -792,6 +792,7 @@ void engine_make_hierarchical_tasks_common(struct engine *e, struct cell *c) {
struct scheduler *s = &e->sched;
const int with_star_formation = (e->policy & engine_policy_star_formation);
const int with_limiter = (e->policy & engine_policy_limiter);
/* Are we at the top-level? */
if (c->top == c && c->nodeID == e->nodeID) {
......@@ -841,6 +842,16 @@ void engine_make_hierarchical_tasks_common(struct engine *e, struct cell *c) {
scheduler_addunlock(s, kick2_or_logger, c->top->hydro.star_formation);
scheduler_addunlock(s, c->top->hydro.star_formation, c->timestep);
}
/* Time-step limiter */
if (with_limiter) {
c->timestep_limiter = scheduler_addtask(
s, task_type_timestep_limiter, task_subtype_none, 0, 0, c, NULL);
scheduler_addunlock(s, c->timestep, c->timestep_limiter);
scheduler_addunlock(s, c->timestep_limiter, c->kick1);
}
}
} else { /* We are above the super-cell so need to go deeper */
......@@ -1159,9 +1170,6 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c,
/* Time-step limiter */
if (with_limiter) {
c->hydro.timestep_limiter = scheduler_addtask(
s, task_type_timestep_limiter, task_subtype_none, 0, 0, c, NULL);
c->hydro.limiter_in =
scheduler_addtask(s, task_type_limiter_in, task_subtype_none, 0,
/* implicit = */ 1, c, NULL);
......@@ -1172,9 +1180,8 @@ void engine_make_hierarchical_tasks_hydro(struct engine *e, struct cell *c,
scheduler_addunlock(s, c->super->kick2, c->hydro.limiter_in);
scheduler_addunlock(s, c->hydro.limiter_out, c->super->timestep);
scheduler_addunlock(s, c->hydro.limiter_out, c->hydro.timestep_limiter);
scheduler_addunlock(s, c->super->timestep, c->hydro.timestep_limiter);
scheduler_addunlock(s, c->hydro.timestep_limiter, c->super->kick1);
scheduler_addunlock(s, c->hydro.limiter_out,
c->super->timestep_limiter);
if (with_star_formation && c->hydro.count > 0) {
scheduler_addunlock(s, c->top->hydro.star_formation,
......
......@@ -253,7 +253,7 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements,
c->timestep = NULL;
c->hydro.limiter_in = NULL;
c->hydro.limiter_out = NULL;
c->hydro.timestep_limiter = NULL;
c->timestep_limiter = NULL;
c->hydro.end_force = NULL;
c->hydro.drift = NULL;
c->stars.drift = NULL;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment