Skip to content

Commit

Permalink
Add staggering shift when calculating field location
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgrote committed Nov 11, 2024
1 parent 9476692 commit ba7b32e
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions Source/BoundaryConditions/PEC_Insulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,13 @@ PEC_Insulator::ApplyPEC_InsulatortoField (
amrex::ignore_unused(j, k);

amrex::IntVect const iv(AMREX_D_DECL(i, j, k));
amrex::Real const x = (AMREX_SPACEDIM > 1 ? xyzmin_x.x + (iv[0] - lo_x[0])*dx[0] : 0._rt);
amrex::Real const y = (AMREX_SPACEDIM == 3 ? xyzmin_x.y + (iv[1] - lo_x[1])*dx[1] : 0._rt);
amrex::Real const shiftx = (Fx_nodal[0] ? 0._rt : 0.5_rt);
amrex::Real const x = (AMREX_SPACEDIM > 1 ? xyzmin_x.x + (iv[0] - lo_x[0] + shiftx)*dx[0] : 0._rt);
amrex::Real const shifty = (Fx_nodal[1] ? 0._rt : 0.5_rt);
amrex::Real const y = (AMREX_SPACEDIM == 3 ? xyzmin_x.y + (iv[1] - lo_x[1] + shifty)*dx[1] : 0._rt);
#if (AMREX_SPACEDIM > 1)
amrex::Real const z = xyzmin_x.z + (iv[WARPX_ZINDEX] - lo_x[WARPX_ZINDEX])*dx[2];
amrex::Real const shiftz = (Fx_nodal[2] ? 0._rt : 0.5_rt);
amrex::Real const z = xyzmin_x.z + (iv[WARPX_ZINDEX] - lo_x[WARPX_ZINDEX] + shiftz)*dx[2];
#endif

amrex::IntVect is_insulator_lo;
Expand Down Expand Up @@ -471,10 +474,13 @@ PEC_Insulator::ApplyPEC_InsulatortoField (
amrex::ignore_unused(j, k);

amrex::IntVect const iv(AMREX_D_DECL(i, j, k));
amrex::Real const x = (AMREX_SPACEDIM > 1 ? xyzmin_y.x + (iv[0] - lo_y[0])*dx[0] : 0._rt);
amrex::Real const y = (AMREX_SPACEDIM == 3 ? xyzmin_y.y + (iv[1] - lo_y[1])*dx[1] : 0._rt);
amrex::Real const shiftx = (Fy_nodal[0] ? 0._rt : 0.5_rt);
amrex::Real const x = (AMREX_SPACEDIM > 1 ? xyzmin_y.x + (iv[0] - lo_y[0] + shiftx)*dx[0] : 0._rt);
amrex::Real const shifty = (Fy_nodal[1] ? 0._rt : 0.5_rt);
amrex::Real const y = (AMREX_SPACEDIM == 3 ? xyzmin_y.y + (iv[1] - lo_y[1] + shifty)*dx[1] : 0._rt);
#if (AMREX_SPACEDIM > 1)
amrex::Real const z = xyzmin_y.z + (iv[WARPX_ZINDEX] - lo_y[WARPX_ZINDEX])*dx[2];
amrex::Real const shiftz = (Fy_nodal[2] ? 0._rt : 0.5_rt);
amrex::Real const z = xyzmin_y.z + (iv[WARPX_ZINDEX] - lo_y[WARPX_ZINDEX] + shiftz)*dx[2];
#endif

amrex::IntVect is_insulator_lo;
Expand Down Expand Up @@ -516,10 +522,13 @@ PEC_Insulator::ApplyPEC_InsulatortoField (
amrex::ignore_unused(j, k);

amrex::IntVect const iv(AMREX_D_DECL(i, j, k));
amrex::Real const x = (AMREX_SPACEDIM > 1 ? xyzmin_z.x + (iv[0] - lo_z[0])*dx[0] : 0._rt);
amrex::Real const y = (AMREX_SPACEDIM == 3 ? xyzmin_z.y + (iv[1] - lo_z[1])*dx[1] : 0._rt);
amrex::Real const shiftx = (Fz_nodal[0] ? 0._rt : 0.5_rt);
amrex::Real const x = (AMREX_SPACEDIM > 1 ? xyzmin_z.x + (iv[0] - lo_z[0] + shiftx)*dx[0] : 0._rt);
amrex::Real const shifty = (Fz_nodal[1] ? 0._rt : 0.5_rt);
amrex::Real const y = (AMREX_SPACEDIM == 3 ? xyzmin_z.y + (iv[1] - lo_z[1] + shifty)*dx[1] : 0._rt);
#if (AMREX_SPACEDIM > 1)
amrex::Real const z = xyzmin_z.z + (iv[WARPX_ZINDEX] - lo_z[WARPX_ZINDEX])*dx[2];
amrex::Real const shiftz = (Fz_nodal[2] ? 0._rt : 0.5_rt);
amrex::Real const z = xyzmin_z.z + (iv[WARPX_ZINDEX] - lo_z[WARPX_ZINDEX] + shiftz)*dx[2];
#endif

amrex::IntVect is_insulator_lo;
Expand Down

0 comments on commit ba7b32e

Please sign in to comment.