OGS
TimeStepAlgorithm.cpp
Go to the documentation of this file.
1
10#include "TimeStepAlgorithm.h"
11
12#include <algorithm>
13#include <limits>
14
16
17namespace NumLib
18{
20 Time const& t, double const dt,
21 std::vector<double> const& fixed_output_times)
22{
23 auto const specific_time = std::upper_bound(
24 std::cbegin(fixed_output_times), std::cend(fixed_output_times), t());
25
26 if (specific_time == std::cend(fixed_output_times))
27 {
28 return dt;
29 }
30
31 if ((t < Time(*specific_time)) && t + dt > Time(*specific_time))
32 {
33 double const t_to_specific_time = *specific_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:31
double dt() const
time step size from _previous
Definition TimeStep.h:80
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)