8 #ifndef CHARGEDEPOSITION_H_ 9 #define CHARGEDEPOSITION_H_ 39 template <
int depos_order>
41 const amrex::ParticleReal *
const wp,
42 const int *
const ion_lev,
44 const long np_to_depose,
45 const std::array<amrex::Real,3>&
dx,
46 const std::array<amrex::Real, 3> xyzmin,
49 const int n_rz_azimuthal_modes,
51 const long load_balance_costs_update_algo)
53 using namespace amrex;
55 #if !defined(AMREX_USE_GPU) 61 const bool do_ionization = ion_lev;
62 const amrex::Real dzi = 1.0_rt/dx[2];
63 #if defined(WARPX_DIM_1D_Z) 64 const amrex::Real invvol = dzi;
66 #if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) 67 const amrex::Real dxi = 1.0_rt/dx[0];
68 const amrex::Real invvol = dxi*dzi;
69 #elif defined(WARPX_DIM_3D) 70 const amrex::Real dxi = 1.0_rt/dx[0];
71 const amrex::Real dyi = 1.0_rt/dx[1];
72 const amrex::Real invvol = dxi*dyi*dzi;
75 #if (AMREX_SPACEDIM >= 2) 76 const amrex::Real xmin = xyzmin[0];
78 #if defined(WARPX_DIM_3D) 79 const amrex::Real ymin = xyzmin[1];
81 const amrex::Real zmin = xyzmin[2];
90 #if defined(WARPX_USE_GPUCLOCK) 91 amrex::Real* cost_real =
nullptr;
100 #if defined(WARPX_USE_GPUCLOCK) 101 KernelTimer kernelTimer(cost && load_balance_costs_update_algo
105 amrex::Real wq = q*wp[ip]*invvol;
110 amrex::ParticleReal xp, yp, zp;
111 GetPosition(ip, xp, yp, zp);
115 #if (AMREX_SPACEDIM >= 2) 118 #if defined(WARPX_DIM_RZ) 119 const amrex::Real rp = std::sqrt(xp*xp + yp*yp);
120 amrex::Real costheta;
121 amrex::Real sintheta;
130 const amrex::Real x = (rp - xmin)*dxi;
132 const amrex::Real x = (xp - xmin)*dxi;
137 amrex::Real sx[depos_order + 1] = {0._rt};
139 if (rho_type[0] == NODE) {
140 i = compute_shape_factor(sx, x);
141 }
else if (rho_type[0] == CELL) {
142 i = compute_shape_factor(sx, x - 0.5_rt);
144 #endif //AMREX_SPACEDIM >= 2 145 #if defined(WARPX_DIM_3D) 147 const amrex::Real y = (yp - ymin)*dyi;
148 amrex::Real sy[depos_order + 1] = {0._rt};
150 if (rho_type[1] == NODE) {
151 j = compute_shape_factor(sy, y);
152 }
else if (rho_type[1] == CELL) {
153 j = compute_shape_factor(sy, y - 0.5_rt);
157 const amrex::Real z = (zp - zmin)*dzi;
158 amrex::Real sz[depos_order + 1] = {0._rt};
160 if (rho_type[WARPX_ZINDEX] == NODE) {
161 k = compute_shape_factor(sz, z);
162 }
else if (rho_type[WARPX_ZINDEX] == CELL) {
163 k = compute_shape_factor(sz, z - 0.5_rt);
167 #if defined(WARPX_DIM_1D_Z) 168 for (
int iz=0; iz<=depos_order; iz++){
170 &rho_arr(lo.
x+k+iz, 0, 0, 0),
174 #if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ) 175 for (
int iz=0; iz<=depos_order; iz++){
176 for (
int ix=0; ix<=depos_order; ix++){
178 &rho_arr(lo.
x+i+ix, lo.
y+k+iz, 0, 0),
180 #if defined(WARPX_DIM_RZ) 182 for (
int imode=1 ; imode < n_rz_azimuthal_modes ; imode++) {
191 #elif defined(WARPX_DIM_3D) 192 for (
int iz=0; iz<=depos_order; iz++){
193 for (
int iy=0; iy<=depos_order; iy++){
194 for (
int ix=0; ix<=depos_order; ix++){
196 &rho_arr(lo.
x+i+ix, lo.
y+j+iy, lo.
z+k+iz),
197 sx[ix]*sy[iy]*sz[iz]*wq);
204 #if defined(WARPX_USE_GPUCLOCK) 217 #endif // CHARGEDEPOSITION_H_
const Box & box() const noexcept
AMREX_FORCE_INLINE Array4< Real const > array() const noexcept
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 int n_rz_azimuthal_modes, amrex::Real *cost, const long load_balance_costs_update_algo)
Definition: ChargeDeposition.H:40
int dx
Definition: compute_domain.py:35
virtual void free(void *pt)=0
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
Definition: ShapeFactors.H:26
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T imag() const noexcept
std::enable_if_t< std::is_integral< T >::value > ParallelFor(TypeList< CTOs... >, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition: WarpXAlgorithmSelection.H:124
i
Definition: check_interp_points_and_weights.py:174
virtual void * alloc(std::size_t sz)=0
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AddNoRet(T *sum, T value) noexcept
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T real() const noexcept
Functor that can be used to extract the positions of the macroparticles inside a ParallelFor kernel...
Definition: GetAndSetPosition.H:52
void streamSynchronize() noexcept
Defines a timer object to be used on GPU; measures summed thread cycles.
Definition: KernelTimer.H:23
AMREX_GPU_HOST_DEVICE IntVect type() const noexcept
Arena * The_Managed_Arena()