21 double const t_initial,
double const t_end,
double const min_dt,
22 double const max_dt,
double const initial_dt,
24 std::vector<int>&& iter_times_vector,
25 std::vector<double>&& multiplier_vector,
26 std::vector<double>
const& fixed_times_for_output)
39 OGS_FATAL(
"Vector of iteration numbers must not be empty.");
44 "Vector of iteration numbers must be of the same size as the "
45 "vector of multipliers.");
50 OGS_FATAL(
"Vector of iteration numbers must be sorted.");
55 int const number_iterations,
63 ts_previous = ts_current;
76 if (std::abs(dt - ts_current.
dt()) < std::numeric_limits<double>::epsilon())
96 int const number_iterations,
bool const current_time_step_is_accepted,
97 std::vector<int>
const& nonlinear_iteration_numbers,
98 std::vector<double>
const& multipliers,
101 double const multiplier = [&]
103 switch (multiplier_interpolation_type)
108 nonlinear_iteration_numbers, multipliers,
false);
109 return pwli.getValue(number_iterations);
113 auto const& piecewise_constant_interpolation =
115 nonlinear_iteration_numbers, multipliers);
116 return piecewise_constant_interpolation.value(
120 OGS_FATAL(
"Unknown multiplier interpolation type.");
123 if (!current_time_step_is_accepted && (multiplier >= 1.0))
125 return *std::min_element(multipliers.begin(), multipliers.end());
147 dt = ts_previous.
dt() *
163 auto fixed_output_time_it = std::find_if(
165 [&ts_current](
auto const fixed_output_time)
166 {
return ts_current.
current()() < fixed_output_time; });
172 if (*fixed_output_time_it < ts_current.
current()() + dt)
175 if (std::abs(*fixed_output_time_it - ts_current.
current()()) >
176 std::numeric_limits<double>::epsilon() * ts_current.
current()())
178 return *fixed_output_time_it - ts_current.
current()();
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.
const int _max_iter
The maximum allowed iteration number to accept current time step.
TimeStepAlgorithm(const double t0, const double t_end)
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