8 #ifndef WARPX_PARTICLES_PUSHER_GETANDSETPOSITION_H_ 9 #define WARPX_PARTICLES_PUSHER_GETANDSETPOSITION_H_ 24 amrex::ParticleReal& x,
25 amrex::ParticleReal& y,
26 amrex::ParticleReal& z) noexcept
30 amrex::ParticleReal r = p.pos(0);
31 x = r*std::cos(theta);
32 y = r*std::sin(theta);
40 y = amrex::ParticleReal(0.0);
43 x = amrex::ParticleReal(0.0);
44 y = amrex::ParticleReal(0.0);
55 using RType = amrex::ParticleReal;
58 #if defined(WARPX_DIM_RZ) 60 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) 61 static constexpr
RType m_y_default =
RType(0.0);
62 #elif defined(WARPX_DIM_1D_Z) 63 static constexpr
RType m_x_default =
RType(0.0);
64 static constexpr
RType m_y_default =
RType(0.0);
76 template <
typename ptiType>
79 const auto& aos = a_pti.GetArrayOfStructs();
80 m_structs = aos().dataPtr() + a_offset;
81 #if defined(WARPX_DIM_RZ) 82 const auto& soa = a_pti.GetStructOfArrays();
83 m_theta = soa.GetRealData(
PIdx::theta).dataPtr() + a_offset;
93 const PType& p = m_structs[
i];
96 x = r*std::cos(m_theta[
i]);
97 y = r*std::sin(m_theta[i]);
122 const PType& p = m_structs[
i];
155 #if defined(WARPX_DIM_RZ) 159 template <
typename ptiType>
162 auto& aos = a_pti.GetArrayOfStructs();
163 m_structs = aos().dataPtr() + a_offset;
164 #if defined(WARPX_DIM_RZ) 165 auto& soa = a_pti.GetStructOfArrays();
166 m_theta = soa.GetRealData(
PIdx::theta).dataPtr() + a_offset;
175 #if defined(WARPX_DIM_XZ) 178 #if defined(WARPX_DIM_1D_Z) 182 m_theta[
i] = std::atan2(y, x);
183 m_structs[
i].pos(0) = std::sqrt(x*x + y*y);
184 m_structs[
i].pos(1) = z;
186 m_structs[
i].pos(0) = x;
187 m_structs[
i].pos(1) = y;
188 m_structs[
i].pos(2) = z;
190 m_structs[
i].pos(0) = x;
191 m_structs[
i].pos(1) = z;
193 m_structs[
i].pos(0) = z;
204 #if defined(WARPX_DIM_XZ) 207 #if defined(WARPX_DIM_1D_Z) 211 m_structs[
i].pos(0) = x;
213 m_structs[
i].pos(1) = z;
215 m_structs[
i].pos(0) = x;
216 m_structs[
i].pos(1) = y;
217 m_structs[
i].pos(2) = z;
219 m_structs[
i].pos(0) = x;
220 m_structs[
i].pos(1) = z;
222 m_structs[
i].pos(0) = z;
227 #endif // WARPX_PARTICLES_PUSHER_GETANDSETPOSITION_H_
SetParticlePosition(const ptiType &a_pti, int a_offset=0) noexcept
Definition: GetAndSetPosition.H:160
GetParticlePosition()=default
WarpXParticleContainer::ParticleType PType
Definition: GetAndSetPosition.H:54
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:23
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
GetParticlePosition(const ptiType &a_pti, int a_offset=0) noexcept
Definition: GetAndSetPosition.H:77
const RType * m_theta
Definition: GetAndSetPosition.H:59
#define AMREX_FORCE_INLINE
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(const int 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:91
amrex::ParticleReal RType
Definition: GetAndSetPosition.H:55
#define AMREX_GPU_HOST_DEVICE
i
Definition: check_interp_points_and_weights.py:174
Particle< NStructReal, NStructInt > ParticleType
PType *AMREX_RESTRICT m_structs
Definition: GetAndSetPosition.H:154
RType *AMREX_RESTRICT m_theta
Definition: GetAndSetPosition.H:156
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AsStored(const int 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:202
RZ needs all three position components.
Definition: NamedComponentParticleContainer.H:27
amrex::ParticleReal RType
Definition: GetAndSetPosition.H:152
const PType *AMREX_RESTRICT m_structs
Definition: GetAndSetPosition.H:57
WarpXParticleContainer::ParticleType PType
Definition: GetAndSetPosition.H:151
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AsStored(const int 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:120
Functor that can be used to extract the positions of the macroparticles inside a ParallelFor kernel...
Definition: GetAndSetPosition.H:52
Functor that can be used to modify the positions of the macroparticles, inside a ParallelFor kernel...
Definition: GetAndSetPosition.H:149