Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PEC-Insulator boundary condition with staggering #5451

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Examples/Tests/pec/inputs_test_2d_pec_field_insulator
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ geometry.prob_hi = 1.e-2 3.e-2

# Boundary condition
boundary.field_lo = neumann periodic
boundary.field_hi = PECInsulator periodic
boundary.field_hi = pec_insulator periodic
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an incidental fix, making the name consistent with what is in the documentation.


warpx.serialize_initial_conditions = 1

Expand Down
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];
dpgrote marked this conversation as resolved.
Show resolved Hide resolved
#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
Loading