From 77879f50fe3972d73643f4d8ce64dfefef40517b Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 28 Nov 2019 13:47:56 +0100 Subject: [PATCH] changed: use a macro to declare prototypes in ParallelRestart.hpp more readable, less tedious to add new types --- opm/simulators/utils/ParallelRestart.hpp | 101 +++++------------------ 1 file changed, 20 insertions(+), 81 deletions(-) diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 1dee1f0a3..37228aa71 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -32,6 +32,7 @@ #include #include #include + namespace Opm { namespace Mpi @@ -74,24 +75,6 @@ std::size_t packSize(const std::map& data, Dune::MPIHelper::MPICommun template std::size_t packSize(const std::unordered_map& data, Dune::MPIHelper::MPICommunicator comm); -std::size_t packSize(const data::Rates& data, Dune::MPIHelper::MPICommunicator comm); - -std::size_t packSize(const data::Connection& data, Dune::MPIHelper::MPICommunicator comm); - -std::size_t packSize(const data::Segment& data, Dune::MPIHelper::MPICommunicator comm); - -std::size_t packSize(const data::Well& data, Dune::MPIHelper::MPICommunicator comm); - -std::size_t packSize(const data::CellData& data, Dune::MPIHelper::MPICommunicator comm); - -std::size_t packSize(const RestartKey& data, Dune::MPIHelper::MPICommunicator comm); - -std::size_t packSize(const data::Solution& data, Dune::MPIHelper::MPICommunicator comm); - -std::size_t packSize(const data::WellRates& data, Dune::MPIHelper::MPICommunicator comm); - -std::size_t packSize(const RestartValue& data, Dune::MPIHelper::MPICommunicator comm); - ////// pack routines template @@ -127,48 +110,15 @@ template void pack(const std::vector& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); - -void pack(const char* str, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void pack(const std::string& str, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - template void pack(const std::map& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); - template void pack(const std::unordered_map& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); - -void pack(const data::Rates& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void pack(const data::Connection& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void pack(const data::Segment& data,std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void pack(const data::Well& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void pack(const RestartKey& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void pack(const data::CellData& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void pack(const data::Solution& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void pack(const data::WellRates& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void pack(const RestartValue& data, std::vector& buffer, int& position, +void pack(const char* str, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); /// unpack routines @@ -206,13 +156,6 @@ template void unpack(std::vector& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); - -void unpack(char* str, std::size_t length, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void unpack(std::string& str, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - template void unpack(std::map& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); @@ -221,32 +164,28 @@ template void unpack(std::unordered_map& data, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); -void unpack(data::Rates& data, std::vector& buffer, int& position, +void unpack(char* str, std::size_t length, std::vector& buffer, int& position, Dune::MPIHelper::MPICommunicator comm); -void unpack(data::Connection& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); +/// prototypes for complex types -void unpack(data::Segment& data,std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); +#define ADD_PACK_PROTOTYPES(T) \ + std::size_t packSize(const T& data, Dune::MPIHelper::MPICommunicator comm); \ + void pack(const T& data, std::vector& buffer, int& position, \ + Dune::MPIHelper::MPICommunicator comm); \ + void unpack(T& data, std::vector& buffer, int& position, \ + Dune::MPIHelper::MPICommunicator comm); -void unpack(data::Well& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void unpack(RestartKey& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void unpack(data::CellData& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void unpack(data::Solution& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void unpack(data::WellRates& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); - -void unpack(RestartValue& data, std::vector& buffer, int& position, - Dune::MPIHelper::MPICommunicator comm); +ADD_PACK_PROTOTYPES(data::CellData) +ADD_PACK_PROTOTYPES(data::Connection) +ADD_PACK_PROTOTYPES(data::Rates) +ADD_PACK_PROTOTYPES(data::Segment) +ADD_PACK_PROTOTYPES(data::Solution) +ADD_PACK_PROTOTYPES(data::Well) +ADD_PACK_PROTOTYPES(data::WellRates) +ADD_PACK_PROTOTYPES(RestartKey) +ADD_PACK_PROTOTYPES(RestartValue) +ADD_PACK_PROTOTYPES(std::string) } // end namespace Mpi RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,