diff --git a/src/runner_doiact_grav.h b/src/runner_doiact_grav.h index 59f44936304d810ff2c7e4da3968638d4c6c89cb..7f2570b493a97d46e1e5380c27c4c83d561a2ef1 100644 --- a/src/runner_doiact_grav.h +++ b/src/runner_doiact_grav.h @@ -200,6 +200,9 @@ void runner_dopair_grav_pp_full(struct runner *r, struct cell *ci, /* Loop over all particles in ci... */ for (int pid = 0; pid < gcount_i; pid++) { + /* Skip inactive particles */ + if (!gpart_is_active(&gparts_i[pid], e)) continue; + const float x_i = ci_cache->x[pid]; const float y_i = ci_cache->y[pid]; const float z_i = ci_cache->z[pid]; @@ -272,7 +275,8 @@ void runner_dopair_grav_pp_full(struct runner *r, struct cell *ci, a_z -= f_ij * dz; #ifdef SWIFT_DEBUG_CHECKS - gparts_i[pid].num_interacted++; + /* Update the interaction counter if it's not a padded gpart */ + if (pjd < gcount_j) gparts_i[pid].num_interacted++; #endif } @@ -289,6 +293,9 @@ void runner_dopair_grav_pp_full(struct runner *r, struct cell *ci, /* Loop over all particles in ci... */ for (int pjd = 0; pjd < gcount_j; pjd++) { + /* Skip inactive particles */ + if (!gpart_is_active(&gparts_j[pjd], e)) continue; + const float x_j = cj_cache->x[pjd]; const float y_j = cj_cache->y[pjd]; const float z_j = cj_cache->z[pjd]; @@ -361,7 +368,8 @@ void runner_dopair_grav_pp_full(struct runner *r, struct cell *ci, a_z -= f_ji * dz; #ifdef SWIFT_DEBUG_CHECKS - gparts_j[pjd].num_interacted++; + /* Update the interaction counter if it's not a padded gpart */ + if (pid < gcount_i) gparts_j[pjd].num_interacted++; #endif } @@ -535,6 +543,9 @@ void runner_dopair_grav_pp_truncated(struct runner *r, struct cell *ci, /* Loop over all particles in ci... */ for (int pid = 0; pid < gcount_i; pid++) { + /* Skip inactive particles */ + if (!gpart_is_active(&gparts_i[pid], e)) continue; + const float x_i = ci_cache->x[pid]; const float y_i = ci_cache->y[pid]; const float z_i = ci_cache->z[pid]; @@ -612,7 +623,8 @@ void runner_dopair_grav_pp_truncated(struct runner *r, struct cell *ci, a_z -= f_ij * dz; #ifdef SWIFT_DEBUG_CHECKS - gparts_i[pid].num_interacted++; + /* Update the interaction counter if it's not a padded gpart */ + if (pjd < gcount_j) gparts_i[pid].num_interacted++; #endif } @@ -629,6 +641,9 @@ void runner_dopair_grav_pp_truncated(struct runner *r, struct cell *ci, /* Loop over all particles in ci... */ for (int pjd = 0; pjd < gcount_j; pjd++) { + /* Skip inactive particles */ + if (!gpart_is_active(&gparts_j[pjd], e)) continue; + const float x_j = cj_cache->x[pjd]; const float y_j = cj_cache->y[pjd]; const float z_j = cj_cache->z[pjd]; @@ -706,7 +721,8 @@ void runner_dopair_grav_pp_truncated(struct runner *r, struct cell *ci, a_z -= f_ji * dz; #ifdef SWIFT_DEBUG_CHECKS - gparts_j[pjd].num_interacted++; + /* Update the interaction counter if it's not a padded gpart */ + if (pid < gcount_i) gparts_j[pjd].num_interacted++; #endif }