Skip to content

Commit

Permalink
Adapted the PushSingleParticle function to SoAParticle
Browse files Browse the repository at this point in the history
  • Loading branch information
Thierry992 committed Oct 12, 2022
1 parent 1233fab commit ce90eae
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/particles/Push.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ namespace detail
struct PushSingleParticle
{
using PType = ImpactXParticleContainer::ParticleType;
using ParticleTileType = amrex::ParticleTile<amrex::SoAParticle<RealSoA::nattribs, IntSoA::nattribs>,RealSoA::nattribs, IntSoA::nattribs>;
using ParticleTileDataType = amrex::ParticleTileData<ParticleTileType::StorageParticleType,RealSoA::nattribs, IntSoA::nattribs>;

/** Constructor taking in pointers to particle data
*
Expand All @@ -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)
{
Expand All @@ -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];
Expand All @@ -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;
Expand Down Expand Up @@ -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<amrex::SoAParticle<RealSoA::nattribs, IntSoA::nattribs>,RealSoA::nattribs, IntSoA::nattribs>;
using ParticleTileDataType = amrex::ParticleTileData<ParticleTile::StorageParticleType,RealSoA::nattribs, IntSoA::nattribs>;

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();
Expand All @@ -143,7 +149,7 @@ namespace detail
[=, &ref_part](auto element) {
// push beam particles relative to reference particle
detail::PushSingleParticle<decltype(element)> 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);

Expand Down

0 comments on commit ce90eae

Please sign in to comment.