1 #ifndef WARPX_PEC_KERNELS_H_ 2 #define WARPX_PEC_KERNELS_H_ 9 #include <AMReX_Config.H> 21 using namespace amrex;
107 bool OnPECBoundary =
false;
108 bool GuardCell =
false;
109 amrex::Real sign = 1._rt;
111 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
114 for (
int iside = 0; iside < 2; ++iside) {
115 const bool isPECBoundary = ( (iside == 0)
118 #if (defined WARPX_DIM_XZ) || (defined WARPX_DIM_RZ) 122 const bool is_tangent_to_PEC = ( (icomp == AMREX_SPACEDIM*idim)
125 const bool is_tangent_to_PEC = ( ( icomp == idim) ?
false :
true );
127 if (isPECBoundary ==
true) {
129 const int ig = ( (iside == 0)
130 ? (dom_lo[idim] - ijk_vec[idim])
131 : (ijk_vec[idim] - (dom_hi[idim] + is_nodal[idim]) ) );
133 if (is_tangent_to_PEC ==
true and is_nodal[idim] == 1) {
134 OnPECBoundary =
true;
138 ijk_mirror[idim] = ( ( iside == 0)
139 ? (dom_lo[idim] + ig)
140 : (dom_hi[idim] + is_nodal[idim] - ig));
143 if (is_tangent_to_PEC ==
true) sign *= -1._rt;
148 if (OnPECBoundary ==
true) {
150 Efield(ijk_vec,n) = 0._rt;
151 }
else if (GuardCell ==
true) {
152 Efield(ijk_vec,n) = sign * Efield(ijk_mirror,n);
219 bool OnPECBoundary =
false;
220 bool GuardCell =
false;
221 amrex::Real sign = 1._rt;
223 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
225 for (
int iside = 0; iside < 2; ++iside) {
226 const bool isPECBoundary = ( (iside == 0 )
229 if (isPECBoundary ==
true) {
230 #if (defined WARPX_DIM_XZ) || (defined WARPX_DIM_RZ) 234 const bool is_normal_to_PEC = ( (icomp == AMREX_SPACEDIM*idim)
237 const bool is_normal_to_PEC = ( ( icomp == idim) ?
true :
false );
240 const int ig = ( (iside == 0)
241 ? (dom_lo[idim] - ijk_vec[idim])
242 : (ijk_vec[idim] - (dom_hi[idim] + is_nodal[idim]) ) );
245 if (is_normal_to_PEC ==
true and is_nodal[idim]==1) {
246 OnPECBoundary =
true;
248 }
else if ( ig > 0) {
251 ijk_mirror[idim] = ( (iside == 0)
252 ? (dom_lo[idim] + ig)
253 : (dom_hi[idim] + is_nodal[idim] - ig));
256 if (is_normal_to_PEC ==
true) sign *= -1._rt;
262 if (OnPECBoundary ==
true) {
264 Bfield(ijk_vec,n) = 0._rt;
265 }
else if (GuardCell ==
true) {
268 Bfield(ijk_vec,n) = sign * Bfield(ijk_mirror,n);
287 const bool split_pml_field =
false);
301 #endif // WarpX_PEC_KERNELS_H_ AMREX_GPU_DEVICE AMREX_FORCE_INLINE void SetBfieldOnPEC(const int icomp, const amrex::IntVect &dom_lo, const amrex::IntVect &dom_hi, const amrex::IntVect &ijk_vec, const int n, amrex::Array4< amrex::Real > const &Bfield, const amrex::IntVect &is_nodal, amrex::GpuArray< int, 3 > const &fbndry_lo, amrex::GpuArray< int, 3 > const &fbndry_hi)
Sets the magnetic field value normal to the PEC boundary to zero. The tangential (and normal) field v...
Definition: WarpX_PEC.H:210
bool isAnyBoundaryPEC()
Definition: WarpX_PEC.cpp:18
perfect electric conductor (PEC) with E_tangential=0
Definition: WarpXAlgorithmSelection.H:117
#define AMREX_FORCE_INLINE
int n
Definition: run_libensemble_on_warpx.py:67
void ApplyPECtoBfield(std::array< amrex::MultiFab *, 3 > Bfield, const int lev, PatchType patch_type)
Sets the normal component of the magnetic field at the PEC boundary to zero. The guard cell values ar...
Definition: WarpX_PEC.cpp:124
Definition: WarpX_PEC.H:20
PatchType
Definition: WarpX.H:69
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void SetEfieldOnPEC(const int icomp, const amrex::IntVect &dom_lo, const amrex::IntVect &dom_hi, const amrex::IntVect &ijk_vec, const int n, amrex::Array4< amrex::Real > const &Efield, const amrex::IntVect &is_nodal, amrex::GpuArray< int, 3 > const &fbndry_lo, amrex::GpuArray< int, 3 > const &fbndry_hi)
Sets the electric field value tangential to the PEC boundary to zero. The tangential Efield component...
Definition: WarpX_PEC.H:94
void ApplyPECtoEfield(std::array< amrex::MultiFab *, 3 > Efield, const int lev, PatchType patch_type, const bool split_pml_field=false)
Sets the tangential electric field at the PEC boundary to zero. The guard cell values are set equal a...
Definition: WarpX_PEC.cpp:27
AMREX_GPU_DEVICE AMREX_FORCE_INLINE bool is_boundary_PEC(amrex::GpuArray< int, 3 > const &fboundary, int dir)
Determines if the field boundary condition stored in fboundary is PEC in direction, dir, is PEC.
Definition: WarpX_PEC.H:32