diff --git a/src/cell.c b/src/cell.c index 332750cd26337286af3249d00d06f918a7d70151..d0235f70267cf3fd1e9149e7268ab126028f45cf 100644 --- a/src/cell.c +++ b/src/cell.c @@ -6418,5 +6418,5 @@ int cell_can_use_pair_mm(const struct cell *ci, const struct cell *cj, const double r2 = dx * dx + dy * dy + dz * dz; return gravity_M2L_accept_symmetric(props, multi_i, multi_j, r2, - use_rebuild_data); + use_rebuild_data, periodic); } diff --git a/src/gravity_cache.h b/src/gravity_cache.h index a1cc3b3b259516d7367d4edd24c6661f6c089dad..80636479117214f574cdbc676c2594e8e6c2f113 100644 --- a/src/gravity_cache.h +++ b/src/gravity_cache.h @@ -255,8 +255,8 @@ INLINE static void gravity_cache_populate( const float r2 = dx * dx + dy * dy + dz * dz; /* Check whether we can use the multipole instead of P-P */ - use_mpole[i] = allow_mpole && - gravity_M2P_accept(grav_props, &gparts[i], multipole, r2); + use_mpole[i] = allow_mpole && gravity_M2P_accept(grav_props, &gparts[i], + multipole, r2, periodic); } #ifdef SWIFT_DEBUG_CHECKS @@ -430,7 +430,7 @@ INLINE static void gravity_cache_populate_all_mpole( } const float r2 = dx * dx + dy * dy + dz * dz; - if (!gravity_M2P_accept(grav_props, &gparts[i], multipole, r2)) + if (!gravity_M2P_accept(grav_props, &gparts[i], multipole, r2, periodic)) error("Using m-pole where the test fails"); #endif } diff --git a/src/multipole_accept.h b/src/multipole_accept.h index 5bafa6d175ddecac6f5e5ddb249fe114f52c0c7f..4cdee6131870af0e736971e0f5412391e9fd5fa6 100644 --- a/src/multipole_accept.h +++ b/src/multipole_accept.h @@ -43,11 +43,12 @@ * @param r2 The square of the distance between the centres of mass of A and B. * @param use_rebuild_sizes Are we considering the sizes at the last tree-build * (1) or current sizes (0)? + * @param periodic Are we using periodic BCs? */ __attribute__((nonnull, pure)) INLINE static int gravity_M2L_accept( const struct gravity_props *props, const struct gravity_tensors *restrict A, const struct gravity_tensors *restrict B, const float r2, - const int use_rebuild_sizes) { + const int use_rebuild_sizes, const int periodic) { /* Order of the expansion */ const int p = SELF_GRAVITY_MULTIPOLE_ORDER; @@ -144,14 +145,15 @@ __attribute__((nonnull, pure)) INLINE static int gravity_M2L_accept( * @param r2 The square of the distance between the centres of mass of A and B. * @param use_rebuild_sizes Are we considering the sizes at the last tree-build * (1) or current sizes (0)? + * @param periodic Are we using periodic BCs? */ __attribute__((nonnull, pure)) INLINE static int gravity_M2L_accept_symmetric( const struct gravity_props *props, const struct gravity_tensors *restrict A, const struct gravity_tensors *restrict B, const float r2, - const int use_rebuild_sizes) { + const int use_rebuild_sizes, const int periodic) { - return gravity_M2L_accept(props, A, B, r2, use_rebuild_sizes) && - gravity_M2L_accept(props, B, A, r2, use_rebuild_sizes); + return gravity_M2L_accept(props, A, B, r2, use_rebuild_sizes, periodic) && + gravity_M2L_accept(props, B, A, r2, use_rebuild_sizes, periodic); } /** @@ -164,10 +166,11 @@ __attribute__((nonnull, pure)) INLINE static int gravity_M2L_accept_symmetric( * @param pa The particle we want to compute forces for (sink) * @param B The gravity tensors that act as a source. * @param r2 The square of the distance between pa and the centres of mass of B. + * @param periodic Are we using periodic BCs? */ __attribute__((nonnull, pure)) INLINE static int gravity_M2P_accept( const struct gravity_props *props, const struct gpart *pa, - const struct gravity_tensors *B, const float r2) { + const struct gravity_tensors *B, const float r2, const int periodic) { /* Order of the expansion */ const int p = SELF_GRAVITY_MULTIPOLE_ORDER; diff --git a/src/runner_doiact_grav.c b/src/runner_doiact_grav.c index 5a2f18f18f0c2bf2909ddc26a227d2d287994b56..8c5824012b90aae745e274d90e005abffa7797a1 100644 --- a/src/runner_doiact_grav.c +++ b/src/runner_doiact_grav.c @@ -1678,7 +1678,7 @@ void runner_dopair_recursive_grav(struct runner *r, struct cell *ci, /* Can we use M-M interactions ? */ if (gravity_M2L_accept_symmetric(e->gravity_properties, multi_i, multi_j, r2, - /* use_rebuild_sizes=*/0)) { + /* use_rebuild_sizes=*/0, periodic)) { /* Go M-M */ runner_dopair_grav_mm(r, ci, cj); @@ -1906,7 +1906,8 @@ void runner_do_grav_long_range(struct runner *r, struct cell *ci, /* Are we in charge of this cell pair? */ if (gravity_M2L_accept_symmetric(e->gravity_properties, multi_top, multi_j, - r2_rebuild, /*use_rebuild_sizes=*/1)) { + r2_rebuild, /*use_rebuild_sizes=*/1, + periodic)) { /* Call the PM interaction fucntion on the active sub-cells of ci */ runner_dopair_grav_mm_nonsym(r, ci, cj);