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:
@@ -108,7 +108,7 @@ namespace Opm
|
|||||||
////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////
|
||||||
|
|
||||||
HardcodedTimeStepControl::
|
HardcodedTimeStepControl::
|
||||||
HardcodedTimeStepControl( const std::string& filename)
|
HardcodedTimeStepControl(const std::string& filename)
|
||||||
{
|
{
|
||||||
std::ifstream infile (filename);
|
std::ifstream infile (filename);
|
||||||
if (!infile.is_open()) {
|
if (!infile.is_open()) {
|
||||||
@@ -125,6 +125,14 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HardcodedTimeStepControl HardcodedTimeStepControl::serializationTestObject()
|
||||||
|
{
|
||||||
|
HardcodedTimeStepControl result;
|
||||||
|
result.subStepTime_ = {1.0, 2.0};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
double HardcodedTimeStepControl::
|
double HardcodedTimeStepControl::
|
||||||
computeTimeStepSize( const double /*dt */, const int /*iterations */, const RelativeChangeInterface& /* relativeChange */ , const double simulationTimeElapsed) const
|
computeTimeStepSize( const double /*dt */, const int /*iterations */, const RelativeChangeInterface& /* relativeChange */ , const double simulationTimeElapsed) const
|
||||||
{
|
{
|
||||||
@@ -132,6 +140,11 @@ namespace Opm
|
|||||||
return (*nextTime - simulationTimeElapsed);
|
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
|
class HardcodedTimeStepControl : public TimeStepControlInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
HardcodedTimeStepControl() = default;
|
||||||
|
|
||||||
/// \brief constructor
|
/// \brief constructor
|
||||||
/// \param filename filename contaning the timesteps
|
/// \param filename filename contaning the timesteps
|
||||||
explicit HardcodedTimeStepControl( const std::string& filename);
|
explicit HardcodedTimeStepControl( const std::string& filename);
|
||||||
|
|
||||||
|
static HardcodedTimeStepControl serializationTestObject();
|
||||||
|
|
||||||
/// \brief \copydoc TimeStepControlInterface::computeTimeStepSize
|
/// \brief \copydoc TimeStepControlInterface::computeTimeStepSize
|
||||||
double computeTimeStepSize( const double dt, const int /* iterations */, const RelativeChangeInterface& /*relativeChange */, const double simulationTimeElapsed) const;
|
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:
|
protected:
|
||||||
// store the time (in days) of the substeps the simulator should use
|
// store the time (in days) of the substeps the simulator should use
|
||||||
std::vector<double> subStepTime_;
|
std::vector<double> subStepTime_;
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ BOOST_AUTO_TEST_CASE(NAME) \
|
|||||||
#define TEST_FOR_TYPE(TYPE) \
|
#define TEST_FOR_TYPE(TYPE) \
|
||||||
TEST_FOR_TYPE_NAMED(TYPE, TYPE)
|
TEST_FOR_TYPE_NAMED(TYPE, TYPE)
|
||||||
|
|
||||||
|
TEST_FOR_TYPE(HardcodedTimeStepControl)
|
||||||
TEST_FOR_TYPE(SimpleIterationCountTimeStepControl)
|
TEST_FOR_TYPE(SimpleIterationCountTimeStepControl)
|
||||||
TEST_FOR_TYPE(SimulatorTimer)
|
TEST_FOR_TYPE(SimulatorTimer)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user