8 #ifndef CHARGEDEPOSITION_H_ 9 #define CHARGEDEPOSITION_H_ 30 template <
int depos_order>
32 const amrex::ParticleReal *
const wp,
33 const int *
const ion_lev,
34 amrex::FArrayBox& rho_fab,
35 const long np_to_depose,
36 const std::array<amrex::Real,3>&
dx,
37 const std::array<amrex::Real, 3> xyzmin,
40 const long n_rz_azimuthal_modes)
42 using namespace amrex;
46 const bool do_ionization = ion_lev;
47 const amrex::Real dxi = 1.0/dx[0];
48 const amrex::Real dzi = 1.0/dx[2];
49 #if (AMREX_SPACEDIM == 2) 50 const amrex::Real invvol = dxi*dzi;
51 #elif (defined WARPX_DIM_3D) 52 const amrex::Real dyi = 1.0/dx[1];
53 const amrex::Real invvol = dxi*dyi*dzi;
56 const amrex::Real xmin = xyzmin[0];
57 #if (defined WARPX_DIM_3D) 58 const amrex::Real ymin = xyzmin[1];
60 const amrex::Real zmin = xyzmin[2];
62 amrex::Array4<amrex::Real>
const& rho_arr = rho_fab.array();
63 amrex::IntVect
const rho_type = rho_fab.box().type();
65 constexpr
int zdir = (AMREX_SPACEDIM - 1);
67 constexpr
int CELL = amrex::IndexType::CELL;
72 [=] AMREX_GPU_DEVICE (
long ip) {
74 amrex::Real wq = q*wp[ip]*invvol;
79 amrex::ParticleReal xp, yp, zp;
80 GetPosition(ip, xp, yp, zp);
85 #if (defined WARPX_DIM_RZ) 86 const amrex::Real rp = std::sqrt(xp*xp + yp*yp);
97 const amrex::Real
x = (rp - xmin)*dxi;
99 const amrex::Real x = (xp - xmin)*dxi;
104 amrex::Real sx[depos_order + 1];
107 if (rho_type[0] == NODE) {
108 i = compute_shape_factor(sx, x);
109 }
else if (rho_type[0] == CELL) {
110 i = compute_shape_factor(sx, x - 0.5_rt);
113 #if (defined WARPX_DIM_3D) 115 const amrex::Real y = (yp - ymin)*dyi;
116 amrex::Real sy[depos_order + 1];
118 if (rho_type[1] == NODE) {
119 j = compute_shape_factor(sy, y);
120 }
else if (rho_type[1] == CELL) {
121 j = compute_shape_factor(sy, y - 0.5_rt);
125 const amrex::Real
z = (zp - zmin)*dzi;
126 amrex::Real sz[depos_order + 1];
128 if (rho_type[zdir] == NODE) {
129 k = compute_shape_factor(sz, z);
130 }
else if (rho_type[zdir] == CELL) {
131 k = compute_shape_factor(sz, z - 0.5_rt);
135 #if (defined WARPX_DIM_XZ) || (defined WARPX_DIM_RZ) 136 for (
int iz=0; iz<=depos_order; iz++){
137 for (
int ix=0; ix<=depos_order; ix++){
138 amrex::Gpu::Atomic::Add(
139 &rho_arr(lo.x+i+ix, lo.y+k+iz, 0, 0),
141 #if (defined WARPX_DIM_RZ) 143 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
145 amrex::Gpu::Atomic::Add( &rho_arr(lo.x+i+ix, lo.y+k+iz, 0, 2*imode-1), 2._rt*sx[ix]*sz[iz]*wq*xy.real());
146 amrex::Gpu::Atomic::Add( &rho_arr(lo.x+i+ix, lo.y+k+iz, 0, 2*imode ), 2._rt*sx[ix]*sz[iz]*wq*xy.imag());
152 #elif (defined WARPX_DIM_3D) 153 for (
int iz=0; iz<=depos_order; iz++){
154 for (
int iy=0; iy<=depos_order; iy++){
155 for (
int ix=0; ix<=depos_order; ix++){
156 amrex::Gpu::Atomic::Add(
157 &rho_arr(lo.x+i+ix, lo.y+j+iy, lo.z+k+iz),
158 sx[ix]*sy[iy]*sz[iz]*wq);
167 amrex::ignore_unused(n_rz_azimuthal_modes);
171 #endif // CHARGEDEPOSITION_H_ amrex::GpuComplex< amrex::Real > Complex
Definition: WarpX_Complex.H:22
Definition: wp_parser.tab.cpp:115
def x
Definition: read_lab_particles.py:25
int dx
Definition: compute_domain.py:35
def z
Definition: read_lab_particles.py:26
Definition: ShapeFactors.H:22
void doChargeDepositionShapeN(const GetParticlePosition &GetPosition, const amrex::ParticleReal *const wp, const int *const ion_lev, amrex::FArrayBox &rho_fab, const long np_to_depose, const std::array< amrex::Real, 3 > &dx, const std::array< amrex::Real, 3 > xyzmin, const amrex::Dim3 lo, const amrex::Real q, const long n_rz_azimuthal_modes)
Definition: ChargeDeposition.H:31
i
Definition: check_interp_points_and_weights.py:171
Functor that can be used to extract the positions of the macroparticles inside a ParallelFor kernel...
Definition: GetAndSetPosition.H:25