OGS
TimeStepAlgorithm.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <cmath>
7#include <tuple>
8#include <vector>
9
10#include "BaseLib/Error.h"
12
13namespace NumLib
14{
15struct Time;
16
21{
22public:
23 TimeStepAlgorithm(const double t0, const double t_end)
24 : _t_initial(t0), _t_end(t_end)
25 {
26 }
27
28 virtual ~TimeStepAlgorithm() = default;
29
31 Time begin() const { return _t_initial; }
33 Time end() const { return _t_end; }
34
44 virtual double next(const double solution_error,
45 int number_iterations,
46 NumLib::TimeStep& ts_previous,
47 NumLib::TimeStep& ts_current) = 0;
48
51 virtual bool isSolutionErrorComputationNeeded() const { return false; }
52
55 NumLib::TimeStep const& /*timestep_previous*/,
56 NumLib::TimeStep const& /*timestep_current*/) const
57 {
58 return false;
59 }
60
61protected:
65 const Time _t_end;
66};
67
75 Time const& t, double const dt,
76 std::vector<double> const& fixed_output_times);
77
78bool canReduceTimestepSize(TimeStep const& timestep_previous,
79 TimeStep const& timestep_current,
80 double const min_dt);
81} // namespace NumLib
Time begin() const
return the beginning of time steps
virtual bool isSolutionErrorComputationNeeded() const
virtual 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:24
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)