My Project
Loading...
Searching...
No Matches
TimeStepControl.hpp
1/*
2 Copyright 2014 IRIS AS
3 Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services
4 Copyright 2015 Statoil AS
5
6 This file is part of the Open Porous Media project (OPM).
7
8 OPM is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 OPM is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with OPM. If not, see <http://www.gnu.org/licenses/>.
20*/
21#ifndef OPM_TIMESTEPCONTROL_HEADER_INCLUDED
22#define OPM_TIMESTEPCONTROL_HEADER_INCLUDED
23
24#include <opm/simulators/timestepping/TimeStepControlInterface.hpp>
25#include <opm/simulators/timestepping/AdaptiveSimulatorTimer.hpp>
26
27#include <string>
28#include <vector>
29
30namespace Opm
31{
32 enum class TimeStepControlType {
33 SimpleIterationCount,
34 PID,
35 PIDAndIterationCount,
36 HardCodedTimeStep,
37 General3rdOrder,
38 };
39
43 //
46 {
47 public:
48 static constexpr TimeStepControlType Type = TimeStepControlType::SimpleIterationCount;
50
53 // \param decayrate decayrate of time step when target iterations are not met (should be <= 1)
54 // \param growthrate growthrate of time step when target iterations are not met (should be >= 1)
57 const double decayrate,
58 const double growthrate,
59 const bool verbose = false);
60
61 static SimpleIterationCountTimeStepControl serializationTestObject();
62
64 double computeTimeStepSize(const double dt,
65 const int iterations,
66 const RelativeChangeInterface& /* relativeChange */,
67 const AdaptiveSimulatorTimer& /* substepTimer */ ) const override;
68
69 template<class Serializer>
70 void serializeOp(Serializer& serializer)
71 {
72 serializer(target_iterations_);
73 serializer(decayrate_);
74 serializer(growthrate_);
75 serializer(verbose_);
76 }
77
78 bool operator==(const SimpleIterationCountTimeStepControl&) const;
79
80 protected:
81 const int target_iterations_ = 0;
82 const double decayrate_ = 0.0;
83 const double growthrate_ = 0.0;
84 const bool verbose_ = false;
85 };
86
102 {
103 public:
104 static constexpr TimeStepControlType Type = TimeStepControlType::PID;
109 explicit PIDTimeStepControl(const double tol = 1e-3,
110 const bool verbose = false);
111
112 static PIDTimeStepControl serializationTestObject();
113
115 double computeTimeStepSize(const double dt,
116 const int /* iterations */,
117 const RelativeChangeInterface& relativeChange,
118 const AdaptiveSimulatorTimer& /* substepTimer */ ) const override;
119
120 template<class Serializer>
121 void serializeOp(Serializer& serializer)
122 {
123 serializer(tol_);
124 serializer(errors_);
125 serializer(verbose_);
126 }
127
128 bool operator==(const PIDTimeStepControl&) const;
129
130 protected:
131 const double tol_ = 1e-3;
132 mutable std::vector< double > errors_{};
133
134 const bool verbose_ = false;
135 };
136
141 //
144 {
146 public:
147 static constexpr TimeStepControlType Type = TimeStepControlType::PIDAndIterationCount;
148
155 const double decayDampingFactor = 1.0,
156 const double growthDampingFactor = 1.0/1.2,
157 const double tol = 1e-3,
158 const double minTimeStepBasedOnIterations = 0.,
159 const bool verbose = false);
160
161 static PIDAndIterationCountTimeStepControl serializationTestObject();
162
164 double computeTimeStepSize(const double dt,
165 const int iterations,
166 const RelativeChangeInterface& relativeChange,
167 const AdaptiveSimulatorTimer& /* substepTimer */ ) const override;
168
169 template<class Serializer>
170 void serializeOp(Serializer& serializer)
171 {
172 serializer(static_cast<PIDTimeStepControl&>(*this));
173 serializer(target_iterations_);
174 serializer(decayDampingFactor_);
175 serializer(growthDampingFactor_);
176 serializer(minTimeStepBasedOnIterations_);
177 }
178
179 bool operator==(const PIDAndIterationCountTimeStepControl&) const;
180
181 protected:
182 const int target_iterations_;
183 const double decayDampingFactor_;
184 const double growthDampingFactor_;
185 const double minTimeStepBasedOnIterations_;
186 };
187
194 {
195 public:
196 static constexpr TimeStepControlType Type = TimeStepControlType::General3rdOrder;
197
198 General3rdOrderController( const double tolerance = 1e-3,
199 const double safetyFactor = 0.8,
200 const bool verbose = false );
201
202 static General3rdOrderController serializationTestObject();
203
204 double computeTimeStepSize(const double dt,
205 const int /*iterations */,
206 const RelativeChangeInterface& relativeChange,
207 const AdaptiveSimulatorTimer& substepTimer) const override;
208
209 template<class Serializer>
210 void serializeOp(Serializer& serializer)
211 {
212 serializer(tolerance_);
213 serializer(safetyFactor_);
214 serializer(errors_);
215 serializer(timeSteps_);
216 serializer(verbose_);
217 }
218
219 bool operator==(const General3rdOrderController&) const;
220
221
222 protected:
223 const double tolerance_ = 1e-3;
224 const double safetyFactor_ = 0.8;
225 mutable std::vector<double> errors_{};
226 mutable std::vector<double> timeSteps_{};
227 mutable int counterSinceFailure_ = 0;
228 const bool verbose_ = false;
229 };
230
241 {
242 public:
243 static constexpr TimeStepControlType Type = TimeStepControlType::HardCodedTimeStep;
244 HardcodedTimeStepControl() = default;
245
248 explicit HardcodedTimeStepControl(const std::string& filename);
249
250 static HardcodedTimeStepControl serializationTestObject();
251
253 double computeTimeStepSize(const double dt,
254 const int /* iterations */,
255 const RelativeChangeInterface& /*relativeChange */,
256 const AdaptiveSimulatorTimer& substepTimer) const override;
257
258 template<class Serializer>
259 void serializeOp(Serializer& serializer)
260 {
261 serializer(subStepTime_);
262 }
263
264 bool operator==(const HardcodedTimeStepControl&) const;
265
266 protected:
267 // store the time (in days) of the substeps the simulator should use
268 std::vector<double> subStepTime_;
269 };
270
271
272} // end namespace Opm
273#endif
274
Simulation timer for adaptive time stepping.
Definition AdaptiveSimulatorTimer.hpp:41
General 3rd order controller.
Definition TimeStepControl.hpp:194
double computeTimeStepSize(const double dt, const int, const RelativeChangeInterface &relativeChange, const AdaptiveSimulatorTimer &substepTimer) const override
compute new time step size suggestions based on the PID controller
Definition TimeStepControl.cpp:312
HardcodedTimeStepControl Input generated from summary file using the ert application:
Definition TimeStepControl.hpp:241
double computeTimeStepSize(const double dt, const int, const RelativeChangeInterface &, const AdaptiveSimulatorTimer &substepTimer) const override
compute new time step size suggestions based on the PID controller
Definition TimeStepControl.cpp:139
PID controller based adaptive time step control as above that also takes an target iteration into acc...
Definition TimeStepControl.hpp:144
double computeTimeStepSize(const double dt, const int iterations, const RelativeChangeInterface &relativeChange, const AdaptiveSimulatorTimer &) const override
compute new time step size suggestions based on the PID controller
Definition TimeStepControl.cpp:254
PID controller based adaptive time step control as suggested in: Turek and Kuzmin.
Definition TimeStepControl.hpp:102
double computeTimeStepSize(const double dt, const int, const RelativeChangeInterface &relativeChange, const AdaptiveSimulatorTimer &) const override
compute new time step size suggestions based on the PID controller
Definition TimeStepControl.cpp:175
RelativeChangeInterface.
Definition TimeStepControlInterface.hpp:34
A simple iteration count based adaptive time step control.
Definition TimeStepControl.hpp:46
double computeTimeStepSize(const double dt, const int iterations, const RelativeChangeInterface &, const AdaptiveSimulatorTimer &) const override
compute new time step size suggestions based on the PID controller
Definition TimeStepControl.cpp:78
TimeStepControlInterface.
Definition TimeStepControlInterface.hpp:51
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242