Skip to content

Commit

Permalink
ApplyPECto Rho and J if particle boundary is reflecting
Browse files Browse the repository at this point in the history
  • Loading branch information
RevathiJambunathan committed Mar 18, 2024
1 parent d22e423 commit f3c4220
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Source/BoundaryConditions/WarpXFieldBoundaries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Source/BoundaryConditions/WarpX_PEC.H
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 17 additions & 4 deletions Source/BoundaryConditions/WarpX_PEC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<amrex::MultiFab*, 3> Efield, const int lev,
PatchType patch_type, const bool split_pml_field)
Expand Down Expand Up @@ -248,8 +257,10 @@ PEC::ApplyPECtoRhofield (amrex::MultiFab* rho, const int lev, PatchType patch_ty
amrex::GpuArray<GpuArray<amrex::Real,2>, AMREX_SPACEDIM> psign;
amrex::GpuArray<GpuArray<int,2>, 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]); }

Expand Down Expand Up @@ -340,8 +351,10 @@ PEC::ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
amrex::GpuArray<GpuArray<GpuArray<amrex::Real, 2>, AMREX_SPACEDIM>, 3> psign;
amrex::GpuArray<GpuArray<GpuArray<int, 2>, 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]); }

Expand Down

0 comments on commit f3c4220

Please sign in to comment.