diff --git a/src/cell.c b/src/cell.c index 69cdbb7fb29d9b7132bc69994cb7ddb9a3b52b5e..786ce2386fad8599cac3b5ba8d62961d6d67b2fa 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 657ff737ed8e1e53c2addb88a7e80961a11dbd8e..2302f8859bb682277947ecfab8d20d1b35948156 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 2437724c9d321fbe1a4fb8ecf4cd8d1d3991ad0e..81599b9e3ef7dd33b8d743486fc7d477130b273a 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 fccad7eb54890f4ec585ed98aa74d9508ff88d59..af0f5e3900d66c6d70a08cfcfbda149662317f23 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"); }