OGS
TimeStepAlgorithm.cpp
Go to the documentation of this file.
1
9
10#include "TimeStepAlgorithm.h"
11
12#include <range/v3/algorithm/upper_bound.hpp>
13
15
16namespace NumLib
17{
19 Time const& t, double const dt,
20 std::vector<double> const& fixed_output_times)
21{
22 auto const specific_time = ranges::upper_bound(
23 fixed_output_times, t, ranges::less{}, [](auto t) { return Time(t); });
24
25 if (specific_time == ranges::cend(fixed_output_times))
26 {
27 return dt;
28 }
29
30 Time const fixed_output_time(*specific_time);
31 if ((t < fixed_output_time) && (t + dt) > fixed_output_time)
32 {
33 double const t_to_specific_time = fixed_output_time() - t();
34 return t_to_specific_time;
35 }
36
37 return dt;
38}
39
40bool canReduceTimestepSize(TimeStep const& timestep_previous,
41 TimeStep const& timestep_current,
42 double const min_dt)
43{
44 return !(timestep_current.dt() == min_dt &&
45 timestep_previous.dt() == min_dt);
46}
47} // namespace NumLib
Time step object.
Definition TimeStep.h:33
double dt() const
time step size from _previous
Definition TimeStep.h:82
double possiblyClampDtToNextFixedTime(Time const &t, double const dt, std::vector< double > const &fixed_output_times)
bool canReduceTimestepSize(TimeStep const &timestep_previous, TimeStep const &timestep_current, double const min_dt)