Skip to content

Commit 59432e8

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

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

Source/Evolve/WarpXComputeDt.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ WarpX::ComputeDt ()
4848
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(m_const_dt.has_value(), "warpx.const_dt must be specified with the hybrid-PIC solver.");
4949
} else if (electromagnetic_solver_id == ElectromagneticSolverAlgo::None) {
5050
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
51-
m_const_dt.has_value() || dt_update_interval.isActivated(),
51+
m_const_dt.has_value() || m_dt_update_interval.isActivated(),
5252
"warpx.const_dt must be specified with the electrostatic solver, or warpx.dt_update_interval must be > 0."
5353
);
5454
}

Source/Evolve/WarpXEvolve.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ WarpX::Evolve (int numsteps)
130130
// Update timestep for electrostatic solver if a constant dt is not provided
131131
// This first synchronizes the position and velocity before setting the new timestep
132132
if (electromagnetic_solver_id == ElectromagneticSolverAlgo::None &&
133-
!m_const_dt.has_value() && dt_update_interval.contains(step+1)) {
133+
!m_const_dt.has_value() && m_dt_update_interval.contains(step+1)) {
134134
if (verbose) {
135135
amrex::Print() << Utils::TextMsg::Info("updating timestep");
136136
}

Source/WarpX.H

+1-1
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ private:
13891389
amrex::Vector<amrex::Real> t_new;
13901390
amrex::Vector<amrex::Real> t_old;
13911391
amrex::Vector<amrex::Real> dt;
1392-
static utils::parser::IntervalsParser dt_update_interval; // How often to update the timestep when using adaptive timestepping
1392+
utils::parser::IntervalsParser m_dt_update_interval = utils::parser::IntervalsParser{}; // How often to update the timestep when using adaptive timestepping
13931393

13941394
// Particle container
13951395
std::unique_ptr<MultiParticleContainer> mypc;

Source/WarpX.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ bool WarpX::do_multi_J = false;
182182
int WarpX::do_multi_J_n_depositions;
183183
bool WarpX::safe_guard_cells = false;
184184

185-
utils::parser::IntervalsParser WarpX::dt_update_interval;
186-
187185
std::map<std::string, amrex::iMultiFab *> WarpX::imultifab_map;
188186

189187
IntVect WarpX::filter_npass_each_dir(1);
@@ -740,7 +738,7 @@ WarpX::ReadParameters ()
740738
utils::parser::queryWithParser(pp_warpx, "max_dt", m_max_dt);
741739
std::vector<std::string> dt_interval_vec = {"-1"};
742740
pp_warpx.queryarr("dt_update_interval", dt_interval_vec);
743-
dt_update_interval = utils::parser::IntervalsParser(dt_interval_vec);
741+
m_dt_update_interval = utils::parser::IntervalsParser(dt_interval_vec);
744742

745743
// Filter defaults to true for the explicit scheme, and false for the implicit schemes
746744
if (evolve_scheme != EvolveScheme::Explicit) {

0 commit comments

Comments
 (0)