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,
"'");
70 template <
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)
161 if (!dynamic_cast<TimeSequenceStepperBase *>(ts))
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)
187 if (
auto tss = dynamic_cast<TimeSequenceStepperBase *>(ts))
188 time_sequence_steppers.push_back(tss);
190 if (time_sequence_steppers.empty())
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)
240 std::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;
TimeStepper * _largest_bound_time_stepper
static InputParameters compositionDTParams()
TransientBase & _executioner
Reference to transient executioner.
static InputParameters validParams()
virtual void preStep() override final
virtual void rejectStep() override final
This gets called when time step is rejected for all input time steppers.
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 ...
TimeStepper * _current_time_stepper
const bool _has_initial_dt
TimeSequenceStepperBase * _closest_time_sequence_stepper
virtual void postStep() override final
virtual void preSolve() override final
registerMooseObject("MooseApp", CompositionDT)
void actOnTimeSteppers(Lambda &&act)
Base class for time stepping.
virtual void step() override final
Functions called after the current DT is computed.
virtual bool constrainStep(Real &dt)
Called after computeStep() is called.
virtual bool converged() const
If the time step converged.
auto max(const L &left, const R &right)
static InputParameters validParams()
Comparator for sorting by the value of dt for the TimeStepper sets which stored the pairs of the dt a...
FEProblemBase & _fe_problem
A TimeStepper that takes time steppers as inputs and computes the minimum time step size among all ti...
virtual bool converged() const override final
The _current_time_stepper is used to check whether convergence was reached on the time step...
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...
TheWarehouse & theWarehouse() const
virtual void preExecute() override final
virtual void acceptStep() override final
This gets called when time step is accepted for all input time steppers.
bool testCheckpointHalfTransient() const
Whether or not this simulation should only run half its transient (useful for testing recovery) ...
MooseApp & _app
The MOOSE application this is associated with.
const std::set< std::string > _lower_bound
std::vector< TimeStepper * > getTimeSteppers()
Internal method for querying TheWarehouse for the currently active timesteppers.
CompositionDT(const InputParameters ¶meters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real & endTime()
Get a modifiable reference to the end time.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Real getSequenceSteppersNextTime()
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...
virtual void step()
Take a time step.
virtual Real computeDT() override final
Computes time step size after the initial time step.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
virtual void postExecute() override final
virtual void init() override final
Initialize all the input time stepper(s).
virtual Real computeInitialDT() override final
Computes time step size for the initial time step.
unsigned int _failure_count
Cumulative amount of steps that have failed.
auto min(const L &left, const R &right)
Real & _time
Values from executioner.
virtual bool constrainStep(Real &dt) override final
Called after computeStep() is called.
virtual void postSolve() override final