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; }
44 virtual void resetCurrentTimeStep(const double /*dt*/,
45 TimeStep& /*ts_previous*/,
46 TimeStep& /*ts_current*/)
47 {
48 }
49
59 virtual std::tuple<bool, double> next(const double solution_error,
60 int number_iterations,
61 NumLib::TimeStep& ts_previous,
62 NumLib::TimeStep& ts_current) = 0;
63
66 virtual bool isSolutionErrorComputationNeeded() const { return false; }
67
70 NumLib::TimeStep const& /*timestep_previous*/,
71 NumLib::TimeStep const& /*timestep_current*/) const
72 {
73 return false;
74 }
75
76protected:
80 const Time _t_end;
81};
82
90 Time const& t, double const dt,
91 std::vector<double> const& fixed_output_times);
92
93bool canReduceTimestepSize(TimeStep const& timestep_previous,
94 TimeStep const& timestep_current,
95 double const min_dt);
96} // 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
virtual void resetCurrentTimeStep(const double, TimeStep &, TimeStep &)
reset the current step size from the previous time
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)