diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index 740556de2afbf1c98207d75fe3dc31841e5e1a2d..ebd08a662cee9595f8a82cbd5e4091d8325e1380 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -238,7 +238,8 @@ static INLINE void runner_dopair_grav_pp_full( error("Updating an inhibited particle!"); /* Check that the particle we interact with was not inhibited */ - if (gpart_is_inhibited(&gparts_j[pjd], e) && mass_j != 0.f) + if (pjd < gcount_j && gpart_is_inhibited(&gparts_j[pjd], e) && + mass_j != 0.f) error("Inhibited particle used as gravity source."); /* Check that the particle was initialised */ @@ -259,7 +260,8 @@ static INLINE void runner_dopair_grav_pp_full( #ifdef SWIFT_DEBUG_CHECKS /* Update the interaction counter if it's not a padded gpart */ - if (pjd < gcount_j) gparts_i[pid].num_interacted++; + if (pjd < gcount_j && !gpart_is_inhibited(&gparts_j[pjd], e)) + gparts_i[pid].num_interacted++; #endif } @@ -377,7 +379,8 @@ static INLINE void runner_dopair_grav_pp_truncated( error("Updating an inhibited particle!"); /* Check that the particle we interact with was not inhibited */ - if (gpart_is_inhibited(&gparts_j[pjd], e) && mass_j != 0.f) + if (pjd < gcount_j && gpart_is_inhibited(&gparts_j[pjd], e) && + mass_j != 0.f) error("Inhibited particle used as gravity source."); /* Check that the particle was initialised */ @@ -398,7 +401,8 @@ static INLINE void runner_dopair_grav_pp_truncated( #ifdef SWIFT_DEBUG_CHECKS /* Update the interaction counter if it's not a padded gpart */ - if (pjd < gcount_j) gparts_i[pid].num_interacted++; + if (pjd < gcount_j && !gpart_is_inhibited(&gparts_j[pjd], e)) + gparts_i[pid].num_interacted++; #endif } @@ -963,7 +967,7 @@ static INLINE void runner_doself_grav_pp_full( error("Updating an inhibited particle!"); /* Check that the particle we interact with was not inhibited */ - if (gpart_is_inhibited(&gparts[pjd], e) && mass_j != 0.f) + if (pjd < gcount && gpart_is_inhibited(&gparts[pjd], e) && mass_j != 0.f) error("Inhibited particle used as gravity source."); /* Check that the particle was initialised */ @@ -984,7 +988,8 @@ static INLINE void runner_doself_grav_pp_full( #ifdef SWIFT_DEBUG_CHECKS /* Update the interaction counter if it's not a padded gpart */ - if (pjd < gcount) gparts[pid].num_interacted++; + if (pjd < gcount && !gpart_is_inhibited(&gparts[pjd], e)) + gparts[pid].num_interacted++; #endif } @@ -1086,7 +1091,7 @@ static INLINE void runner_doself_grav_pp_truncated( error("Updating an inhibited particle!"); /* Check that the particle we interact with was not inhibited */ - if (gpart_is_inhibited(&gparts[pjd], e) && mass_j != 0.f) + if (pjd < gcount && gpart_is_inhibited(&gparts[pjd], e) && mass_j != 0.f) error("Inhibited particle used as gravity source."); /* Check that the particle was initialised */ @@ -1107,7 +1112,8 @@ static INLINE void runner_doself_grav_pp_truncated( #ifdef SWIFT_DEBUG_CHECKS /* Update the interaction counter if it's not a padded gpart */ - if (pjd < gcount) gparts[pid].num_interacted++; + if (pjd < gcount && !gpart_is_inhibited(&gparts[pjd], e)) + gparts[pid].num_interacted++; #endif }