Skip to content

Commit

Permalink
Modyfing RedistributeMPI to make it work with 2 ranks
Browse files Browse the repository at this point in the history
  • Loading branch information
Thierry992 committed Oct 17, 2022
1 parent 203346b commit 7051a6c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Src/Particle/AMReX_ParticleContainerI.H
Original file line number Diff line number Diff line change
Expand Up @@ -2026,14 +2026,32 @@ RedistributeMPI (std::map<int, Vector<char> >& not_ours,

auto p = make_particle<ParticleType>{}(ptile.getParticleTileData(),ipart);

std::memcpy(&p, pbuf, sizeof(ParticleType));
if constexpr(ParticleType::is_soa_particle) {
auto * const pbuf_real = reinterpret_cast<amrex::ParticleReal*>(pbuf);
AMREX_D_TERM(
p.pos(0) = pbuf_real[0];,
p.pos(1) = pbuf_real[1];,
p.pos(2) = pbuf_real[2];
)
}
else {
std::memcpy(&p, pbuf, sizeof(ParticleType));
}

pbuf += sizeof(ParticleType);
ptile.push_back(p);
int array_comp_start = AMREX_SPACEDIM + NStructReal;
for (int comp = 0; comp < NumRealComps(); ++comp) {
if (h_redistribute_real_comp[array_comp_start + comp]) {
ParticleReal rdata;
std::memcpy(&rdata, pbuf, sizeof(ParticleReal));
if constexpr(ParticleType::is_soa_particle) {
auto * const pbuf_int = reinterpret_cast<int*>(pbuf + sizeof(amrex::ParticleReal)*AMREX_SPACEDIM);
p.id() = pbuf_int[0];
p.cpu() = pbuf_int[1];
}
else {
std::memcpy(&p, pbuf, sizeof(ParticleType));
}
pbuf += sizeof(ParticleReal);
ptile.push_back_real(comp, rdata);
} else {
Expand Down

0 comments on commit 7051a6c

Please sign in to comment.