Skip to content
Snippets Groups Projects
Commit fda03b15 authored by Berenger Bramas's avatar Berenger Bramas
Browse files

Add a method to extract some states of the particles --...

Add a method to extract some states of the particles -- extractParticlesState(0,3) should return the positions
parent 5eaf4028
No related branches found
No related tags found
1 merge request!23WIP: Feature/use cmake
Pipeline #
......@@ -35,6 +35,8 @@ public:
virtual const real_number* getParticlesState() const = 0;
virtual std::unique_ptr<real_number[]> extractParticlesState(const int firstState, const int lastState) const = 0;
virtual const std::unique_ptr<real_number[]>* getParticlesRhs() const = 0;
virtual const partsize_t* getParticlesIndexes() const = 0;
......
......@@ -17,6 +17,8 @@
template <class partsize_t, class real_number, class field_rnumber, class field_class, class interpolator_class, int interp_neighbours,
int size_particle_positions, int size_particle_rhs, class p2p_computer_class, class particles_inner_computer_class>
class particles_system : public abstract_particles_system<partsize_t, real_number> {
static_assert(size_particle_positions >= 3, "There should be at least the positions X,Y,Z in the state");
MPI_Comm mpi_com;
const std::pair<int,int> current_partition_interval;
......@@ -272,6 +274,20 @@ public:
return my_particles_positions.get();
}
std::unique_ptr<real_number[]> extractParticlesState(const int firstState, const int lastState) const final {
const int nbStates = std::max(0,(std::min(lastState,size_particle_positions)-firstState));
std::unique_ptr<real_number[]> stateExtract(new real_number[my_nb_particles*nbStates]);
for(partsize_t idx_part = 0 ; idx_part < my_nb_particles ; ++idx_part){
for(int idxState = 0 ; idxState < nbStates ; ++idxState){
stateExtract[idx_part*nbStates + idxState] = my_particles_positions[idx_part*size_particle_positions + idxState+firstState];
}
}
return stateExtract;
}
const std::unique_ptr<real_number[]>* getParticlesRhs() const final {
return my_particles_rhs.data();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment