aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/WarpXParticleContainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Particles/WarpXParticleContainer.cpp')
-rw-r--r--Source/Particles/WarpXParticleContainer.cpp40
1 files changed, 31 insertions, 9 deletions
diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp
index d22de00e0..9f02da338 100644
--- a/Source/Particles/WarpXParticleContainer.cpp
+++ b/Source/Particles/WarpXParticleContainer.cpp
@@ -1,4 +1,3 @@
-
#include <limits>
#include <MultiParticleContainer.H>
@@ -8,7 +7,7 @@
#include <WarpX_f.H>
#include <WarpX.H>
#include <WarpXAlgorithmSelection.H>
-
+#include <WarpXComm.H>
// Import low-level single-particle kernels
#include <GetAndSetPosition.H>
#include <UpdatePosition.H>
@@ -18,6 +17,7 @@
using namespace amrex;
int WarpXParticleContainer::do_not_push = 0;
+int WarpXParticleContainer::do_not_deposit = 0;
WarpXParIter::WarpXParIter (ContainerType& pc, int level)
: ParIter(pc, level, MFItInfo().SetDynamic(WarpX::do_dynamic_scheduling))
@@ -271,6 +271,9 @@ WarpXParticleContainer::DepositCurrent(WarpXParIter& pti,
// If no particles, do not do anything
if (np_to_depose == 0) return;
+ // If user decides not to deposit
+ if (do_not_deposit) return;
+
const long ngJ = jx->nGrow();
const std::array<Real,3>& dx = WarpX::CellSize(std::max(depos_lev,0));
Real q = this->charge;
@@ -428,6 +431,9 @@ WarpXParticleContainer::DepositCharge (WarpXParIter& pti, RealVector& wp,
// If no particles, do not do anything
if (np_to_depose == 0) return;
+ // If user decides not to deposit
+ if (do_not_deposit) return;
+
const long ngRho = rho->nGrow();
const std::array<Real,3>& dx = WarpX::CellSize(std::max(depos_lev,0));
const Real q = this->charge;
@@ -501,11 +507,16 @@ WarpXParticleContainer::DepositCharge (WarpXParIter& pti, RealVector& wp,
}
void
-WarpXParticleContainer::DepositCharge (Vector<std::unique_ptr<MultiFab> >& rho, bool local)
+WarpXParticleContainer::DepositCharge (Vector<std::unique_ptr<MultiFab> >& rho,
+ bool local, bool reset,
+ bool do_rz_volume_scaling)
{
// Loop over the refinement levels
int const finest_level = rho.size() - 1;
- for (int lev = 0; lev < finest_level; ++lev) {
+ for (int lev = 0; lev <= finest_level; ++lev) {
+
+ // Reset the `rho` array if `reset` is True
+ if (reset) rho[lev]->setVal(0.0, rho[lev]->nGrow());
// Loop over particle tiles and deposit charge on each level
#ifdef _OPENMP
@@ -534,6 +545,13 @@ WarpXParticleContainer::DepositCharge (Vector<std::unique_ptr<MultiFab> >& rho,
#ifdef _OPENMP
}
#endif
+
+#ifdef WARPX_DIM_RZ
+ if (do_rz_volume_scaling) {
+ WarpX::GetInstance().ApplyInverseVolumeScalingToChargeDensity(rho[lev].get(), lev);
+ }
+#endif
+
// Exchange guard cells
if (!local) rho[lev]->SumBoundary( m_gdb->Geom(lev).periodicity() );
}
@@ -612,7 +630,8 @@ Real WarpXParticleContainer::sumParticleCharge(bool local) {
amrex::Real total_charge = 0.0;
- for (int lev = 0; lev < finestLevel(); ++lev)
+ const int nLevels = finestLevel();
+ for (int lev = 0; lev < nLevels; ++lev)
{
#ifdef _OPENMP
@@ -642,7 +661,8 @@ std::array<Real, 3> WarpXParticleContainer::meanParticleVelocity(bool local) {
amrex::Real inv_clight_sq = 1.0/PhysConst::c/PhysConst::c;
- for (int lev = 0; lev <= finestLevel(); ++lev) {
+ const int nLevels = finestLevel();
+ for (int lev = 0; lev <= nLevels; ++lev) {
#ifdef _OPENMP
#pragma omp parallel reduction(+:vx_total, vy_total, vz_total, np_total)
@@ -686,7 +706,8 @@ Real WarpXParticleContainer::maxParticleVelocity(bool local) {
amrex::ParticleReal max_v = 0.0;
- for (int lev = 0; lev <= finestLevel(); ++lev)
+ const int nLevels = finestLevel();
+ for (int lev = 0; lev <= nLevels; ++lev)
{
#ifdef _OPENMP
@@ -712,7 +733,7 @@ WarpXParticleContainer::PushXES (Real dt)
{
BL_PROFILE("WPC::PushXES()");
- int num_levels = finestLevel() + 1;
+ const int num_levels = finestLevel() + 1;
for (int lev = 0; lev < num_levels; ++lev) {
const auto& gm = m_gdb->Geom(lev);
@@ -741,7 +762,8 @@ WarpXParticleContainer::PushXES (Real dt)
void
WarpXParticleContainer::PushX (Real dt)
{
- for (int lev = 0; lev <= finestLevel(); ++lev) {
+ const int nLevels = finestLevel();
+ for (int lev = 0; lev <= nLevels; ++lev) {
PushX(lev, dt);
}
}