22 "use_last_dt_after_last_t",
24 "If true, uses the final time step size for times after the last time in the sequence, "
25 "instead of taking a single step directly to the simulation end time");
27 "use_last_t_for_end_time",
false,
"Use last time in sequence as 'end_time' in Executioner.");
33 _use_last_dt_after_last_t(getParam<bool>(
"use_last_dt_after_last_t")),
34 _current_step(declareRestartableData<unsigned
int>(
"current_step", 0)),
35 _time_sequence(declareRestartableData<
std::vector<Real>>(
"time_sequence")),
36 _set_end_time(getParam<bool>(
"use_last_t_for_end_time"))
56 "The recovered current step must identify the last reached sequence time");
60 mooseError(
"Timesequencestepper does not allow the start time to be modified.");
66 const auto completed_prefix_size = [
this](
const auto & sequence)
68 return std::distance(sequence.begin(),
69 std::find_if(sequence.begin(),
71 [
this](
const auto sequence_time)
72 { return sequence_time - _time > _timestep_tolerance; }));
75 const auto saved_prefix_size = completed_prefix_size(
_time_sequence);
76 const auto current_prefix_size = completed_prefix_size(current_input_sequence);
77 if (current_prefix_size != saved_prefix_size)
78 mooseError(
"The timesequence provided in the restart file must be identical to "
79 "the one in the old file through the restart time, but it contains ",
81 " completed value(s) instead of ",
85 for (
const auto j : make_range(saved_prefix_size))
86 if (!MooseUtils::absoluteFuzzyEqual(current_input_sequence[j],
_time_sequence[j]))
87 mooseError(
"The timesequence provided in the restart file must be identical to "
88 "the one in the old file through the restart time, but entry ",
91 current_input_sequence[j],
92 " in the restart input and ",
94 " in the restarted input.");
121 if (!std::is_sorted(times.begin(), times.end(), std::less_equal<Real>()))
122 paramError(
"time_sequence",
"Time points must be in strictly ascending order.");
124 std::vector<Real> sequence{start_time};
125 for (
const auto time : times)
126 if (time > start_time && time <= end_time)
127 sequence.push_back(time);
131 sequence.push_back(end_time);
157 next_time = *first_future;
161std::vector<Real>::const_iterator
166 [time, tolerance](
const auto sequence_time)
167 { return sequence_time - time <= tolerance; });
177 :
static_cast<unsigned int>(std::distance(
_time_sequence.cbegin(), first_future) - 1);
185 "The time sequence must contain a future time");
210 "The time sequence must contain a future time");
221 return next_time -
_time;
void ErrorVector unsigned int
bool isRestarting() const
Whether or not this is a "restart" calculation.
bool isRecovering() const
Whether or not this is a "recover" calculation.
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.
TimeSequenceStepperBase(const InputParameters ¶meters)
bool advanceToFutureTime(Real time, Real tolerance, Real &next_time)
Return the first sequence time that has not yet been reached, if any.
std::vector< Real >::const_iterator findFirstFutureTime(Real time, Real tolerance) const
Find the first sequence time greater than time by more than tolerance.
void updateSequence(const std::vector< Real > ×)
virtual void acceptStep() override
This gets called when time step is accepted.
virtual void refreshSequence()
Re-read a time sequence source that can change during the simulation.
void setupSequence(const std::vector< Real > ×)
void increaseCurrentStep()
virtual Real computeInitialDT() override
Computes time step size for the initial time step.
const bool _set_end_time
Whether to use the last t in sequence as Executioner end_time.
unsigned int & _current_step
the step that the time stepper is currently at
virtual Real computeDT() override
Computes time step size after the initial time step.
static InputParameters validParams()
void synchronizeCurrentStep(Real time, Real tolerance)
Set the current sequence position from time.
std::vector< Real > & _time_sequence
stores the sequence of time points
const bool _use_last_dt_after_last_t
Whether to use the final dt past the last t in sequence.
std::vector< Real > buildSequence(const std::vector< Real > ×) const
Build the canonical time sequence for the current start and end times.
virtual Real getNextTimeInSequence()
Get the next time in the input time sequence.
Base class for time stepping.
static InputParameters validParams()
virtual void acceptStep()
This gets called when time step is accepted.
TransientBase & _executioner
Reference to transient executioner.
Real & _timestep_tolerance
Real & _time
Values from executioner.
Real getStartTime() const
Return the start time.
Real & endTime()
Get a modifiable reference to the end time.