diff --git a/src/cell.h b/src/cell.h index 18eae5cb2d5e78d6375017ee5044ebb49bb474fa..09c144675ea4b57bfa0da882754a7232656dc601 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 5ec1457de9428bed73f26dab41d834489763b636..a683c5693079da7904f446eda5e25c5b7a6eff14 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 8de790acdf0c6f6efd0ba68ad1b444925ef8cd20..2c7b64badd317190ccc13fda4ac0e9064b78408d 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); } -