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)
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;
161 std::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;
TransientBase & _executioner
Reference to transient executioner.
static InputParameters validParams()
Real & _timestep_tolerance
std::vector< Real > buildSequence(const std::vector< Real > ×) const
Build the canonical time sequence for the current start and end times.
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 ...
virtual void refreshSequence()
Re-read a time sequence source that can change during the simulation.
unsigned int & _current_step
the step that the time stepper is currently at
Base class for time stepping.
TimeSequenceStepperBase(const InputParameters ¶meters)
Real getStartTime() const
Return the start time.
void synchronizeCurrentStep(Real time, Real tolerance)
Set the current sequence position from time.
void setupSequence(const std::vector< Real > ×)
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 increaseCurrentStep()
bool isRestarting() const
Whether or not this is a "restart" calculation.
const bool _set_end_time
Whether to use the last t in sequence as Executioner end_time.
virtual void acceptStep()
This gets called when time step is accepted.
virtual Real getNextTimeInSequence()
Get the next time in the input time sequence.
std::vector< Real > & _time_sequence
stores the sequence of time points
bool testCheckpointHalfTransient() const
Whether or not this simulation should only run half its transient (useful for testing recovery) ...
constexpr bool is_sorted()
Check if the given index sequence is sorted ()internal function)
MooseApp & _app
The MOOSE application this is associated with.
virtual Real computeDT() override
Computes time step size after the initial time step.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real & endTime()
Get a modifiable reference to the end time.
virtual Real computeInitialDT() override
Computes time step size for the initial time step.
static InputParameters validParams()
const bool _use_last_dt_after_last_t
Whether to use the final dt past the last t in sequence.
IntRange< T > make_range(T beg, T end)
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 acceptStep() override
This gets called when time step is accepted.
bool isRecovering() const
Whether or not this is a "recover" calculation.
void ErrorVector unsigned int
Real & _time
Values from executioner.
void updateSequence(const std::vector< Real > ×)