Skip to content

Commit 7790292

Browse files
authored
WarpX class: make safe_guard_cells a private member variable (#5599)
This PR changes `safe_guard_cells` from a static WarpX class variable to a private member variable (renamed `m_safe_guard_cells`). This is a small step towards reducing the use of static variables in the WarpX class.
1 parent 59432e8 commit 7790292

File tree

5 files changed

+53
-51
lines changed

5 files changed

+53
-51
lines changed

Source/Evolve/WarpXEvolve.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ WarpX::OneStep_nosub (Real cur_time)
446446

447447
// E and B are up-to-date in the domain, but all guard cells are
448448
// outdated.
449-
if (safe_guard_cells) {
449+
if (m_safe_guard_cells) {
450450
FillBoundaryB(guard_cells.ng_alloc_EB);
451451
}
452452
} // !PSATD
@@ -978,7 +978,7 @@ WarpX::OneStep_sub1 (Real cur_time)
978978
FillBoundaryE(fine_lev, PatchType::fine, guard_cells.ng_FieldSolver);
979979
}
980980

981-
if ( safe_guard_cells ) {
981+
if ( m_safe_guard_cells ) {
982982
FillBoundaryF(fine_lev, PatchType::fine, guard_cells.ng_FieldSolver);
983983
}
984984
FillBoundaryB(fine_lev, PatchType::fine, guard_cells.ng_FieldSolver);
@@ -1034,12 +1034,12 @@ WarpX::OneStep_sub1 (Real cur_time)
10341034
WarpX::sync_nodal_points);
10351035
}
10361036
DampPML(coarse_lev, PatchType::fine);
1037-
if ( safe_guard_cells ) {
1037+
if ( m_safe_guard_cells ) {
10381038
FillBoundaryE(coarse_lev, PatchType::fine, guard_cells.ng_FieldSolver,
10391039
WarpX::sync_nodal_points);
10401040
}
10411041
}
1042-
if ( safe_guard_cells ) {
1042+
if ( m_safe_guard_cells ) {
10431043
FillBoundaryB(coarse_lev, PatchType::fine, guard_cells.ng_FieldSolver,
10441044
WarpX::sync_nodal_points);
10451045
}

Source/Parallelization/WarpXComm.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ WarpX::FillBoundaryE (const int lev, const PatchType patch_type, const amrex::In
756756
ng.allLE(mf[i]->nGrowVect()),
757757
"Error: in FillBoundaryE, requested more guard cells than allocated");
758758

759-
const amrex::IntVect nghost = (safe_guard_cells) ? mf[i]->nGrowVect() : ng;
759+
const amrex::IntVect nghost = (m_safe_guard_cells) ? mf[i]->nGrowVect() : ng;
760760
ablastr::utils::communication::FillBoundary(*mf[i], nghost, WarpX::do_single_precision_comms, period, nodal_sync);
761761
}
762762
}
@@ -821,7 +821,7 @@ WarpX::FillBoundaryB (const int lev, const PatchType patch_type, const amrex::In
821821
ng.allLE(mf[i]->nGrowVect()),
822822
"Error: in FillBoundaryB, requested more guard cells than allocated");
823823

824-
const amrex::IntVect nghost = (safe_guard_cells) ? mf[i]->nGrowVect() : ng;
824+
const amrex::IntVect nghost = (m_safe_guard_cells) ? mf[i]->nGrowVect() : ng;
825825
ablastr::utils::communication::FillBoundary(*mf[i], nghost, WarpX::do_single_precision_comms, period, nodal_sync);
826826
}
827827
}
@@ -846,7 +846,7 @@ WarpX::FillBoundaryE_avg (int lev, PatchType patch_type, IntVect ng)
846846
ablastr::fields::MultiLevelVectorField Efield_avg_fp = m_fields.get_mr_levels_alldirs(FieldType::Efield_avg_fp, finest_level);
847847

848848
const amrex::Periodicity& period = Geom(lev).periodicity();
849-
if ( safe_guard_cells ){
849+
if ( m_safe_guard_cells ){
850850
const Vector<MultiFab*> mf{Efield_avg_fp[lev][0],Efield_avg_fp[lev][1],Efield_avg_fp[lev][2]};
851851
ablastr::utils::communication::FillBoundary(mf, WarpX::do_single_precision_comms, period);
852852
} else {
@@ -868,7 +868,7 @@ WarpX::FillBoundaryE_avg (int lev, PatchType patch_type, IntVect ng)
868868
ablastr::fields::MultiLevelVectorField Efield_avg_cp = m_fields.get_mr_levels_alldirs(FieldType::Efield_avg_cp, finest_level);
869869

870870
const amrex::Periodicity& cperiod = Geom(lev-1).periodicity();
871-
if ( safe_guard_cells ) {
871+
if ( m_safe_guard_cells ) {
872872
const Vector<MultiFab*> mf{Efield_avg_cp[lev][0],Efield_avg_cp[lev][1],Efield_avg_cp[lev][2]};
873873
ablastr::utils::communication::FillBoundary(mf, WarpX::do_single_precision_comms, cperiod);
874874

@@ -906,7 +906,7 @@ WarpX::FillBoundaryB_avg (int lev, PatchType patch_type, IntVect ng)
906906
ablastr::fields::MultiLevelVectorField Bfield_avg_fp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_avg_fp, finest_level);
907907

908908
const amrex::Periodicity& period = Geom(lev).periodicity();
909-
if ( safe_guard_cells ) {
909+
if ( m_safe_guard_cells ) {
910910
const Vector<MultiFab*> mf{Bfield_avg_fp[lev][0],Bfield_avg_fp[lev][1],Bfield_avg_fp[lev][2]};
911911
ablastr::utils::communication::FillBoundary(mf, WarpX::do_single_precision_comms, period);
912912
} else {
@@ -928,7 +928,7 @@ WarpX::FillBoundaryB_avg (int lev, PatchType patch_type, IntVect ng)
928928
ablastr::fields::MultiLevelVectorField Bfield_avg_cp = m_fields.get_mr_levels_alldirs(FieldType::Bfield_avg_cp, finest_level);
929929

930930
const amrex::Periodicity& cperiod = Geom(lev-1).periodicity();
931-
if ( safe_guard_cells ){
931+
if ( m_safe_guard_cells ){
932932
const Vector<MultiFab*> mf{Bfield_avg_cp[lev][0],Bfield_avg_cp[lev][1],Bfield_avg_cp[lev][2]};
933933
ablastr::utils::communication::FillBoundary(mf, WarpX::do_single_precision_comms, cperiod);
934934
} else {
@@ -967,7 +967,7 @@ WarpX::FillBoundaryF (int lev, PatchType patch_type, IntVect ng, std::optional<b
967967
if (m_fields.has(FieldType::F_fp, lev))
968968
{
969969
const amrex::Periodicity& period = Geom(lev).periodicity();
970-
const amrex::IntVect& nghost = (safe_guard_cells) ? m_fields.get(FieldType::F_fp, lev)->nGrowVect() : ng;
970+
const amrex::IntVect& nghost = (m_safe_guard_cells) ? m_fields.get(FieldType::F_fp, lev)->nGrowVect() : ng;
971971
ablastr::utils::communication::FillBoundary(*m_fields.get(FieldType::F_fp, lev), nghost, WarpX::do_single_precision_comms, period, nodal_sync);
972972
}
973973
}
@@ -986,7 +986,7 @@ WarpX::FillBoundaryF (int lev, PatchType patch_type, IntVect ng, std::optional<b
986986
if (m_fields.has(FieldType::F_cp, lev))
987987
{
988988
const amrex::Periodicity& period = Geom(lev-1).periodicity();
989-
const amrex::IntVect& nghost = (safe_guard_cells) ? m_fields.get(FieldType::F_cp, lev)->nGrowVect() : ng;
989+
const amrex::IntVect& nghost = (m_safe_guard_cells) ? m_fields.get(FieldType::F_cp, lev)->nGrowVect() : ng;
990990
ablastr::utils::communication::FillBoundary(*m_fields.get(FieldType::F_cp, lev), nghost, WarpX::do_single_precision_comms, period, nodal_sync);
991991
}
992992
}
@@ -1020,7 +1020,7 @@ void WarpX::FillBoundaryG (int lev, PatchType patch_type, IntVect ng, std::optio
10201020
{
10211021
const amrex::Periodicity& period = Geom(lev).periodicity();
10221022
MultiFab* G_fp = m_fields.get(FieldType::G_fp,lev);
1023-
const amrex::IntVect& nghost = (safe_guard_cells) ? G_fp->nGrowVect() : ng;
1023+
const amrex::IntVect& nghost = (m_safe_guard_cells) ? G_fp->nGrowVect() : ng;
10241024
ablastr::utils::communication::FillBoundary(*G_fp, nghost, WarpX::do_single_precision_comms, period, nodal_sync);
10251025
}
10261026
}
@@ -1040,7 +1040,7 @@ void WarpX::FillBoundaryG (int lev, PatchType patch_type, IntVect ng, std::optio
10401040
{
10411041
const amrex::Periodicity& period = Geom(lev-1).periodicity();
10421042
MultiFab* G_cp = m_fields.get(FieldType::G_cp,lev);
1043-
const amrex::IntVect& nghost = (safe_guard_cells) ? G_cp->nGrowVect() : ng;
1043+
const amrex::IntVect& nghost = (m_safe_guard_cells) ? G_cp->nGrowVect() : ng;
10441044
ablastr::utils::communication::FillBoundary(*G_cp, nghost, WarpX::do_single_precision_comms, period, nodal_sync);
10451045
}
10461046
}

0 commit comments

Comments
 (0)