add mpi serialization for Location

This commit is contained in:
Arne Morten Kvarving 2019-12-13 11:40:43 +01:00
parent 3a893fb149
commit 8ba18cf038
3 changed files with 40 additions and 1 deletions

View File

@ -22,6 +22,7 @@
#endif
#include "ParallelRestart.hpp"
#include <opm/common/OpmLog/Location.hpp>
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/NNC.hpp>
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
@ -1480,6 +1481,13 @@ std::size_t packSize(const DeckRecord& data,
return packSize(data.getItems(), comm);
}
std::size_t packSize(const Location& data,
Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.filename, comm) +
packSize(data.lineno, comm);
}
////// pack routines
template<class T>
@ -2988,6 +2996,14 @@ void pack(const DeckRecord& data,
pack(data.getItems(), buffer, position, comm);
}
void pack(const Location& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.filename, buffer, position, comm);
pack(data.lineno, buffer, position, comm);
}
/// unpack routines
template<class T>
@ -5109,6 +5125,15 @@ void unpack(DeckRecord& data,
data = DeckRecord(std::move(items));
}
void unpack(Location& data,
std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
data.filename.clear();
unpack(data.filename, buffer, position, comm);
unpack(data.lineno, buffer, position, comm);
}
#define INSTANTIATE_PACK_VECTOR(T) \
template std::size_t packSize(const std::vector<T>& data, \
Dune::MPIHelper::MPICommunicator comm); \

View File

@ -84,6 +84,7 @@ class InitConfig;
class IOConfig;
template<class T> class IOrderSet;
class JFunc;
class Location;
class MessageLimits;
class MLimits;
class NNC;
@ -622,6 +623,7 @@ ADD_PACK_PROTOTYPES(Group::GroupProductionProperties)
ADD_PACK_PROTOTYPES(InitConfig)
ADD_PACK_PROTOTYPES(IOConfig)
ADD_PACK_PROTOTYPES(JFunc)
ADD_PACK_PROTOTYPES(Location)
ADD_PACK_PROTOTYPES(MessageLimits)
ADD_PACK_PROTOTYPES(MLimits)
ADD_PACK_PROTOTYPES(NNC)

View File

@ -24,7 +24,7 @@
#include <boost/test/unit_test.hpp>
#include <opm/simulators/utils/ParallelRestart.hpp>
#include <opm/common/OpmLog/Location.hpp>
#include <opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/SolventPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp>
@ -86,6 +86,7 @@
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp>
#include <opm/output/eclipse/RestartValue.hpp>
#include <opm/simulators/utils/ParallelRestart.hpp>
namespace {
@ -2029,6 +2030,17 @@ BOOST_AUTO_TEST_CASE(DeckRecord)
}
BOOST_AUTO_TEST_CASE(Location)
{
#ifdef HAVE_MPI
Opm::Location val1{"test", 1};
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;