Skip to content
Snippets Groups Projects
Commit 1483f29f authored by James Willis's avatar James Willis
Browse files

Place inhibited particles out of range of neighbouring particles so no...

Place inhibited particles out of range of neighbouring particles so no interactions are computed. cache_read_particles_subset().
parent bdc6671e
No related branches found
No related tags found
1 merge request!699Inhibit vec
...@@ -272,10 +272,32 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset( ...@@ -272,10 +272,32 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset(
if (*last_pi + pad < ci->hydro.count) *last_pi += pad; 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 /* Shift the particles positions to a local frame so single precision can be
* used instead of double precision. */ * used instead of double precision. */
for (int i = 0; i < *last_pi; i++) { for (int i = 0; i < *last_pi; i++) {
const int idx = sort_i[i].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]); x[i] = (float)(parts[idx].x[0] - loc[0]);
y[i] = (float)(parts[idx].x[1] - loc[1]); y[i] = (float)(parts[idx].x[1] - loc[1]);
z[i] = (float)(parts[idx].x[2] - loc[2]); z[i] = (float)(parts[idx].x[2] - loc[2]);
...@@ -289,12 +311,6 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset( ...@@ -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 /* 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 * interact. We use values of the same magnitude (but negative!) as the real
* particles to avoid overflow problems. */ * 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++) { for (int i = *last_pi; i < *last_pi + VEC_SIZE; i++) {
x[i] = pos_padded[0]; x[i] = pos_padded[0];
y[i] = pos_padded[1]; y[i] = pos_padded[1];
...@@ -319,11 +335,32 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset( ...@@ -319,11 +335,32 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset(
} }
const int ci_cache_count = ci->hydro.count - *first_pi; 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 /* Shift the particles positions to a local frame so single precision can be
* used instead of double precision. */ * used instead of double precision. */
for (int i = 0; i < ci_cache_count; i++) { for (int i = 0; i < ci_cache_count; i++) {
const int idx = sort_i[i + *first_pi].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]); x[i] = (float)(parts[idx].x[0] - loc[0]);
y[i] = (float)(parts[idx].x[1] - loc[1]); y[i] = (float)(parts[idx].x[1] - loc[1]);
z[i] = (float)(parts[idx].x[2] - loc[2]); z[i] = (float)(parts[idx].x[2] - loc[2]);
...@@ -337,12 +374,6 @@ __attribute__((always_inline)) INLINE void cache_read_particles_subset( ...@@ -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 /* 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 * interact. We use values of the same magnitude (but negative!) as the real
* particles to avoid overflow problems. */ * 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; for (int i = ci->hydro.count - *first_pi;
i < ci->hydro.count - *first_pi + VEC_SIZE; i++) { i < ci->hydro.count - *first_pi + VEC_SIZE; i++) {
x[i] = pos_padded[0]; x[i] = pos_padded[0];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment