21#ifndef OPM_TIMESTEPCONTROL_HEADER_INCLUDED
22#define OPM_TIMESTEPCONTROL_HEADER_INCLUDED
24#include <opm/simulators/timestepping/TimeStepControlInterface.hpp>
25#include <opm/simulators/timestepping/AdaptiveSimulatorTimer.hpp>
32 enum class TimeStepControlType {
40 enum class ToleranceTestVersions {
42 ControlErrorFiltering,
45 enum class InternalControlVersions {
55 class SimpleIterationCountTimeStepControl :
public TimeStepControlInterface
58 static constexpr TimeStepControlType Type = TimeStepControlType::SimpleIterationCount;
60 SimpleIterationCountTimeStepControl() =
default;
67 SimpleIterationCountTimeStepControl(
const int target_iterations,
68 const double decayrate,
69 const double growthrate,
72 static SimpleIterationCountTimeStepControl serializationTestObject();
81 const double )
const override {
return true; }
83 template<
class Serializer>
84 void serializeOp(Serializer& serializer)
86 serializer(target_iterations_);
87 serializer(decayrate_);
88 serializer(growthrate_);
92 bool operator==(
const SimpleIterationCountTimeStepControl&)
const;
95 const int target_iterations_ = 0;
96 const double decayrate_ = 0.0;
97 const double growthrate_ = 0.0;
98 const bool verbose_ =
false;
115 class PIDTimeStepControl :
public TimeStepControlInterface
118 static constexpr TimeStepControlType Type = TimeStepControlType::PID;
120 PIDTimeStepControl() =
default;
126 PIDTimeStepControl(
const double tol,
129 static PIDTimeStepControl serializationTestObject();
140 const double )
const override {
return true; }
142 template<
class Serializer>
143 void serializeOp(Serializer& serializer)
147 serializer(verbose_);
150 bool operator==(
const PIDTimeStepControl&)
const;
153 const double tol_ = 0.1;
154 mutable std::vector< double > errors_{};
155 const bool verbose_ =
false;
164 class PIDAndIterationCountTimeStepControl :
public PIDTimeStepControl
166 typedef PIDTimeStepControl BaseType;
168 static constexpr TimeStepControlType Type = TimeStepControlType::PIDAndIterationCount;
170 PIDAndIterationCountTimeStepControl() =
default;
180 PIDAndIterationCountTimeStepControl(
const int target_iterations,
181 const double decayDampingFactor,
182 const double growthDampingFactor,
184 const double minTimeStepBasedOnIterations,
187 static PIDAndIterationCountTimeStepControl serializationTestObject();
194 const int iterations,
199 const double )
const override {
return true; }
201 template<
class Serializer>
202 void serializeOp(Serializer& serializer)
205 serializer(target_iterations_);
206 serializer(decayDampingFactor_);
207 serializer(growthDampingFactor_);
208 serializer(minTimeStepBasedOnIterations_);
209 serializer(verbose_);
212 bool operator==(
const PIDAndIterationCountTimeStepControl&)
const;
215 const int target_iterations_ = 8;
216 const double decayDampingFactor_ = 1.0;
217 const double growthDampingFactor_ = 3.2;
218 const double minTimeStepBasedOnIterations_ = 0.0;
219 const bool verbose_ =
false;
227 class General3rdOrderController :
public TimeStepControlInterface
230 static constexpr TimeStepControlType Type = TimeStepControlType::General3rdOrder;
232 General3rdOrderController() =
default;
244 General3rdOrderController(
const double tolerance,
245 const double safetyFactor,
246 const bool rejectCompletedStep,
247 const std::string& toleranceTestVersion,
248 const double maxReductionTimeStep,
249 const std::string& parameters,
252 static General3rdOrderController serializationTestObject();
259 double timeStepFactor(
const std::array<double, 3>& errors,
const std::array<double, 3>& timeSteps)
const;
262 const double timeStepJustCompleted)
const override;
264 template<
class Serializer>
265 void serializeOp(Serializer& serializer)
267 serializer(tolerance_);
268 serializer(safetyFactor_);
269 serializer(rejectCompletedStep_);
271 serializer(timeSteps_);
274 serializer(controllerVersion_);
275 serializer(toleranceTestVersion_);
276 serializer(maxReductionTimeStep_);
277 serializer(verbose_);
280 bool operator==(
const General3rdOrderController&)
const;
284 const double tolerance_ = 0.1;
285 const double safetyFactor_ = 0.8;
286 const bool rejectCompletedStep_ =
false;
287 mutable std::array<double, 3> errors_{};
288 mutable std::array<double, 3> timeSteps_{};
289 mutable std::array<double, 3> beta_{0.125, 0.25, 0.125};
290 mutable std::array<double, 2> alpha_{0.75, 0.25};
291 mutable InternalControlVersions controllerVersion_{InternalControlVersions::IController};
292 ToleranceTestVersions toleranceTestVersion_{ToleranceTestVersions::Standard};
293 const double maxReductionTimeStep_ = 0.1;
294 const bool verbose_ =
false;
306 class HardcodedTimeStepControl :
public TimeStepControlInterface
309 static constexpr TimeStepControlType Type = TimeStepControlType::HardCodedTimeStep;
311 HardcodedTimeStepControl() =
default;
315 explicit HardcodedTimeStepControl(
const std::string& filename);
317 static HardcodedTimeStepControl serializationTestObject();
328 const double )
const override {
return true; }
330 template<
class Serializer>
331 void serializeOp(Serializer& serializer)
333 serializer(subStepTime_);
336 bool operator==(
const HardcodedTimeStepControl&)
const;
340 std::vector<double> subStepTime_;
Simulation timer for adaptive time stepping.
Definition AdaptiveSimulatorTimer.hpp:41
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:373
bool timeStepAccepted(const double error, const double timeStepJustCompleted) const override
For the general 3rd order controller, the internal shifting of errors and time steps happens here,...
Definition TimeStepControl.cpp:446
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:148
bool timeStepAccepted(const double, const double) const override
For the general 3rd order controller, the internal shifting of errors and time steps happens here,...
Definition TimeStepControl.hpp:327
bool timeStepAccepted(const double, const double) const override
For the general 3rd order controller, the internal shifting of errors and time steps happens here,...
Definition TimeStepControl.hpp:198
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:274
PID controller based adaptive time step control as suggested in: Turek and Kuzmin.
Definition TimeStepControl.hpp:116
bool timeStepAccepted(const double, const double) const override
For the general 3rd order controller, the internal shifting of errors and time steps happens here,...
Definition TimeStepControl.hpp:139
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:188
RelativeChangeInterface.
Definition TimeStepControlInterface.hpp:34
bool timeStepAccepted(const double, const double) const override
For the general 3rd order controller, the internal shifting of errors and time steps happens here,...
Definition TimeStepControl.hpp:80
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:79
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43