7 #ifndef ABLASTR_DEPOSIT_CHARGE_H_
8 #define ABLASTR_DEPOSIT_CHARGE_H_
48 template<
typename T_PC >
51 typename T_PC::RealVector
const& wp,
52 amrex::Real
const charge,
53 int const *
const ion_lev,
56 int const particle_shape,
59 int const n_rz_azimuthal_modes = 0,
60 std::optional<amrex::IntVect> num_rho_deposition_guards = std::nullopt,
61 std::optional<int> depos_lev = std::nullopt,
62 std::optional<amrex::IntVect> rel_ref_ratio = std::nullopt,
63 long const offset = 0,
64 std::optional<long> np_to_deposit = std::nullopt,
65 int const icomp = 0,
int const nc = 1)
69 if (num_rho_deposition_guards.has_value()) {
70 ng_rho = num_rho_deposition_guards.value();
73 "num_rho_deposition_guards are larger than allocated!");
75 auto const[nox, noy, noz] = std::array<int, 3>{particle_shape, particle_shape, particle_shape};
79 if (!np_to_deposit.has_value()) {
80 np_to_deposit = pti.numParticles();
83 "np_to_deposit + offset are out-of-bounds for particle iterator");
85 int const lev = pti.GetLevel();
86 if (!depos_lev.has_value()) {
90 (depos_lev.value() == (lev )),
91 "Deposition buffers only work for lev or lev-1");
92 if (!rel_ref_ratio.has_value()) {
94 "rel_ref_ratio must be set if lev != depos_lev");
99 if (np_to_deposit == 0) {
return; }
106 #if defined(WARPX_DIM_1D_Z)
110 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
113 static_cast<int>(noz/2+1));
114 #elif defined(WARPX_DIM_3D)
116 static_cast<int>(noy/2+1),
117 static_cast<int>(noz/2+1));
122 #ifndef AMREX_USE_GPU
130 "Particles shape does not fit within tile (CPU) or guard cells (GPU) used for charge deposition");
139 if (lev == depos_lev) {
140 tilebox = pti.tilebox();
145 #ifndef AMREX_USE_GPU
150 tilebox.
grow(ng_rho);
156 auto & rho_fab = rhoi.
get(pti);
166 auto & rho_fab = local_rho;
177 doChargeDepositionShapeN<1>(GetPosition, wp.dataPtr()+
offset, ion_lev,
178 rho_fab, np_to_deposit.value(), dinv, xyzmin, lo, charge,
179 n_rz_azimuthal_modes);
180 }
else if (nox == 2){
181 doChargeDepositionShapeN<2>(GetPosition, wp.dataPtr()+
offset, ion_lev,
182 rho_fab, np_to_deposit.value(), dinv, xyzmin, lo, charge,
183 n_rz_azimuthal_modes);
184 }
else if (nox == 3){
185 doChargeDepositionShapeN<3>(GetPosition, wp.dataPtr()+
offset, ion_lev,
186 rho_fab, np_to_deposit.value(), dinv, xyzmin, lo, charge,
187 n_rz_azimuthal_modes);
188 }
else if (nox == 4){
189 doChargeDepositionShapeN<4>(GetPosition, wp.dataPtr()+
offset, ion_lev,
190 rho_fab, np_to_deposit.value(), dinv, xyzmin, lo, charge,
191 n_rz_azimuthal_modes);
195 #ifndef AMREX_USE_GPU
198 (*rho)[pti].lockAdd(local_rho, tb, tb, 0, icomp*
nc,
nc);
Array4< int const > offset
#define AMREX_D_DECL(a, b, c)
#define ABLASTR_PROFILE_VAR_NS(fname, vname)
Definition: ProfilerWrapper.H:15
#define ABLASTR_PROFILE_VAR_START(vname)
Definition: ProfilerWrapper.H:16
#define ABLASTR_PROFILE_VAR_STOP(vname)
Definition: ProfilerWrapper.H:17
#define ABLASTR_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition: TextMsg.H:75
void setVal(Real const &x, const Box &bx, int dcomp, int ncomp) noexcept
AMREX_GPU_HOST_DEVICE BoxND & grow(int i) noexcept
void resize(const Box &b, int N=1, Arena *ar=nullptr)
IntVect nGrowVect() const noexcept
IndexType ixType() const noexcept
const FArrayBox & get(const MFIter &mfi) const noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > toIntVect() const noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allLE(const IntVectND< dim > &rhs) const noexcept
Definition: DepositCharge.H:21
static void deposit_charge(typename T_PC::ParIterType &pti, typename T_PC::RealVector const &wp, amrex::Real const charge, int const *const ion_lev, amrex::MultiFab *rho, amrex::FArrayBox &local_rho, int const particle_shape, const amrex::XDim3 dinv, const amrex::XDim3 xyzmin, int const n_rz_azimuthal_modes=0, std::optional< amrex::IntVect > num_rho_deposition_guards=std::nullopt, std::optional< int > depos_lev=std::nullopt, std::optional< amrex::IntVect > rel_ref_ratio=std::nullopt, long const offset=0, std::optional< long > np_to_deposit=std::nullopt, int const icomp=0, int const nc=1)
Definition: DepositCharge.H:50
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > convert(const BoxND< dim > &b, const IntVectND< dim > &typ) noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 lbound(Array4< T > const &a) noexcept
IntVectND< AMREX_SPACEDIM > IntVect
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
int numParticlesOutOfRange(Iterator const &pti, int nGrow)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
int nc
Definition: check_interp_points_and_weights.py:130