diff --git a/ebos/eclgenericproblem.cc b/ebos/eclgenericproblem.cc index affea1487..4d080d374 100644 --- a/ebos/eclgenericproblem.cc +++ b/ebos/eclgenericproblem.cc @@ -104,6 +104,37 @@ EclGenericProblem(const EclipseState& eclState, { } +template +EclGenericProblem +EclGenericProblem:: +serializationTestObject(const EclipseState& eclState, + const Schedule& schedule, + const GridView& gridView) +{ + EclGenericProblem result(eclState, schedule, gridView); + result.maxOilSaturation_ = {1.0, 2.0}; + result.maxPolymerAdsorption_ = {3.0, 4.0, 5.0}; + result.maxWaterSaturation_ = {6.0}; + result.minOilPressure_ = {7.0, 8.0, 9.0, 10.0}; + result.overburdenPressure_ = {11.0}; + result.polymerConcentration_ = {12.0}; + result.polymerMoleWeight_ = {13.0, 14.0}; + result.solventSaturation_ = {15.0}; + result.microbialConcentration_ = {16.0}; + result.oxygenConcentration_ = {17.0}; + result.ureaConcentration_ = {18.0}; + result.biofilmConcentration_ = {19.0}; + result.calciteConcentration_ = {20.0}; + result.lastRv_ = {21.0}; + result.maxDRv_ = {22.0, 23.0}; + result.convectiveDrs_ = {24.0, 25.0, 26.0}; + result.lastRs_ = {27.0}; + result.maxDRs_ = {28.0}; + result.dRsDtOnlyFreeGas_ = {false, true}; + + return result; +} + template std::string EclGenericProblem:: @@ -755,6 +786,31 @@ initDRSDT_(size_t numDof, } } +template +bool EclGenericProblem:: +operator==(const EclGenericProblem& rhs) const +{ + return this->maxOilSaturation_ == rhs.maxOilSaturation_ && + this->maxPolymerAdsorption_ == rhs.maxPolymerAdsorption_ && + this->maxWaterSaturation_ == rhs.maxWaterSaturation_ && + this->minOilPressure_ == rhs.minOilPressure_ && + this->overburdenPressure_ == rhs.overburdenPressure_ && + this->polymerConcentration_ == rhs.polymerConcentration_ && + this->polymerMoleWeight_ == rhs.polymerMoleWeight_ && + this->solventSaturation_ == rhs.solventSaturation_ && + this->microbialConcentration_ == rhs.microbialConcentration_ && + this->oxygenConcentration_ == rhs.oxygenConcentration_ && + this->ureaConcentration_ == rhs.ureaConcentration_ && + this->biofilmConcentration_ == rhs.biofilmConcentration_ && + this->calciteConcentration_ == rhs.calciteConcentration_ && + this->lastRv_ == rhs.lastRv_ && + this->maxDRv_ == rhs.maxDRv_ && + this->convectiveDrs_ == rhs.convectiveDrs_ && + this->lastRs_ == rhs.lastRs_ && + this->maxDRs_ == rhs.maxDRs_ && + this->dRsDtOnlyFreeGas_ == rhs.dRsDtOnlyFreeGas_; +} + #if HAVE_DUNE_FEM template class EclGenericProblem>>, BlackOilFluidSystem, diff --git a/ebos/eclgenericproblem.hh b/ebos/eclgenericproblem.hh index f9037df4f..9348bf921 100644 --- a/ebos/eclgenericproblem.hh +++ b/ebos/eclgenericproblem.hh @@ -74,6 +74,11 @@ public: const Schedule& schedule, const GridView& gridView); + + static EclGenericProblem serializationTestObject(const EclipseState& eclState, + const Schedule& schedule, + const GridView& gridView); + /*! * \copydoc FvBaseProblem::helpPreamble */ @@ -257,6 +262,32 @@ public: bool vapparsActive(int episodeIdx) const; + bool operator==(const EclGenericProblem& rhs) const; + + template + void serializeOp(Serializer& serializer) + { + serializer(maxOilSaturation_); + serializer(maxPolymerAdsorption_); + serializer(maxWaterSaturation_); + serializer(minOilPressure_); + serializer(overburdenPressure_); + serializer(polymerConcentration_); + serializer(polymerMoleWeight_); + serializer(solventSaturation_); + serializer(microbialConcentration_); + serializer(oxygenConcentration_); + serializer(ureaConcentration_); + serializer(biofilmConcentration_); + serializer(calciteConcentration_); + serializer(lastRv_); + serializer(maxDRv_); + serializer(convectiveDrs_); + serializer(lastRs_); + serializer(maxDRs_); + serializer(dRsDtOnlyFreeGas_); + } + protected: bool drsdtActive_(int episodeIdx) const; bool drvdtActive_(int episodeIdx) const; diff --git a/tests/test_RestartSerialization.cpp b/tests/test_RestartSerialization.cpp index ef0e904de..2a65803c6 100644 --- a/tests/test_RestartSerialization.cpp +++ b/tests/test_RestartSerialization.cpp @@ -114,6 +114,26 @@ BOOST_AUTO_TEST_CASE(EclGenericVanguard) BOOST_CHECK_MESSAGE(val1 == val2, "Deserialized EclGenericVanguard differ"); } +BOOST_AUTO_TEST_CASE(EclGenericProblem) +{ + Opm::EclipseState eclState; + Opm::Schedule schedule; + Dune::CpGrid grid; + auto data_out = Opm::EclGenericProblem>, + Opm::BlackOilFluidSystem, + double>:: + serializationTestObject(eclState, schedule, grid.leafGridView()); + Opm::Serialization::MemPacker packer; + Opm::Serializer ser(packer); + ser.pack(data_out); + const size_t pos1 = ser.position(); + decltype(data_out) data_in(eclState, schedule, grid.leafGridView()); + ser.unpack(data_in); + const size_t pos2 = ser.position(); + BOOST_CHECK_MESSAGE(pos1 == pos2, "Packed size differ from unpack size for EclGenericProblem"); + BOOST_CHECK_MESSAGE(data_out == data_in, "Deserialized EclGenericProblem differ"); +} + bool init_unit_test_func() { return true; @@ -121,5 +141,6 @@ bool init_unit_test_func() int main(int argc, char** argv) { + Dune::MPIHelper::instance(argc, argv); return boost::unit_test::unit_test_main(&init_unit_test_func, argc, argv); }