diff options
Diffstat (limited to '')
-rw-r--r-- | Source/Particles/Gather/FieldGather.H | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/Source/Particles/Gather/FieldGather.H b/Source/Particles/Gather/FieldGather.H index 0a58f8425..12d9b6291 100644 --- a/Source/Particles/Gather/FieldGather.H +++ b/Source/Particles/Gather/FieldGather.H @@ -8,12 +8,13 @@ #ifndef FIELDGATHER_H_ #define FIELDGATHER_H_ +#include "GetAndSetPosition.H" #include "ShapeFactors.H" #include <WarpX_Complex.H> /** * \brief Field gather for particles handled by thread thread_num - * \param xp, yp, zp : Pointer to arrays of particle positions. + * /param GetPosition : A functor for returning the particle position. * \param Exp, Eyp, Ezp: Pointer to array of electric field on particles. * \param Bxp, Byp, Bzp: Pointer to array of magnetic field on particles. * \param ex_arr ey_arr: Array4 of current density, either full array or tile. @@ -27,9 +28,7 @@ * \param n_rz_azimuthal_modes: Number of azimuthal modes when using RZ geometry */ template <int depos_order, int lower_in_v> -void doGatherShapeN(const amrex::ParticleReal * const xp, - const amrex::ParticleReal * const yp, - const amrex::ParticleReal * const zp, +void doGatherShapeN(const GetParticlePosition& GetPosition, amrex::ParticleReal * const Exp, amrex::ParticleReal * const Eyp, amrex::ParticleReal * const Ezp, amrex::ParticleReal * const Bxp, amrex::ParticleReal * const Byp, amrex::ParticleReal * const Bzp, @@ -80,14 +79,18 @@ void doGatherShapeN(const amrex::ParticleReal * const xp, amrex::ParallelFor( np_to_gather, [=] AMREX_GPU_DEVICE (long ip) { + + amrex::ParticleReal xp, yp, zp; + GetPosition(ip, xp, yp, zp); + // --- Compute shape factors // x direction // Get particle position #ifdef WARPX_DIM_RZ - const amrex::Real rp = std::sqrt(xp[ip]*xp[ip] + yp[ip]*yp[ip]); + const amrex::Real rp = std::sqrt(xp*xp + yp*yp); const amrex::Real x = (rp - xmin)*dxi; #else - const amrex::Real x = (xp[ip]-xmin)*dxi; + const amrex::Real x = (xp-xmin)*dxi; #endif // j_[eb][xyz] leftmost grid point in x that the particle touches for the centering of each current @@ -129,7 +132,7 @@ void doGatherShapeN(const amrex::ParticleReal * const xp, #if (AMREX_SPACEDIM == 3) // y direction - const amrex::Real y = (yp[ip]-ymin)*dyi; + const amrex::Real y = (yp-ymin)*dyi; amrex::Real sy_node[depos_order + 1]; amrex::Real sy_cell[depos_order + 1]; amrex::Real sy_node_v[depos_order + 1 - lower_in_v]; @@ -165,7 +168,7 @@ void doGatherShapeN(const amrex::ParticleReal * const xp, #endif // z direction - const amrex::Real z = (zp[ip]-zmin)*dzi; + const amrex::Real z = (zp-zmin)*dzi; amrex::Real sz_node[depos_order + 1]; amrex::Real sz_cell[depos_order + 1]; amrex::Real sz_node_v[depos_order + 1 - lower_in_v]; @@ -245,8 +248,8 @@ void doGatherShapeN(const amrex::ParticleReal * const xp, amrex::Real costheta; amrex::Real sintheta; if (rp > 0.) { - costheta = xp[ip]/rp; - sintheta = yp[ip]/rp; + costheta = xp/rp; + sintheta = yp/rp; } else { costheta = 1.; sintheta = 0.; |