diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 05e624f20..de616cfdc 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -1306,6 +1307,15 @@ std::size_t packSize(const UDQASTNode& data, packSize(data.getRight(), comm); } +std::size_t packSize(const UDQDefine& data, + Dune::MPIHelper::MPICommunicator comm) +{ + return packSize(data.keyword(), comm) + + packSize(data.getAst(), comm) + + packSize(data.var_type(), comm) + + packSize(data.input_string(), comm); +} + ////// pack routines template @@ -2628,6 +2638,16 @@ void pack(const UDQASTNode& data, pack(data.getRight(), buffer, position, comm); } +void pack(const UDQDefine& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + pack(data.keyword(), buffer, position, comm); + pack(data.getAst(), buffer, position, comm); + pack(data.var_type(), buffer, position, comm); + pack(data.input_string(), buffer, position, comm); +} + /// unpack routines template @@ -4496,6 +4516,22 @@ void unpack(UDQASTNode& data, data = UDQASTNode(var_type, type, stringValue, scalarValue, selectors, left, right); } +void unpack(UDQDefine& data, + std::vector& buffer, int& position, + Dune::MPIHelper::MPICommunicator comm) +{ + std::string keyword; + std::shared_ptr ast; + UDQVarType varType; + std::string string_data; + + unpack(keyword, buffer, position, comm); + unpack(ast, buffer, position, comm); + unpack(varType, buffer, position, comm); + unpack(string_data, buffer, position, comm); + data = UDQDefine(keyword, ast, varType, string_data); +} + #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 ed22ad017..bf8f3b916 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -113,6 +113,7 @@ class TableSchema; class ThresholdPressure; class UDAValue; class UDQASTNode; +class UDQDefine; class UDQFunction; class UDQFunctionTable; class UDQParams; @@ -631,6 +632,7 @@ ADD_PACK_PROTOTYPES(TimeMap) ADD_PACK_PROTOTYPES(TimeMap::StepData) ADD_PACK_PROTOTYPES(UDAValue) ADD_PACK_PROTOTYPES(UDQASTNode) +ADD_PACK_PROTOTYPES(UDQDefine) ADD_PACK_PROTOTYPES(UDQFunction) ADD_PACK_PROTOTYPES(UDQFunctionTable) ADD_PACK_PROTOTYPES(UDQParams) diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index 2dd2962bf..77e7f474d 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -1708,6 +1709,21 @@ BOOST_AUTO_TEST_CASE(UDQASTNode) #endif } +BOOST_AUTO_TEST_CASE(UDQDefine) +{ +#ifdef HAVE_MPI + std::shared_ptr n0; + Opm::UDQASTNode n1(Opm::UDQVarType::NONE, + Opm::UDQTokenType::error, + "test", 1.0, {"test1", "test2"}, n0, n0); + Opm::UDQDefine val1("test", std::make_shared(n1), + Opm::UDQVarType::NONE, "test2"); + 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() {