Commit 2c918198 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

add method to extract subset of abstract particles system

parent 5a4e9838
Pipeline #95333 failed with stages
in 19 minutes and 39 seconds
......@@ -349,6 +349,53 @@ class particle_set: public abstract_particle_set
return EXIT_SUCCESS;
}
int init_as_subset_of(
abstract_particles_system<partsize_t, particle_rnumber> &src,
const std::vector<partsize_t> &indices_to_copy)
{
TIMEZONE("particle_set::init_as_subset_of");
assert(indices_to_copy.size() > 0);
particle_rnumber *tmp_local_state = new particle_rnumber[state_size * src.getLocalNbParticles()];
partsize_t *tmp_local_index = new partsize_t[src.getLocalNbParticles()];
this->local_number_of_particles = 0;
this->total_number_of_particles = indices_to_copy.size();
// dumb selection of interesting particles
for (partsize_t ii = 0; ii < partsize_t(src.getLocalNbParticles()); ii++)
{
partsize_t src_index = src.getParticlesIndexes()[ii];
for (partsize_t iii=0; iii < partsize_t(indices_to_copy.size()); iii++)
{
if (src_index == indices_to_copy[iii])
{
tmp_local_index[this->local_number_of_particles] = src_index;
std::copy(src.getParticlesState()+state_size*ii,
src.getParticlesState()+state_size*(ii+1),
tmp_local_state + state_size*this->local_number_of_particles);
this->local_number_of_particles++;
break;
}
}
}
// now we actually put the data "here"
if (this->local_number_of_particles > 0)
{
this->local_state.reset(new particle_rnumber[state_size*this->local_number_of_particles]);
this->local_index.reset(new partsize_t[this->local_number_of_particles]);
std::copy(tmp_local_state,
tmp_local_state + state_size*this->local_number_of_particles,
this->local_state.get());
std::copy(tmp_local_index,
tmp_local_index + this->local_number_of_particles,
this->local_index.get());
}
delete[] tmp_local_state;
delete[] tmp_local_index;
return EXIT_SUCCESS;
}
particle_rnumber getSpatialLowLimitZ()
{
return this->pInterpolator.getSpatialLowLimitZ();
......
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