diff --git a/src/cell.c b/src/cell.c index 2919839d501a96e6607802af21ceab2796e5d63b..7a50e80000e9ae099ab67c2f2fd70cc17df3fb46 100644 --- a/src/cell.c +++ b/src/cell.c @@ -178,8 +178,6 @@ int cell_pack(struct cell *restrict c, struct pcell *restrict pc, #ifdef WITH_MPI /* Start by packing the data of the current cell. */ - if(with_gravity) - pc->multipole = *(c->multipole); pc->h_max = c->h_max; pc->ti_hydro_end_min = c->ti_hydro_end_min; pc->ti_hydro_end_max = c->ti_hydro_end_max; @@ -192,6 +190,22 @@ int cell_pack(struct cell *restrict c, struct pcell *restrict pc, pc->gcount = c->gcount; pc->scount = c->scount; + /* Copy the Multipole related information */ + if(with_gravity) { + const struct gravity_tensors *mp = c->multipole; + + pc->m_pole = mp->m_pole; + pc->CoM[0] = mp->CoM[0]; + pc->CoM[1] = mp->CoM[1]; + pc->CoM[2] = mp->CoM[2]; + pc->CoM_rebuild[0] = mp->CoM_rebuild[0]; + pc->CoM_rebuild[1] = mp->CoM_rebuild[1]; + pc->CoM_rebuild[2] = mp->CoM_rebuild[2]; + pc->r_max = mp->r_max; + pc->r_max_rebuild = mp->r_max_rebuild; + } + + #ifdef SWIFT_DEBUG_CHECKS pc->cellID = c->cellID; #endif @@ -267,8 +281,6 @@ int cell_unpack(struct pcell *restrict pc, struct cell *restrict c, #ifdef WITH_MPI /* Unpack the current pcell. */ - if(with_gravity) - *(c->multipole) = pc->multipole; c->h_max = pc->h_max; c->ti_hydro_end_min = pc->ti_hydro_end_min; c->ti_hydro_end_max = pc->ti_hydro_end_max; @@ -284,6 +296,22 @@ int cell_unpack(struct pcell *restrict pc, struct cell *restrict c, c->cellID = pc->cellID; #endif + /* Copy the Multipole related information */ + if(with_gravity) { + + struct gravity_tensors *mp = c->multipole; + + mp->m_pole = pc->m_pole; + mp->CoM[0] = pc->CoM[0]; + mp->CoM[1] = pc->CoM[1]; + mp->CoM[2] = pc->CoM[2]; + mp->CoM_rebuild[0] = pc->CoM_rebuild[0]; + mp->CoM_rebuild[1] = pc->CoM_rebuild[1]; + mp->CoM_rebuild[2] = pc->CoM_rebuild[2]; + mp->r_max = pc->r_max; + mp->r_max_rebuild = pc->r_max_rebuild; + } + /* Number of new cells created. */ int count = 1; diff --git a/src/cell.h b/src/cell.h index c209f8d99bee684663c47ca8e1b1f4892e7ac5dd..8e53bb185e150e6d97791c846e694265ee261c65 100644 --- a/src/cell.h +++ b/src/cell.h @@ -78,7 +78,19 @@ struct link { struct pcell { /*! This cell's gravity-related tensors */ - struct gravity_tensors multipole; + struct multipole m_pole; + + /*! Centre of mass. */ + double CoM[3]; + + /*! Centre of mass at rebuild time. */ + double CoM_rebuild[3]; + + /*! Upper limit of the CoM<->gpart distance. */ + double r_max; + + /*! Upper limit of the CoM<->gpart distance at last rebuild. */ + double r_max_rebuild; /*! Relative indices of the cell's progeny. */ int progeny[8]; diff --git a/src/multipole.h b/src/multipole.h index c05aa36890313ea22f725ee272746bdf63f597ea..2ada835e32565dc4075dd1352ba3959b2ba4766b 100644 --- a/src/multipole.h +++ b/src/multipole.h @@ -186,12 +186,12 @@ struct gravity_tensors { /*! The actual content */ struct { - /*! Multipole mass */ - struct multipole m_pole; - /*! Field tensor for the potential */ struct grav_tensor pot; + /*! Multipole mass */ + struct multipole m_pole; + /*! Centre of mass of the matter dsitribution */ double CoM[3];