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>
125 for (
auto & ts : time_steppers)
126 if (ts->constrainStep(dt))
128 return at_sync_point;
143 if (time_steppers.size() < 1)
144 mooseError(
"No TimeStepper(s) are currently active to compute a timestep");
146 std::set<std::pair<Real, TimeStepper *>,
CompareFirst> dts, bound_dt;
148 for (
auto & ts : time_steppers)
149 if (!dynamic_cast<TimeSequenceStepperBase *>(ts))
152 const auto dt = ts->getCurrentDT();
155 bound_dt.emplace(dt, ts);
173 std::vector<TimeSequenceStepperBase *> time_sequence_steppers;
174 for (
auto & ts : time_steppers)
175 if (
auto tss = dynamic_cast<TimeSequenceStepperBase *>(ts))
176 time_sequence_steppers.push_back(tss);
178 if (time_sequence_steppers.empty())
182 for (
auto & tss : time_sequence_steppers)
184 Real ts_time_to_hit = tss->getNextTimeInSequence();
187 tss->increaseCurrentStep();
188 ts_time_to_hit = tss->getNextTimeInSequence();
190 if (next_time_to_hit > ts_time_to_hit)
193 next_time_to_hit = ts_time_to_hit;
196 return next_time_to_hit;
201 std::set<std::pair<Real, TimeStepper *>,
CompareFirst> & dts,
202 std::set<std::pair<Real, TimeStepper *>,
CompareFirst> & bound_dts)
204 Real minDT, lower_bound, dt;
205 minDT = lower_bound = dt = 0.0;
207 minDT = dts.begin()->first;
208 if (!bound_dts.empty())
209 lower_bound = bound_dts.rbegin()->first;
211 if (minDT > lower_bound)
221 if (ts != 0 && (ts -
_time) < dt)
230 std::vector<TimeStepper *>
233 std::vector<TimeStepper *> time_steppers;
237 .queryInto(time_steppers);
240 time_steppers.erase(std::remove(time_steppers.begin(), time_steppers.end(),
this),
241 time_steppers.end());
242 return time_steppers;
TimeStepper * _largest_bound_time_stepper
static InputParameters compositionDTParams()
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.
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
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