Skip to content

Commit

Permalink
Add PTD version of getParticleCell (AMReX-Codes#3675)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
atmyers authored Dec 18, 2023
1 parent 78c4fda commit d1e55fb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Src/Particle/AMReX_ParticleUtil.H
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,26 @@ IntVect getParticleCell (P const& p,
return iv;
}

template <typename PTD>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
IntVect getParticleCell (PTD const& ptd, int i,
amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> const& plo,
amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> 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
{

Expand Down

0 comments on commit d1e55fb

Please sign in to comment.