From f3c42202f135ee729311a524d1527abe3a2f963a Mon Sep 17 00:00:00 2001 From: RevathiJambunathan Date: Mon, 18 Mar 2024 15:00:11 -0700 Subject: [PATCH] ApplyPECto Rho and J if particle boundary is reflecting --- .../WarpXFieldBoundaries.cpp | 4 ++-- Source/BoundaryConditions/WarpX_PEC.H | 3 +++ Source/BoundaryConditions/WarpX_PEC.cpp | 21 +++++++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Source/BoundaryConditions/WarpXFieldBoundaries.cpp b/Source/BoundaryConditions/WarpXFieldBoundaries.cpp index af7a385b729..69c379ecbe6 100644 --- a/Source/BoundaryConditions/WarpXFieldBoundaries.cpp +++ b/Source/BoundaryConditions/WarpXFieldBoundaries.cpp @@ -106,14 +106,14 @@ void WarpX::ApplyBfieldBoundary (const int lev, PatchType patch_type, DtType a_d void WarpX::ApplyRhofieldBoundary (const int lev, MultiFab* rho, PatchType patch_type) { - if (PEC::isAnyBoundaryPEC()) { PEC::ApplyPECtoRhofield(rho, lev, patch_type); } + if (PEC::isAnyParticleBoundaryReflecting()) { PEC::ApplyPECtoRhofield(rho, lev, patch_type); } } void WarpX::ApplyJfieldBoundary (const int lev, amrex::MultiFab* Jx, amrex::MultiFab* Jy, amrex::MultiFab* Jz, PatchType patch_type) { - if (PEC::isAnyBoundaryPEC()) { PEC::ApplyPECtoJfield(Jx, Jy, Jz, lev, patch_type); } + if (PEC::isAnyParticleBoundaryReflecting()) { PEC::ApplyPECtoJfield(Jx, Jy, Jz, lev, patch_type); } } #ifdef WARPX_DIM_RZ diff --git a/Source/BoundaryConditions/WarpX_PEC.H b/Source/BoundaryConditions/WarpX_PEC.H index 62b92ba94b5..50e05833e35 100644 --- a/Source/BoundaryConditions/WarpX_PEC.H +++ b/Source/BoundaryConditions/WarpX_PEC.H @@ -479,6 +479,9 @@ using namespace amrex; /** Returns 1 if any domain boundary is set to PEC, else returns 0.*/ bool isAnyBoundaryPEC(); + + /** Return true if any particle boundary is set to reflecting, else returns false*/ + bool isAnyParticleBoundaryReflecting (); /** * \brief Sets the tangential electric field at the PEC boundary to zero. * The guard cell values are set equal and opposite to the valid cell diff --git a/Source/BoundaryConditions/WarpX_PEC.cpp b/Source/BoundaryConditions/WarpX_PEC.cpp index 7555e2aaef2..977b43e587a 100644 --- a/Source/BoundaryConditions/WarpX_PEC.cpp +++ b/Source/BoundaryConditions/WarpX_PEC.cpp @@ -24,6 +24,15 @@ PEC::isAnyBoundaryPEC() { return false; } +bool +PEC::isAnyParticleBoundaryReflecting () { + for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) { + if (WarpX::particle_boundary_lo[idim] == ParticleBoundaryType::Reflecting) {return true;} + if (WarpX::particle_boundary_hi[idim] == ParticleBoundaryType::Reflecting) {return true;} + } + return false; +} + void PEC::ApplyPECtoEfield (std::array Efield, const int lev, PatchType patch_type, const bool split_pml_field) @@ -248,8 +257,10 @@ PEC::ApplyPECtoRhofield (amrex::MultiFab* rho, const int lev, PatchType patch_ty amrex::GpuArray, AMREX_SPACEDIM> psign; amrex::GpuArray, AMREX_SPACEDIM> mirrorfac; for (int idim=0; idim < AMREX_SPACEDIM; ++idim) { - is_pec[idim][0] = WarpX::field_boundary_lo[idim] == FieldBoundaryType::PEC; - is_pec[idim][1] = WarpX::field_boundary_hi[idim] == FieldBoundaryType::PEC; + is_pec[idim][0] = ( WarpX::field_boundary_lo[idim] == FieldBoundaryType::PEC + || WarpX::particle_boundary_lo[idim] == ParticleBoundaryType::Reflecting); + is_pec[idim][1] = ( WarpX::field_boundary_hi[idim] == FieldBoundaryType::PEC + || WarpX::particle_boundary_lo[idim] == ParticleBoundaryType::Reflecting); if (!is_pec[idim][0]) { grown_domain_box.growLo(idim, ng_fieldgather[idim]); } if (!is_pec[idim][1]) { grown_domain_box.growHi(idim, ng_fieldgather[idim]); } @@ -340,8 +351,10 @@ PEC::ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy, amrex::GpuArray, AMREX_SPACEDIM>, 3> psign; amrex::GpuArray, AMREX_SPACEDIM>, 3> mirrorfac; for (int idim=0; idim < AMREX_SPACEDIM; ++idim) { - is_pec[idim][0] = WarpX::field_boundary_lo[idim] == FieldBoundaryType::PEC; - is_pec[idim][1] = WarpX::field_boundary_hi[idim] == FieldBoundaryType::PEC; + is_pec[idim][0] = ( WarpX::field_boundary_lo[idim] == FieldBoundaryType::PEC + || WarpX::particle_boundary_lo[idim] == ParticleBoundaryType::Reflecting); + is_pec[idim][1] = ( WarpX::field_boundary_hi[idim] == FieldBoundaryType::PEC + || WarpX::particle_boundary_hi[idim] == ParticleBoundaryType::Reflecting); if (!is_pec[idim][0]) { grown_domain_box.growLo(idim, ng_fieldgather[idim]); } if (!is_pec[idim][1]) { grown_domain_box.growHi(idim, ng_fieldgather[idim]); }