add mpi serialization for UDQDefine

This commit is contained in:
Arne Morten Kvarving
2019-12-11 15:56:33 +01:00
parent 7d825cea82
commit 3d17266476
3 changed files with 54 additions and 0 deletions

View File

@@ -37,6 +37,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp>
@@ -1306,6 +1307,15 @@ std::size_t packSize(const UDQASTNode& data,
packSize(data.getRight(), comm); 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 ////// pack routines
template<class T> template<class T>
@@ -2628,6 +2638,16 @@ void pack(const UDQASTNode& data,
pack(data.getRight(), buffer, position, comm); pack(data.getRight(), buffer, position, comm);
} }
void pack(const UDQDefine& data,
std::vector<char>& 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 /// unpack routines
template<class T> template<class T>
@@ -4496,6 +4516,22 @@ void unpack(UDQASTNode& data,
data = UDQASTNode(var_type, type, stringValue, scalarValue, selectors, left, right); data = UDQASTNode(var_type, type, stringValue, scalarValue, selectors, left, right);
} }
void unpack(UDQDefine& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
std::string keyword;
std::shared_ptr<UDQASTNode> 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) \ #define INSTANTIATE_PACK_VECTOR(T) \
template std::size_t packSize(const std::vector<T>& data, \ template std::size_t packSize(const std::vector<T>& data, \
Dune::MPIHelper::MPICommunicator comm); \ Dune::MPIHelper::MPICommunicator comm); \

View File

@@ -113,6 +113,7 @@ class TableSchema;
class ThresholdPressure; class ThresholdPressure;
class UDAValue; class UDAValue;
class UDQASTNode; class UDQASTNode;
class UDQDefine;
class UDQFunction; class UDQFunction;
class UDQFunctionTable; class UDQFunctionTable;
class UDQParams; class UDQParams;
@@ -631,6 +632,7 @@ ADD_PACK_PROTOTYPES(TimeMap)
ADD_PACK_PROTOTYPES(TimeMap::StepData) ADD_PACK_PROTOTYPES(TimeMap::StepData)
ADD_PACK_PROTOTYPES(UDAValue) ADD_PACK_PROTOTYPES(UDAValue)
ADD_PACK_PROTOTYPES(UDQASTNode) ADD_PACK_PROTOTYPES(UDQASTNode)
ADD_PACK_PROTOTYPES(UDQDefine)
ADD_PACK_PROTOTYPES(UDQFunction) ADD_PACK_PROTOTYPES(UDQFunction)
ADD_PACK_PROTOTYPES(UDQFunctionTable) ADD_PACK_PROTOTYPES(UDQFunctionTable)
ADD_PACK_PROTOTYPES(UDQParams) ADD_PACK_PROTOTYPES(UDQParams)

View File

@@ -44,6 +44,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp>
@@ -1708,6 +1709,21 @@ BOOST_AUTO_TEST_CASE(UDQASTNode)
#endif #endif
} }
BOOST_AUTO_TEST_CASE(UDQDefine)
{
#ifdef HAVE_MPI
std::shared_ptr<Opm::UDQASTNode> n0;
Opm::UDQASTNode n1(Opm::UDQVarType::NONE,
Opm::UDQTokenType::error,
"test", 1.0, {"test1", "test2"}, n0, n0);
Opm::UDQDefine val1("test", std::make_shared<Opm::UDQASTNode>(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() bool init_unit_test_func()
{ {