Commit 906f54b2 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

rename IDX_X etc to IDXC_X etc

I think it's more obvious when we talk about "index of component" and
"index of variable" what is meant, rather than having "FIELD_IDX" and
plain "IDX".
parent 94f89084
Pipeline #37203 canceled with stage
......@@ -62,15 +62,15 @@ public:
/// (4 / \tau) \sum_j W_\ell ( | x^i - x^j | ) (p^i \cdot p^j)p^j
/// \f]
///
const double dot_product = (pos_part1[3+IDX_X]*pos_part2[3+IDX_X] +
pos_part1[3+IDX_Y]*pos_part2[3+IDX_Y] +
pos_part1[3+IDX_Z]*pos_part2[3+IDX_Z]);
rhs_part1[3+IDX_X] += pos_part2[3+IDX_X] * 4 * ww * dot_product;
rhs_part1[3+IDX_Y] += pos_part2[3+IDX_Y] * 4 * ww * dot_product;
rhs_part1[3+IDX_Z] += pos_part2[3+IDX_Z] * 4 * ww * dot_product;
rhs_part2[3+IDX_X] += pos_part1[3+IDX_X] * 4 * ww * dot_product;
rhs_part2[3+IDX_Y] += pos_part1[3+IDX_Y] * 4 * ww * dot_product;
rhs_part2[3+IDX_Z] += pos_part1[3+IDX_Z] * 4 * ww * dot_product;
const double dot_product = (pos_part1[3+IDXC_X]*pos_part2[3+IDXC_X] +
pos_part1[3+IDXC_Y]*pos_part2[3+IDXC_Y] +
pos_part1[3+IDXC_Z]*pos_part2[3+IDXC_Z]);
rhs_part1[3+IDXC_X] += pos_part2[3+IDXC_X] * 4 * ww * dot_product;
rhs_part1[3+IDXC_Y] += pos_part2[3+IDXC_Y] * 4 * ww * dot_product;
rhs_part1[3+IDXC_Z] += pos_part2[3+IDXC_Z] * 4 * ww * dot_product;
rhs_part2[3+IDXC_X] += pos_part1[3+IDXC_X] * 4 * ww * dot_product;
rhs_part2[3+IDXC_Y] += pos_part1[3+IDXC_Y] * 4 * ww * dot_product;
rhs_part2[3+IDXC_Z] += pos_part1[3+IDXC_Z] * 4 * ww * dot_product;
}
bool isEnable() const {
......
This diff is collapsed.
......@@ -11,21 +11,21 @@ class p2p_tree{
std::array<long int,3> nb_cell_levels;
long int get_cell_coord_x_from_index(const long int index) const{
return index % nb_cell_levels[IDX_X];
return index % nb_cell_levels[IDXC_X];
}
long int get_cell_coord_y_from_index(const long int index) const{
return (index % (nb_cell_levels[IDX_X]*nb_cell_levels[IDX_Y]))
/ nb_cell_levels[IDX_X];
return (index % (nb_cell_levels[IDXC_X]*nb_cell_levels[IDXC_Y]))
/ nb_cell_levels[IDXC_X];
}
long int get_cell_coord_z_from_index(const long int index) const{
return index / (nb_cell_levels[IDX_X]*nb_cell_levels[IDX_Y]);
return index / (nb_cell_levels[IDXC_X]*nb_cell_levels[IDXC_Y]);
}
long int get_cell_idx(const long int idx_x, const long int idx_y,
const long int idx_z) const {
return (((idx_z*nb_cell_levels[IDX_Y])+idx_y)*nb_cell_levels[IDX_X])+idx_x;
return (((idx_z*nb_cell_levels[IDXC_Y])+idx_y)*nb_cell_levels[IDXC_X])+idx_x;
}
public:
......@@ -61,11 +61,11 @@ public:
long int neigh_x_pbc = neigh_x+idx_x;
ShiftType shift_x = 0;
if(neigh_x_pbc < 0){
neigh_x_pbc += nb_cell_levels[IDX_X];
neigh_x_pbc += nb_cell_levels[IDXC_X];
shift_x = 1;
}
else if(nb_cell_levels[IDX_X] <= neigh_x_pbc){
neigh_x_pbc -= nb_cell_levels[IDX_X];
else if(nb_cell_levels[IDXC_X] <= neigh_x_pbc){
neigh_x_pbc -= nb_cell_levels[IDXC_X];
shift_x = -1;
}
......@@ -73,11 +73,11 @@ public:
long int neigh_y_pbc = neigh_y+idx_y;
ShiftType shift_y = 0;
if(neigh_y_pbc < 0){
neigh_y_pbc += nb_cell_levels[IDX_Y];
neigh_y_pbc += nb_cell_levels[IDXC_Y];
shift_y = 1;
}
else if(nb_cell_levels[IDX_Y] <= neigh_y_pbc){
neigh_y_pbc -= nb_cell_levels[IDX_Y];
else if(nb_cell_levels[IDXC_Y] <= neigh_y_pbc){
neigh_y_pbc -= nb_cell_levels[IDXC_Y];
shift_y = -1;
}
......@@ -85,11 +85,11 @@ public:
long int neigh_z_pbc = neigh_z+idx_z;
ShiftType shift_z = 0;
if(neigh_z_pbc < 0){
neigh_z_pbc += nb_cell_levels[IDX_Z];
neigh_z_pbc += nb_cell_levels[IDXC_Z];
shift_z = 1;
}
else if(nb_cell_levels[IDX_Z] <= neigh_z_pbc){
neigh_z_pbc -= nb_cell_levels[IDX_Z];
else if(nb_cell_levels[IDXC_Z] <= neigh_z_pbc){
neigh_z_pbc -= nb_cell_levels[IDXC_Z];
shift_z = -1;
}
......@@ -102,9 +102,9 @@ public:
output[nbNeighbors] = &(iter->second);
output_indexes[nbNeighbors] = idx_neigh;
shift[nbNeighbors][IDX_X] = shift_x;
shift[nbNeighbors][IDX_Y] = shift_y;
shift[nbNeighbors][IDX_Z] = shift_z;
shift[nbNeighbors][IDXC_X] = shift_x;
shift[nbNeighbors][IDXC_Y] = shift_y;
shift[nbNeighbors][IDXC_Z] = shift_z;
nbNeighbors += 1;
}
......
......@@ -127,7 +127,7 @@ public:
assert(partition_interval_size_per_proc[idx_proc_involved] != 0);
}
assert(int(field_grid_dim[IDX_Z]) == partition_interval_offset_per_proc[nb_processes_involved]);
assert(int(field_grid_dim[IDXC_Z]) == partition_interval_offset_per_proc[nb_processes_involved]);
}
virtual ~particles_distr_mpi(){}
......@@ -522,11 +522,11 @@ public:
partsize_t partOffset = 0;
for(int idxPartition = 0 ; idxPartition < current_partition_size ; ++idxPartition){
for(partsize_t idx = 0 ; idx < current_my_nb_particles_per_partition[idxPartition] ; ++idx){
const int partition_level = in_computer.pbc_field_layer((*inout_positions_particles)[(idx+partOffset)*size_particle_positions+IDX_Z], IDX_Z);
const int partition_level = in_computer.pbc_field_layer((*inout_positions_particles)[(idx+partOffset)*size_particle_positions+IDXC_Z], IDXC_Z);
variable_used_only_in_assert(partition_level);
assert(partition_level == current_partition_interval.first + idxPartition
|| partition_level == (current_partition_interval.first + idxPartition-1+int(field_grid_dim[IDX_Z]))%int(field_grid_dim[IDX_Z])
|| partition_level == (current_partition_interval.first + idxPartition+1)%int(field_grid_dim[IDX_Z]));
|| partition_level == (current_partition_interval.first + idxPartition-1+int(field_grid_dim[IDXC_Z]))%int(field_grid_dim[IDXC_Z])
|| partition_level == (current_partition_interval.first + idxPartition+1)%int(field_grid_dim[IDXC_Z]));
}
partOffset += current_my_nb_particles_per_partition[idxPartition];
}
......@@ -543,11 +543,11 @@ public:
// Find particles outside my interval
const partsize_t nbOutLower = particles_utils::partition_extra<partsize_t, size_particle_positions>(&(*inout_positions_particles)[0], current_my_nb_particles_per_partition[0],
[&](const real_number val[]){
const int partition_level = in_computer.pbc_field_layer(val[IDX_Z], IDX_Z);
const int partition_level = in_computer.pbc_field_layer(val[IDXC_Z], IDXC_Z);
assert(partition_level == current_partition_interval.first
|| partition_level == (current_partition_interval.first-1+int(field_grid_dim[IDX_Z]))%int(field_grid_dim[IDX_Z])
|| partition_level == (current_partition_interval.first+1)%int(field_grid_dim[IDX_Z]));
const bool isLower = partition_level == (current_partition_interval.first-1+int(field_grid_dim[IDX_Z]))%int(field_grid_dim[IDX_Z]);
|| partition_level == (current_partition_interval.first-1+int(field_grid_dim[IDXC_Z]))%int(field_grid_dim[IDXC_Z])
|| partition_level == (current_partition_interval.first+1)%int(field_grid_dim[IDXC_Z]));
const bool isLower = partition_level == (current_partition_interval.first-1+int(field_grid_dim[IDXC_Z]))%int(field_grid_dim[IDXC_Z]);
return isLower;
},
[&](const partsize_t idx1, const partsize_t idx2){
......@@ -569,11 +569,11 @@ public:
&(*inout_positions_particles)[(current_offset_particles_for_partition[current_partition_size-1]+offesetOutLow)*size_particle_positions],
myTotalNbParticles - (current_offset_particles_for_partition[current_partition_size-1]+offesetOutLow),
[&](const real_number val[]){
const int partition_level = in_computer.pbc_field_layer(val[IDX_Z], IDX_Z);
const int partition_level = in_computer.pbc_field_layer(val[IDXC_Z], IDXC_Z);
assert(partition_level == (current_partition_interval.second-1)
|| partition_level == ((current_partition_interval.second-1)-1+int(field_grid_dim[IDX_Z]))%int(field_grid_dim[IDX_Z])
|| partition_level == ((current_partition_interval.second-1)+1)%int(field_grid_dim[IDX_Z]));
const bool isUpper = (partition_level == ((current_partition_interval.second-1)+1)%int(field_grid_dim[IDX_Z]));
|| partition_level == ((current_partition_interval.second-1)-1+int(field_grid_dim[IDXC_Z]))%int(field_grid_dim[IDXC_Z])
|| partition_level == ((current_partition_interval.second-1)+1)%int(field_grid_dim[IDXC_Z]));
const bool isUpper = (partition_level == ((current_partition_interval.second-1)+1)%int(field_grid_dim[IDXC_Z]));
return !isUpper;
},
[&](const partsize_t idx1, const partsize_t idx2){
......@@ -822,7 +822,7 @@ public:
myTotalNbParticles,current_partition_size,
current_my_nb_particles_per_partition, current_offset_particles_for_partition.get(),
[&](const real_number& z_pos){
const int partition_level = in_computer.pbc_field_layer(z_pos, IDX_Z);
const int partition_level = in_computer.pbc_field_layer(z_pos, IDXC_Z);
assert(current_partition_interval.first <= partition_level && partition_level < current_partition_interval.second);
return partition_level - current_partition_interval.first;
},
......@@ -845,7 +845,7 @@ public:
assert(current_my_nb_particles_per_partition[idxPartition] ==
current_offset_particles_for_partition[idxPartition+1] - current_offset_particles_for_partition[idxPartition]);
for(partsize_t idx = current_offset_particles_for_partition[idxPartition] ; idx < current_offset_particles_for_partition[idxPartition+1] ; ++idx){
assert(in_computer.pbc_field_layer((*inout_positions_particles)[idx*size_particle_positions+IDX_Z], IDX_Z)-current_partition_interval.first == idxPartition);
assert(in_computer.pbc_field_layer((*inout_positions_particles)[idx*size_particle_positions+IDXC_Z], IDXC_Z)-current_partition_interval.first == idxPartition);
}
}
}
......
......@@ -44,9 +44,9 @@ public:
: field_grid_dim({{int(in_field_grid_dim[0]),int(in_field_grid_dim[1]),int(in_field_grid_dim[2])}}), current_partition_interval(in_current_partitions),
interpolator(in_interpolator),
spatial_box_width(in_spatial_box_width), spatial_box_offset(in_spatial_box_offset), box_step_width(in_box_step_width){
deriv[IDX_X] = 0;
deriv[IDX_Y] = 0;
deriv[IDX_Z] = 0;
deriv[IDXC_X] = 0;
deriv[IDXC_Y] = 0;
deriv[IDXC_Z] = 0;
}
////////////////////////////////////////////////////////////////////////
......@@ -82,25 +82,25 @@ public:
TIMEZONE("particles_field_computer::apply_computation");
for(partsize_t idxPart = 0 ; idxPart < nb_particles ; ++idxPart){
const real_number reltv_x = get_norm_pos_in_cell(particles_positions[idxPart*size_particle_positions+IDX_X], IDX_X);
const real_number reltv_y = get_norm_pos_in_cell(particles_positions[idxPart*size_particle_positions+IDX_Y], IDX_Y);
const real_number reltv_z = get_norm_pos_in_cell(particles_positions[idxPart*size_particle_positions+IDX_Z], IDX_Z);
const real_number reltv_x = get_norm_pos_in_cell(particles_positions[idxPart*size_particle_positions+IDXC_X], IDXC_X);
const real_number reltv_y = get_norm_pos_in_cell(particles_positions[idxPart*size_particle_positions+IDXC_Y], IDXC_Y);
const real_number reltv_z = get_norm_pos_in_cell(particles_positions[idxPart*size_particle_positions+IDXC_Z], IDXC_Z);
typename interpolator_class::real_number
bx[interp_neighbours*2+2],
by[interp_neighbours*2+2],
bz[interp_neighbours*2+2];
interpolator.compute_beta(deriv[IDX_X], reltv_x, bx);
interpolator.compute_beta(deriv[IDX_Y], reltv_y, by);
interpolator.compute_beta(deriv[IDX_Z], reltv_z, bz);
interpolator.compute_beta(deriv[IDXC_X], reltv_x, bx);
interpolator.compute_beta(deriv[IDXC_Y], reltv_y, by);
interpolator.compute_beta(deriv[IDXC_Z], reltv_z, bz);
const int partGridIdx_x = pbc_field_layer(particles_positions[idxPart*size_particle_positions+IDX_X], IDX_X);
const int partGridIdx_y = pbc_field_layer(particles_positions[idxPart*size_particle_positions+IDX_Y], IDX_Y);
const int partGridIdx_z = pbc_field_layer(particles_positions[idxPart*size_particle_positions+IDX_Z], IDX_Z);
const int partGridIdx_x = pbc_field_layer(particles_positions[idxPart*size_particle_positions+IDXC_X], IDXC_X);
const int partGridIdx_y = pbc_field_layer(particles_positions[idxPart*size_particle_positions+IDXC_Y], IDXC_Y);
const int partGridIdx_z = pbc_field_layer(particles_positions[idxPart*size_particle_positions+IDXC_Z], IDXC_Z);
assert(0 <= partGridIdx_x && partGridIdx_x < int(field_grid_dim[IDX_X]));
assert(0 <= partGridIdx_y && partGridIdx_y < int(field_grid_dim[IDX_Y]));
assert(0 <= partGridIdx_z && partGridIdx_z < int(field_grid_dim[IDX_Z]));
assert(0 <= partGridIdx_x && partGridIdx_x < int(field_grid_dim[IDXC_X]));
assert(0 <= partGridIdx_y && partGridIdx_y < int(field_grid_dim[IDXC_Y]));
assert(0 <= partGridIdx_z && partGridIdx_z < int(field_grid_dim[IDXC_Z]));
const int interp_limit_mx = partGridIdx_x-interp_neighbours;
const int interp_limit_x = partGridIdx_x+interp_neighbours+1;
......@@ -113,8 +113,8 @@ public:
int nb_z_intervals;
if((partGridIdx_z-interp_neighbours) < 0){
assert(partGridIdx_z+interp_neighbours+1 < int(field_grid_dim[IDX_Z]));
interp_limit_mz[0] = std::max(current_partition_interval.first, partGridIdx_z-interp_neighbours+int(field_grid_dim[IDX_Z]));
assert(partGridIdx_z+interp_neighbours+1 < int(field_grid_dim[IDXC_Z]));
interp_limit_mz[0] = std::max(current_partition_interval.first, partGridIdx_z-interp_neighbours+int(field_grid_dim[IDXC_Z]));
interp_limit_z[0] = current_partition_interval.second-1;
interp_limit_mz[1] = std::max(0, current_partition_interval.first);
......@@ -122,12 +122,12 @@ public:
nb_z_intervals = 2;
}
else if(int(field_grid_dim[IDX_Z]) <= (partGridIdx_z+interp_neighbours+1)){
else if(int(field_grid_dim[IDXC_Z]) <= (partGridIdx_z+interp_neighbours+1)){
interp_limit_mz[0] = std::max(current_partition_interval.first, partGridIdx_z-interp_neighbours);
interp_limit_z[0] = std::min(int(field_grid_dim[IDX_Z])-1,current_partition_interval.second-1);
interp_limit_z[0] = std::min(int(field_grid_dim[IDXC_Z])-1,current_partition_interval.second-1);
interp_limit_mz[1] = std::max(0, current_partition_interval.first);
interp_limit_z[1] = std::min(partGridIdx_z+interp_neighbours+1-int(field_grid_dim[IDX_Z]), current_partition_interval.second-1);
interp_limit_z[1] = std::min(partGridIdx_z+interp_neighbours+1-int(field_grid_dim[IDXC_Z]), current_partition_interval.second-1);
nb_z_intervals = 2;
}
......@@ -139,19 +139,19 @@ public:
for(int idx_inter = 0 ; idx_inter < nb_z_intervals ; ++idx_inter){
for(int idx_z = interp_limit_mz[idx_inter] ; idx_z <= interp_limit_z[idx_inter] ; ++idx_z ){
const int idx_z_pbc = (idx_z + field_grid_dim[IDX_Z])%field_grid_dim[IDX_Z];
const int idx_z_pbc = (idx_z + field_grid_dim[IDXC_Z])%field_grid_dim[IDXC_Z];
assert(current_partition_interval.first <= idx_z_pbc && idx_z_pbc < current_partition_interval.second);
assert(((idx_z+field_grid_dim[IDX_Z]-interp_limit_mz_bz)%field_grid_dim[IDX_Z]) < interp_neighbours*2+2);
assert(((idx_z+field_grid_dim[IDXC_Z]-interp_limit_mz_bz)%field_grid_dim[IDXC_Z]) < interp_neighbours*2+2);
for(int idx_x = interp_limit_mx ; idx_x <= interp_limit_x ; ++idx_x ){
const int idx_x_pbc = (idx_x + field_grid_dim[IDX_X])%field_grid_dim[IDX_X];
const int idx_x_pbc = (idx_x + field_grid_dim[IDXC_X])%field_grid_dim[IDXC_X];
assert(idx_x-interp_limit_mx < interp_neighbours*2+2);
for(int idx_y = interp_limit_my ; idx_y <= interp_limit_y ; ++idx_y ){
const int idx_y_pbc = (idx_y + field_grid_dim[IDX_Y])%field_grid_dim[IDX_Y];
const int idx_y_pbc = (idx_y + field_grid_dim[IDXC_Y])%field_grid_dim[IDXC_Y];
assert(idx_y-interp_limit_my < interp_neighbours*2+2);
const real_number coef = (bz[((idx_z+field_grid_dim[IDX_Z]-interp_limit_mz_bz)%field_grid_dim[IDX_Z])]
const real_number coef = (bz[((idx_z+field_grid_dim[IDXC_Z]-interp_limit_mz_bz)%field_grid_dim[IDXC_Z])]
* by[idx_y-interp_limit_my]
* bx[idx_x-interp_limit_mx]);
......
......@@ -240,7 +240,7 @@ public:
&split_particles_positions[previousOffset*size_particle_positions],
partsize_t(load_splitter.getMySize())-previousOffset,
[&](const real_number val[]){
const real_number shiftPos = val[IDX_Z]-spatial_box_offset;
const real_number shiftPos = val[IDXC_Z]-spatial_box_offset;
const real_number nbRepeat = floor(shiftPos/spatial_box_width);
const real_number posInBox = shiftPos - (spatial_box_width*nbRepeat);
return posInBox < limitPartitionShifted;
......
......@@ -70,7 +70,7 @@ public:
particles_inner_computer_class in_computer_particules_inner,
const int in_current_iteration = 1)
: mpi_com(in_mpi_com),
current_partition_interval({in_local_field_offset[IDX_Z], in_local_field_offset[IDX_Z] + in_local_field_dims[IDX_Z]}),
current_partition_interval({in_local_field_offset[IDXC_Z], in_local_field_offset[IDXC_Z] + in_local_field_dims[IDXC_Z]}),
partition_interval_size(current_partition_interval.second - current_partition_interval.first),
interpolator(),
particles_distr(in_mpi_com, current_partition_interval,field_grid_dim),
......@@ -100,7 +100,7 @@ public:
my_nb_particles = particles_input.getLocalNbParticles();
for(partsize_t idx_part = 0 ; idx_part < my_nb_particles ; ++idx_part){ // TODO remove me
const int partition_level = computer.pbc_field_layer(my_particles_positions[idx_part*size_particle_positions+IDX_Z], IDX_Z);
const int partition_level = computer.pbc_field_layer(my_particles_positions[idx_part*size_particle_positions+IDXC_Z], IDXC_Z);
variable_used_only_in_assert(partition_level);
assert(partition_level >= current_partition_interval.first);
assert(partition_level < current_partition_interval.second);
......@@ -109,7 +109,7 @@ public:
particles_utils::partition_extra_z<partsize_t, size_particle_positions>(&my_particles_positions[0], my_nb_particles, partition_interval_size,
current_my_nb_particles_per_partition.get(), current_offset_particles_for_partition.get(),
[&](const real_number& z_pos){
const int partition_level = computer.pbc_field_layer(z_pos, IDX_Z);
const int partition_level = computer.pbc_field_layer(z_pos, IDXC_Z);
assert(current_partition_interval.first <= partition_level && partition_level < current_partition_interval.second);
return partition_level - current_partition_interval.first;
},
......@@ -128,7 +128,7 @@ public:
assert(current_my_nb_particles_per_partition[idxPartition] ==
current_offset_particles_for_partition[idxPartition+1] - current_offset_particles_for_partition[idxPartition]);
for(partsize_t idx = current_offset_particles_for_partition[idxPartition] ; idx < current_offset_particles_for_partition[idxPartition+1] ; ++idx){
assert(computer.pbc_field_layer(my_particles_positions[idx*size_particle_positions+IDX_Z], IDX_Z)-current_partition_interval.first == idxPartition);
assert(computer.pbc_field_layer(my_particles_positions[idx*size_particle_positions+IDXC_Z], IDXC_Z)-current_partition_interval.first == idxPartition);
}
}
}
......@@ -331,9 +331,9 @@ public:
void checkNan() const { // TODO remove
for(partsize_t idx_part = 0 ; idx_part < my_nb_particles ; ++idx_part){ // TODO remove me
assert(std::isnan(my_particles_positions[idx_part*size_particle_positions+IDX_X]) == false);
assert(std::isnan(my_particles_positions[idx_part*size_particle_positions+IDX_Y]) == false);
assert(std::isnan(my_particles_positions[idx_part*size_particle_positions+IDX_Z]) == false);
assert(std::isnan(my_particles_positions[idx_part*size_particle_positions+IDXC_X]) == false);
assert(std::isnan(my_particles_positions[idx_part*size_particle_positions+IDXC_Y]) == false);
assert(std::isnan(my_particles_positions[idx_part*size_particle_positions+IDXC_Z]) == false);
for(int idx_rhs = 0 ; idx_rhs < my_particles_rhs.size() ; ++idx_rhs){
for(int idx_rhs_val = 0 ; idx_rhs_val < size_particle_rhs ; ++idx_rhs_val){
......
......@@ -130,21 +130,21 @@ struct particles_system_build_container {
// The size of the field grid (global size) all_size seems
std::array<size_t,3> field_grid_dim;
field_grid_dim[IDX_X] = fs_field->rlayout->sizes[FIELD_IDX_X];// nx
field_grid_dim[IDX_Y] = fs_field->rlayout->sizes[FIELD_IDX_Y];// nx
field_grid_dim[IDX_Z] = fs_field->rlayout->sizes[FIELD_IDX_Z];// nz
field_grid_dim[IDXC_X] = fs_field->rlayout->sizes[IDXV_X];// nx
field_grid_dim[IDXC_Y] = fs_field->rlayout->sizes[IDXV_Y];// nx
field_grid_dim[IDXC_Z] = fs_field->rlayout->sizes[IDXV_Z];// nz
// The size of the local field grid (the field nodes that belong to current process)
std::array<size_t,3> local_field_dims;
local_field_dims[IDX_X] = fs_field->rlayout->subsizes[FIELD_IDX_X];
local_field_dims[IDX_Y] = fs_field->rlayout->subsizes[FIELD_IDX_Y];
local_field_dims[IDX_Z] = fs_field->rlayout->subsizes[FIELD_IDX_Z];
local_field_dims[IDXC_X] = fs_field->rlayout->subsizes[IDXV_X];
local_field_dims[IDXC_Y] = fs_field->rlayout->subsizes[IDXV_Y];
local_field_dims[IDXC_Z] = fs_field->rlayout->subsizes[IDXV_Z];
// The offset of the local field grid
std::array<size_t,3> local_field_offset;
local_field_offset[IDX_X] = fs_field->rlayout->starts[FIELD_IDX_X];
local_field_offset[IDX_Y] = fs_field->rlayout->starts[FIELD_IDX_Y];
local_field_offset[IDX_Z] = fs_field->rlayout->starts[FIELD_IDX_Z];
local_field_offset[IDXC_X] = fs_field->rlayout->starts[IDXV_X];
local_field_offset[IDXC_Y] = fs_field->rlayout->starts[IDXV_Y];
local_field_offset[IDXC_Z] = fs_field->rlayout->starts[IDXV_Z];
// Retreive split from fftw to know processes that have no work
......@@ -152,51 +152,51 @@ struct particles_system_build_container {
AssertMpi(MPI_Comm_rank(mpi_comm, &my_rank));
AssertMpi(MPI_Comm_size(mpi_comm, &nb_processes));
const int split_step = (int(field_grid_dim[IDX_Z])+nb_processes-1)/nb_processes;
const int nb_processes_involved = (int(field_grid_dim[IDX_Z])+split_step-1)/split_step;
const int split_step = (int(field_grid_dim[IDXC_Z])+nb_processes-1)/nb_processes;
const int nb_processes_involved = (int(field_grid_dim[IDXC_Z])+split_step-1)/split_step;
assert((my_rank < nb_processes_involved && local_field_dims[IDX_Z] != 0)
|| (nb_processes_involved <= my_rank && local_field_dims[IDX_Z] == 0));
assert(nb_processes_involved <= int(field_grid_dim[IDX_Z]));
assert((my_rank < nb_processes_involved && local_field_dims[IDXC_Z] != 0)
|| (nb_processes_involved <= my_rank && local_field_dims[IDXC_Z] == 0));
assert(nb_processes_involved <= int(field_grid_dim[IDXC_Z]));
// Make the idle processes starting from the limit (and not 0 as set by fftw)
if(nb_processes_involved <= my_rank){
local_field_offset[IDX_Z] = field_grid_dim[IDX_Z];
local_field_offset[IDXC_Z] = field_grid_dim[IDXC_Z];
}
// Ensure that 1D partitioning is used
{
assert(local_field_offset[IDX_X] == 0);
assert(local_field_offset[IDX_Y] == 0);
assert(local_field_dims[IDX_X] == field_grid_dim[IDX_X]);
assert(local_field_dims[IDX_Y] == field_grid_dim[IDX_Y]);
assert(my_rank >= nb_processes_involved || ((my_rank == 0 && local_field_offset[IDX_Z] == 0)
|| (my_rank != 0 && local_field_offset[IDX_Z] != 0)));
assert(my_rank >= nb_processes_involved || ((my_rank == nb_processes_involved-1 && local_field_offset[IDX_Z]+local_field_dims[IDX_Z] == field_grid_dim[IDX_Z])
|| (my_rank != nb_processes_involved-1 && local_field_offset[IDX_Z]+local_field_dims[IDX_Z] != field_grid_dim[IDX_Z])));
assert(local_field_offset[IDXC_X] == 0);
assert(local_field_offset[IDXC_Y] == 0);
assert(local_field_dims[IDXC_X] == field_grid_dim[IDXC_X]);
assert(local_field_dims[IDXC_Y] == field_grid_dim[IDXC_Y]);
assert(my_rank >= nb_processes_involved || ((my_rank == 0 && local_field_offset[IDXC_Z] == 0)
|| (my_rank != 0 && local_field_offset[IDXC_Z] != 0)));
assert(my_rank >= nb_processes_involved || ((my_rank == nb_processes_involved-1 && local_field_offset[IDXC_Z]+local_field_dims[IDXC_Z] == field_grid_dim[IDXC_Z])
|| (my_rank != nb_processes_involved-1 && local_field_offset[IDXC_Z]+local_field_dims[IDXC_Z] != field_grid_dim[IDXC_Z])));
}
// The spatial box size (all particles should be included inside)
std::array<particles_rnumber,3> spatial_box_width;
spatial_box_width[IDX_X] = 4 * acos(0) / (fs_kk->dkx);
spatial_box_width[IDX_Y] = 4 * acos(0) / (fs_kk->dky);
spatial_box_width[IDX_Z] = 4 * acos(0) / (fs_kk->dkz);
spatial_box_width[IDXC_X] = 4 * acos(0) / (fs_kk->dkx);
spatial_box_width[IDXC_Y] = 4 * acos(0) / (fs_kk->dky);
spatial_box_width[IDXC_Z] = 4 * acos(0) / (fs_kk->dkz);
// Box is in the corner
std::array<particles_rnumber,3> spatial_box_offset;
spatial_box_offset[IDX_X] = 0;
spatial_box_offset[IDX_Y] = 0;
spatial_box_offset[IDX_Z] = 0;
spatial_box_offset[IDXC_X] = 0;
spatial_box_offset[IDXC_Y] = 0;
spatial_box_offset[IDXC_Z] = 0;
// The distance between two field nodes in z
std::array<particles_rnumber,3> spatial_partition_width;
spatial_partition_width[IDX_X] = spatial_box_width[IDX_X]/particles_rnumber(field_grid_dim[IDX_X]);
spatial_partition_width[IDX_Y] = spatial_box_width[IDX_Y]/particles_rnumber(field_grid_dim[IDX_Y]);
spatial_partition_width[IDX_Z] = spatial_box_width[IDX_Z]/particles_rnumber(field_grid_dim[IDX_Z]);
spatial_partition_width[IDXC_X] = spatial_box_width[IDXC_X]/particles_rnumber(field_grid_dim[IDXC_X]);
spatial_partition_width[IDXC_Y] = spatial_box_width[IDXC_Y]/particles_rnumber(field_grid_dim[IDXC_Y]);
spatial_partition_width[IDXC_Z] = spatial_box_width[IDXC_Z]/particles_rnumber(field_grid_dim[IDXC_Z]);
// The spatial interval of the current process
const particles_rnumber my_spatial_low_limit_z = particles_rnumber(local_field_offset[IDX_Z])*spatial_partition_width[IDX_Z];
const particles_rnumber my_spatial_up_limit_z = particles_rnumber(local_field_offset[IDX_Z]+local_field_dims[IDX_Z])*spatial_partition_width[IDX_Z];
const particles_rnumber my_spatial_low_limit_z = particles_rnumber(local_field_offset[IDXC_Z])*spatial_partition_width[IDXC_Z];
const particles_rnumber my_spatial_up_limit_z = particles_rnumber(local_field_offset[IDXC_Z]+local_field_dims[IDXC_Z])*spatial_partition_width[IDXC_Z];
// Create the particles system
using particles_system_type = particles_system<partsize_t, particles_rnumber, field_rnumber,
......
......@@ -19,16 +19,28 @@
#define AssertMpi(X) if(MPI_SUCCESS != (X)) { printf("MPI Error at line %d\n",__LINE__); fflush(stdout) ; throw std::runtime_error("Stop from from mpi erro"); }
#endif
enum IDXS_3D {
IDX_X = 0,
IDX_Y = 1,
IDX_Z = 2
enum IDX_COMPONENT_3D {
IDXC_X = 0,
IDXC_Y = 1,
IDXC_Z = 2
};
enum FIELD_IDXS_3D {
FIELD_IDX_X = 2,
FIELD_IDX_Y = 1,
FIELD_IDX_Z = 0
enum IDX_COMPONENT_DEL_3D {
IDXC_DX_X = 0,
IDXC_DX_Y = 1,
IDXC_DX_Z = 2,
IDXC_DY_X = 3,
IDXC_DY_Y = 4,
IDXC_DY_Z = 5,
IDXC_DZ_X = 6,
IDXC_DZ_Y = 7,
IDXC_DZ_Z = 8,
};
enum IDX_VARIABLE_3D {
IDXV_X = 2,
IDXV_Y = 1,
IDXV_Z = 0
};
namespace particles_utils {
......@@ -123,7 +135,7 @@ inline void partition_extra_z(real_number* array, const partsize_t size, const i
if(nb_partitions == 2){
const partsize_t size_current = partition_extra<partsize_t, nb_values>(array, size,
[&](const real_number inval[]){
return partitions_levels(inval[IDX_Z]) == 0;
return partitions_levels(inval[IDXC_Z]) == 0;
}, pdcswap);
partitions_size[0] = size_current;
partitions_size[1] = size-size_current;
......@@ -152,7 +164,7 @@ inline void partition_extra_z(real_number* array, const partsize_t size, const i
const partsize_t size_current = partition_extra<partsize_t, nb_values>(&array[partitions_offset[current_part.first]*nb_values],
size_unpart,
[&](const real_number inval[]){
return partitions_levels(inval[IDX_Z]) <= idx_middle;
return partitions_levels(inval[IDXC_Z]) <= idx_middle;
}, pdcswap, partitions_offset[current_part.first]);
partitions_offset[idx_middle+1] = size_current + partitions_offset[current_part.first];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment