From d1e55fbab7c5d5cb72d3c448a91430a568628b9e Mon Sep 17 00:00:00 2001 From: Andrew Myers Date: Mon, 18 Dec 2023 12:01:08 -0800 Subject: [PATCH] Add PTD version of getParticleCell (#3675) The proposed changes: - [ ] fix a bug or incorrect behavior in AMReX - [x] 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_ParticleUtil.H | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Src/Particle/AMReX_ParticleUtil.H b/Src/Particle/AMReX_ParticleUtil.H index 182802e51f2..682a82450f0 100644 --- a/Src/Particle/AMReX_ParticleUtil.H +++ b/Src/Particle/AMReX_ParticleUtil.H @@ -371,6 +371,26 @@ IntVect getParticleCell (P const& p, return iv; } +template +AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE +IntVect getParticleCell (PTD const& ptd, int i, + amrex::GpuArray const& plo, + amrex::GpuArray const& dxi, + const Box& domain) noexcept +{ + if constexpr (PTD::ParticleType::is_soa_particle) + { + IntVect iv( + AMREX_D_DECL(int(amrex::Math::floor((ptd.m_rdata[0][i]-plo[0])*dxi[0])), + int(amrex::Math::floor((ptd.m_rdata[1][i]-plo[1])*dxi[1])), + int(amrex::Math::floor((ptd.m_rdata[2][i]-plo[2])*dxi[2])))); + iv += domain.smallEnd(); + return iv; + } else { + return getParticleCell(ptd.m_aos[i], plo, dxi, domain);; + } +} + struct DefaultAssignor {