diff options
author | 2021-01-19 18:25:14 -0800 | |
---|---|---|
committer | 2021-01-19 18:25:14 -0800 | |
commit | 16651c50bf37e45c6ad36b059a4da617d25c94c7 (patch) | |
tree | 7187cd7808f23b51b1255f7c8b3b8a57d495671b /Source/Particles/Pusher/GetAndSetPosition.H | |
parent | df0ec7a204c1de02daef2b3baa32c8ef220bea3e (diff) | |
download | WarpX-16651c50bf37e45c6ad36b059a4da617d25c94c7.tar.gz WarpX-16651c50bf37e45c6ad36b059a4da617d25c94c7.tar.zst WarpX-16651c50bf37e45c6ad36b059a4da617d25c94c7.zip |
Add Superparticle version of getParticlePosition. (#1640)
* Add Superparticle version of GetParticlePosition.
* move unpack_particle to a free function and rename
* no longer need SuperPType
* Update Source/Particles/Pusher/GetAndSetPosition.H
* remove templating from get_particle_position
* remove template
* Add missing include
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/Particles/Pusher/GetAndSetPosition.H')
-rw-r--r-- | Source/Particles/Pusher/GetAndSetPosition.H | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/Source/Particles/Pusher/GetAndSetPosition.H b/Source/Particles/Pusher/GetAndSetPosition.H index dba4c0a34..b1d897833 100644 --- a/Source/Particles/Pusher/GetAndSetPosition.H +++ b/Source/Particles/Pusher/GetAndSetPosition.H @@ -13,8 +13,34 @@ #include <AMReX.H> #include <AMReX_REAL.H> +#include <cmath> #include <limits> +/** \brief Extract the cartesian position coordinates of the particle + * p and store them in the variables `x`, `y`, `z` + * This version operates on a SuperParticle */ +AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE +void get_particle_position (const WarpXParticleContainer::SuperParticleType& p, + amrex::ParticleReal& x, + amrex::ParticleReal& y, + amrex::ParticleReal& z) noexcept +{ +#ifdef WARPX_DIM_RZ + amrex::ParticleReal theta = p.rdata(PIdx::theta); + amrex::ParticleReal r = p.pos(0); + x = r*std::cos(theta); + y = r*std::sin(theta); + z = p.pos(1); +#elif WARPX_DIM_3D + x = p.pos(0); + y = p.pos(1); + z = p.pos(2); +#else + x = p.pos(0); + y = std::numeric_limits<amrex::ParticleReal>::quiet_NaN(); + z = p.pos(1); +#endif +} /** \brief Functor that can be used to extract the positions of the macroparticles * inside a ParallelFor kernel @@ -52,19 +78,20 @@ struct GetParticlePosition AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator() (const int i, RType& x, RType& y, RType& z) const noexcept { + const PType& p = m_structs[i]; #ifdef WARPX_DIM_RZ - RType r = m_structs[i].pos(0); + RType r = p.pos(0); x = r*std::cos(m_theta[i]); y = r*std::sin(m_theta[i]); - z = m_structs[i].pos(1); + z = p.pos(1); #elif WARPX_DIM_3D - x = m_structs[i].pos(0); - y = m_structs[i].pos(1); - z = m_structs[i].pos(2); + x = p.pos(0); + y = p.pos(1); + z = p.pos(2); #else - x = m_structs[i].pos(0); + x = p.pos(0); y = m_snan; - z = m_structs[i].pos(1); + z = p.pos(1); #endif } }; |