diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index de616cfdc..6816f3f50 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -1316,6 +1316,21 @@ std::size_t packSize(const UDQDefine& data, packSize(data.input_string(), comm); } +std::size_t packSize(const UDQAssign::AssignRecord& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.selector, comm) + + packSize(data.value, comm); +} + +std::size_t packSize(const UDQAssign& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.keyword(), comm) + + packSize(data.var_type(), comm) + + packSize(data.getRecords(), comm); +} + ////// pack routines template @@ -2648,6 +2663,23 @@ void pack(const UDQDefine& data, pack(data.input_string(), buffer, position, comm); } +void pack(const UDQAssign::AssignRecord& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.selector, buffer, position, comm); + pack(data.value, buffer, position, comm); +} + +void pack(const UDQAssign& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.keyword(), buffer, position, comm); + pack(data.var_type(), buffer, position, comm); + pack(data.getRecords(), buffer, position, comm); +} + /// unpack routines template @@ -4532,6 +4564,29 @@ void unpack(UDQDefine& data, data = UDQDefine(keyword, ast, varType, string_data); } +void unpack(UDQAssign::AssignRecord& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + unpack(data.selector, buffer, position, comm); + unpack(data.value, buffer, position, comm); +} + +void unpack(UDQAssign& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::string keyword; + UDQVarType varType; + std::vector records; + unpack(keyword, buffer, position, comm); + unpack(varType, buffer, position, comm); + unpack(records, buffer, position, comm); + data = UDQAssign(keyword, varType, records); +} + + + #define INSTANTIATE_PACK_VECTOR(T) \ template std::size_t packSize(const std::vector& data, \ Dune::MPIHelper::MPICommunicator comm); \ diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index bf8f3b916..ef191865f 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -631,6 +632,8 @@ ADD_PACK_PROTOTYPES(ThresholdPressure) ADD_PACK_PROTOTYPES(TimeMap) ADD_PACK_PROTOTYPES(TimeMap::StepData) ADD_PACK_PROTOTYPES(UDAValue) +ADD_PACK_PROTOTYPES(UDQAssign) +ADD_PACK_PROTOTYPES(UDQAssign::AssignRecord) ADD_PACK_PROTOTYPES(UDQASTNode) ADD_PACK_PROTOTYPES(UDQDefine) ADD_PACK_PROTOTYPES(UDQFunction) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 77e7f474d..51c711ef2 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -1725,6 +1726,19 @@ BOOST_AUTO_TEST_CASE(UDQDefine) } +BOOST_AUTO_TEST_CASE(UDQAssign) +{ +#ifdef HAVE_MPI + Opm::UDQAssign val1("test", Opm::UDQVarType::NONE, + {Opm::UDQAssign::AssignRecord{{"test1"}, 1.0}, + Opm::UDQAssign::AssignRecord{{"test2"}, 2.0}}); + auto val2 = PackUnpack(val1); + BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2)); + BOOST_CHECK(val1 == std::get<0>(val2)); +#endif +} + + bool init_unit_test_func() { return true;