PIDAndIterationCountTimeStepControl: add serialization support

This commit is contained in:
Arne Morten Kvarving 2023-01-31 12:38:54 +01:00
parent 1827de96a2
commit 5f6bc76512
3 changed files with 30 additions and 0 deletions

View File

@ -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<const PIDTimeStepControl&>(*this) == ctrl &&
this->target_iterations_ == ctrl.target_iterations_ &&
this->decayDampingFactor_ == ctrl.decayDampingFactor_ &&
this->growthDampingFactor_ == ctrl.growthDampingFactor_ &&
this->minTimeStepBasedOnIterations_ == ctrl.minTimeStepBasedOnIterations_;
}
} // end namespace Opm

View File

@ -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<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(static_cast<PIDTimeStepControl&>(*this));
serializer(target_iterations_);
serializer(decayDampingFactor_);
serializer(growthDampingFactor_);
serializer(minTimeStepBasedOnIterations_);
}
bool operator==(const PIDAndIterationCountTimeStepControl&) const;
protected:
const int target_iterations_;
const double decayDampingFactor_;

View File

@ -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)