aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/WarpXPushFieldsEM.cpp
diff options
context:
space:
mode:
authorGravatar David Grote <grote1@llnl.gov> 2020-07-17 06:21:48 -0700
committerGravatar GitHub <noreply@github.com> 2020-07-17 06:21:48 -0700
commitcdf25708d17c76fcd2e7dec825343b559589968e (patch)
treed79918b8613147840a0e3f4f6f0f7e61e2bb32af /Source/FieldSolver/WarpXPushFieldsEM.cpp
parentabd9291980ae09c928449b542c43ac1293641946 (diff)
downloadWarpX-cdf25708d17c76fcd2e7dec825343b559589968e.tar.gz
WarpX-cdf25708d17c76fcd2e7dec825343b559589968e.tar.zst
WarpX-cdf25708d17c76fcd2e7dec825343b559589968e.zip
For RZ, fix the deposition near the axis (#1072)
* For RZ, fix the deposition near the axis * Updated LaserAccelerationRZ checksum The change was expected since the code changes modified the charge and current density near the axis. * Updated LaserAccelerationRZ checksum The change was expected since the code changes modified the charge and current density near the axis. * Update benchmark Co-authored-by: Remi Lehe <remi.lehe@normalesup.org>
Diffstat (limited to '')
-rw-r--r--Source/FieldSolver/WarpXPushFieldsEM.cpp33
1 files changed, 16 insertions, 17 deletions
diff --git a/Source/FieldSolver/WarpXPushFieldsEM.cpp b/Source/FieldSolver/WarpXPushFieldsEM.cpp
index a0281f783..8bce9f3d2 100644
--- a/Source/FieldSolver/WarpXPushFieldsEM.cpp
+++ b/Source/FieldSolver/WarpXPushFieldsEM.cpp
@@ -348,6 +348,8 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu
const Real rminz = xyzmin[0] + (tbz.type(0) == NODE ? 0. : 0.5*dx[0]);
const Dim3 lo = lbound(tilebox);
const int irmin = lo.x;
+
+ // For ishift, 1 means cell centered, 0 means node centered
int const ishift_t = (rmint > rmin ? 1 : 0);
int const ishift_z = (rminz > rmin ? 1 : 0);
@@ -385,13 +387,12 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu
Jr_arr(i,j,0,0) /= (2.*MathConst::pi*r);
for (int imode=1 ; imode < nmodes ; imode++) {
- const Real ifact = ( (imode%2) == 0 ? +1. : -1.);
// Wrap the current density deposited in the guard cells around
// to the cells above the axis.
// Note that Jr(i==0) is at 1/2 dr.
if (rmin == 0. && 0 <= i && i < ngJ) {
- Jr_arr(i,j,0,2*imode-1) -= ifact*Jr_arr(-1-i,j,0,2*imode-1);
- Jr_arr(i,j,0,2*imode) -= ifact*Jr_arr(-1-i,j,0,2*imode);
+ Jr_arr(i,j,0,2*imode-1) -= Jr_arr(-1-i,j,0,2*imode-1);
+ Jr_arr(i,j,0,2*imode) -= Jr_arr(-1-i,j,0,2*imode);
}
// Apply the inverse volume scaling
// Since Jr is never node centered in r, no need for distinction
@@ -406,8 +407,8 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu
// to the cells above the axis.
// If Jt is node centered, Jt[0] is located on the boundary.
// If Jt is cell centered, Jt[0] is at 1/2 dr.
- if (rmin == 0. && 0 < i && i <= ngJ-ishift_t) {
- Jt_arr(i,j,0,0) += Jt_arr(-ishift_t-i,j,0,0);
+ if (rmin == 0. && 1-ishift_t <= i && i <= ngJ-ishift_t) {
+ Jt_arr(i,j,0,0) -= Jt_arr(-ishift_t-i,j,0,0);
}
// Apply the inverse volume scaling
@@ -420,12 +421,11 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu
}
for (int imode=1 ; imode < nmodes ; imode++) {
- const Real ifact = ( (imode%2) == 0 ? +1. : -1.);
// Wrap the current density deposited in the guard cells around
// to the cells above the axis.
- if (rmin == 0. && 0 < i && i <= ngJ-ishift_t) {
- Jt_arr(i,j,0,2*imode-1) += ifact*Jt_arr(-ishift_t-i,j,0,2*imode-1);
- Jt_arr(i,j,0,2*imode) += ifact*Jt_arr(-ishift_t-i,j,0,2*imode);
+ if (rmin == 0. && 1-ishift_t <= i && i <= ngJ-ishift_t) {
+ Jt_arr(i,j,0,2*imode-1) -= Jt_arr(-ishift_t-i,j,0,2*imode-1);
+ Jt_arr(i,j,0,2*imode) -= Jt_arr(-ishift_t-i,j,0,2*imode);
}
// Apply the inverse volume scaling
@@ -445,8 +445,8 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu
// to the cells above the axis.
// If Jz is node centered, Jt[0] is located on the boundary.
// If Jz is cell centered, Jt[0] is at 1/2 dr.
- if (rmin == 0. && 0 < i && i <= ngJ-ishift_z) {
- Jz_arr(i,j,0,0) += Jz_arr(-ishift_z-i,j,0,0);
+ if (rmin == 0. && 1-ishift_z <= i && i <= ngJ-ishift_z) {
+ Jz_arr(i,j,0,0) -= Jz_arr(-ishift_z-i,j,0,0);
}
// Apply the inverse volume scaling
@@ -459,12 +459,11 @@ WarpX::ApplyInverseVolumeScalingToCurrentDensity (MultiFab* Jx, MultiFab* Jy, Mu
}
for (int imode=1 ; imode < nmodes ; imode++) {
- const Real ifact = ( (imode%2) == 0 ? +1. : -1.);
// Wrap the current density deposited in the guard cells around
// to the cells above the axis.
- if (rmin == 0. && 0 < i && i <= ngJ-ishift_z) {
- Jz_arr(i,j,0,2*imode-1) += ifact*Jz_arr(-ishift_z-i,j,0,2*imode-1);
- Jz_arr(i,j,0,2*imode) += ifact*Jz_arr(-ishift_z-i,j,0,2*imode);
+ if (rmin == 0. && 1-ishift_z <= i && i <= ngJ-ishift_z) {
+ Jz_arr(i,j,0,2*imode-1) -= Jz_arr(-ishift_z-i,j,0,2*imode-1);
+ Jz_arr(i,j,0,2*imode) -= Jz_arr(-ishift_z-i,j,0,2*imode);
}
// Apply the inverse volume scaling
@@ -530,8 +529,8 @@ WarpX::ApplyInverseVolumeScalingToChargeDensity (MultiFab* Rho, int lev)
// 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-ishift) {
- Rho_arr(i,j,0,icomp) += Rho_arr(-ishift-i,j,0,icomp);
+ if (rmin == 0. && 1-ishift <= i && i <= ngRho-ishift) {
+ Rho_arr(i,j,0,icomp) -= Rho_arr(-ishift-i,j,0,icomp);
}
// Apply the inverse volume scaling