From 7e8d5d0bf4e0d7976b71e6bca6de3fe578d281a7 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Mon, 4 Dec 2017 18:06:52 +0000 Subject: [PATCH] Do not recurse in the gravity pairs if the active cell is foreign. --- src/runner_doiact_grav.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index 6cbec7e368..881847df92 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -935,6 +935,7 @@ void runner_dopair_grav(struct runner *r, struct cell *ci, struct cell *cj, /* Some constants */ const struct engine *e = r->e; const struct space *s = e->s; + const int nodeID = e->nodeID; const int periodic = s->periodic; const double cell_width = s->width[0]; const double dim[3] = {s->dim[0], s->dim[1], s->dim[2]}; @@ -943,6 +944,11 @@ void runner_dopair_grav(struct runner *r, struct cell *ci, struct cell *cj, const double max_distance = props->a_smooth * props->r_cut_max * cell_width; const double max_distance2 = max_distance * max_distance; + /* Anything to do here? */ + if(!((cell_is_active(ci,e) && ci->nodeID == nodeID) || + (cell_is_active(cj,e) && cj->nodeID == nodeID))) + return; + #ifdef SWIFT_DEBUG_CHECKS const int gcount_i = ci->gcount; @@ -963,9 +969,6 @@ void runner_dopair_grav(struct runner *r, struct cell *ci, struct cell *cj, TIMER_TIC; - /* Anything to do here? */ - if (!cell_is_active(ci, e) && !cell_is_active(cj, e)) return; - /* Recover the multipole information */ struct gravity_tensors *const multi_i = ci->multipole; struct gravity_tensors *const multi_j = cj->multipole; -- GitLab