23 num_my_particles -= num_destroyed_particles;
33 unsigned num_active_procs =
grid_->give_number_of_active_processes();
34 if (num_active_procs > 1)
38 size_t num_total_particles;
46 size_t num_my_particles = R.
size();
48 for (
size_t ip = 0; ip < num_my_particles; ++ ip) {
49 D3vector pos(R[ip](0), R[ip](1), R[ip](2));
51 msg <<
"Particle " << ip <<
" moved outside domain." <<
endl;
64 unsigned num_active_procs =
grid_->give_number_of_active_processes();
67 if (my_id >= num_active_procs)
68 return num_my_particles;
70 std::vector<D3vector> bb_min;
71 std::vector<D3vector> bb_max;
72 for (
int p = 0; p < num_active_procs; ++ p) {
73 double xmin[3], xmax[3];
74 grid_->localbox(xmin, xmax, p);
75 bb_min.push_back(D3vector(xmin[0], xmin[1], xmin[2]));
76 bb_max.push_back(D3vector(xmax[0], xmax[1], xmax[2]));
82 std::vector<Message> messages(num_active_procs);
84 std::vector<size_t>* put_list =
new std::vector<size_t>[num_active_procs];
86 for (
size_t ip = 0; ip < num_my_particles; ++ ip) {
87 D3vector pos(particles.
R[ip][0], particles.
R[ip][1], particles.
R[ip][2]);
94 unsigned target_id = num_active_procs;
95 for (
unsigned p = 0; p < num_active_procs; ++ p) {
101 assert(target_id != num_active_procs && target_id != my_id);
102 put_list[target_id].push_back(ip);
111 for (
int p = 0; p < num_active_procs; ++ p) {
114 particles.
putMessage(messages[p], put_list[p]);
115 particles.
putMessage(messages[p], (
size_t) 0, (
size_t) 0);
131 unsigned sendnum = num_active_procs - 1;
132 while (sendnum-- > 0) {
136 size_t total_recvd = 0;
137 while ((recvd = particles.
getMessage(*recmsg)) > 0)
138 total_recvd += recvd;
139 num_my_particles += total_recvd;
147 return num_my_particles;
void destroy(size_t, size_t, bool=false)
void performDestroy(bool updateLocalNum=false)
static bool is_inside_box(const D3vector &corner_min, const D3vector &corner_max, const D3vector &x)
size_t getDestroyNum() const
int next_tag(int t, int s=1000)
size_t getMessage(Message &)
bool reduce(Communicate &, InputIterator, InputIterator, OutputIterator, const ReduceOp &, bool *IncludeVal=0)
void setLocalNum(size_t n)
void apply_bconds(ParticlePos_t &R)
bool is_local_pos(const Vector_t &x) const
size_t redistribute_particles(IpplParticleBase< ParticleLayoutFromGrid > &particles)
void update(IpplParticleBase< ParticleLayoutFromGrid > &particles)
size_t getLocalNum() const
size_t putMessage(Message &, size_t, size_t)
Message * receive_block(int &node, int &tag)
static Communicate * Comm
#define P_SPATIAL_TRANSFER_TAG
bool send(Message *, int node, int tag, bool delmsg=true)
void setTotalNum(size_t n)
Inform & endl(Inform &inf)