OGS
TimeStepAlgorithm.cpp
Go to the documentation of this file.
1 
10 #include "TimeStepAlgorithm.h"
11 
12 #include <algorithm>
13 #include <limits>
14 
15 namespace NumLib
16 {
18  double const t, double const dt,
19  std::vector<double> const& fixed_output_times)
20 {
21  auto const specific_time = std::upper_bound(
22  std::cbegin(fixed_output_times), std::cend(fixed_output_times), t);
23 
24  if (specific_time == std::cend(fixed_output_times))
25  {
26  return dt;
27  }
28 
29  double const t_to_specific_time = *specific_time - t;
30  if ((t_to_specific_time > std::numeric_limits<double>::epsilon()) &&
31  (t + dt - *specific_time > 0.0))
32  {
33  return t_to_specific_time;
34  }
35 
36  return dt;
37 }
38 } // namespace NumLib
double possiblyClampDtToNextFixedTime(double const t, double const dt, std::vector< double > const &fixed_output_times)