diff --git a/src/multipole.h b/src/multipole.h index 0daef6de24039afe63f529ee53f0afda761bc6c3..47f4764daf7402cdebad2e6218fda9adfd5190fe 100644 --- a/src/multipole.h +++ b/src/multipole.h @@ -354,6 +354,11 @@ INLINE static void gravity_field_tensors_print(const struct grav_tensor *l) { #endif } +INLINE static void gravity_multipole_init(struct multipole *m) { + + bzero(m, sizeof(struct multipole)); +} + /** * @brief Prints the content of a #multipole to stdout. * diff --git a/src/space.c b/src/space.c index 72ab8baa44a9498552293d0705d9b6193f6bcc8f..04bb3a513f8acba84e816289cae05198163daf16 100644 --- a/src/space.c +++ b/src/space.c @@ -2150,7 +2150,16 @@ 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 && gcount > 0) gravity_P2M(c->multipole, c->gparts, c->gcount); + if (s->gravity) { + if(gcount > 0) + gravity_P2M(c->multipole, c->gparts, c->gcount); + else { + gravity_multipole_init(&c->multipole->m_pole); + c->multipole->CoM[0] = c->loc[0] + c->width[0] / 2.; + c->multipole->CoM[1] = c->loc[1] + c->width[1] / 2.; + c->multipole->CoM[2] = c->loc[2] + c->width[2] / 2.; + } + } } /* Set the values for this cell. */