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{
28{
29public:
30 TimeStepAlgorithm(const double t0, const double t_end)
31 : _t_initial(t0), _t_end(t_end)
32 {
33 }
34
35 virtual ~TimeStepAlgorithm() = default;
36
38 double begin() const { return _t_initial; }
40 double end() const { return _t_end; }
42 virtual void resetCurrentTimeStep(const double /*dt*/,
43 TimeStep& /*ts_previous*/,
44 TimeStep& /*ts_current*/)
45 {
46 }
47
57 virtual std::tuple<bool, double> next(const double solution_error,
58 int number_iterations,
59 NumLib::TimeStep& ts_previous,
60 NumLib::TimeStep& ts_current) = 0;
61
64 virtual bool isSolutionErrorComputationNeeded() const { return false; }
65
68 NumLib::TimeStep const& /*timestep_previous*/,
69 NumLib::TimeStep const& /*timestep_current*/) const
70 {
71 return false;
72 }
73
74protected:
76 const double _t_initial;
78 const double _t_end;
79};
80
88 double const t, double const dt,
89 std::vector<double> const& fixed_output_times);
90
91bool canReduceTimestepSize(TimeStep const& timestep_previous,
92 TimeStep const& timestep_current,
93 double const min_dt);
94} // namespace NumLib
Interface of time stepping algorithms.
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
double begin() const
return the beginning of time steps
const double _t_initial
initial time
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
const double _t_end
end time
double end() const
return the end of time steps
Time step object.
Definition TimeStep.h:28
double possiblyClampDtToNextFixedTime(double 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)