From 913232cbece56c6b1574ec4e317f892756df3e55 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Tue, 19 Dec 2017 15:10:38 +0100 Subject: [PATCH] Avoid empty cells in the long-range gravity tasks. --- src/engine.c | 4 ++++ src/runner_doiact_grav.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/engine.c b/src/engine.c index f4841ee7c1..f97cb7a72f 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2321,6 +2321,10 @@ void engine_make_self_gravity_tasks(struct engine *e) { if (periodic) for (int i = 0; i < s->nr_cells; ++i) { const struct cell *c = &s->cells_top[i]; + /* Skip empty cells */ + if (c->gcount == 0) continue; + + /* Did we correctly attach the FFT task ghosts? */ if (c->nodeID == engine_rank && (c->grav_ghost_in == NULL || c->grav_ghost_out == NULL)) error("Invalid gravity_ghost for local cell"); diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index 384e7fa842..2f8f535ff7 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -1179,6 +1179,9 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, int timer) { /* Avoid self contributions */ if (ci == cj) continue; + /* Skip empty cells */ + if (cj->gcount == 0) continue; + /* Get the distance between the CoMs at the last rebuild*/ double dx_r = CoM_rebuild_i[0] - multi_j->CoM_rebuild[0]; double dy_r = CoM_rebuild_i[1] - multi_j->CoM_rebuild[1]; -- GitLab