aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/WarpXParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar Remi Lehe <remi.lehe@normalesup.org> 2019-11-16 07:56:54 -0800
committerGravatar GitHub <noreply@github.com> 2019-11-16 07:56:54 -0800
commit89c8309bc7e61524233685b00637e1082f914d06 (patch)
tree11376f287732e74ef35d1bfc18676584f763c226 /Source/Particles/WarpXParticleContainer.cpp
parent2b58b1e40e813722a3e51e609c7b5196bc2e106d (diff)
parent3983a4153a21164fe2a955a22c1824687e1148a8 (diff)
downloadWarpX-89c8309bc7e61524233685b00637e1082f914d06.tar.gz
WarpX-89c8309bc7e61524233685b00637e1082f914d06.tar.zst
WarpX-89c8309bc7e61524233685b00637e1082f914d06.zip
Merge pull request #465 from RemiLehe/poisson
Implement space-charge initialization (non-relativistic, single-level)
Diffstat (limited to 'Source/Particles/WarpXParticleContainer.cpp')
-rw-r--r--Source/Particles/WarpXParticleContainer.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp
index d22de00e0..09f51ef49 100644
--- a/Source/Particles/WarpXParticleContainer.cpp
+++ b/Source/Particles/WarpXParticleContainer.cpp
@@ -8,7 +8,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>
@@ -501,11 +501,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 +539,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() );
}