From ce90eae2704cc648b2f0ab4cb3d65790a1eee50b Mon Sep 17 00:00:00 2001 From: Thierry Antoun Date: Wed, 28 Sep 2022 15:13:27 -0700 Subject: [PATCH] Adapted the PushSingleParticle function to SoAParticle --- src/particles/Push.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/particles/Push.cpp b/src/particles/Push.cpp index 10c17d571..e8d05b1a7 100644 --- a/src/particles/Push.cpp +++ b/src/particles/Push.cpp @@ -35,6 +35,8 @@ namespace detail struct PushSingleParticle { using PType = ImpactXParticleContainer::ParticleType; + using ParticleTileType = amrex::ParticleTile,RealSoA::nattribs, IntSoA::nattribs>; + using ParticleTileDataType = amrex::ParticleTileData; /** Constructor taking in pointers to particle data * @@ -46,12 +48,12 @@ namespace detail * @param ref_part the struct containing the reference particle */ PushSingleParticle (T_Element element, - PType* AMREX_RESTRICT aos_ptr, + ParticleTileDataType ptd, amrex::ParticleReal* AMREX_RESTRICT part_px, amrex::ParticleReal* AMREX_RESTRICT part_py, amrex::ParticleReal* AMREX_RESTRICT part_pt, RefPart ref_part) - : m_element(element), m_aos_ptr(aos_ptr), + : m_element(element), m_ptd(ptd), m_part_px(part_px), m_part_py(part_py), m_part_pt(part_pt), m_ref_part(ref_part) { @@ -70,8 +72,8 @@ namespace detail void operator() (long i) const { - // access AoS data such as positions and cpu/id - PType& AMREX_RESTRICT p = m_aos_ptr[i]; + + PType p(m_ptd,i); // access SoA Real data amrex::ParticleReal & AMREX_RESTRICT px = m_part_px[i]; @@ -85,7 +87,7 @@ namespace detail private: T_Element const m_element; - PType* const AMREX_RESTRICT m_aos_ptr; + ParticleTileDataType const m_ptd; amrex::ParticleReal* const AMREX_RESTRICT m_part_px; amrex::ParticleReal* const AMREX_RESTRICT m_part_py; amrex::ParticleReal* const AMREX_RESTRICT m_part_pt; @@ -129,8 +131,12 @@ namespace detail // preparing access to particle data: AoS using PType = ImpactXParticleContainer::ParticleType; - auto& aos = pti.GetArrayOfStructs(); - PType* AMREX_RESTRICT aos_ptr = aos().dataPtr(); + using ParticleTile = amrex::ParticleTile,RealSoA::nattribs, IntSoA::nattribs>; + using ParticleTileDataType = amrex::ParticleTileData; + + ParticleTileDataType tile_data = pti.GetParticleTile().getParticleTileData(); + //auto& aos = pti.GetArrayOfStructs(); + //PType* AMREX_RESTRICT aos_ptr = aos().dataPtr(); // preparing access to particle data: SoA of Reals auto& soa_real = pti.GetStructOfArrays().GetRealData(); @@ -143,7 +149,7 @@ namespace detail [=, &ref_part](auto element) { // push beam particles relative to reference particle detail::PushSingleParticle const pushSingleParticle( - element, aos_ptr, part_px, part_py, part_pt, ref_part); + element, tile_data, part_px, part_py, part_pt, ref_part); // loop over beam particles in the box amrex::ParallelFor(np, pushSingleParticle);