Commit a0931f61 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Zero the multipoles when rebuilding if there are no gparts.

parent fb11828e
......@@ -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.
*
......
......@@ -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. */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment