From b2052f2d2e5ce44317450ba13de705a3e01ef0ea Mon Sep 17 00:00:00 2001 From: Andrew Myers Date: Mon, 18 Sep 2023 17:54:35 -0700 Subject: [PATCH] Another terrain fix for MPI (#3557) The proposed changes: - [x] fix a bug or incorrect behavior in AMReX - [ ] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate --- Src/Particle/AMReX_ParticleContainerI.H | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Src/Particle/AMReX_ParticleContainerI.H b/Src/Particle/AMReX_ParticleContainerI.H index 5c961e34942..0b8000f6880 100644 --- a/Src/Particle/AMReX_ParticleContainerI.H +++ b/Src/Particle/AMReX_ParticleContainerI.H @@ -2043,16 +2043,17 @@ RedistributeMPI (std::map >& not_ours, { char* pbuf = ((char*) &recvdata[offset]) + i*superparticle_size; - Particle<0, 0> p; - ParticleReal pos[AMREX_SPACEDIM]; - std::memcpy(&pos[0], pbuf, AMREX_SPACEDIM*sizeof(ParticleReal)); - AMREX_D_TERM(p.pos(0) = pos[0];, - p.pos(1) = pos[1];, - p.pos(2) = pos[2]); + Particle p; if constexpr (!ParticleType::is_soa_particle) { - std::memcpy(&(p.m_idcpu), pbuf + NumRealComps()*sizeof(ParticleReal), sizeof(uint64_t)); + std::memcpy(&p, pbuf, sizeof(ParticleType)); } else { + ParticleReal pos[AMREX_SPACEDIM]; + std::memcpy(&pos[0], pbuf, AMREX_SPACEDIM*sizeof(ParticleReal)); + AMREX_D_TERM(p.pos(0) = pos[0];, + p.pos(1) = pos[1];, + p.pos(2) = pos[2]); + int idcpu[2]; std::memcpy(&idcpu[0], pbuf + NumRealComps()*sizeof(ParticleReal), 2*sizeof(int));