PIDTimeStepControl: add serialization support

This commit is contained in:
Arne Morten Kvarving 2023-01-31 12:38:54 +01:00
parent 87bc1d8c10
commit 1827de96a2
3 changed files with 33 additions and 4 deletions

View File

@ -160,6 +160,15 @@ namespace Opm
, verbose_( verbose )
{}
PIDTimeStepControl
PIDTimeStepControl::serializationTestObject()
{
PIDTimeStepControl result(1.0, true);
result.errors_ = {2.0, 3.0};
return result;;
}
double PIDTimeStepControl::
computeTimeStepSize( const double dt, const int /* iterations */, const RelativeChangeInterface& relChange, const double /*simulationTimeElapsed */) const
{
@ -204,6 +213,13 @@ namespace Opm
}
}
bool PIDTimeStepControl::operator==(const PIDTimeStepControl& ctrl) const
{
return this->tol_ == ctrl.tol_ &&
this->errors_ == ctrl.errors_ &&
this->verbose_ == ctrl.verbose_;
}
////////////////////////////////////////////////////////////

View File

@ -94,14 +94,26 @@ namespace Opm
PIDTimeStepControl( const double tol = 1e-3,
const bool verbose = false );
static PIDTimeStepControl serializationTestObject();
/// \brief \copydoc TimeStepControlInterface::computeTimeStepSize
double computeTimeStepSize( const double dt, const int /* iterations */, const RelativeChangeInterface& relativeChange, const double /*simulationTimeElapsed */ ) const;
protected:
const double tol_;
mutable std::vector< double > errors_;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(tol_);
serializer(errors_);
serializer(verbose_);
}
const bool verbose_;
bool operator==(const PIDTimeStepControl&) const;
protected:
const double tol_ = 1e-3;
mutable std::vector< double > errors_{};
const bool verbose_ = false;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -61,6 +61,7 @@ BOOST_AUTO_TEST_CASE(NAME) \
TEST_FOR_TYPE_NAMED(TYPE, TYPE)
TEST_FOR_TYPE(HardcodedTimeStepControl)
TEST_FOR_TYPE(PIDTimeStepControl)
TEST_FOR_TYPE(SimpleIterationCountTimeStepControl)
TEST_FOR_TYPE(SimulatorTimer)