add mpi serialization for FaultCollection

This commit is contained in:
Arne Morten Kvarving 2020-01-14 15:00:42 +01:00
parent d00ee94561
commit 468c220bca
3 changed files with 39 additions and 0 deletions

View File

@ -2005,6 +2005,12 @@ std::size_t packSize(const Fault& data,
packSize(data.getFaceList(), comm);
}
std::size_t packSize(const FaultCollection& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getFaults(), comm);
}
////// pack routines
template<class T>
@ -3919,6 +3925,13 @@ void pack(const Fault& data,
pack(data.getFaceList(), buffer, position, comm);
}
void pack(const FaultCollection& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.getFaults(), buffer, position, comm);
}
/// unpack routines
template<class T>
@ -6659,6 +6672,16 @@ void unpack(Fault& data,
data = Fault(name, transMult, faceList);
}
void unpack(FaultCollection& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
OrderedMap<std::string, Fault> faults;
unpack(faults, buffer, position, comm);
data = FaultCollection(faults);
}
#define INSTANTIATE_PACK_VECTOR(...) \
template std::size_t packSize(const std::vector<__VA_ARGS__>& data, \
Dune::MPIHelper::MPICommunicator comm); \

View File

@ -92,6 +92,7 @@ class Equil;
class EquilRecord;
class Events;
class Fault;
class FaultCollection;
class FaultFace;
class FoamConfig;
class FoamData;
@ -668,6 +669,7 @@ ADD_PACK_PROTOTYPES(Eqldims)
ADD_PACK_PROTOTYPES(EquilRecord)
ADD_PACK_PROTOTYPES(Events)
ADD_PACK_PROTOTYPES(Fault)
ADD_PACK_PROTOTYPES(FaultCollection)
ADD_PACK_PROTOTYPES(FaultFace)
ADD_PACK_PROTOTYPES(FoamConfig)
ADD_PACK_PROTOTYPES(FoamData)

View File

@ -2512,6 +2512,20 @@ BOOST_AUTO_TEST_CASE(Fault)
}
BOOST_AUTO_TEST_CASE(FaultCollection)
{
#ifdef HAVE_MPI
Opm::Fault fault("test", 1.0, {{{1,2,3,4,5,6}, Opm::FaceDir::YPlus}});
Opm::OrderedMap<std::string, Opm::Fault> faults;
faults.insert({"test2", fault});
Opm::FaultCollection val1(faults);
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;