From 1483f29f047c92b81aff4b2bebbf0343632f669d Mon Sep 17 00:00:00 2001 From: James Willis <james.s.willis@durham.ac.uk> Date: Tue, 18 Dec 2018 15:58:39 +0000 Subject: [PATCH] Place inhibited particles out of range of neighbouring particles so no interactions are computed. cache_read_particles_subset(). --- src/cache.h | 55 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/src/cache.h b/src/cache.h index e90e32cb14..002b91e1ac 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]; -- GitLab