diff --git a/src/gravity/Default/gravity.h b/src/gravity/Default/gravity.h index 623d04dc0bf57ca19f469dc547ea3d10c1d5b2b6..cba60ce5b282fd5dc8852967d9bb83b7b747e9b5 100644 --- a/src/gravity/Default/gravity.h +++ b/src/gravity/Default/gravity.h @@ -187,10 +187,11 @@ __attribute__((always_inline)) INLINE static void gravity_init_gpart( * @param const_G Newton's constant in internal units. * @param potential_normalisation Term to be added to all the particles. * @param periodic Are we using periodic BCs? + * @param with_self_gravity Are we running with self-gravity? */ __attribute__((always_inline)) INLINE static void gravity_end_force( - struct gpart* gp, float const_G, const float potential_normalisation, - const int periodic) { + struct gpart* gp, const float const_G, const float potential_normalisation, + const int periodic, const int with_self_gravity) { /* Record the norm of the acceleration for the adaptive opening criteria. * Will always be an (active) timestep behind. */ @@ -201,7 +202,8 @@ __attribute__((always_inline)) INLINE static void gravity_end_force( gp->old_a_grav_norm = sqrtf(gp->old_a_grav_norm); #ifdef SWIFT_DEBUG_CHECKS - if (gp->old_a_grav_norm == 0.f) error("Old acceleration is 0!"); + if (with_self_gravity && gp->old_a_grav_norm == 0.f) + error("Old acceleration is 0!"); #endif /* Let's get physical... */ diff --git a/src/gravity/MultiSoftening/gravity.h b/src/gravity/MultiSoftening/gravity.h index e436cc3c144571645f32879d2ce950d64d080825..bbbea116e4c397a03236aa6d06db82f2a537b5d2 100644 --- a/src/gravity/MultiSoftening/gravity.h +++ b/src/gravity/MultiSoftening/gravity.h @@ -181,10 +181,11 @@ __attribute__((always_inline)) INLINE static void gravity_init_gpart( * @param const_G Newton's constant in internal units. * @param potential_normalisation Term to be added to all the particles. * @param periodic Are we using periodic BCs? + * @param with_self_gravity Are we running with self-gravity? */ __attribute__((always_inline)) INLINE static void gravity_end_force( - struct gpart* gp, float const_G, const float potential_normalisation, - const int periodic) { + struct gpart* gp, const float const_G, const float potential_normalisation, + const int periodic, const int with_self_gravity) { /* Apply the periodic correction to the peculiar potential */ if (periodic) gp->potential += potential_normalisation; @@ -198,7 +199,8 @@ __attribute__((always_inline)) INLINE static void gravity_end_force( gp->old_a_grav_norm = sqrtf(gp->old_a_grav_norm); #ifdef SWIFT_DEBUG_CHECKS - if (gp->old_a_grav_norm == 0.f) error("Old acceleration is 0!"); + if (with_self_gravity && gp->old_a_grav_norm == 0.f) + error("Old acceleration is 0!"); #endif /* Let's get physical... */ diff --git a/src/gravity/Potential/gravity.h b/src/gravity/Potential/gravity.h index 8c5e36919539cd4ad6c6308310528fff3d19eeed..d642e798c7308e69ceb2a99e77a890df7cb8be84 100644 --- a/src/gravity/Potential/gravity.h +++ b/src/gravity/Potential/gravity.h @@ -168,10 +168,11 @@ __attribute__((always_inline)) INLINE static void gravity_init_gpart( * @param gp The particle to act upon * @param const_G Newton's constant in internal units. * @param potential_normalisation Term to be added to all the particles. + * @param with_self_gravity Are we running with self-gravity? */ __attribute__((always_inline)) INLINE static void gravity_end_force( - struct gpart* gp, float const_G, const float potential_normalisation, - const int periodic) { + struct gpart* gp, const float const_G, const float potential_normalisation, + const int periodic, const int with_self_gravity) { /* Apply the periodic correction to the peculiar potential */ if (periodic) gp->potential += potential_normalisation; @@ -185,7 +186,8 @@ __attribute__((always_inline)) INLINE static void gravity_end_force( gp->old_a_grav_norm = sqrtf(gp->old_a_grav_norm); #ifdef SWIFT_DEBUG_CHECKS - if (gp->old_a_grav_norm == 0.f) error("Old acceleration is 0!"); + if (with_self_gravity && gp->old_a_grav_norm == 0.f) + error("Old acceleration is 0!"); #endif /* Let's get physical... */ diff --git a/src/runner_others.c b/src/runner_others.c index 6f0c4ac9e8c078285714fe89f9dce7deb6b7a001..b037b005aa36426e50b3f1e4ba5eeb0853ec9572 100644 --- a/src/runner_others.c +++ b/src/runner_others.c @@ -555,7 +555,8 @@ void runner_do_end_grav_force(struct runner *r, struct cell *c, int timer) { if (gpart_is_active(gp, e)) { /* Finish the force calculation */ - gravity_end_force(gp, G_newton, potential_normalisation, periodic); + gravity_end_force(gp, G_newton, potential_normalisation, periodic, + with_self_gravity); #ifdef SWIFT_MAKE_GRAVITY_GLASS