8 #ifndef WARPX_PARTICLES_PUSHER_GETANDSETPOSITION_H_
9 #define WARPX_PARTICLES_PUSHER_GETANDSETPOSITION_H_
26 template<
typename T_PIdx = PIdx>
29 amrex::ParticleReal& x,
30 amrex::ParticleReal& y,
31 amrex::ParticleReal& z) noexcept
33 using namespace amrex::literals;
35 #if defined(WARPX_DIM_RZ)
36 amrex::ParticleReal
const theta = p.rdata(T_PIdx::theta);
37 amrex::ParticleReal
const r = p.pos(T_PIdx::x);
38 x =
r*std::cos(theta);
39 y =
r*std::sin(theta);
41 #elif defined(WARPX_DIM_3D)
45 #elif defined(WARPX_DIM_XZ)
61 template<
typename T_PIdx = PIdx>
64 using RType = amrex::ParticleReal;
66 #if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
69 #elif defined(WARPX_DIM_3D)
73 #elif defined(WARPX_DIM_1D_Z)
77 #if defined(WARPX_DIM_RZ)
79 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
80 static constexpr
RType m_y_default =
RType(0.0);
81 #elif defined(WARPX_DIM_1D_Z)
82 static constexpr
RType m_x_default =
RType(0.0);
83 static constexpr
RType m_y_default =
RType(0.0);
95 template <
typename ptiType>
98 const auto& soa = a_pti.GetStructOfArrays();
100 #if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
101 m_x = soa.GetRealData(
PIdx::x).dataPtr() + a_offset;
102 m_z = soa.GetRealData(
PIdx::z).dataPtr() + a_offset;
103 #elif defined(WARPX_DIM_3D)
104 m_x = soa.GetRealData(
PIdx::x).dataPtr() + a_offset;
105 m_y = soa.GetRealData(PIdx::y).dataPtr() + a_offset;
106 m_z = soa.GetRealData(
PIdx::z).dataPtr() + a_offset;
107 #elif defined(WARPX_DIM_1D_Z)
108 m_z = soa.GetRealData(
PIdx::z).dataPtr() + a_offset;
110 #if defined(WARPX_DIM_RZ)
111 m_theta = soa.GetRealData(T_PIdx::theta).dataPtr() + a_offset;
176 template<
typename T_PIdx = PIdx>
181 #if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
184 #elif defined(WARPX_DIM_3D)
188 #elif defined(WARPX_DIM_1D_Z)
191 #if defined(WARPX_DIM_RZ)
195 template <
typename ptiType>
198 auto& soa = a_pti.GetStructOfArrays();
199 #if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
200 m_x = soa.GetRealData(
PIdx::x).dataPtr() + a_offset;
201 m_z = soa.GetRealData(
PIdx::z).dataPtr() + a_offset;
202 #elif defined(WARPX_DIM_3D)
203 m_x = soa.GetRealData(
PIdx::x).dataPtr() + a_offset;
204 m_y = soa.GetRealData(PIdx::y).dataPtr() + a_offset;
205 m_z = soa.GetRealData(
PIdx::z).dataPtr() + a_offset;
206 #elif defined(WARPX_DIM_1D_Z)
207 m_z = soa.GetRealData(
PIdx::z).dataPtr() + a_offset;
209 #if defined(WARPX_DIM_RZ)
210 m_theta = soa.GetRealData(T_PIdx::theta).dataPtr() + a_offset;
219 #if defined(WARPX_DIM_XZ)
222 #if defined(WARPX_DIM_1D_Z)
227 m_x[
i] = std::sqrt(
x*
x + y*y);
248 #if defined(WARPX_DIM_XZ)
251 #if defined(WARPX_DIM_1D_Z)
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
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
Extract the cartesian position coordinates of the particle p and store them in the variables x,...
Definition: GetAndSetPosition.H:28
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
i
Definition: check_interp_points_and_weights.py:174
Functor that can be used to extract the positions of the macroparticles inside a ParallelFor kernel.
Definition: GetAndSetPosition.H:63
const RType *AMREX_RESTRICT m_x
Definition: GetAndSetPosition.H:67
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AsStored(const long i, RType &x, RType &y, RType &z) const noexcept
Extract the position coordinates of the particle as stored located at index i + a_offset and store th...
Definition: GetAndSetPosition.H:147
GetParticlePosition(const ptiType &a_pti, long a_offset=0) noexcept
Definition: GetAndSetPosition.H:96
amrex::ParticleReal RType
Definition: GetAndSetPosition.H:64
GetParticlePosition()=default
const RType *AMREX_RESTRICT m_z
Definition: GetAndSetPosition.H:68
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(const long i, RType &x, RType &y, RType &z) const noexcept
Extract the cartesian position coordinates of the particle located at index i + a_offset and store th...
Definition: GetAndSetPosition.H:119
const RType * m_theta
Definition: GetAndSetPosition.H:78
@ x
Definition: NamedComponentParticleContainer.H:27
@ z
Definition: NamedComponentParticleContainer.H:32
Functor that can be used to modify the positions of the macroparticles, inside a ParallelFor kernel.
Definition: GetAndSetPosition.H:178
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(const long i, RType x, RType y, RType z) const noexcept
Set the position of the particle at index i + a_offset to x, y, z
Definition: GetAndSetPosition.H:217
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AsStored(const long i, RType x, RType y, RType z) const noexcept
Set the position of the particle at index i + a_offset to x, y, z This is only different for RZ since...
Definition: GetAndSetPosition.H:246
RType *AMREX_RESTRICT m_z
Definition: GetAndSetPosition.H:183
SetParticlePosition(const ptiType &a_pti, long a_offset=0) noexcept
Definition: GetAndSetPosition.H:196
RType *AMREX_RESTRICT m_theta
Definition: GetAndSetPosition.H:192
amrex::ParticleReal RType
Definition: GetAndSetPosition.H:179
RType *AMREX_RESTRICT m_x
Definition: GetAndSetPosition.H:182