24 double const solution_error,
int const ,
27 const bool is_previous_step_accepted = timestep_current.
isAccepted();
29 const double e_n = solution_error;
30 const double zero_threshold = std::numeric_limits<double>::epsilon();
36 double h_new = (e_n > zero_threshold)
37 ? timestep_current.
dt() *
_tol / e_n
38 : 0.5 * timestep_current.
dt();
41 limitStepSize(h_new, is_previous_step_accepted, timestep_current);
44 "This step is rejected due to the relative change from the"
45 " solution of the previous\n"
46 "\t time step to the current solution exceeds the given tolerance"
48 "\t This time step will be repeated with a new time step size of"
50 "\t or the simulation will be halted.",
53 return std::make_tuple(timestep_current.
isAccepted(), h_new);
67 const double h_n = timestep_current.
dt();
70 if (e_n > zero_threshold)
86 std::pow(
_tol / e_n,
_kI) * h_n;
91 h_new = std::pow(
_tol / e_n,
_kI) * h_n;
96 limitStepSize(h_new, is_previous_step_accepted, timestep_current);
101 return std::make_tuple(timestep_current.
isAccepted(), h_new);
106 const double h_new,
const bool previous_step_accepted,
109 const double h_n = timestep_current.
dt();
112 const double h_in_range = std::max(
_h_min, std::min(h_new,
_h_max));
117 if (!previous_step_accepted)
122 if (std::abs(limited_h - timestep_current.
dt()) <
123 std::numeric_limits<double>::min())
125 limited_h = std::max(
_h_min, 0.5 * limited_h);
134 if (limited_h > timestep_current.
dt())
136 limited_h = std::max(
_h_min, 0.5 * timestep_current.
dt());
147 auto fixed_output_time_it = std::find_if(
149 [×tep_current](
auto const fixed_output_time)
150 {
return timestep_current.
current() <
Time{fixed_output_time}; });
156 if (
Time{*fixed_output_time_it} <
157 timestep_current.
current() + limited_h)
160 if (std::abs(*fixed_output_time_it - timestep_current.
current()()) >
161 std::numeric_limits<double>::epsilon() *
164 return *fixed_output_time_it - timestep_current.
current()();
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
const double _h_max
maximum step size.
std::vector< double > const _fixed_times_for_output
const double _kD
Parameter.
std::tuple< bool, double > next(double solution_error, int number_iterations, NumLib::TimeStep ×tep_previous, NumLib::TimeStep ×tep_current) override
const double _rel_h_min
in
const double _kI
Parameter.
const double _kP
Parameter.
const double _h_min
minimum step size.
virtual 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.
double limitStepSize(const double h_new, const bool previous_step_accepted, NumLib::TimeStep const ×tep_current) const
const double _h0
initial time step size.
const double _rel_h_max
in
void setAccepted(bool const accepted)
Time current() const
return current time step
double dt() const
time step size from _previous
std::size_t timeStepNumber() const
the time step number
bool canReduceTimestepSize(TimeStep const ×tep_previous, TimeStep const ×tep_current, double const min_dt)