26 params.addParam<Real>(
"initial_dt",
"Initial value of dt");
27 params.addParam<std::vector<std::string>>(
30 "The maximum of these TimeSteppers will form the lower bound on the time "
31 "step size. A single or multiple time steppers may be specified.");
42 params.
addClassDescription(
"The time stepper takes all the other time steppers as input and "
43 "returns the minimum time step size.");
50 _has_initial_dt(isParamValid(
"initial_dt")),
51 _initial_dt(_has_initial_dt ? getParam<Real>(
"initial_dt") : 0.),
52 _lower_bound(getParam<
std::vector<
std::string>>(
"lower_bound").begin(),
53 getParam<
std::vector<
std::string>>(
"lower_bound").end()),
54 _current_time_stepper(nullptr),
55 _largest_bound_time_stepper(nullptr),
56 _closest_time_sequence_stepper(nullptr)
61 if (std::find_if(time_steppers.begin(),
63 [&time_stepper_name](
const auto & ts)
64 { return ts->name() == time_stepper_name; }) == time_steppers.end() &&
67 "lower_bound",
"Failed to find a timestepper with the name '", time_stepper_name,
"'");
70template <
typename Lambda>
85 [
this, half_end_time](
auto & ts)
137 for (
auto & ts : time_steppers)
138 if (ts->constrainStep(dt))
140 return at_sync_point;
155 if (time_steppers.size() < 1)
156 mooseError(
"No TimeStepper(s) are currently active to compute a timestep");
158 std::set<std::pair<Real, TimeStepper *>,
CompareFirst> dts, bound_dt;
160 for (
auto & ts : time_steppers)
164 const auto dt = ts->getCurrentDT();
167 bound_dt.emplace(dt, ts);
185 std::vector<TimeSequenceStepperBase *> time_sequence_steppers;
186 for (
auto & ts : time_steppers)
188 time_sequence_steppers.push_back(tss);
190 if (time_sequence_steppers.empty())
193 Real next_time_to_hit = std::numeric_limits<Real>::max();
194 for (
auto & tss : time_sequence_steppers)
197 if (!tss->advanceToFutureTime(
_time,
_dt_min, ts_time_to_hit))
200 if (next_time_to_hit > ts_time_to_hit)
203 next_time_to_hit = ts_time_to_hit;
206 return next_time_to_hit;
211 std::set<std::pair<Real, TimeStepper *>,
CompareFirst> & dts,
212 std::set<std::pair<Real, TimeStepper *>,
CompareFirst> & bound_dts)
214 Real minDT, lower_bound, dt;
215 minDT = lower_bound = dt = 0.0;
217 minDT = dts.begin()->first;
218 if (!bound_dts.empty())
219 lower_bound = bound_dts.rbegin()->first;
221 if (minDT > lower_bound)
231 if (ts != 0 && (ts -
_time) < dt)
234 return std::min((ts -
_time), dt);
240std::vector<TimeStepper *>
243 std::vector<TimeStepper *> time_steppers;
247 .queryInto(time_steppers);
250 time_steppers.erase(std::remove(time_steppers.begin(), time_steppers.end(),
this),
251 time_steppers.end());
252 return time_steppers;
registerMooseObject("MooseApp", CompositionDT)
A TimeStepper that takes time steppers as inputs and computes the minimum time step size among all ti...
virtual void preStep() override final
virtual void preExecute() override final
virtual void postSolve() override final
virtual bool constrainStep(Real &dt) override final
Called after computeStep() is called.
virtual void step() override final
Functions called after the current DT is computed.
virtual void preSolve() override final
const bool _has_initial_dt
const std::set< std::string > _lower_bound
virtual void postExecute() override final
Real getSequenceSteppersNextTime()
CompositionDT(const InputParameters ¶meters)
TimeStepper * _current_time_stepper
Real produceCompositionDT(std::set< std::pair< Real, TimeStepper * >, CompareFirst > &dts, std::set< std::pair< Real, TimeStepper * >, CompareFirst > &bound_dts)
Find the composed time step size by selecting the minimum value and compare it with the lower bound i...
static InputParameters validParams()
virtual void postStep() override final
TimeSequenceStepperBase * _closest_time_sequence_stepper
std::vector< TimeStepper * > getTimeSteppers()
Internal method for querying TheWarehouse for the currently active timesteppers.
TimeStepper * _largest_bound_time_stepper
virtual bool converged() const override final
The _current_time_stepper is used to check whether convergence was reached on the time step.
virtual void rejectStep() override final
This gets called when time step is rejected for all input time steppers.
virtual void acceptStep() override final
This gets called when time step is accepted for all input time steppers.
virtual void init() override final
Initialize all the input time stepper(s).
virtual Real computeDT() override final
Computes time step size after the initial time step.
virtual Real computeInitialDT() override final
Computes time step size for the initial time step.
void actOnTimeSteppers(Lambda &&act)
static InputParameters compositionDTParams()
TheWarehouse & theWarehouse() const
bool testCheckpointHalfTransient() const
Whether or not this simulation should only run half its transient (useful for testing recovery)
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
MooseApp & _app
The MOOSE application this is associated with.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse.
Solves the PDEs at a sequence of given time points.
Base class for time stepping.
virtual bool converged() const
If the time step converged.
unsigned int _failure_count
Cumulative amount of steps that have failed.
FEProblemBase & _fe_problem
static InputParameters validParams()
TransientBase & _executioner
Reference to transient executioner.
virtual void step()
Take a time step.
virtual bool constrainStep(Real &dt)
Called after computeStep() is called.
Real & _time
Values from executioner.
Real & endTime()
Get a modifiable reference to the end time.
Comparator for sorting by the value of dt for the TimeStepper sets which stored the pairs of the dt a...