Skip to content

Commit

Permalink
rename functions
Browse files Browse the repository at this point in the history
  • Loading branch information
RevathiJambunathan committed Mar 18, 2024
1 parent f3c4220 commit cf00663
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 30 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::isAnyParticleBoundaryReflecting()) { PEC::ApplyPECtoRhofield(rho, lev, patch_type); }
if (PEC::isAnyParticleBoundaryReflecting()) { PEC::ApplyReflectiveBoundarytoRhofield(rho, lev, patch_type); }
}

void WarpX::ApplyJfieldBoundary (const int lev, amrex::MultiFab* Jx,
amrex::MultiFab* Jy, amrex::MultiFab* Jz,
PatchType patch_type)
{
if (PEC::isAnyParticleBoundaryReflecting()) { PEC::ApplyPECtoJfield(Jx, Jy, Jz, lev, patch_type); }
if (PEC::isAnyParticleBoundaryReflecting()) { PEC::ApplyReflectiveBoundarytoJfield(Jx, Jy, Jz, lev, patch_type); }
}

#ifdef WARPX_DIM_RZ
Expand Down
16 changes: 8 additions & 8 deletions Source/BoundaryConditions/WarpX_PEC.H
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,12 @@ using namespace amrex;


/**
* \brief Sets the rho or J field value in cells close to and on a PEC boundary. The
* \brief Sets the rho or J field value in cells close to and on reflecting particle boundary. The
* charge/current density deposited in the guard cells are either reflected
* back into the simulation domain (if a reflecting particle
* boundary is used), or the opposite charge/current density is deposited
* back in the domain to capture the effect of an image charge.
* The charge/current density on the PEC boundary is set to 0 while values
* The charge/current density on the reflecting boundary is set to 0 while values
* in the guard cells are set equal (and opposite) to their mirror
* location inside the domain - representing image charges - in the
* normal (tangential) direction.
Expand All @@ -370,7 +370,7 @@ using namespace amrex;
* \param[in out] field field data to be updated
* \param[in] mirrorfac mirror cell is given by mirrorfac - ijk_vec
* \param[in] psign Whether the field value should be flipped across the boundary
* \param[in] is_pec Whether the given boundary is PEC
* \param[in] is_reflective Whether the given particle boundary is reflecting
* \param[in] tangent_to_bndy Whether a given direction is perpendicular to the boundary
* \param[in] fabbox multifab box including ghost cells
*/
Expand All @@ -380,7 +380,7 @@ using namespace amrex;
amrex::Array4<amrex::Real> const& field,
amrex::GpuArray<GpuArray<int, 2>, AMREX_SPACEDIM> const& mirrorfac,
amrex::GpuArray<GpuArray<amrex::Real, 2>, AMREX_SPACEDIM> const& psign,
amrex::GpuArray<GpuArray<bool, 2>, AMREX_SPACEDIM> const& is_pec,
amrex::GpuArray<GpuArray<bool, 2>, AMREX_SPACEDIM> const& is_reflective,
amrex::GpuArray<bool, AMREX_SPACEDIM> const& tangent_to_bndy,
amrex::Box const& fabbox)
{
Expand All @@ -391,7 +391,7 @@ using namespace amrex;
{
for (int iside = 0; iside < 2; ++iside)
{
if (!is_pec[idim][iside]) { continue; }
if (!is_reflective[idim][iside]) { continue; }

// Get the mirror guard cell index
amrex::IntVect iv_mirror = ijk_vec;
Expand All @@ -412,7 +412,7 @@ using namespace amrex;
{
for (int iside = 0; iside < 2; ++iside)
{
if (!is_pec[idim][iside]) { continue; }
if (!is_reflective[idim][iside]) { continue; }

amrex::IntVect iv_mirror = ijk_vec;
iv_mirror[idim] = mirrorfac[idim][iside] - ijk_vec[idim];
Expand Down Expand Up @@ -516,7 +516,7 @@ using namespace amrex;
* \param[in] lev level of the Multifab
* \param[in] patch_type coarse or fine
*/
void ApplyPECtoRhofield(amrex::MultiFab* rho, int lev,
void ApplyReflectiveBoundarytoRhofield(amrex::MultiFab* rho, int lev,
PatchType patch_type);

/**
Expand All @@ -527,7 +527,7 @@ using namespace amrex;
* \param[in] lev level of the Multifab
* \param[in] patch_type coarse or fine
*/
void ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
void ApplyReflectiveBoundarytoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
amrex::MultiFab* Jz, int lev,
PatchType patch_type);

Expand Down
36 changes: 16 additions & 20 deletions Source/BoundaryConditions/WarpX_PEC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ PEC::ApplyPECtoBfield (std::array<amrex::MultiFab*, 3> Bfield, const int lev,
* location inside the domain - representing image charges.
**/
void
PEC::ApplyPECtoRhofield (amrex::MultiFab* rho, const int lev, PatchType patch_type)
PEC::ApplyReflectiveBoundarytoRhofield (amrex::MultiFab* rho, const int lev, PatchType patch_type)
{
auto& warpx = WarpX::GetInstance();

Expand All @@ -252,17 +252,15 @@ PEC::ApplyPECtoRhofield (amrex::MultiFab* rho, const int lev, PatchType patch_ty
// cells for boundaries that are NOT PEC
amrex::Box grown_domain_box = domain_box;

amrex::GpuArray<GpuArray<bool,2>, AMREX_SPACEDIM> is_pec;
amrex::GpuArray<GpuArray<bool,2>, AMREX_SPACEDIM> is_reflective;
amrex::GpuArray<bool, AMREX_SPACEDIM> is_tangent_to_bndy;
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
|| 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]); }
is_reflective[idim][0] = ( WarpX::particle_boundary_lo[idim] == ParticleBoundaryType::Reflecting);
is_reflective[idim][1] = ( WarpX::particle_boundary_lo[idim] == ParticleBoundaryType::Reflecting);
if (!is_reflective[idim][0]) { grown_domain_box.growLo(idim, ng_fieldgather[idim]); }
if (!is_reflective[idim][1]) { grown_domain_box.growHi(idim, ng_fieldgather[idim]); }

// rho values inside guard cells are updated the same as tangential
// components of the current density
Expand Down Expand Up @@ -304,7 +302,7 @@ PEC::ApplyPECtoRhofield (amrex::MultiFab* rho, const int lev, PatchType patch_ty
const amrex::IntVect iv(AMREX_D_DECL(i,j,k));

PEC::SetRhoOrJfieldFromPEC(
n, iv, rho_array, mirrorfac, psign, is_pec,
n, iv, rho_array, mirrorfac, psign, is_reflective,
is_tangent_to_bndy, fabbox
);
});
Expand All @@ -313,7 +311,7 @@ PEC::ApplyPECtoRhofield (amrex::MultiFab* rho, const int lev, PatchType patch_ty


void
PEC::ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
PEC::ApplyReflectiveBoundarytoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
amrex::MultiFab* Jz, const int lev,
PatchType patch_type)
{
Expand Down Expand Up @@ -346,17 +344,15 @@ PEC::ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
// directions of the current density multifab
const amrex::IntVect ng_fieldgather = Jx->nGrowVect();

amrex::GpuArray<GpuArray<bool, 2>, AMREX_SPACEDIM> is_pec;
amrex::GpuArray<GpuArray<bool, 2>, AMREX_SPACEDIM> is_reflective;
amrex::GpuArray<GpuArray<bool, AMREX_SPACEDIM>, 3> is_tangent_to_bndy;
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
|| 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]); }
is_reflective[idim][0] = ( WarpX::particle_boundary_lo[idim] == ParticleBoundaryType::Reflecting);
is_reflective[idim][1] = ( WarpX::particle_boundary_hi[idim] == ParticleBoundaryType::Reflecting);
if (!is_reflective[idim][0]) { grown_domain_box.growLo(idim, ng_fieldgather[idim]); }
if (!is_reflective[idim][1]) { grown_domain_box.growHi(idim, ng_fieldgather[idim]); }

for (int icomp=0; icomp < 3; ++icomp) {
// Set the psign value correctly for each current component for each
Expand Down Expand Up @@ -428,7 +424,7 @@ PEC::ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
const amrex::IntVect iv(AMREX_D_DECL(i,j,k));

PEC::SetRhoOrJfieldFromPEC(
n, iv, Jx_array, mirrorfac[0], psign[0], is_pec,
n, iv, Jx_array, mirrorfac[0], psign[0], is_reflective,
is_tangent_to_bndy[0], fabbox
);
});
Expand Down Expand Up @@ -463,7 +459,7 @@ PEC::ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
const amrex::IntVect iv(AMREX_D_DECL(i,j,k));

PEC::SetRhoOrJfieldFromPEC(
n, iv, Jy_array, mirrorfac[1], psign[1], is_pec,
n, iv, Jy_array, mirrorfac[1], psign[1], is_reflective,
is_tangent_to_bndy[1], fabbox
);
});
Expand Down Expand Up @@ -498,7 +494,7 @@ PEC::ApplyPECtoJfield(amrex::MultiFab* Jx, amrex::MultiFab* Jy,
const amrex::IntVect iv(AMREX_D_DECL(i,j,k));

PEC::SetRhoOrJfieldFromPEC(
n, iv, Jz_array, mirrorfac[2], psign[2], is_pec,
n, iv, Jz_array, mirrorfac[2], psign[2], is_reflective,
is_tangent_to_bndy[2], fabbox
);
});
Expand Down

0 comments on commit cf00663

Please sign in to comment.