From fb11828ec33cbe761232fc7b034d111c8887aecc Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Tue, 11 Apr 2017 23:18:36 +0100
Subject: [PATCH] Only construct multipoles if the cell has gparts

---
 src/space.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/space.c b/src/space.c
index 7b03571e9e..72ab8baa44 100644
--- a/src/space.c
+++ b/src/space.c
@@ -2150,7 +2150,7 @@ void space_split_recursive(struct space *s, struct cell *c,
     ti_beg_max = get_integer_time_begin(e->ti_current + 1, time_bin_max);
 
     /* Construct the multipole and the centre of mass*/
-    if (s->gravity) gravity_P2M(c->multipole, c->gparts, c->gcount);
+    if (s->gravity && gcount > 0) gravity_P2M(c->multipole, c->gparts, c->gcount);
   }
 
   /* Set the values for this cell. */
-- 
GitLab