From 3bb148ebbc1c8eae47d1f00ab60e68a041289cb6 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Mon, 15 Aug 2022 13:43:38 -0700 Subject: Move handling of do_not_deposit to physics callers (#3225) * Rearrange in preparation for lifting do_not_deposit higher in the call stack * Make do_not_deposit public, so callers can test on it * Make all DepositCharge call sites respect WarpXParticleContainer::do_not_deposit * Drop check for do_not_deposit in DepositCharge * Fix comment to accurately describe np_to_depose * Fix logic to account for other logic in AddSpaceChargeField * Match zero charge density array to filled array in RZ PSATD case * Structure control flow per @dpgrote's preference * Reword comment for clarity --- Source/FieldSolver/ElectrostaticSolver.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Source/FieldSolver/ElectrostaticSolver.cpp') diff --git a/Source/FieldSolver/ElectrostaticSolver.cpp b/Source/FieldSolver/ElectrostaticSolver.cpp index 164b24d00..e50098e7d 100644 --- a/Source/FieldSolver/ElectrostaticSolver.cpp +++ b/Source/FieldSolver/ElectrostaticSolver.cpp @@ -165,15 +165,18 @@ WarpX::AddSpaceChargeField (WarpXParticleContainer& pc) BoxArray nba = boxArray(lev); nba.surroundingNodes(); rho[lev] = std::make_unique(nba, DistributionMap(lev), 1, ng); + rho[lev]->setVal(0.); phi[lev] = std::make_unique(nba, DistributionMap(lev), 1, 1); phi[lev]->setVal(0.); } // Deposit particle charge density (source of Poisson solver) bool const local = false; - bool const reset = true; + bool const reset = false; bool const do_rz_volume_scaling = true; - pc.DepositCharge(rho, local, reset, do_rz_volume_scaling); + if ( !pc.do_not_deposit) { + pc.DepositCharge(rho, local, reset, do_rz_volume_scaling); + } // Get the particle beta vector bool const local_average = false; // Average across all MPI ranks @@ -218,9 +221,11 @@ WarpX::AddSpaceChargeFieldLabFrame () bool const do_rz_volume_scaling = false; for (int ispecies=0; ispeciesnSpecies(); ispecies++){ WarpXParticleContainer& species = mypc->GetParticleContainer(ispecies); - species.DepositCharge( - rho_fp, local, reset, do_rz_volume_scaling, interpolate_across_levels - ); + if (!species.do_not_deposit) { + species.DepositCharge( rho_fp, + local, reset, do_rz_volume_scaling, interpolate_across_levels + ); + } } #ifdef WARPX_DIM_RZ for (int lev = 0; lev <= max_level; lev++) { -- cgit v1.2.3