Skip to content

Commit d1e55fb

Browse files
authored
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
1 parent 78c4fda commit d1e55fb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Src/Particle/AMReX_ParticleUtil.H

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,26 @@ IntVect getParticleCell (P const& p,
371371
return iv;
372372
}
373373

374+
template <typename PTD>
375+
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
376+
IntVect getParticleCell (PTD const& ptd, int i,
377+
amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> const& plo,
378+
amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> const& dxi,
379+
const Box& domain) noexcept
380+
{
381+
if constexpr (PTD::ParticleType::is_soa_particle)
382+
{
383+
IntVect iv(
384+
AMREX_D_DECL(int(amrex::Math::floor((ptd.m_rdata[0][i]-plo[0])*dxi[0])),
385+
int(amrex::Math::floor((ptd.m_rdata[1][i]-plo[1])*dxi[1])),
386+
int(amrex::Math::floor((ptd.m_rdata[2][i]-plo[2])*dxi[2]))));
387+
iv += domain.smallEnd();
388+
return iv;
389+
} else {
390+
return getParticleCell(ptd.m_aos[i], plo, dxi, domain);;
391+
}
392+
}
393+
374394
struct DefaultAssignor
375395
{
376396

0 commit comments

Comments
 (0)