mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
HardcodedTimeStepControl: add serialization support
This commit is contained in:
@@ -125,6 +125,14 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
HardcodedTimeStepControl HardcodedTimeStepControl::serializationTestObject()
|
||||
{
|
||||
HardcodedTimeStepControl result;
|
||||
result.subStepTime_ = {1.0, 2.0};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
double HardcodedTimeStepControl::
|
||||
computeTimeStepSize( const double /*dt */, const int /*iterations */, const RelativeChangeInterface& /* relativeChange */ , const double simulationTimeElapsed) const
|
||||
{
|
||||
@@ -132,6 +140,11 @@ namespace Opm
|
||||
return (*nextTime - simulationTimeElapsed);
|
||||
}
|
||||
|
||||
bool HardcodedTimeStepControl::operator==(const HardcodedTimeStepControl& ctrl) const
|
||||
{
|
||||
return this->subStepTime_ == ctrl.subStepTime_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
@@ -148,13 +148,25 @@ namespace Opm
|
||||
class HardcodedTimeStepControl : public TimeStepControlInterface
|
||||
{
|
||||
public:
|
||||
HardcodedTimeStepControl() = default;
|
||||
|
||||
/// \brief constructor
|
||||
/// \param filename filename contaning the timesteps
|
||||
explicit HardcodedTimeStepControl( const std::string& filename);
|
||||
|
||||
static HardcodedTimeStepControl 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(subStepTime_);
|
||||
}
|
||||
|
||||
bool operator==(const HardcodedTimeStepControl&) const;
|
||||
|
||||
protected:
|
||||
// store the time (in days) of the substeps the simulator should use
|
||||
std::vector<double> subStepTime_;
|
||||
|
||||
@@ -60,6 +60,7 @@ BOOST_AUTO_TEST_CASE(NAME) \
|
||||
#define TEST_FOR_TYPE(TYPE) \
|
||||
TEST_FOR_TYPE_NAMED(TYPE, TYPE)
|
||||
|
||||
TEST_FOR_TYPE(HardcodedTimeStepControl)
|
||||
TEST_FOR_TYPE(SimpleIterationCountTimeStepControl)
|
||||
TEST_FOR_TYPE(SimulatorTimer)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user