diff --git a/src/cache.h b/src/cache.h index e90e32cb141e991d34d6104c0c821f7f4fd06172..002b91e1ac44faa7df5d5f9562e17c0c67c77dc3 100644 --- a/src/cache.h +++ b/src/cache.h @@ -272,10 +272,32 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset( if (*last_pi + pad < ci->hydro.count) *last_pi += pad; } + const double max_dx = ci->hydro.dx_max_part; + const float pos_padded[3] = {-(2. * ci->width[0] + max_dx), + -(2. * ci->width[1] + max_dx), + -(2. * ci->width[2] + max_dx)}; + const float h_padded = ci->hydro.parts[0].h; + /* Shift the particles positions to a local frame so single precision can be * used instead of double precision. */ for (int i = 0; i < *last_pi; i++) { const int idx = sort_i[i].i; + + /* Put inhibited particles out of range. */ + if (parts[idx].time_bin >= time_bin_inhibited) { + x[i] = pos_padded[0]; + y[i] = pos_padded[1]; + z[i] = pos_padded[2]; + h[i] = h_padded; + + m[i] = 1.f; + vx[i] = 1.f; + vy[i] = 1.f; + vz[i] = 1.f; + + continue; + } + x[i] = (float)(parts[idx].x[0] - loc[0]); y[i] = (float)(parts[idx].x[1] - loc[1]); z[i] = (float)(parts[idx].x[2] - loc[2]); @@ -289,12 +311,6 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset( /* Pad cache with fake particles that exist outside the cell so will not * interact. We use values of the same magnitude (but negative!) as the real * particles to avoid overflow problems. */ - const double max_dx = ci->hydro.dx_max_part; - const float pos_padded[3] = {-(2. * ci->width[0] + max_dx), - -(2. * ci->width[1] + max_dx), - -(2. * ci->width[2] + max_dx)}; - const float h_padded = ci->hydro.parts[0].h; - for (int i = *last_pi; i < *last_pi + VEC_SIZE; i++) { x[i] = pos_padded[0]; y[i] = pos_padded[1]; @@ -319,11 +335,32 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset( } const int ci_cache_count = ci->hydro.count - *first_pi; + const double max_dx = ci->hydro.dx_max_part; + const float pos_padded[3] = {-(2. * ci->width[0] + max_dx), + -(2. * ci->width[1] + max_dx), + -(2. * ci->width[2] + max_dx)}; + const float h_padded = ci->hydro.parts[0].h; /* Shift the particles positions to a local frame so single precision can be * used instead of double precision. */ for (int i = 0; i < ci_cache_count; i++) { const int idx = sort_i[i + *first_pi].i; + + /* Put inhibited particles out of range. */ + if (parts[idx].time_bin >= time_bin_inhibited) { + x[i] = pos_padded[0]; + y[i] = pos_padded[1]; + z[i] = pos_padded[2]; + h[i] = h_padded; + + m[i] = 1.f; + vx[i] = 1.f; + vy[i] = 1.f; + vz[i] = 1.f; + + continue; + } + x[i] = (float)(parts[idx].x[0] - loc[0]); y[i] = (float)(parts[idx].x[1] - loc[1]); z[i] = (float)(parts[idx].x[2] - loc[2]); @@ -337,12 +374,6 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset( /* Pad cache with fake particles that exist outside the cell so will not * interact. We use values of the same magnitude (but negative!) as the real * particles to avoid overflow problems. */ - const double max_dx = ci->hydro.dx_max_part; - const float pos_padded[3] = {-(2. * ci->width[0] + max_dx), - -(2. * ci->width[1] + max_dx), - -(2. * ci->width[2] + max_dx)}; - const float h_padded = ci->hydro.parts[0].h; - for (int i = ci->hydro.count - *first_pi; i < ci->hydro.count - *first_pi + VEC_SIZE; i++) { x[i] = pos_padded[0];