diff --git a/opm/simulators/timestepping/TimeStepControl.cpp b/opm/simulators/timestepping/TimeStepControl.cpp index 11cb2e76f..5c70f287b 100644 --- a/opm/simulators/timestepping/TimeStepControl.cpp +++ b/opm/simulators/timestepping/TimeStepControl.cpp @@ -242,6 +242,12 @@ namespace Opm , minTimeStepBasedOnIterations_(minTimeStepBasedOnIterations) {} + PIDAndIterationCountTimeStepControl + PIDAndIterationCountTimeStepControl::serializationTestObject() + { + return {1, 2.0, 3.0, 4.0, 5.0, true}; + } + double PIDAndIterationCountTimeStepControl:: computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& relChange, const double simulationTimeElapsed ) const { @@ -264,4 +270,13 @@ namespace Opm return std::min(dtEstimatePID, dtEstimateIter); } + bool PIDAndIterationCountTimeStepControl::operator==(const PIDAndIterationCountTimeStepControl& ctrl) const + { + return static_cast(*this) == ctrl && + this->target_iterations_ == ctrl.target_iterations_ && + this->decayDampingFactor_ == ctrl.decayDampingFactor_ && + this->growthDampingFactor_ == ctrl.growthDampingFactor_ && + this->minTimeStepBasedOnIterations_ == ctrl.minTimeStepBasedOnIterations_; + } + } // end namespace Opm diff --git a/opm/simulators/timestepping/TimeStepControl.hpp b/opm/simulators/timestepping/TimeStepControl.hpp index a133d6958..11c5fa574 100644 --- a/opm/simulators/timestepping/TimeStepControl.hpp +++ b/opm/simulators/timestepping/TimeStepControl.hpp @@ -138,9 +138,23 @@ namespace Opm const double minTimeStepBasedOnIterations = 0., const bool verbose = false); + static PIDAndIterationCountTimeStepControl serializationTestObject(); + /// \brief \copydoc TimeStepControlInterface::computeTimeStepSize double computeTimeStepSize( const double dt, const int iterations, const RelativeChangeInterface& relativeChange, const double /*simulationTimeElapsed */ ) const; + template + void serializeOp(Serializer& serializer) + { + serializer(static_cast(*this)); + serializer(target_iterations_); + serializer(decayDampingFactor_); + serializer(growthDampingFactor_); + serializer(minTimeStepBasedOnIterations_); + } + + bool operator==(const PIDAndIterationCountTimeStepControl&) const; + protected: const int target_iterations_; const double decayDampingFactor_; diff --git a/tests/test_RestartSerialization.cpp b/tests/test_RestartSerialization.cpp index 30df39bdc..3983000c6 100644 --- a/tests/test_RestartSerialization.cpp +++ b/tests/test_RestartSerialization.cpp @@ -61,6 +61,7 @@ BOOST_AUTO_TEST_CASE(NAME) \ TEST_FOR_TYPE_NAMED(TYPE, TYPE) TEST_FOR_TYPE(HardcodedTimeStepControl) +TEST_FOR_TYPE(PIDAndIterationCountTimeStepControl) TEST_FOR_TYPE(PIDTimeStepControl) TEST_FOR_TYPE(SimpleIterationCountTimeStepControl) TEST_FOR_TYPE(SimulatorTimer)