OGS
EvolutionaryPIDcontroller.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 <memory>
7#include <vector>
8
9#include "TimeStepAlgorithm.h"
10
11namespace NumLib
12{
39{
40public:
41 EvolutionaryPIDcontroller(const double t0, const double t_end,
42 const double h0, const double h_min,
43 const double h_max, const double rel_h_min,
44 const double rel_h_max, const double tol,
45 std::vector<double> const& fixed_times_for_output)
46 : TimeStepAlgorithm(t0, t_end),
47 _h0(h0),
48 _h_min(h_min),
49 _h_max(h_max),
50 _rel_h_min(rel_h_min),
51 _rel_h_max(rel_h_max),
52 _tol(tol),
53 _e_n_minus1(0.),
54 _e_n_minus2(0.),
55 _fixed_times_for_output(fixed_times_for_output)
56 {
57 }
58
59 double next(double solution_error,
60 int number_iterations,
61 NumLib::TimeStep& timestep_previous,
62 NumLib::TimeStep& timestep_current) override;
63
64 bool isSolutionErrorComputationNeeded() const override { return true; }
65
66 virtual bool canReduceTimestepSize(
67 NumLib::TimeStep const& timestep_previous,
68 NumLib::TimeStep const& timestep_current) const override;
69
70private:
71 const double _kP = 0.075;
72 const double _kI = 0.175;
73 const double _kD = 0.01;
74
75 const double _h0;
76 const double _h_min;
77 const double _h_max;
78
80 const double _rel_h_min;
82 const double _rel_h_max;
83
84 const double _tol;
85
86 double _e_n_minus1;
87 double _e_n_minus2;
88
89 std::vector<double> const _fixed_times_for_output;
90
103 double limitStepSize(const double h_new,
104 const bool previous_step_accepted,
105 NumLib::TimeStep const& timestep_current) const;
106};
107
108} // end of namespace NumLib
const double _h_max
maximum step size.
EvolutionaryPIDcontroller(const double t0, const double t_end, const double h0, const double h_min, const double h_max, const double rel_h_min, const double rel_h_max, const double tol, std::vector< double > const &fixed_times_for_output)
std::vector< double > const _fixed_times_for_output
const double _h_min
minimum step size.
virtual bool canReduceTimestepSize(NumLib::TimeStep const &timestep_previous, NumLib::TimeStep const &timestep_current) const override
Query the timestepper if further time step size reduction is possible.
bool isSolutionErrorComputationNeeded() const override
double limitStepSize(const double h_new, const bool previous_step_accepted, NumLib::TimeStep const &timestep_current) const
const double _h0
initial time step size.
double next(double solution_error, int number_iterations, NumLib::TimeStep &timestep_previous, NumLib::TimeStep &timestep_current) override
TimeStepAlgorithm(const double t0, const double t_end)
Time step object.
Definition TimeStep.h:24