diff --git a/src/cell.c b/src/cell.c index de34f37b5e9724f7c28d9de7fb7062ee16842da6..25d5f21832132e31420d55f687024602a6cf262e 100644 --- a/src/cell.c +++ b/src/cell.c @@ -1317,9 +1317,8 @@ int cell_is_drift_needed(struct cell *c, const struct engine *e) { } /** - * @brief Can a task recurse to a lower level based on the staus of the - * particles - * in the cell. + * @brief Can a sub-pair hydro task recurse to a lower level based + * on the status of the particles in the cell. * * @param c The #cell. */ @@ -1328,25 +1327,64 @@ int cell_can_recurse_in_pair_task(const struct cell *c) { /* Is the cell split ? */ /* If so, is the cut-off radius plus the max distance the parts have moved */ /* smaller than the sub-cell sizes ? */ + /* Note: We use the _old values as these might have been updated by a drift */ return c->split && ((kernel_gamma * c->h_max_old + c->dx_max_old) < 0.5f * c->dmin); } /** - * @brief Can a task associated with a cell be split into smaller sub-tasks. + * @brief Can a sub-self hydro task recurse to a lower level based + * on the status of the particles in the cell. * * @param c The #cell. */ -int cell_can_split_task(const struct cell *c) { +int cell_can_recurse_in_self_task(const struct cell *c) { + + /* Is the cell split ? */ + /* Note: No need for more checks here as all the sub-pairs and sub-self */ + /* operations will be executed. So no need for the particle to be at exactly + */ + /* the right place. */ + return c->split; +} + +/** + * @brief Can a pair task associated with a cell be split into smaller + * sub-tasks. + * + * @param c The #cell. + */ +int cell_can_split_pair_task(const struct cell *c) { /* Is the cell split ? */ /* If so, is the cut-off radius with some leeway smaller than */ /* the sub-cell sizes ? */ - /* Note that since tasks are build after a rebuild no need to take */ + /* Note that since tasks are create after a rebuild no need to take */ /* into account any part motion (i.e. dx_max == 0 here) */ return c->split && (space_stretch * kernel_gamma * c->h_max < 0.5f * c->dmin); } +/** + * @brief Can a self task associated with a cell be split into smaller + * sub-tasks. + * + * @param c The #cell. + */ +int cell_can_split_self_task(const struct cell *c) { + + /* Is the cell split ? */ + /* Note: No need for more checks here as all the sub-pairs and sub-self */ + /* tasks will be created. So no need to check for h_max */ + return c->split; +} + +/** + * @brief Have particles in a pair of cells moved too much and require a rebuild + * ? + * + * @param ci The first #cell. + * @param cj The second #cell. + */ int cell_need_rebuild_for_pair(const struct cell *ci, const struct cell *cj) { /* Is the cut-off radius plus the max distance the parts in both cells have */ diff --git a/src/cell.h b/src/cell.h index 899503997d1aa8f9f1c93690a07e41c02341cdb8..b13e8f65b09a8d7f9cbbfc097dd488f10bd52cc2 100644 --- a/src/cell.h +++ b/src/cell.h @@ -389,7 +389,9 @@ void cell_store_pre_drift_values(struct cell *c); void cell_activate_subcell_tasks(struct cell *ci, struct cell *cj, struct scheduler *s); int cell_can_recurse_in_pair_task(const struct cell *c); -int cell_can_split_task(const struct cell *c); +int cell_can_recurse_in_self_task(const struct cell *c); +int cell_can_split_pair_task(const struct cell *c); +int cell_can_split_self_task(const struct cell *c); int cell_need_rebuild_for_pair(const struct cell *ci, const struct cell *cj); #endif /* SWIFT_CELL_H */ diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 86a2181adac65309c9ad073ceb6920f55ead6e17..f83132e41dbb5e9c180edb9f526ccc59149d2ce6 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -2333,7 +2333,7 @@ void DOSUB_SELF1(struct runner *r, struct cell *ci, int gettimer) { if (ci->count == 0 || !cell_is_active(ci, r->e)) return; /* Recurse? */ - if (cell_can_recurse_in_pair_task(ci)) { + if (cell_can_recurse_in_self_task(ci)) { /* Loop over all progeny. */ for (int k = 0; k < 8; k++) @@ -2628,7 +2628,7 @@ void DOSUB_SELF2(struct runner *r, struct cell *ci, int gettimer) { if (ci->count == 0 || !cell_is_active(ci, r->e)) return; /* Recurse? */ - if (cell_can_recurse_in_pair_task(ci)) { + if (cell_can_recurse_in_self_task(ci)) { /* Loop over all progeny. */ for (int k = 0; k < 8; k++) @@ -2678,7 +2678,7 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts, if (cj == NULL) { /* Recurse? */ - if (cell_can_recurse_in_pair_task(ci)) { + if (cell_can_recurse_in_self_task(ci)) { /* Loop over all progeny. */ DOSUB_SUBSET(r, sub, parts, ind, count, NULL, -1, 0); diff --git a/src/scheduler.c b/src/scheduler.c index f669e629450df5df04aa2d18c4e6fccbd5cdbaad..c26e14dcc718bb6a8478beea2ec0308469e6bdad 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -188,7 +188,7 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) { } /* Is this cell even split and the task does not violate h ? */ - if (cell_can_split_task(ci)) { + if (cell_can_split_self_task(ci)) { /* Make a sub? */ if (scheduler_dosub && /* Note division here to avoid overflow */ @@ -260,7 +260,7 @@ static void scheduler_splittask_hydro(struct task *t, struct scheduler *s) { const int sid = space_getsid(s->space, &ci, &cj, shift); /* Should this task be split-up? */ - if (cell_can_split_task(ci) && cell_can_split_task(cj)) { + if (cell_can_split_pair_task(ci) && cell_can_split_pair_task(cj)) { /* Replace by a single sub-task? */ if (scheduler_dosub &&