From d578629b88f6eb43b0def33ccfaf1da0c18cf3a9 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Mon, 21 Aug 2017 17:07:40 +0100 Subject: [PATCH] Restored the old behaviour of the external gravity tasks. --- src/cell.c | 56 +++++++++++++++++++++++++++++++++++++++++++++---- src/cell.h | 2 ++ src/engine.c | 6 ++++-- src/scheduler.c | 2 +- 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/src/cell.c b/src/cell.c index 69cdbb7fb2..786ce2386f 100644 --- a/src/cell.c +++ b/src/cell.c @@ -1401,8 +1401,13 @@ void cell_activate_sorts(struct cell *c, int sid, struct scheduler *s) { } /** - * @brief Traverse a sub-cell task and activate the drift and sort tasks along - * the way. + * @brief Traverse a sub-cell task and activate the hydro drift tasks that are + * required + * by a hydro task + * + * @param ci The first #cell we recurse in. + * @param cj The second #cell we recurse in. + * @param s The task #scheduler. */ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, struct scheduler *s) { @@ -1670,7 +1675,13 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, } /** - * @brief Traverse a sub-cell task and activate the gravity drift tasks + * @brief Traverse a sub-cell task and activate the gravity drift tasks that are + * required + * by a self gravity task. + * + * @param ci The first #cell we recurse in. + * @param cj The second #cell we recurse in. + * @param s The task #scheduler. */ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj, struct scheduler *s) { @@ -1795,6 +1806,40 @@ void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj, } } +/** + * @brief Traverse a sub-cell task and activate the gravity drift tasks that are + * required + * by an external gravity task. + * + * @param ci The #cell we recurse in. + * @param s The task #scheduler. + */ +void cell_activate_subcell_external_grav_tasks(struct cell *ci, + struct scheduler *s) { + + /* Some constants */ + const struct space *sp = s->space; + const struct engine *e = sp->e; + + /* Do anything? */ + if (!cell_is_active(ci, e)) return; + + /* Recurse? */ + if (ci->split) { + + /* Loop over all progenies (no need for pairs for self-gravity) */ + for (int j = 0; j < 8; j++) { + if (ci->progeny[j] != NULL) { + cell_activate_subcell_external_grav_tasks(ci->progeny[j], s); + } + } + } else { + + /* We have reached the bottom of the tree: activate gpart drift */ + cell_activate_drift_gpart(ci, s); + } +} + /** * @brief Un-skips all the tasks associated with a given cell and checks * if the space needs to be rebuilt. @@ -1987,7 +2032,10 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) { scheduler_activate(s, t); /* Set the drifting flags */ - if (t->type == task_type_self) { + if (t->type == task_type_self && + t->subtype == task_subtype_external_grav) { + cell_activate_subcell_external_grav_tasks(t->ci, s); + } else if (t->type == task_type_self && t->subtype == task_subtype_grav) { cell_activate_subcell_grav_tasks(t->ci, NULL, s); } else if (t->type == task_type_pair) { cell_activate_subcell_grav_tasks(t->ci, t->cj, s); diff --git a/src/cell.h b/src/cell.h index 657ff737ed..2302f8859b 100644 --- a/src/cell.h +++ b/src/cell.h @@ -408,6 +408,8 @@ void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, struct scheduler *s); void cell_activate_subcell_grav_tasks(struct cell *ci, struct cell *cj, struct scheduler *s); +void cell_activate_subcell_external_grav_tasks(struct cell *ci, + struct scheduler *s); void cell_activate_drift_part(struct cell *c, struct scheduler *s); void cell_activate_drift_gpart(struct cell *c, struct scheduler *s); void cell_activate_sorts(struct cell *c, int sid, struct scheduler *s); diff --git a/src/engine.c b/src/engine.c index 2437724c9d..81599b9e3e 100644 --- a/src/engine.c +++ b/src/engine.c @@ -196,7 +196,7 @@ void engine_make_hierarchical_tasks(struct engine *e, struct cell *c) { scheduler_addunlock(s, c->kick2, c->timestep); scheduler_addunlock(s, c->timestep, c->kick1); - /* Add the gravity tasks */ + /* Add the self-gravity tasks */ if (is_self_gravity) { /* Initialisation of the multipoles */ @@ -217,8 +217,10 @@ void engine_make_hierarchical_tasks(struct engine *e, struct cell *c) { scheduler_addunlock(s, c->grav_down, c->kick2); } - /* Generate the ghost tasks. */ + /* Add the hydrodynamics tasks */ if (is_with_hydro) { + + /* Generate the ghost tasks. */ c->ghost_in = scheduler_addtask(s, task_type_ghost, task_subtype_none, 0, /* implicit = */ 1, c, NULL); diff --git a/src/scheduler.c b/src/scheduler.c index fccad7eb54..af0f5e3900 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -695,7 +695,7 @@ void scheduler_splittasks_mapper(void *map_data, int num_elements, scheduler_splittask_gravity(t, s); } else if (t->type == task_type_grav_top_level || t->type == task_type_grav_ghost) { - // MATTHIEU: for the future + /* For future use */ } else { error("Unexpected task sub-type"); } -- GitLab