Commit 6b9a0345 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Fix a faulty debugging check in the new gravity code that triggered when using...

Fix a faulty debugging check in the new gravity code that triggered when using an empty external potential
parent ce522086
......@@ -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... */
......
......@@ -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... */
......
......@@ -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... */
......
......@@ -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
......
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