From b5252837613d2466d592a0de1e542b4536d1ef5b Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Wed, 13 Dec 2017 17:55:50 +0000 Subject: [PATCH] Only recurse in the hydro tasks if the cells are larger than the smoothing length. --- src/cell.h | 8 ++------ src/runner_doiact.h | 18 ++++++++++++++++++ src/space.c | 1 - 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/cell.h b/src/cell.h index 18eae5cb2d..09c144675e 100644 --- a/src/cell.h +++ b/src/cell.h @@ -548,12 +548,8 @@ __attribute__((always_inline)) INLINE static int cell_can_recurse_in_pair_task( __attribute__((always_inline)) INLINE static 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; + /* Is the cell split and not smaller than the smoothing length? */ + return c->split && (kernel_gamma * c->h_max < 0.5f * c->dmin); } /** diff --git a/src/runner_doiact.h b/src/runner_doiact.h index 5ec1457de9..a683c56930 100644 --- a/src/runner_doiact.h +++ b/src/runner_doiact.h @@ -981,6 +981,11 @@ void DOPAIR1_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) { /* Anything to do here? */ if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) return; + /* Did we mess up the recursion? */ + if (max(ci->h_max, cj->h_max) * kernel_gamma > ci->dmin || + max(ci->h_max, cj->h_max) * kernel_gamma > cj->dmin) + error("Cell smaller than smoothing length"); + /* Check that cells are drifted. */ if (!cell_are_part_drifted(ci, e) || !cell_are_part_drifted(cj, e)) error("Interacting undrifted cells."); @@ -1466,6 +1471,11 @@ void DOPAIR2_BRANCH(struct runner *r, struct cell *ci, struct cell *cj) { /* Anything to do here? */ if (!cell_is_active_hydro(ci, e) && !cell_is_active_hydro(cj, e)) return; + /* Did we mess up the recursion? */ + if (max(ci->h_max, cj->h_max) * kernel_gamma > ci->dmin || + max(ci->h_max, cj->h_max) * kernel_gamma > cj->dmin) + error("Cell smaller than smoothing length"); + /* Check that cells are drifted. */ if (!cell_are_part_drifted(ci, e) || !cell_are_part_drifted(cj, e)) error("Interacting undrifted cells."); @@ -1674,6 +1684,10 @@ void DOSELF1_BRANCH(struct runner *r, struct cell *c) { /* Anything to do here? */ if (!cell_is_active_hydro(c, e)) return; + /* Did we mess up the recursion? */ + if (c->h_max * kernel_gamma > c->dmin) + error("Cell smaller than smoothing length"); + /* Check that cells are drifted. */ if (!cell_are_part_drifted(c, e)) error("Interacting undrifted cell."); @@ -1821,6 +1835,10 @@ void DOSELF2_BRANCH(struct runner *r, struct cell *c) { /* Anything to do here? */ if (!cell_is_active_hydro(c, e)) return; + /* Did we mess up the recursion? */ + if (c->h_max * kernel_gamma > c->dmin) + error("Cell smaller than smoothing length"); + /* Check that cells are drifted. */ if (!cell_are_part_drifted(c, e)) error("Interacting undrifted cell."); diff --git a/src/space.c b/src/space.c index 8de790acdf..2c7b64badd 100644 --- a/src/space.c +++ b/src/space.c @@ -3197,4 +3197,3 @@ void space_clean(struct space *s) { free(s->gparts); free(s->sparts); } - -- GitLab