mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-07 15:03:01 -06:00
add mpi serialization for MULTREGTScanner
This commit is contained in:
parent
252f323fb6
commit
ff8fac563f
@ -1963,6 +1963,16 @@ std::size_t packSize(const MULTREGTRecord& data,
|
||||
packSize(data.region_name, comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const MULTREGTScanner& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.getSize(), comm) +
|
||||
packSize(data.getRecords(), comm) +
|
||||
packSize(data.getSearchMap(), comm) +
|
||||
packSize(data.getRegions(), comm) +
|
||||
packSize(data.getDefaultRegion(), comm);
|
||||
}
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -3830,6 +3840,17 @@ void pack(const MULTREGTRecord& data,
|
||||
pack(data.region_name, buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const MULTREGTScanner& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.getSize(), buffer, position, comm);
|
||||
pack(data.getRecords(), buffer, position, comm);
|
||||
pack(data.getSearchMap(), buffer, position, comm);
|
||||
pack(data.getRegions(), buffer, position, comm);
|
||||
pack(data.getDefaultRegion(), buffer, position, comm);
|
||||
}
|
||||
|
||||
/// unpack routines
|
||||
|
||||
template<class T>
|
||||
@ -6495,6 +6516,25 @@ void unpack(MULTREGTRecord& data,
|
||||
unpack(data.region_name, buffer, position, comm);
|
||||
}
|
||||
|
||||
void unpack(MULTREGTScanner& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::array<size_t, 3> size;
|
||||
std::vector<MULTREGTRecord> records;
|
||||
MULTREGTScanner::ExternalSearchMap searchMap;
|
||||
std::map<std::string, std::vector<int>> regions;
|
||||
std::string defaultRegion;
|
||||
|
||||
unpack(size, buffer, position, comm);
|
||||
unpack(records, buffer, position, comm);
|
||||
unpack(searchMap, buffer, position, comm);
|
||||
unpack(regions, buffer, position, comm);
|
||||
unpack(defaultRegion, buffer, position, comm);
|
||||
|
||||
data = MULTREGTScanner(size, records, searchMap, regions, defaultRegion);
|
||||
}
|
||||
|
||||
#define INSTANTIATE_PACK_VECTOR(...) \
|
||||
template std::size_t packSize(const std::vector<__VA_ARGS__>& data, \
|
||||
Dune::MPIHelper::MPICommunicator comm); \
|
||||
|
@ -100,6 +100,7 @@ class Location;
|
||||
class MessageLimits;
|
||||
class MLimits;
|
||||
class MULTREGTRecord;
|
||||
class MULTREGTScanner;
|
||||
class NNC;
|
||||
struct NNCdata;
|
||||
class OilVaporizationProperties;
|
||||
@ -681,6 +682,7 @@ ADD_PACK_PROTOTYPES(Location)
|
||||
ADD_PACK_PROTOTYPES(MessageLimits)
|
||||
ADD_PACK_PROTOTYPES(MLimits)
|
||||
ADD_PACK_PROTOTYPES(MULTREGTRecord)
|
||||
ADD_PACK_PROTOTYPES(MULTREGTScanner)
|
||||
ADD_PACK_PROTOTYPES(NNC)
|
||||
ADD_PACK_PROTOTYPES(NNCdata)
|
||||
ADD_PACK_PROTOTYPES(OilVaporizationProperties)
|
||||
|
@ -2426,6 +2426,26 @@ BOOST_AUTO_TEST_CASE(MULTREGTRecord)
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(MULTREGTScanner)
|
||||
{
|
||||
#ifdef HAVE_MPI
|
||||
std::vector<Opm::MULTREGTRecord> records{{1, 2, 3.0, 4, Opm::MULTREGT::ALL, "test1"}};
|
||||
std::map<std::pair<int, int>, int> searchRecord{{{5,6},0}};
|
||||
Opm::MULTREGTScanner::ExternalSearchMap searchMap;
|
||||
searchMap.insert({"test2", searchRecord});
|
||||
Opm::MULTREGTScanner val1({1, 2, 3},
|
||||
records,
|
||||
searchMap,
|
||||
{{"test3", {7,8}}},
|
||||
"test4");
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user