diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 81369fa21..56b2ed2c4 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -31,6 +31,22 @@ #include #include +#define HANDLE_AS_POD(T) \ + std::size_t packSize(const T& data, Dune::MPIHelper::MPICommunicator comm) \ + { \ + return packSize(data, comm, std::integral_constant()); \ + } \ + void pack(const T& data, std::vector& buffer, int& position, \ + Dune::MPIHelper::MPICommunicator comm) \ + { \ + pack(data, buffer, position, comm, std::integral_constant()); \ + } \ + void unpack(T& data, std::vector& buffer, int& position, \ + Dune::MPIHelper::MPICommunicator comm) \ + { \ + unpack(data, buffer, position, comm, std::integral_constant()); \ + } + namespace Opm { namespace Mpi @@ -160,23 +176,9 @@ std::size_t packSize(const std::unordered_map& data, Dune::MPIHelpe return totalSize; } -std::size_t packSize(const data::Rates& data, Dune::MPIHelper::MPICommunicator comm) -{ - // plain struct no pointers -> treat as pod - return packSize(data, comm, std::integral_constant()); -} - -std::size_t packSize(const data::Connection& data, Dune::MPIHelper::MPICommunicator comm) -{ - // plain struct no pointers -> treat as pod - return packSize(data, comm, std::integral_constant()); -} - -std::size_t packSize(const data::Segment& data, Dune::MPIHelper::MPICommunicator comm) -{ - // plain struct no pointers -> treat as pod - return packSize(data, comm, std::integral_constant()); -} +HANDLE_AS_POD(data::Connection) +HANDLE_AS_POD(data::Rates) +HANDLE_AS_POD(data::Segment) std::size_t packSize(const data::Well& data, Dune::MPIHelper::MPICommunicator comm) { @@ -409,27 +411,6 @@ void pack(const std::unordered_map& data, std::vector& buffer } } -void pack(const data::Rates& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - // plain struct no pointers -> treat as pod - pack(data, buffer, position, comm, std::integral_constant()); -} - -void pack(const data::Connection& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - // plain struct no pointers -> treat as pod - pack(data, buffer, position, comm, std::integral_constant()); -} - -void pack(const data::Segment& data,std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - // plain struct no pointers -> treat as pod - pack(data, buffer, position, comm, std::integral_constant()); -} - void pack(const data::Well& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) { @@ -689,27 +670,6 @@ void unpack(std::unordered_map& data, std::vector& buffer, in } } -void unpack(data::Rates& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - // plain struct no pointers -> treat as pod - unpack(data, buffer, position, comm, std::integral_constant()); -} - -void unpack(data::Connection& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - // plain struct no pointers -> treat as pod - unpack(data, buffer, position, comm, std::integral_constant()); -} - -void unpack(data::Segment& data,std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm) -{ - // plain struct no pointers -> treat as pod - unpack(data, buffer, position, comm, std::integral_constant()); -} - void unpack(data::Well& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm) {