8#ifndef WARPX_PARTICLES_PUSHER_GETANDSETPOSITION_H_
9#define WARPX_PARTICLES_PUSHER_GETANDSETPOSITION_H_
25template<
typename T_PIdx = PIdx>
34#if defined(WARPX_DIM_RZ)
37 x = r*std::cos(theta);
38 y = r*std::sin(theta);
40#elif defined(WARPX_DIM_RCYLINDER)
43 x = r*std::cos(theta);
44 y = r*std::sin(theta);
46#elif defined(WARPX_DIM_RSPHERE)
50 x = r*std::cos(theta)*std::cos(phi);
51 y = r*std::sin(theta)*std::cos(phi);
53#elif defined(WARPX_DIM_3D)
57#elif defined(WARPX_DIM_XZ)
73template<
typename T_PIdx = PIdx>
82#if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_RCYLINDER) || defined(WARPX_DIM_RSPHERE)
85#if defined(WARPX_DIM_RSPHERE)
102 template <
typename ptiType>
106 const auto& soa = a_pti.GetStructOfArrays();
108#if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
109 m_x = soa.GetRealData(
PIdx::x).dataPtr() + a_offset;
110 m_z = soa.GetRealData(
PIdx::z).dataPtr() + a_offset;
111#elif defined(WARPX_DIM_3D)
112 m_x = soa.GetRealData(
PIdx::x).dataPtr() + a_offset;
113 m_y = soa.GetRealData(PIdx::y).dataPtr() + a_offset;
114 m_z = soa.GetRealData(
PIdx::z).dataPtr() + a_offset;
115#elif defined(WARPX_DIM_1D_Z)
116 m_z = soa.GetRealData(
PIdx::z).dataPtr() + a_offset;
117#elif defined(WARPX_DIM_RCYLINDER)
118 m_x = soa.GetRealData(
PIdx::x).dataPtr() + a_offset;
119 m_theta = soa.GetRealData(T_PIdx::theta).dataPtr() + a_offset;
120#elif defined(WARPX_DIM_RSPHERE)
121 m_x = soa.GetRealData(
PIdx::x).dataPtr() + a_offset;
122 m_theta = soa.GetRealData(T_PIdx::theta).dataPtr() + a_offset;
123 m_phi = soa.GetRealData(T_PIdx::phi).dataPtr() + a_offset;
125#if defined(WARPX_DIM_RZ)
126 m_theta = soa.GetRealData(T_PIdx::theta).dataPtr() + a_offset;
136#if defined(WARPX_DIM_RZ)
141#elif defined(WARPX_DIM_RCYLINDER)
146#elif defined(WARPX_DIM_RSPHERE)
148 x = r*std::cos(
m_theta[i])*std::cos(m_phi[i]);
149 y = r*std::sin(
m_theta[i])*std::cos(m_phi[i]);
150 z = r*std::sin(m_phi[i]);
151#elif defined(WARPX_DIM_3D)
155#elif defined(WARPX_DIM_XZ)
159#elif defined(WARPX_DIM_1D_Z)
174#if defined(WARPX_DIM_RZ)
178#elif defined(WARPX_DIM_RCYLINDER)
182#elif defined(WARPX_DIM_RSPHERE)
186#elif defined(WARPX_DIM_3D)
190#elif defined(WARPX_DIM_XZ)
194#elif defined(WARPX_DIM_1D_Z)
209template<
typename T_PIdx = PIdx>
214#if defined(WARPX_DIM_3D)
218#elif defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
221#elif defined(WARPX_DIM_1D_Z)
223#elif defined(WARPX_DIM_RCYLINDER) || defined(WARPX_DIM_RSPHERE)
227#if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_RCYLINDER) || defined(WARPX_DIM_RSPHERE)
230#if defined(WARPX_DIM_RSPHERE)
234 template <
typename ptiType>
238 auto& soa = a_pti.GetStructOfArrays();
239#if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
240 m_x = soa.GetRealData(
PIdx::x).dataPtr() + a_offset;
241 m_z = soa.GetRealData(
PIdx::z).dataPtr() + a_offset;
242#elif defined(WARPX_DIM_3D)
243 m_x = soa.GetRealData(
PIdx::x).dataPtr() + a_offset;
244 m_y = soa.GetRealData(PIdx::y).dataPtr() + a_offset;
245 m_z = soa.GetRealData(
PIdx::z).dataPtr() + a_offset;
246#elif defined(WARPX_DIM_1D_Z)
247 m_z = soa.GetRealData(
PIdx::z).dataPtr() + a_offset;
248#elif defined(WARPX_DIM_RCYLINDER)
249 m_x = soa.GetRealData(
PIdx::x).dataPtr() + a_offset;
250 m_theta = soa.GetRealData(T_PIdx::theta).dataPtr() + a_offset;
251#elif defined(WARPX_DIM_RSPHERE)
252 m_x = soa.GetRealData(
PIdx::x).dataPtr() + a_offset;
253 m_theta = soa.GetRealData(T_PIdx::theta).dataPtr() + a_offset;
254 m_phi = soa.GetRealData(T_PIdx::phi).dataPtr() + a_offset;
256#if defined(WARPX_DIM_RZ)
257 m_theta = soa.GetRealData(T_PIdx::theta).dataPtr() + a_offset;
267#if defined(WARPX_DIM_RZ)
269 m_x[i] = std::sqrt(x*x + y*y);
271#elif defined(WARPX_DIM_RCYLINDER)
273 m_x[i] = std::sqrt(x*x + y*y);
274#elif defined(WARPX_DIM_RSPHERE)
275 RType const rxy = std::sqrt(x*x + y*y);
276 RType const r = std::sqrt(x*x + y*y + z*z);
279 m_phi[i] = std::atan2(z, rxy);
280#elif defined(WARPX_DIM_3D)
284#elif defined(WARPX_DIM_XZ)
287#elif defined(WARPX_DIM_1D_Z)
300#if defined(WARPX_DIM_RZ)
304#elif defined(WARPX_DIM_RCYLINDER)
307#elif defined(WARPX_DIM_RSPHERE)
311#elif defined(WARPX_DIM_3D)
315#elif defined(WARPX_DIM_XZ)
318#elif 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:27
Particle< NStructReal+NArrayReal, NStructInt+NArrayInt > SuperParticleType
amrex_particle_real ParticleReal
__host__ __device__ void ignore_unused(const Ts &...)
const RType *AMREX_RESTRICT m_y
Definition GetAndSetPosition.H:79
static constexpr RType m_y_default
Definition GetAndSetPosition.H:90
const RType *AMREX_RESTRICT m_x
Definition GetAndSetPosition.H:78
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:172
const RType *AMREX_RESTRICT m_theta
Definition GetAndSetPosition.H:83
static constexpr RType m_x_default
Definition GetAndSetPosition.H:89
GetParticlePosition(const ptiType &a_pti, long a_offset=0) noexcept
Definition GetAndSetPosition.H:104
static constexpr RType m_z_default
Definition GetAndSetPosition.H:91
amrex::ParticleReal RType
Definition GetAndSetPosition.H:76
GetParticlePosition()=default
const RType *AMREX_RESTRICT m_z
Definition GetAndSetPosition.H:80
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:134
@ x
Definition WarpXParticleContainer.H:70
@ z
Definition WarpXParticleContainer.H:70
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:264
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:297
RType *AMREX_RESTRICT m_z
Definition GetAndSetPosition.H:220
SetParticlePosition(const ptiType &a_pti, long a_offset=0) noexcept
Definition GetAndSetPosition.H:236
RType *AMREX_RESTRICT m_theta
Definition GetAndSetPosition.H:228
amrex::ParticleReal RType
Definition GetAndSetPosition.H:212
RType *AMREX_RESTRICT m_x
Definition GetAndSetPosition.H:219