diff --git a/src/gravity/Default/gravity_iact.h b/src/gravity/Default/gravity_iact.h index eca5c2491cbdcf5f0eca01417c8e6b29efc53459..5beba6f1b7603cb0231990974d7881942414b4eb 100644 --- a/src/gravity/Default/gravity_iact.h +++ b/src/gravity/Default/gravity_iact.h @@ -32,7 +32,7 @@ */ __attribute__((always_inline)) INLINE static void runner_iact_grav_pp( float rlr_inv, float r2, const float *dx, struct gpart *gpi, - struct gpart *gpj) { + struct gpart *gpj, int periodic) { /* Apply the gravitational acceleration. */ const float r = sqrtf(r2); @@ -49,7 +49,10 @@ __attribute__((always_inline)) INLINE static void runner_iact_grav_pp( #endif /* Get long-range correction */ - kernel_long_grav_eval(u, &f_lr); + if (periodic) + kernel_long_grav_eval(u, &f_lr); + else + f_lr = 1.f; if (r >= hi) { @@ -101,7 +104,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_grav_pp( */ __attribute__((always_inline)) INLINE static void runner_iact_grav_pp_nonsym( float rlr_inv, float r2, const float *dx, struct gpart *gpi, - const struct gpart *gpj) { + const struct gpart *gpj, int periodic) { /* Apply the gravitational acceleration. */ const float r = sqrtf(r2); @@ -116,7 +119,10 @@ __attribute__((always_inline)) INLINE static void runner_iact_grav_pp_nonsym( #endif /* Get long-range correction */ - kernel_long_grav_eval(u, &f_lr); + if (periodic) + kernel_long_grav_eval(u, &f_lr); + else + f_lr = 1.f; if (r >= hi) { diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index 8dcdc2d3197cacfad2b92f6f093f2e0eeffdf04f..d8e82c313e1ed18d98457c8065e7f9a8b90a5213 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -267,7 +267,7 @@ void runner_dopair_grav_pp(struct runner *r, struct cell *ci, struct cell *cj) { #endif /* Interact ! */ - runner_iact_grav_pp_nonsym(rlr_inv, r2, dx, gpi, gpj); + runner_iact_grav_pp_nonsym(rlr_inv, r2, dx, gpi, gpj, periodic); #ifdef SWIFT_DEBUG_CHECKS gpi->num_interacted++; @@ -310,7 +310,7 @@ void runner_dopair_grav_pp(struct runner *r, struct cell *ci, struct cell *cj) { #endif /* Interact ! */ - runner_iact_grav_pp_nonsym(rlr_inv, r2, dx, gpj, gpi); + runner_iact_grav_pp_nonsym(rlr_inv, r2, dx, gpj, gpi, periodic); #ifdef SWIFT_DEBUG_CHECKS gpj->num_interacted++; @@ -334,6 +334,8 @@ void runner_doself_grav_pp(struct runner *r, struct cell *c) { /* Some constants */ const struct engine *e = r->e; + const struct space *s = e->s; + const int periodic = s->periodic; const float a_smooth = e->gravity_properties->a_smooth; const float rlr_inv = 1. / (a_smooth * c->super->width[0]); @@ -397,7 +399,7 @@ void runner_doself_grav_pp(struct runner *r, struct cell *c) { /* Interact ! */ if (gpart_is_active(gpi, e) && gpart_is_active(gpj, e)) { - runner_iact_grav_pp(rlr_inv, r2, dx, gpi, gpj); + runner_iact_grav_pp(rlr_inv, r2, dx, gpi, gpj, periodic); #ifdef SWIFT_DEBUG_CHECKS gpi->num_interacted++; @@ -408,7 +410,7 @@ void runner_doself_grav_pp(struct runner *r, struct cell *c) { if (gpart_is_active(gpi, e)) { - runner_iact_grav_pp_nonsym(rlr_inv, r2, dx, gpi, gpj); + runner_iact_grav_pp_nonsym(rlr_inv, r2, dx, gpi, gpj, periodic); #ifdef SWIFT_DEBUG_CHECKS gpi->num_interacted++; @@ -419,7 +421,7 @@ void runner_doself_grav_pp(struct runner *r, struct cell *c) { dx[0] = -dx[0]; dx[1] = -dx[1]; dx[2] = -dx[2]; - runner_iact_grav_pp_nonsym(rlr_inv, r2, dx, gpj, gpi); + runner_iact_grav_pp_nonsym(rlr_inv, r2, dx, gpj, gpi, periodic); #ifdef SWIFT_DEBUG_CHECKS gpj->num_interacted++; diff --git a/src/tools.c b/src/tools.c index b2932f3eb09bfe2acaf435a18e25b0421984542a..d701afc5fd1c81960ff014c7f45af2b8debd0123 100644 --- a/src/tools.c +++ b/src/tools.c @@ -430,7 +430,7 @@ void pairs_single_grav(double *dim, long long int pid, fdx[i] = dx[i]; } r2 = fdx[0] * fdx[0] + fdx[1] * fdx[1] + fdx[2] * fdx[2]; - runner_iact_grav_pp(0.f, r2, fdx, &pi, &pj); + runner_iact_grav_pp(0.f, r2, fdx, &pi, &pj, 0); a[0] += pi.a_grav[0]; a[1] += pi.a_grav[1]; a[2] += pi.a_grav[2]; @@ -790,7 +790,7 @@ void gravity_n2(struct gpart *gparts, const int gcount, if (r2 < max_d2 || 1) { /* Apply the gravitational acceleration. */ - runner_iact_grav_pp(rlr_inv, r2, dx, gpi, gpj); + runner_iact_grav_pp(rlr_inv, r2, dx, gpi, gpj, 0); } } }