add mpi serialization for UDQAssign

This commit is contained in:
Arne Morten Kvarving
2019-12-11 16:31:47 +01:00
parent 3d17266476
commit fcd6c7582b
3 changed files with 72 additions and 0 deletions

View File

@@ -1316,6 +1316,21 @@ std::size_t packSize(const UDQDefine& data,
packSize(data.input_string(), comm); 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 ////// pack routines
template<class T> template<class T>
@@ -2648,6 +2663,23 @@ void pack(const UDQDefine& data,
pack(data.input_string(), buffer, position, comm); pack(data.input_string(), buffer, position, comm);
} }
void pack(const UDQAssign::AssignRecord& data,
std::vector<char>& 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<char>& 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 /// unpack routines
template<class T> template<class T>
@@ -4532,6 +4564,29 @@ void unpack(UDQDefine& data,
data = UDQDefine(keyword, ast, varType, string_data); data = UDQDefine(keyword, ast, varType, string_data);
} }
void unpack(UDQAssign::AssignRecord& data,
std::vector<char>& 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<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
std::string keyword;
UDQVarType varType;
std::vector<UDQAssign::AssignRecord> 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) \ #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

@@ -43,6 +43,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/DynamicVector.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/DynamicVector.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestConfig.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp> #include <opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp>
@@ -631,6 +632,8 @@ ADD_PACK_PROTOTYPES(ThresholdPressure)
ADD_PACK_PROTOTYPES(TimeMap) 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(UDQAssign)
ADD_PACK_PROTOTYPES(UDQAssign::AssignRecord)
ADD_PACK_PROTOTYPES(UDQASTNode) ADD_PACK_PROTOTYPES(UDQASTNode)
ADD_PACK_PROTOTYPES(UDQDefine) ADD_PACK_PROTOTYPES(UDQDefine)
ADD_PACK_PROTOTYPES(UDQFunction) ADD_PACK_PROTOTYPES(UDQFunction)

View File

@@ -43,6 +43,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.hpp>
#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/UDQAssign.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/UDQDefine.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp>
@@ -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() bool init_unit_test_func()
{ {
return true; return true;