OGS
TimeStepAlgorithm.h
Go to the documentation of this file.
1
13#pragma once
14
15#include <cmath>
16#include <tuple>
17#include <vector>
18
19#include "BaseLib/Error.h"
21
22namespace NumLib
23{
24struct Time;
25
30{
31public:
32 TimeStepAlgorithm(const double t0, const double t_end)
33 : _t_initial(t0), _t_end(t_end)
34 {
35 }
36
37 virtual ~TimeStepAlgorithm() = default;
38
40 Time begin() const { return _t_initial; }
42 Time end() const { return _t_end; }
43
53 virtual std::tuple<bool, double> next(const double solution_error,
54 int number_iterations,
55 NumLib::TimeStep& ts_previous,
56 NumLib::TimeStep& ts_current) = 0;
57
60 virtual bool isSolutionErrorComputationNeeded() const { return false; }
61
64 NumLib::TimeStep const& /*timestep_previous*/,
65 NumLib::TimeStep const& /*timestep_current*/) const
66 {
67 return false;
68 }
69
70protected:
74 const Time _t_end;
75};
76
84 Time const& t, double const dt,
85 std::vector<double> const& fixed_output_times);
86
87bool canReduceTimestepSize(TimeStep const& timestep_previous,
88 TimeStep const& timestep_current,
89 double const min_dt);
90} // namespace NumLib
Interface of time stepping algorithms.
Time begin() const
return the beginning of time steps
virtual bool isSolutionErrorComputationNeeded() const
virtual std::tuple< bool, double > next(const double solution_error, int number_iterations, NumLib::TimeStep &ts_previous, NumLib::TimeStep &ts_current)=0
const Time _t_initial
initial time
Time end() const
return the end of time steps
TimeStepAlgorithm(const double t0, const double t_end)
virtual bool canReduceTimestepSize(NumLib::TimeStep const &, NumLib::TimeStep const &) const
Query the timestepper if further time step size reduction is possible.
virtual ~TimeStepAlgorithm()=default
Time step object.
Definition TimeStep.h:31
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)