29 double const t_initial,
double const t_end,
double const min_dt,
30 double const max_dt,
double const initial_dt,
32 std::vector<int>&& iter_times_vector,
33 std::vector<double>&& multiplier_vector,
34 std::vector<double>
const& fixed_times_for_output)
36 _iter_times_vector(std::move(iter_times_vector)),
37 _multiplier_vector(std::move(multiplier_vector)),
40 _initial_dt(initial_dt),
41 _multiplier_interpolation_type(multiplier_interpolation_type),
42 _max_iter(_iter_times_vector.empty() ? 0 : _iter_times_vector.back()),
43 _fixed_times_for_output(fixed_times_for_output)
47 OGS_FATAL(
"Vector of iteration numbers must not be empty.");
52 "Vector of iteration numbers must be of the same size as the "
53 "vector of multipliers.");
58 OGS_FATAL(
"Vector of iteration numbers must be sorted.");
63 int const number_iterations,
71 ts_previous = ts_current;
84 if (std::abs(dt - ts_current.
dt()) < std::numeric_limits<double>::epsilon())
104 int const number_iterations,
bool const current_time_step_is_accepted,
105 std::vector<int>
const& nonlinear_iteration_numbers,
106 std::vector<double>
const& multipliers,
109 double multiplier = multipliers.front();
110 switch (multiplier_interpolation_type)
115 nonlinear_iteration_numbers, multipliers,
false);
116 multiplier = pwli.getValue(number_iterations);
117 DBUG(
"Using piecewise linear iteration-based time stepping.");
121 DBUG(
"Using piecewise constant iteration-based time stepping.");
122 auto const& piecewise_constant_interpolation =
124 nonlinear_iteration_numbers, multipliers);
126 piecewise_constant_interpolation.value(number_iterations);
130 if (!current_time_step_is_accepted && (multiplier >= 1.0))
132 return *std::min_element(multipliers.begin(), multipliers.end());
154 dt = ts_previous.
dt() *
170 auto fixed_output_time_it = std::find_if(
172 [&ts_current](
auto const fixed_output_time)
173 {
return ts_current.
current()() < fixed_output_time; });
179 if (*fixed_output_time_it < ts_current.
current()() + dt)
182 if (std::abs(*fixed_output_time_it - ts_current.
current()()) >
183 std::numeric_limits<double>::epsilon() * ts_current.
current()())
185 return *fixed_output_time_it - ts_current.
current()();
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the PiecewiseConstantInterpolation class.
Definition of the PiecewiseLinearInterpolation class.
IterationNumberBasedTimeStepping(double const t_initial, double const t_end, double const min_dt, double const max_dt, double const initial_dt, MultiplyerInterpolationType const multiplier_interpolation_type, std::vector< int > &&iter_times_vector, std::vector< double > &&multiplier_vector, std::vector< double > const &fixed_times_for_output)
double next(double solution_error, int number_iterations, NumLib::TimeStep &ts_previous, NumLib::TimeStep &ts_current) override
const MultiplyerInterpolationType _multiplier_interpolation_type
Interpolation type for the multiplier.
std::vector< double > const _fixed_times_for_output
double getNextTimeStepSize(NumLib::TimeStep const &ts_previous, NumLib::TimeStep const &ts_current) const
Calculate the next time step size.
const double _max_dt
The maximum allowed time step size.
const std::vector< double > _multiplier_vector
This vector stores the multiplier coefficients.
const std::vector< int > _iter_times_vector
bool canReduceTimestepSize(NumLib::TimeStep const ×tep_previous, NumLib::TimeStep const ×tep_current) const override
Query the timestepper if further time step size reduction is possible.
int _iter_times
The number of nonlinear iterations.
const double _min_dt
The minimum allowed time step size.
const double _initial_dt
Initial time step size.
Interface of time stepping algorithms.
void setAccepted(bool const accepted)
Time current() const
return current time step
Time previous() const
return previous time step
double dt() const
time step size from _previous
std::size_t timeStepNumber() const
the time step number
double findMultiplier(int const number_iterations, bool const current_time_step_is_accepted, std::vector< int > const &nonlinear_iteration_numbers, std::vector< double > const &multipliers, MultiplyerInterpolationType const multiplier_interpolation_type)
Find a multiplier for the given number of iterations.
bool canReduceTimestepSize(TimeStep const ×tep_previous, TimeStep const ×tep_current, double const min_dt)
MultiplyerInterpolationType