diff --git a/Src/Particle/AMReX_ParticleContainerI.H b/Src/Particle/AMReX_ParticleContainerI.H index bed21486144..053fe18c7ac 100644 --- a/Src/Particle/AMReX_ParticleContainerI.H +++ b/Src/Particle/AMReX_ParticleContainerI.H @@ -1203,16 +1203,14 @@ ParticleContainer_impl for(MFIter mfi = MakeMFIter(lev); mfi.isValid(); ++mfi) { - auto& ptile = ParticlesAt(lev, mfi); - auto& aos = ptile.GetArrayOfStructs(); - auto pstruct_ptr = aos().dataPtr(); - const size_t np = aos.numParticles(); + const auto& ptile = ParticlesAt(lev, mfi); + const size_t np = ptile.numParticles(); const Box& box = mfi.validbox(); using index_type = typename decltype(m_bins)::index_type; Gpu::DeviceVector perm; - PermutationForDeposition(perm, np, pstruct_ptr, box, geom, idx_type); + PermutationForDeposition(perm, np, ptile, box, geom, idx_type); ReorderParticles(lev, mfi, perm.dataPtr()); } } diff --git a/Src/Particle/AMReX_ParticleTile.H b/Src/Particle/AMReX_ParticleTile.H index 6d1c3b03822..ba68812e5bf 100644 --- a/Src/Particle/AMReX_ParticleTile.H +++ b/Src/Particle/AMReX_ParticleTile.H @@ -316,7 +316,7 @@ struct ConstSoAParticle : SoAParticleBase //functions to get positions of the particle in the SOA data AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE - RealVect pos () const & {return RealVect(AMREX_D_DECL(this->m_constparticle_tile_data->m_rdata[0][m_index], this->m_constparticle_tile_data.m_rdata[1][m_index], this->m_constparticle_tile_data->m_rdata[2][m_index]));} + RealVect pos () const & {return RealVect(AMREX_D_DECL(this->m_constparticle_tile_data.m_rdata[0][m_index], this->m_constparticle_tile_data.m_rdata[1][m_index], this->m_constparticle_tile_data.m_rdata[2][m_index]));} AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const RealType& pos (int position_index) const & diff --git a/Src/Particle/AMReX_ParticleUtil.H b/Src/Particle/AMReX_ParticleUtil.H index edebca60c4f..04c98d6f389 100644 --- a/Src/Particle/AMReX_ParticleUtil.H +++ b/Src/Particle/AMReX_ParticleUtil.H @@ -881,9 +881,9 @@ void PermutationForDeposition (Gpu::DeviceVector& perm, index_type n Gpu::Device::streamSynchronize(); } -template +template void PermutationForDeposition (Gpu::DeviceVector& perm, index_type nitems, - pos_struct const* v, Box bx, Geometry geom, const IntVect idx_type) + const PTile& ptile, Box bx, Geometry geom, const IntVect idx_type) { AMREX_ALWAYS_ASSERT(idx_type.allGE(IntVect(0)) && idx_type.allLE(IntVect(2))); @@ -904,17 +904,21 @@ void PermutationForDeposition (Gpu::DeviceVector& perm, index_type n const int ref_product = AMREX_D_TERM(refine_vect[0], * refine_vect[1], * refine_vect[2]); const IntVect ref_offset(AMREX_D_DECL(1, refine_vect[0], refine_vect[0] * refine_vect[1])); + auto ptd = ptile.getConstParticleTileData(); + using ParticleType = typename PTile::ParticleType::ConstType; PermutationForDeposition(perm, nitems, bx.numPts() * ref_product, [=] AMREX_GPU_DEVICE (index_type idx) noexcept - { - IntVect iv = ((v[idx].pos() - pos_offset) * dxi).round(); + { + const auto& p = make_particle{}(ptd,idx); + + IntVect iv = ((p.pos() - pos_offset) * dxi).round(); - IntVect iv_coarse = iv / refine_vect; - IntVect iv_remainder = iv - iv_coarse * refine_vect; + IntVect iv_coarse = iv / refine_vect; + IntVect iv_remainder = iv - iv_coarse * refine_vect; - iv_coarse = iv_coarse.max(bx.smallEnd()); - iv_coarse = iv_coarse.min(bx.bigEnd()); - return bx.index(iv_coarse) + bx.numPts() * (iv_remainder * ref_offset).sum(); + iv_coarse = iv_coarse.max(bx.smallEnd()); + iv_coarse = iv_coarse.min(bx.bigEnd()); + return bx.index(iv_coarse) + bx.numPts() * (iv_remainder * ref_offset).sum(); }); }