7 #ifndef ABLASTR_DEPOSIT_CHARGE_H_
8 #define ABLASTR_DEPOSIT_CHARGE_H_
49 template<
typename T_PC >
52 typename T_PC::RealVector
const& wp,
53 amrex::Real
const charge,
54 int const *
const ion_lev,
57 int const particle_shape,
58 std::array<amrex::Real, 3>
const &
dx,
59 std::array<amrex::Real, 3>
const & xyzmin,
60 int const n_rz_azimuthal_modes = 0,
61 std::optional<amrex::IntVect> num_rho_deposition_guards = std::nullopt,
62 std::optional<int> depos_lev = std::nullopt,
63 std::optional<amrex::IntVect> rel_ref_ratio = std::nullopt,
64 long const offset = 0,
65 std::optional<long> np_to_deposit = std::nullopt,
66 int const icomp = 0,
int const nc = 1,
67 bool const do_device_synchronize =
true)
71 if (num_rho_deposition_guards.has_value()) {
72 ng_rho = num_rho_deposition_guards.value();
75 "num_rho_deposition_guards are larger than allocated!");
77 auto const[nox, noy, noz] = std::array<int, 3>{particle_shape, particle_shape, particle_shape};
81 if (!np_to_deposit.has_value()) {
82 np_to_deposit = pti.numParticles();
85 "np_to_deposit + offset are out-of-bounds for particle iterator");
87 int const lev = pti.GetLevel();
88 if (!depos_lev.has_value()) {
92 (depos_lev.value() == (lev )),
93 "Deposition buffers only work for lev or lev-1");
94 if (!rel_ref_ratio.has_value()) {
96 "rel_ref_ratio must be set if lev != depos_lev");
101 if (np_to_deposit == 0) {
return; }
108 #if defined(WARPX_DIM_1D_Z)
112 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
115 static_cast<int>(noz/2+1));
116 #elif defined(WARPX_DIM_3D)
118 static_cast<int>(noy/2+1),
119 static_cast<int>(noz/2+1));
124 #ifndef AMREX_USE_GPU
132 "Particles shape does not fit within tile (CPU) or guard cells (GPU) used for charge deposition");
134 ABLASTR_PROFILE_VAR_NS(
"ablastr::particles::deposit_charge::ChargeDeposition", blp_ppc_chd, do_device_synchronize);
135 ABLASTR_PROFILE_VAR_NS(
"ablastr::particles::deposit_charge::Accumulate", blp_accumulate, do_device_synchronize);
141 if (lev == depos_lev) {
142 tilebox = pti.tilebox();
147 #ifndef AMREX_USE_GPU
152 tilebox.
grow(ng_rho);
158 auto & rho_fab = rhoi.
get(pti);
168 auto & rho_fab = local_rho;
179 doChargeDepositionShapeN<1>(GetPosition, wp.dataPtr()+offset, ion_lev,
180 rho_fab, np_to_deposit.value(),
dx, xyzmin, lo, charge,
181 n_rz_azimuthal_modes);
182 }
else if (nox == 2){
183 doChargeDepositionShapeN<2>(GetPosition, wp.dataPtr()+offset, ion_lev,
184 rho_fab, np_to_deposit.value(),
dx, xyzmin, lo, charge,
185 n_rz_azimuthal_modes);
186 }
else if (nox == 3){
187 doChargeDepositionShapeN<3>(GetPosition, wp.dataPtr()+offset, ion_lev,
188 rho_fab, np_to_deposit.value(),
dx, xyzmin, lo, charge,
189 n_rz_azimuthal_modes);
190 }
else if (nox == 4){
191 doChargeDepositionShapeN<4>(GetPosition, wp.dataPtr()+offset, ion_lev,
192 rho_fab, np_to_deposit.value(),
dx, xyzmin, lo, charge,
193 n_rz_azimuthal_modes);
197 #ifndef AMREX_USE_GPU
200 (*rho)[pti].lockAdd(local_rho, tb, tb, 0, icomp*
nc,
nc);
#define AMREX_D_DECL(a, b, c)
#define ABLASTR_PROFILE_VAR_START(vname, sync)
Definition: ProfilerWrapper.H:58
#define ABLASTR_PROFILE_VAR_NS(fname, vname, sync)
Definition: ProfilerWrapper.H:57
#define ABLASTR_PROFILE_VAR_STOP(vname, sync)
Definition: ProfilerWrapper.H:59
#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 Box & 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 IntVect toIntVect() const noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allLE(const IntVect &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, std::array< amrex::Real, 3 > const &dx, std::array< amrex::Real, 3 > const &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, bool const do_device_synchronize=true)
Definition: DepositCharge.H:51
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Box convert(const Box &b, const IntVect &typ) noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 lbound(Array4< T > const &a) noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Box coarsen(const Box &b, int ref_ratio) noexcept
int numParticlesOutOfRange(Iterator const &pti, int nGrow)
int nc
Definition: check_interp_points_and_weights.py:130
tuple dx
lab frame
Definition: stencil.py:429