1 #ifndef WARPX_PEC_KERNELS_H_ 2 #define WARPX_PEC_KERNELS_H_ 9 #include <AMReX_Config.H> 21 using namespace amrex;
116 bool OnPECBoundary =
false;
117 bool GuardCell =
false;
118 amrex::Real sign = 1._rt;
120 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
123 for (
int iside = 0; iside < 2; ++iside) {
124 const bool isPECBoundary = ( (iside == 0)
127 #if (defined WARPX_DIM_XZ) || (defined WARPX_DIM_RZ) 131 const bool is_tangent_to_PEC = ( (icomp == AMREX_SPACEDIM*idim)
133 #elif (defined WARPX_DIM_1D_Z) 136 const bool is_tangent_to_PEC = ( ( icomp == idim+2) ?
false :
true );
138 const bool is_tangent_to_PEC = ( ( icomp == idim) ?
false :
true );
140 if (isPECBoundary ==
true) {
142 const int ig = ( (iside == 0)
143 ? (dom_lo[idim] - ijk_vec[idim])
144 : (ijk_vec[idim] - (dom_hi[idim] + is_nodal[idim]) ) );
146 if (is_tangent_to_PEC ==
true and is_nodal[idim] == 1) {
147 OnPECBoundary =
true;
151 ijk_mirror[idim] = ( ( iside == 0)
152 ? (dom_lo[idim] + ig)
153 : (dom_hi[idim] + is_nodal[idim] - ig));
156 if (is_tangent_to_PEC ==
true) sign *= -1._rt;
161 if (OnPECBoundary ==
true) {
163 Efield(ijk_vec,n) = 0._rt;
164 }
else if (GuardCell ==
true) {
165 Efield(ijk_vec,n) = sign * Efield(ijk_mirror,n);
241 bool OnPECBoundary =
false;
242 bool GuardCell =
false;
243 amrex::Real sign = 1._rt;
245 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
247 for (
int iside = 0; iside < 2; ++iside) {
248 const bool isPECBoundary = ( (iside == 0 )
251 if (isPECBoundary ==
true) {
252 #if (defined WARPX_DIM_XZ) || (defined WARPX_DIM_RZ) 256 const bool is_normal_to_PEC = ( (icomp == AMREX_SPACEDIM*idim)
258 #elif (defined WARPX_DIM_1D_Z) 261 const bool is_normal_to_PEC = ( ( icomp == idim+2) ?
true :
false );
263 const bool is_normal_to_PEC = ( ( icomp == idim) ?
true :
false );
266 const int ig = ( (iside == 0)
267 ? (dom_lo[idim] - ijk_vec[idim])
268 : (ijk_vec[idim] - (dom_hi[idim] + is_nodal[idim]) ) );
271 if (is_normal_to_PEC ==
true and is_nodal[idim]==1) {
272 OnPECBoundary =
true;
274 }
else if ( ig > 0) {
277 ijk_mirror[idim] = ( (iside == 0)
278 ? (dom_lo[idim] + ig)
279 : (dom_hi[idim] + is_nodal[idim] - ig));
282 if (is_normal_to_PEC ==
true) sign *= -1._rt;
288 if (OnPECBoundary ==
true) {
290 Bfield(ijk_vec,n) = 0._rt;
291 }
else if (GuardCell ==
true) {
294 Bfield(ijk_vec,n) = sign * Bfield(ijk_mirror,n);
313 const bool split_pml_field =
false);
327 #endif // WarpX_PEC_KERNELS_H_ perfect electric conductor (PEC) with E_tangential=0
Definition: WarpXAlgorithmSelection.H:134
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:232
bool isAnyBoundaryPEC()
Definition: WarpX_PEC.cpp:18
#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:71
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:103
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