mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
BlackoilAquiferModel: add serialization of dynamic state
This commit is contained in:
parent
a66fd75715
commit
d5f22dbc99
@ -112,6 +112,9 @@ public:
|
|||||||
template <class Restarter>
|
template <class Restarter>
|
||||||
void deserialize(Restarter& res);
|
void deserialize(Restarter& res);
|
||||||
|
|
||||||
|
template<class Serializer>
|
||||||
|
void serializeOp(Serializer& serializer);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// --------- Types ---------
|
// --------- Types ---------
|
||||||
using ElementContext = GetPropType<TypeTag, Properties::ElementContext>;
|
using ElementContext = GetPropType<TypeTag, Properties::ElementContext>;
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <opm/common/ErrorMacros.hpp>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -184,4 +187,25 @@ data::Aquifers BlackoilAquiferModel<TypeTag>::aquiferData() const
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename TypeTag>
|
||||||
|
template<class Serializer>
|
||||||
|
void BlackoilAquiferModel<TypeTag>::
|
||||||
|
serializeOp(Serializer& serializer)
|
||||||
|
{
|
||||||
|
for (auto& aiPtr : aquifers) {
|
||||||
|
auto* ct = dynamic_cast<AquiferCarterTracy<TypeTag>*>(aiPtr.get());
|
||||||
|
auto* fetp = dynamic_cast<AquiferFetkovich<TypeTag>*>(aiPtr.get());
|
||||||
|
auto* num = dynamic_cast<AquiferNumerical<TypeTag>*>(aiPtr.get());
|
||||||
|
if (ct) {
|
||||||
|
serializer(*ct);
|
||||||
|
} else if (fetp) {
|
||||||
|
serializer(*fetp);
|
||||||
|
} else if (num) {
|
||||||
|
serializer(*num);
|
||||||
|
} else {
|
||||||
|
OPM_THROW(std::logic_error, "Error serializing BlackoilAquiferModel: unknown aquifer type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -152,41 +152,27 @@ struct AquiferFixture {
|
|||||||
|
|
||||||
BOOST_GLOBAL_FIXTURE(AquiferFixture);
|
BOOST_GLOBAL_FIXTURE(AquiferFixture);
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(AquiferCarterTracy)
|
#define TEST_FOR_AQUIFER(TYPE) \
|
||||||
{
|
BOOST_AUTO_TEST_CASE(TYPE) \
|
||||||
using TT = Opm::Properties::TTag::EbosTypeTag;
|
{ \
|
||||||
Opm::EclGenericVanguard::readDeck("GLIFT1.DATA");
|
using TT = Opm::Properties::TTag::EbosTypeTag; \
|
||||||
using Simulator = Opm::GetPropType<TT, Opm::Properties::Simulator>;
|
Opm::EclGenericVanguard::readDeck("GLIFT1.DATA"); \
|
||||||
Simulator sim;
|
using Simulator = Opm::GetPropType<TT, Opm::Properties::Simulator>; \
|
||||||
auto data_out = Opm::AquiferCarterTracy<TT>::serializationTestObject(sim);
|
Simulator sim; \
|
||||||
Opm::Serialization::MemPacker packer;
|
auto data_out = Opm::TYPE<TT>::serializationTestObject(sim); \
|
||||||
Opm::Serializer ser(packer);
|
Opm::Serialization::MemPacker packer; \
|
||||||
ser.pack(data_out);
|
Opm::Serializer ser(packer); \
|
||||||
size_t pos1 = ser.position();
|
ser.pack(data_out); \
|
||||||
decltype(data_out) data_in({}, sim, {});
|
const size_t pos1 = ser.position(); \
|
||||||
ser.unpack(data_in);
|
decltype(data_out) data_in({}, sim, {}); \
|
||||||
size_t pos2 = ser.position();
|
ser.unpack(data_in); \
|
||||||
BOOST_CHECK_MESSAGE(pos1 == pos2, "Packed size differ from unpack size for AquiferCarterTracy");
|
const size_t pos2 = ser.position(); \
|
||||||
BOOST_CHECK_MESSAGE(data_out == data_in, "Deserialized AquiferCarterTracy differ");
|
BOOST_CHECK_MESSAGE(pos1 == pos2, "Packed size differ from unpack size for " #TYPE); \
|
||||||
|
BOOST_CHECK_MESSAGE(data_out == data_in, "Deserialized " #TYPE " differ"); \
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(AquiferFetkovich)
|
TEST_FOR_AQUIFER(AquiferCarterTracy)
|
||||||
{
|
TEST_FOR_AQUIFER(AquiferFetkovich)
|
||||||
using TT = Opm::Properties::TTag::EbosTypeTag;
|
|
||||||
Opm::EclGenericVanguard::readDeck("GLIFT1.DATA");
|
|
||||||
using Simulator = Opm::GetPropType<TT, Opm::Properties::Simulator>;
|
|
||||||
Simulator sim;
|
|
||||||
auto data_out = Opm::AquiferFetkovich<TT>::serializationTestObject(sim);
|
|
||||||
Opm::Serialization::MemPacker packer;
|
|
||||||
Opm::Serializer ser(packer);
|
|
||||||
ser.pack(data_out);
|
|
||||||
size_t pos1 = ser.position();
|
|
||||||
decltype(data_out) data_in({}, sim, {});
|
|
||||||
ser.unpack(data_in);
|
|
||||||
size_t pos2 = ser.position();
|
|
||||||
BOOST_CHECK_MESSAGE(pos1 == pos2, "Packed size differ from unpack size for AquiferFetkovich");
|
|
||||||
BOOST_CHECK_MESSAGE(data_out == data_in, "Deserialized AquiferFetkovich differ");
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(AquiferNumerical)
|
BOOST_AUTO_TEST_CASE(AquiferNumerical)
|
||||||
{
|
{
|
||||||
@ -198,12 +184,12 @@ BOOST_AUTO_TEST_CASE(AquiferNumerical)
|
|||||||
Opm::Serialization::MemPacker packer;
|
Opm::Serialization::MemPacker packer;
|
||||||
Opm::Serializer ser(packer);
|
Opm::Serializer ser(packer);
|
||||||
ser.pack(data_out);
|
ser.pack(data_out);
|
||||||
size_t pos1 = ser.position();
|
const size_t pos1 = ser.position();
|
||||||
decltype(data_out) data_in({}, sim);
|
decltype(data_out) data_in({}, sim);
|
||||||
ser.unpack(data_in);
|
ser.unpack(data_in);
|
||||||
size_t pos2 = ser.position();
|
const size_t pos2 = ser.position();
|
||||||
BOOST_CHECK_MESSAGE(pos1 == pos2, "Packed size differ from unpack size for AquiferFetkovich");
|
BOOST_CHECK_MESSAGE(pos1 == pos2, "Packed size differ from unpack size for AquiferNumerical");
|
||||||
BOOST_CHECK_MESSAGE(data_out == data_in, "Deserialized AquiferFetkovich differ");
|
BOOST_CHECK_MESSAGE(data_out == data_in, "Deserialized AquiferNumerical differ");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool init_unit_test_func()
|
bool init_unit_test_func()
|
||||||
|
Loading…
Reference in New Issue
Block a user