aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/WarpXPushFieldsEM.cpp
diff options
context:
space:
mode:
authorGravatar Dave Grote <grote1@llnl.gov> 2019-08-16 12:53:47 -0700
committerGravatar Dave Grote <grote1@llnl.gov> 2019-08-16 12:53:47 -0700
commita26f56418b18c98e3784d1d48073cae81b938e79 (patch)
treed609a8692e8dd29530d62c87809a54a6699b090d /Source/FieldSolver/WarpXPushFieldsEM.cpp
parentc3ce219b9d25e8d28e5a6cc5b878b3c5793cf90a (diff)
parent2d4cf600befb1ef4d5acbefd9d681ff66c11334e (diff)
downloadWarpX-a26f56418b18c98e3784d1d48073cae81b938e79.tar.gz
WarpX-a26f56418b18c98e3784d1d48073cae81b938e79.tar.zst
WarpX-a26f56418b18c98e3784d1d48073cae81b938e79.zip
Merge branch 'dev' into RZgeometry
Diffstat (limited to 'Source/FieldSolver/WarpXPushFieldsEM.cpp')
-rw-r--r--Source/FieldSolver/WarpXPushFieldsEM.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp
index 21000424d..1df05bc0f 100644
--- a/Source/FieldSolver/WarpXPushFieldsEM.cpp
+++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp
@@ -671,4 +671,53 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu
});
}
}
+
+void
+WarpX::ApplyInverseVolumeScalingToChargeDensity (MultiFab* Rho, int lev)
+{
+ const long ngRho = Rho->nGrow();
+ const std::array<Real,3>& dx = WarpX::CellSize(lev);
+ const Real dr = dx[0];
+
+ Box tilebox;
+
+ for ( MFIter mfi(*Rho, TilingIfNotGPU()); mfi.isValid(); ++mfi )
+ {
+
+ Array4<Real> const& Rho_arr = Rho->array(mfi);
+
+ tilebox = mfi.tilebox();
+ Box tb = convert(tilebox, IntVect::TheUnitVector());
+
+ // Lower corner of tile box physical domain
+ // Note that this is done before the tilebox.grow so that
+ // these do not include the guard cells.
+ const std::array<Real, 3>& xyzmin = WarpX::LowerCorner(tilebox, lev);
+ const Dim3 lo = lbound(tilebox);
+ const Real rmin = xyzmin[0];
+ const int irmin = lo.x;
+
+ // Rescale charge in r-z mode since the inverse volume factor was not
+ // included in the charge deposition.
+ amrex::ParallelFor(tb, Rho->nComp(),
+ [=] AMREX_GPU_DEVICE (int i, int j, int k, int icomp)
+ {
+ // Wrap the charge density deposited in the guard cells around
+ // to the cells above the axis.
+ // Rho is located on the boundary
+ if (rmin == 0. && 0 < i && i <= ngRho) {
+ Rho_arr(i,j,0,icomp) += Rho_arr(-i,j,0,icomp);
+ }
+
+ // Apply the inverse volume scaling
+ const amrex::Real r = std::abs(rmin + (i - irmin)*dr);
+ if (r == 0.) {
+ // Verboncoeur JCP 164, 421-427 (2001) : corrected volume on axis
+ Rho_arr(i,j,0,icomp) /= (MathConst::pi*dr/3.);
+ } else {
+ Rho_arr(i,j,0,icomp) /= (2.*MathConst::pi*r);
+ }
+ });
+ }
+}
#endif