Skip to content

Commit

Permalink
Extend do_pml_Lo/Hi to MR Levels
Browse files Browse the repository at this point in the history
  • Loading branch information
EZoni committed Mar 3, 2022
1 parent 3a0446c commit d9faf00
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
23 changes: 10 additions & 13 deletions Source/Initialization/WarpXInitData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,21 @@ WarpX::InitFromScratch ()
void
WarpX::InitPML ()
{

for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
if (WarpX::field_boundary_lo[idim] == FieldBoundaryType::PML) {
do_pml = 1;
do_pml_Lo[idim] = 1;
do_pml_Lo[0][idim] = 1; // on level 0
}
if (WarpX::field_boundary_hi[idim] == FieldBoundaryType::PML) {
do_pml = 1;
do_pml_Hi[idim] = 1;
do_pml_Hi[0][idim] = 1; // on level 0
}
}
if (finest_level > 0) do_pml = 1;
if (do_pml)
{
amrex::IntVect do_pml_Lo_corrected = do_pml_Lo;

#if (defined WARPX_DIM_RZ) && (defined WARPX_USE_PSATD)
do_pml_Lo_corrected[0] = 0; // no PML at r=0, in cylindrical geometry
do_pml_Lo[0][0] = 0; // no PML at r=0, in cylindrical geometry
pml_rz[0] = std::make_unique<PML_RZ>(0, boxArray(0), DistributionMap(0), &Geom(0), pml_ncell, do_pml_in_domain);
#else
pml[0] = std::make_unique<PML>(0, boxArray(0), DistributionMap(0), &Geom(0), nullptr,
Expand All @@ -255,28 +252,28 @@ WarpX::InitPML ()
do_multi_J,
do_pml_dive_cleaning, do_pml_divb_cleaning,
guard_cells.ng_FieldSolver.max(),
do_pml_Lo_corrected, do_pml_Hi);
do_pml_Lo[0], do_pml_Hi[0]);
#endif

for (int lev = 1; lev <= finest_level; ++lev)
{
amrex::IntVect do_pml_Lo_MR = amrex::IntVect::TheUnitVector();
amrex::IntVect do_pml_Hi_MR = amrex::IntVect::TheUnitVector();
do_pml_Lo[lev] = amrex::IntVect::TheUnitVector();
do_pml_Hi[lev] = amrex::IntVect::TheUnitVector();
// check if fine patch edges co-incide with domain boundary
amrex::Box levelBox = boxArray(lev).minimalBox();
// Domain box at level, lev
amrex::Box DomainBox = Geom(lev).Domain();
for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
if (levelBox.smallEnd(idim) == DomainBox.smallEnd(idim))
do_pml_Lo_MR[idim] = do_pml_Lo[idim];
do_pml_Lo[lev][idim] = do_pml_Lo[0][idim];
if (levelBox.bigEnd(idim) == DomainBox.bigEnd(idim))
do_pml_Hi_MR[idim] = do_pml_Hi[idim];
do_pml_Hi[lev][idim] = do_pml_Hi[0][idim];
}

#ifdef WARPX_DIM_RZ
//In cylindrical geometry, if the edge of the patch is at r=0, do not add PML
if ((max_level > 0) && (fine_tag_lo[0]==0.)) {
do_pml_Lo_MR[0] = 0;
do_pml_Lo[lev][0] = 0;
}
#endif
pml[lev] = std::make_unique<PML>(lev, boxArray(lev), DistributionMap(lev),
Expand All @@ -286,7 +283,7 @@ WarpX::InitPML ()
do_moving_window, pml_has_particles, do_pml_in_domain,
do_multi_J, do_pml_dive_cleaning, do_pml_divb_cleaning,
guard_cells.ng_FieldSolver.max(),
do_pml_Lo_MR, do_pml_Hi_MR);
do_pml_Lo[lev], do_pml_Hi[lev]);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/WarpX.H
Original file line number Diff line number Diff line change
Expand Up @@ -1136,8 +1136,8 @@ private:
static int do_similar_dm_pml;
bool do_pml_dive_cleaning; // default set in WarpX.cpp
bool do_pml_divb_cleaning; // default set in WarpX.cpp
amrex::IntVect do_pml_Lo = amrex::IntVect::TheZeroVector();
amrex::IntVect do_pml_Hi = amrex::IntVect::TheZeroVector();
amrex::Vector<amrex::IntVect> do_pml_Lo;
amrex::Vector<amrex::IntVect> do_pml_Hi;
amrex::Vector<std::unique_ptr<PML> > pml;
#if (defined WARPX_DIM_RZ) && (defined WARPX_USE_PSATD)
amrex::Vector<std::unique_ptr<PML_RZ> > pml_rz;
Expand Down
8 changes: 6 additions & 2 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ WarpX::WarpX ()
#if (defined WARPX_DIM_RZ) && (defined WARPX_USE_PSATD)
pml_rz.resize(nlevs_max);
#endif

do_pml_Lo.resize(nlevs_max);
do_pml_Hi.resize(nlevs_max);

costs.resize(nlevs_max);
load_balance_efficiency.resize(nlevs_max);

Expand Down Expand Up @@ -2326,8 +2330,8 @@ WarpX::getPMLdirections() const
{
for( int i = 0; i < static_cast<int>(dirsWithPML.size()) / 2; ++i )
{
dirsWithPML.at( 2u*i ) = bool(do_pml_Lo[i]);
dirsWithPML.at( 2u*i + 1u ) = bool(do_pml_Hi[i]);
dirsWithPML.at( 2u*i ) = bool(do_pml_Lo[0][i]); // on level 0
dirsWithPML.at( 2u*i + 1u ) = bool(do_pml_Hi[0][i]); // on level 0
}
}
return dirsWithPML;
Expand Down

0 comments on commit d9faf00

Please sign in to comment.