Commit 99d5fe72 authored by Berenger Bramas's avatar Berenger Bramas
Browse files

Update BFPS interface to include the new P2P classes

parent b8eaa38d
Pipeline #18530 passed with stage
in 10 minutes and 6 seconds
#include <string>
#include <cmath>
#include "NSVEparticlesP2P.hpp"
#include "scope_timer.hpp"
#include "particles/particles_sampling.hpp"
#include "particles/p2p_computer.hpp"
template <typename rnumber>
int NSVEparticlesP2P<rnumber>::initialize(void)
{
this->NSVE<rnumber>::initialize();
this->ps = particles_system_builder(
this->fs->cvelocity, // (field object)
this->fs->kk, // (kspace object, contains dkx, dky, dkz)
tracers0_integration_steps, // to check coherency between parameters and hdf input file (nb rhs)
(long long int)nparticles, // to check coherency between parameters and hdf input file
this->fs->get_current_fname(), // particles input filename
std::string("/tracers0/state/") + std::to_string(this->fs->iteration), // dataset name for initial input
std::string("/tracers0/rhs/") + std::to_string(this->fs->iteration), // dataset name for initial input
tracers0_neighbours, // parameter (interpolation no neighbours)
tracers0_smoothness, // parameter
this->comm,
this->fs->iteration+1);
// TODO P2P write particle data too
this->particles_output_writer_mpi = new particles_output_hdf5<
long long int, double, 3, 3>(
MPI_COMM_WORLD,
"tracers0",
nparticles,
tracers0_integration_steps);
return EXIT_SUCCESS;
}
template <typename rnumber>
int NSVEparticlesP2P<rnumber>::step(void)
{
this->fs->compute_velocity(this->fs->cvorticity);
this->fs->cvelocity->ift();
this->ps->completeLoop(this->dt);
this->NSVE<rnumber>::step();
return EXIT_SUCCESS;
}
template <typename rnumber>
int NSVEparticlesP2P<rnumber>::write_checkpoint(void)
{
this->NSVE<rnumber>::write_checkpoint();
this->particles_output_writer_mpi->open_file(this->fs->get_current_fname());
// TODO P2P write particle data too
this->particles_output_writer_mpi->save(
this->ps->getParticlesPositions(),
this->ps->getParticlesRhs(),
this->ps->getParticlesIndexes(),
this->ps->getLocalNbParticles(),
this->fs->iteration);
this->particles_output_writer_mpi->close_file();
return EXIT_SUCCESS;
}
template <typename rnumber>
int NSVEparticlesP2P<rnumber>::finalize(void)
{
this->ps.release();
delete this->particles_output_writer_mpi;
this->NSVE<rnumber>::finalize();
return EXIT_SUCCESS;
}
/** \brief Compute fluid stats and sample fields at particle locations.
*/
template <typename rnumber>
int NSVEparticlesP2P<rnumber>::do_stats()
{
/// fluid stats go here
this->NSVE<rnumber>::do_stats();
if (!(this->iteration % this->niter_part == 0))
return EXIT_SUCCESS;
/// sample position
sample_particles_system_position(
this->ps,
(this->simname + "_particles.h5"), // filename
"tracers0", // hdf5 parent group
"position" // dataset basename TODO
);
/// sample velocity
sample_from_particles_system(*this->tmp_vec_field, // field to save
this->ps,
(this->simname + "_particles.h5"), // filename
"tracers0", // hdf5 parent group
"velocity" // dataset basename TODO
);
/// compute acceleration and sample it
this->fs->compute_Lagrangian_acceleration(this->tmp_vec_field);
this->tmp_vec_field->ift();
sample_from_particles_system(*this->tmp_vec_field,
this->ps,
(this->simname + "_particles.h5"),
"tracers0",
"acceleration");
return EXIT_SUCCESS;
}
template class NSVEparticlesP2P<float>;
template class NSVEparticlesP2P<double>;
/**********************************************************************
* *
* Copyright 2017 Max Planck Institute *
* for Dynamics and Self-Organization *
* *
* This file is part of bfps. *
* *
* bfps is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation, either version 3 of the License, *
* or (at your option) any later version. *
* *
* bfps is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with bfps. If not, see <http://www.gnu.org/licenses/> *
* *
* Contact: Cristian.Lalescu@ds.mpg.de *
* *
**********************************************************************/
#ifndef NSVEPARTICLESP2P_HPP
#define NSVEPARTICLESP2P_HPP
#include <cstdlib>
#include "base.hpp"
#include "vorticity_equation.hpp"
#include "full_code/NSVE.hpp"
#include "particles/particles_system_builder.hpp"
#include "particles/particles_output_hdf5.hpp"
/** \brief Navier-Stokes solver that includes simple Lagrangian tracers.
*
* Child of Navier Stokes vorticity equation solver, this class calls all the
* methods from `NSVE`, and in addition integrates simple Lagrangian tracers
* in the resulting velocity field.
*/
template <typename rnumber>
class NSVEparticlesP2P: public NSVE<rnumber>
{
public:
/* parameters that are read in read_parameters */
int niter_part;
int nparticles;
int tracers0_integration_steps;
int tracers0_neighbours;
int tracers0_smoothness;
/* other stuff */
std::unique_ptr<abstract_particles_system<long long int, double>> ps;
// TODO P2P use a reader with particle data
particles_output_hdf5<long long int, double,3,3> *particles_output_writer_mpi;
NSVEparticlesP2P(
const MPI_Comm COMMUNICATOR,
const std::string &simulation_name):
NSVE<rnumber>(
COMMUNICATOR,
simulation_name){}
~NSVEparticlesP2P(){}
int initialize(void);
int step(void);
int finalize(void);
int read_parameters(void);
int write_checkpoint(void);
int do_stats(void);
};
#endif//NSVEPARTICLESP2P_HPP
...@@ -14,6 +14,8 @@ class abstract_particles_system { ...@@ -14,6 +14,8 @@ class abstract_particles_system {
public: public:
virtual void compute() = 0; virtual void compute() = 0;
virtual void compute_p2p() = 0;
virtual void move(const real_number dt) = 0; virtual void move(const real_number dt) = 0;
virtual void redistribute() = 0; virtual void redistribute() = 0;
......
...@@ -15,7 +15,7 @@ public: ...@@ -15,7 +15,7 @@ public:
} }
} }
void lock(const int inKey){ void lock(const long int inKey){
volatile long int* k = keys[inKey%keys.size()].get(); volatile long int* k = keys[inKey%keys.size()].get();
long int res = 1; long int res = 1;
while(res == 1){ while(res == 1){
...@@ -23,7 +23,7 @@ public: ...@@ -23,7 +23,7 @@ public:
} }
} }
void unlock(const int inKey){ void unlock(const long int inKey){
volatile long int* k = keys[inKey%keys.size()].get(); volatile long int* k = keys[inKey%keys.size()].get();
assert(k && *k); assert(k && *k);
(*k) = 0; (*k) = 0;
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
template <class real_number, class partsize_t> template <class real_number, class partsize_t>
class p2p_computer{ class p2p_computer{
public: public:
constexpr static int size_data = 3;
template <int size_particle_rhs> template <int size_particle_rhs>
void init_result_array(real_number rhs[], const partsize_t nbParticles) const{ void init_result_array(real_number rhs[], const partsize_t nbParticles) const{
memset(rhs, 0, sizeof(real_number)*nbParticles*size_particle_rhs); memset(rhs, 0, sizeof(real_number)*nbParticles*size_particle_rhs);
...@@ -28,6 +30,10 @@ public: ...@@ -28,6 +30,10 @@ public:
// TODO put the kernel here // TODO put the kernel here
static_assert(size_particle_positions == 3, "This kernel works only with 3 values for one position"); static_assert(size_particle_positions == 3, "This kernel works only with 3 values for one position");
} }
constexpr static bool isEmpty() {
return false;
}
}; };
#endif #endif
#ifndef P2P_COMPUTER_EMPTY_HPP
#define P2P_COMPUTER_EMPTY_HPP
#include <cstring>
template <class real_number, class partsize_t>
class p2p_computer_empty{
public:
constexpr int static size_data = 0;
template <int size_particle_rhs>
void init_result_array(real_number /*rhs*/[], const partsize_t /*nbParticles*/) const{
}
template <int size_particle_rhs>
void reduce_particles_rhs(real_number /*rhs_dst*/[], const real_number /*rhs_src*/[], const partsize_t /*nbParticles*/) const{
}
template <int size_particle_positions, int size_particle_data, int size_particle_rhs>
void compute_interaction(const real_number /*pos_part1*/[], const real_number /*data_part1*/[], real_number /*rhs_part1*/[],
const real_number /*pos_part2*/[], const real_number /*data_part2*/[], real_number /*rhs_part2*/[],
const real_number /*dist_pow2*/,
const real_number /*xshift_coef*/, const real_number /*yshift_coef*/, const real_number /*zshift_coef*/) const{
}
constexpr static bool isEmpty() {
return true;
}
};
#endif
...@@ -300,7 +300,7 @@ public: ...@@ -300,7 +300,7 @@ public:
part_to_sort.back().second = idxPart; part_to_sort.back().second = idxPart;
} }
assert(part_to_sort.size() == (current_my_nb_particles_per_partition[idxPartition])); assert(partsize_t(part_to_sort.size()) == (current_my_nb_particles_per_partition[idxPartition]));
std::sort(part_to_sort.begin(), part_to_sort.end(), std::sort(part_to_sort.begin(), part_to_sort.end(),
[](const std::pair<long int,partsize_t>& p1, [](const std::pair<long int,partsize_t>& p1,
...@@ -575,7 +575,7 @@ public: ...@@ -575,7 +575,7 @@ public:
const int nbNeighbors = my_tree.getNeighbors(current_cell_idx, neighbors, neighbors_indexes, shift, true); const int nbNeighbors = my_tree.getNeighbors(current_cell_idx, neighbors, neighbors_indexes, shift, true);
// with other interval // with other interval
for(size_t idx_neighbor = 0 ; idx_neighbor < nbNeighbors ; ++idx_neighbor){ for(int idx_neighbor = 0 ; idx_neighbor < nbNeighbors ; ++idx_neighbor){
cells_locker.lock(neighbors_indexes[idx_neighbor]); cells_locker.lock(neighbors_indexes[idx_neighbor]);
for(size_t idx_2 = 0 ; idx_2 < (*neighbors[idx_neighbor]).size() ; ++idx_2){ for(size_t idx_2 = 0 ; idx_2 < (*neighbors[idx_neighbor]).size() ; ++idx_2){
...@@ -726,7 +726,7 @@ public: ...@@ -726,7 +726,7 @@ public:
for(size_t idx_1 = 0 ; idx_1 < intervals.size() ; ++idx_1){ for(size_t idx_1 = 0 ; idx_1 < intervals.size() ; ++idx_1){
// with other interval // with other interval
for(size_t idx_neighbor = 0 ; idx_neighbor < nbNeighbors ; ++idx_neighbor){ for(int idx_neighbor = 0 ; idx_neighbor < nbNeighbors ; ++idx_neighbor){
if(currenct_cell_idx < neighbors_indexes[idx_neighbor]){ if(currenct_cell_idx < neighbors_indexes[idx_neighbor]){
cells_locker.lock(neighbors_indexes[idx_neighbor]); cells_locker.lock(neighbors_indexes[idx_neighbor]);
......
...@@ -35,6 +35,9 @@ protected: ...@@ -35,6 +35,9 @@ protected:
TAG_LOW_UP_MOVED_PARTICLES_INDEXES, TAG_LOW_UP_MOVED_PARTICLES_INDEXES,
TAG_UP_LOW_MOVED_PARTICLES_INDEXES, TAG_UP_LOW_MOVED_PARTICLES_INDEXES,
TAG_LOW_UP_MOVED_PARTICLES_DATA,
TAG_UP_LOW_MOVED_PARTICLES_DATA,
TAG_LOW_UP_MOVED_PARTICLES_RHS, TAG_LOW_UP_MOVED_PARTICLES_RHS,
TAG_LOW_UP_MOVED_PARTICLES_RHS_MAX = TAG_LOW_UP_MOVED_PARTICLES_RHS+MaxNbRhs, TAG_LOW_UP_MOVED_PARTICLES_RHS_MAX = TAG_LOW_UP_MOVED_PARTICLES_RHS+MaxNbRhs,
...@@ -503,13 +506,14 @@ public: ...@@ -503,13 +506,14 @@ public:
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
template <class computer_class, int size_particle_positions, int size_particle_rhs, int size_particle_index> template <class computer_class, int size_particle_positions, int size_particle_data, int size_particle_rhs, int size_particle_index>
void redistribute(computer_class& in_computer, void redistribute(computer_class& in_computer,
partsize_t current_my_nb_particles_per_partition[], partsize_t current_my_nb_particles_per_partition[],
partsize_t* nb_particles, partsize_t* nb_particles,
std::unique_ptr<real_number[]>* inout_positions_particles, std::unique_ptr<real_number[]>* inout_positions_particles,
std::unique_ptr<real_number[]> inout_rhs_particles[], const int in_nb_rhs, std::unique_ptr<real_number[]> inout_rhs_particles[], const int in_nb_rhs,
std::unique_ptr<partsize_t[]>* inout_index_particles){ std::unique_ptr<partsize_t[]>* inout_index_particles,
std::unique_ptr<real_number[]>* inout_data_particles){
TIMEZONE("redistribute"); TIMEZONE("redistribute");
// Some latest processes might not be involved // Some latest processes might not be involved
...@@ -537,7 +541,13 @@ public: ...@@ -537,7 +541,13 @@ public:
}, },
[&](const partsize_t idx1, const partsize_t idx2){ [&](const partsize_t idx1, const partsize_t idx2){
for(int idx_val = 0 ; idx_val < size_particle_index ; ++idx_val){ for(int idx_val = 0 ; idx_val < size_particle_index ; ++idx_val){
std::swap((*inout_index_particles)[idx1], (*inout_index_particles)[idx2]); std::swap((*inout_index_particles)[size_particle_index*idx1+idx_val],
(*inout_index_particles)[size_particle_index*idx2+idx_val]);
}
for(int idx_val = 0 ; idx_val < size_particle_data ; ++idx_val){
std::swap((*inout_data_particles)[size_particle_data*idx1+idx_val],
(*inout_data_particles)[size_particle_data*idx2+idx_val]);
} }
for(int idx_rhs = 0 ; idx_rhs < in_nb_rhs ; ++idx_rhs){ for(int idx_rhs = 0 ; idx_rhs < in_nb_rhs ; ++idx_rhs){
...@@ -562,7 +572,13 @@ public: ...@@ -562,7 +572,13 @@ public:
}, },
[&](const partsize_t idx1, const partsize_t idx2){ [&](const partsize_t idx1, const partsize_t idx2){
for(int idx_val = 0 ; idx_val < size_particle_index ; ++idx_val){ for(int idx_val = 0 ; idx_val < size_particle_index ; ++idx_val){
std::swap((*inout_index_particles)[idx1], (*inout_index_particles)[idx2]); std::swap((*inout_index_particles)[size_particle_index*idx1+idx_val],
(*inout_index_particles)[size_particle_index*idx2+idx_val]);
}
for(int idx_val = 0 ; idx_val < size_particle_data ; ++idx_val){
std::swap((*inout_data_particles)[size_particle_data*idx1+idx_val],
(*inout_data_particles)[size_particle_data*idx2+idx_val]);
} }
for(int idx_rhs = 0 ; idx_rhs < in_nb_rhs ; ++idx_rhs){ for(int idx_rhs = 0 ; idx_rhs < in_nb_rhs ; ++idx_rhs){
...@@ -581,6 +597,8 @@ public: ...@@ -581,6 +597,8 @@ public:
std::unique_ptr<real_number[]> newParticlesUp; std::unique_ptr<real_number[]> newParticlesUp;
std::unique_ptr<partsize_t[]> newParticlesLowIndexes; std::unique_ptr<partsize_t[]> newParticlesLowIndexes;
std::unique_ptr<partsize_t[]> newParticlesUpIndexes; std::unique_ptr<partsize_t[]> newParticlesUpIndexes;
std::unique_ptr<real_number[]> newParticlesLowData;
std::unique_ptr<real_number[]> newParticlesUpData;
std::vector<std::unique_ptr<real_number[]>> newParticlesLowRhs(in_nb_rhs); std::vector<std::unique_ptr<real_number[]>> newParticlesLowRhs(in_nb_rhs);
std::vector<std::unique_ptr<real_number[]>> newParticlesUpRhs(in_nb_rhs); std::vector<std::unique_ptr<real_number[]>> newParticlesUpRhs(in_nb_rhs);
...@@ -607,13 +625,24 @@ public: ...@@ -607,13 +625,24 @@ public:
assert(nbOutLower*size_particle_positions < std::numeric_limits<int>::max()); assert(nbOutLower*size_particle_positions < std::numeric_limits<int>::max());
AssertMpi(MPI_Isend(&(*inout_positions_particles)[0], int(nbOutLower*size_particle_positions), particles_utils::GetMpiType(real_number()), (my_rank-1+nb_processes_involved)%nb_processes_involved, TAG_LOW_UP_MOVED_PARTICLES, AssertMpi(MPI_Isend(&(*inout_positions_particles)[0], int(nbOutLower*size_particle_positions), particles_utils::GetMpiType(real_number()), (my_rank-1+nb_processes_involved)%nb_processes_involved, TAG_LOW_UP_MOVED_PARTICLES,
MPI_COMM_WORLD, &mpiRequests.back())); MPI_COMM_WORLD, &mpiRequests.back()));
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1}); whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
mpiRequests.emplace_back(); mpiRequests.emplace_back();
assert(nbOutLower < std::numeric_limits<int>::max()); assert(nbOutLower*size_particle_index < std::numeric_limits<int>::max());
AssertMpi(MPI_Isend(&(*inout_index_particles)[0], int(nbOutLower), particles_utils::GetMpiType(partsize_t()), AssertMpi(MPI_Isend(&(*inout_index_particles)[0], int(nbOutLower*size_particle_index), particles_utils::GetMpiType(partsize_t()),
(my_rank-1+nb_processes_involved)%nb_processes_involved, TAG_LOW_UP_MOVED_PARTICLES_INDEXES, (my_rank-1+nb_processes_involved)%nb_processes_involved, TAG_LOW_UP_MOVED_PARTICLES_INDEXES,
MPI_COMM_WORLD, &mpiRequests.back())); MPI_COMM_WORLD, &mpiRequests.back()));
if(size_particle_data){
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
mpiRequests.emplace_back();
assert(nbOutLower*size_particle_data < std::numeric_limits<int>::max());
AssertMpi(MPI_Isend(&(*inout_data_particles)[0], int(nbOutLower*size_particle_data),
particles_utils::GetMpiType(partsize_t()),
(my_rank-1+nb_processes_involved)%nb_processes_involved, TAG_LOW_UP_MOVED_PARTICLES_DATA,
MPI_COMM_WORLD, &mpiRequests.back()));
}
for(int idx_rhs = 0 ; idx_rhs < in_nb_rhs ; ++idx_rhs){ for(int idx_rhs = 0 ; idx_rhs < in_nb_rhs ; ++idx_rhs){
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1}); whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
mpiRequests.emplace_back(); mpiRequests.emplace_back();
...@@ -643,13 +672,23 @@ public: ...@@ -643,13 +672,23 @@ public:
AssertMpi(MPI_Isend(&(*inout_positions_particles)[(myTotalNbParticles-nbOutUpper)*size_particle_positions], AssertMpi(MPI_Isend(&(*inout_positions_particles)[(myTotalNbParticles-nbOutUpper)*size_particle_positions],
int(nbOutUpper*size_particle_positions), particles_utils::GetMpiType(real_number()), (my_rank+1)%nb_processes_involved, TAG_UP_LOW_MOVED_PARTICLES, int(nbOutUpper*size_particle_positions), particles_utils::GetMpiType(real_number()), (my_rank+1)%nb_processes_involved, TAG_UP_LOW_MOVED_PARTICLES,
MPI_COMM_WORLD, &mpiRequests.back())); MPI_COMM_WORLD, &mpiRequests.back()));
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1}); whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
mpiRequests.emplace_back(); mpiRequests.emplace_back();
assert(nbOutUpper < std::numeric_limits<int>::max()); assert(nbOutUpper*size_particle_index < std::numeric_limits<int>::max());
AssertMpi(MPI_Isend(&(*inout_index_particles)[(myTotalNbParticles-nbOutUpper)], int(nbOutUpper), AssertMpi(MPI_Isend(&(*inout_index_particles)[(myTotalNbParticles-nbOutUpper)*size_particle_index], int(nbOutUpper*size_particle_index),
particles_utils::GetMpiType(partsize_t()), (my_rank+1)%nb_processes_involved, TAG_UP_LOW_MOVED_PARTICLES_INDEXES, particles_utils::GetMpiType(partsize_t()), (my_rank+1)%nb_processes_involved, TAG_UP_LOW_MOVED_PARTICLES_INDEXES,
MPI_COMM_WORLD, &mpiRequests.back())); MPI_COMM_WORLD, &mpiRequests.back()));
if(size_particle_data){
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
mpiRequests.emplace_back();
assert(nbOutUpper*size_particle_data < std::numeric_limits<int>::max());
AssertMpi(MPI_Isend(&(*inout_data_particles)[(myTotalNbParticles-nbOutUpper)*size_particle_data],
int(nbOutUpper*size_particle_data),
particles_utils::GetMpiType(partsize_t()), (my_rank+1)%nb_processes_involved, TAG_UP_LOW_MOVED_PARTICLES_DATA,
MPI_COMM_WORLD, &mpiRequests.back()));
}
for(int idx_rhs = 0 ; idx_rhs < in_nb_rhs ; ++idx_rhs){ for(int idx_rhs = 0 ; idx_rhs < in_nb_rhs ; ++idx_rhs){
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1}); whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
...@@ -684,14 +723,26 @@ public: ...@@ -684,14 +723,26 @@ public:
(my_rank-1+nb_processes_involved)%nb_processes_involved, TAG_UP_LOW_MOVED_PARTICLES, (my_rank-1+nb_processes_involved)%nb_processes_involved, TAG_UP_LOW_MOVED_PARTICLES,
MPI_COMM_WORLD, &mpiRequests.back())); MPI_COMM_WORLD, &mpiRequests.back()));
newParticlesLowIndexes.reset(new partsize_t[nbNewFromLow]); newParticlesLowIndexes.reset(new partsize_t[nbNewFromLow*size_particle_index]);
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1}); whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
mpiRequests.emplace_back(); mpiRequests.emplace_back();
assert(nbNewFromLow < std::numeric_limits<int>::max()); assert(nbNewFromLow*size_particle_index < std::numeric_limits<int>::max());
AssertMpi(MPI_Irecv(&newParticlesLowIndexes[0], int(nbNewFromLow), particles_utils::GetMpiType(partsize_t()), AssertMpi(MPI_Irecv(&newParticlesLowIndexes[0], int(nbNewFromLow*size_particle_index),
particles_utils::GetMpiType(partsize_t()),
(my_rank-1+nb_processes_involved)%nb_processes_involved, TAG_UP_LOW_MOVED_PARTICLES_INDEXES, (my_rank-1+nb_processes_involved)%nb_processes_involved, TAG_UP_LOW_MOVED_PARTICLES_INDEXES,
MPI_COMM_WORLD, &mpiRequests.back())); MPI_COMM_WORLD, &mpiRequests.back()));
if(size_particle_data){
newParticlesLowData.reset(new real_number[nbNewFromLow*size_particle_data]);
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
mpiRequests.emplace_back();
assert(nbNewFromLow*size_particle_data < std::numeric_limits<int>::max());
AssertMpi(MPI_Irecv(&newParticlesLowData[0], int(nbNewFromLow*size_particle_data),
particles_utils::GetMpiType(real_number()),
(my_rank-1+nb_processes_involved)%nb_processes_involved, TAG_UP_LOW_MOVED_PARTICLES_DATA,
MPI_COMM_WORLD, &mpiRequests.back()));
}
for(int idx_rhs = 0 ; idx_rhs < in_nb_rhs ; ++idx_rhs){ for(int idx_rhs = 0 ; idx_rhs < in_nb_rhs ; ++idx_rhs){
newParticlesLowRhs[idx_rhs].reset(new real_number[nbNewFromLow*size_particle_rhs]); newParticlesLowRhs[idx_rhs].reset(new real_number[nbNewFromLow*size_particle_rhs]);
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1}); whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
...@@ -713,14 +764,26 @@ public: ...@@ -713,14 +764,26 @@ public:
AssertMpi(MPI_Irecv(&newParticlesUp[0], int(nbNewFromUp*size_particle_positions), particles_utils::GetMpiType(real_number()), (my_rank+1)%nb_processes_involved, TAG_LOW_UP_MOVED_PARTICLES, AssertMpi(MPI_Irecv(&newParticlesUp[0], int(nbNewFromUp*size_particle_positions), particles_utils::GetMpiType(real_number()), (my_rank+1)%nb_processes_involved, TAG_LOW_UP_MOVED_PARTICLES,
MPI_COMM_WORLD, &mpiRequests.back())); MPI_COMM_WORLD, &mpiRequests.back()));
newParticlesUpIndexes.reset(new partsize_t[nbNewFromUp]); newParticlesUpIndexes.reset(new partsize_t[nbNewFromUp*size_particle_index]);
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1}); whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
mpiRequests.emplace_back(); mpiRequests.emplace_back();
assert(nbNewFromUp < std::numeric_limits<int>::max()); assert(nbNewFromUp*size_particle_index < std::numeric_limits<int>::max());
AssertMpi(MPI_Irecv(&newParticlesUpIndexes[0], int(nbNewFromUp), particles_utils::GetMpiType(partsize_t()), AssertMpi(MPI_Irecv(&newParticlesUpIndexes[0], int(nbNewFromUp*size_particle_index),
particles_utils::GetMpiType(partsize_t()),
(my_rank+1)%nb_processes_involved, TAG_LOW_UP_MOVED_PARTICLES_INDEXES, (my_rank+1)%nb_processes_involved, TAG_LOW_UP_MOVED_PARTICLES_INDEXES,
MPI_COMM_WORLD, &mpiRequests.back())); MPI_COMM_WORLD, &mpiRequests.back()));
if(size_particle_data){
newParticlesUpData.reset(new real_number[nbNewFromUp*size_particle_data]);
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
mpiRequests.emplace_back();
assert(nbNewFromUp*size_particle_data < std::numeric_limits<int>::max());
AssertMpi(MPI_Irecv(&newParticlesUpData[0], int(nbNewFromUp*size_particle_data),
particles_utils::GetMpiType(real_number()),
(my_rank+1)%nb_processes_involved, TAG_LOW_UP_MOVED_PARTICLES_DATA,
MPI_COMM_WORLD, &mpiRequests.back()));
}
for(int idx_rhs = 0 ; idx_rhs < in_nb_rhs ; ++idx_rhs){ for(int idx_rhs = 0 ; idx_rhs < in_nb_rhs ; ++idx_rhs){
newParticlesUpRhs[idx_rhs].reset(new real_number[nbNewFromUp*size_particle_rhs]); newParticlesUpRhs[idx_rhs].reset(new real_number[nbNewFromUp*size_particle_rhs]);
whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1}); whatNext.emplace_back(std::pair<Action,int>{NOTHING_TODO, -1});
...@@ -750,7 +813,8 @@ public: ...@@ -750,7 +813,8 @@ public:
const partsize_t myTotalNewNbParticles = nbOldParticlesInside + nbNewFromLow + nbNewFromUp; const partsize_t myTotalNewNbParticles = nbOldParticlesInside + nbNewFromLow + nbNewFromUp;