diff --git a/opm/simulators/utils/ParallelRestart.cpp b/opm/simulators/utils/ParallelRestart.cpp index 890e32ab1..af6c7a17e 100644 --- a/opm/simulators/utils/ParallelRestart.cpp +++ b/opm/simulators/utils/ParallelRestart.cpp @@ -409,6 +409,27 @@ struct Packing } }; +template +struct Packing> +{ + static std::size_t packSize(const std::bitset& data, Opm::Parallel::MPIComm comm) + { + return Mpi::packSize(data.to_ullong(), comm); + } + + static void pack(const std::bitset& data, std::vector& buffer, int& position, Opm::Parallel::MPIComm comm) + { + Mpi::pack(data.to_ullong(), buffer, position, comm); + } + + static void unpack(std::bitset& data, std::vector& buffer, int& position, Opm::Parallel::MPIComm comm) + { + unsigned long long d; + Mpi::unpack(d, buffer, position, comm); + data = std::bitset(d); + } +}; + std::size_t packSize(const data::NumericAquiferData& data, Opm::Parallel::MPIComm comm) { return packSize(data.initPressure, comm); @@ -498,6 +519,12 @@ std::size_t packSize(const data::Segment& data, Opm::Parallel::MPIComm comm) return Packing::packSize(data, comm); } +template +std::size_t packSize(const std::bitset& data, Opm::Parallel::MPIComm comm) +{ + return Packing>::packSize(data, comm); +} + std::size_t packSize(const data::CellData& data, Opm::Parallel::MPIComm comm) { return packSize(data.dim, comm) + packSize(data.data, comm) + packSize(data.target, comm); @@ -877,6 +904,13 @@ void pack(const data::Segment& data, std::vector& buffer, int& position, Packing::pack(data, buffer, position, comm); } +template +void pack(const std::bitset& data, std::vector& buffer, + int& position, Opm::Parallel::MPIComm comm) +{ + Packing>::pack(data, buffer, position, comm); +} + void pack(const data::GroupAndNetworkValues& data, std::vector& buffer, int& position, Opm::Parallel::MPIComm comm) { @@ -1246,6 +1280,13 @@ void unpack(data::Segment& data, std::vector& buffer, int& position, Packing::unpack(data, buffer, position, comm); } +template +void unpack(std::bitset& data, std::vector& buffer, int& position, + Opm::Parallel::MPIComm comm) +{ + Packing>::unpack(data, buffer, position, comm); +} + void unpack(data::GroupAndNetworkValues& data, std::vector& buffer, int& position, Opm::Parallel::MPIComm comm) { @@ -1328,6 +1369,7 @@ INSTANTIATE_PACK(unsigned long long int) INSTANTIATE_PACK(std::array) INSTANTIATE_PACK(std::array) INSTANTIATE_PACK(std::array) +INSTANTIATE_PACK(std::array) INSTANTIATE_PACK(std::map,std::pair>) INSTANTIATE_PACK(std::optional) INSTANTIATE_PACK(std::optional) @@ -1345,6 +1387,8 @@ INSTANTIATE_PACK(std::unordered_map) INSTANTIATE_PACK(std::unordered_set) INSTANTIATE_PACK(std::set) +INSTANTIATE_PACK(std::bitset<4>) + #undef INSTANTIATE_PACK diff --git a/opm/simulators/utils/ParallelRestart.hpp b/opm/simulators/utils/ParallelRestart.hpp index 72df8ac28..55d4791c6 100644 --- a/opm/simulators/utils/ParallelRestart.hpp +++ b/opm/simulators/utils/ParallelRestart.hpp @@ -31,7 +31,9 @@ #include +#include #include +#include #include #include #include @@ -153,6 +155,9 @@ std::size_t packSize(const std::map& data, Opm::Parallel::MPIComm com template std::size_t packSize(const std::unordered_map& data, Opm::Parallel::MPIComm comm); +template +std::size_t packSize(const std::bitset& data, Opm::Parallel::MPIComm comm); + ////// pack routines template @@ -241,6 +246,10 @@ void pack(const std::unordered_map& data, std::vector& buffer void pack(const char* str, std::vector& buffer, int& position, Opm::Parallel::MPIComm comm); +template +void pack(const std::bitset& data, std::vector& buffer, int& position, + Opm::Parallel::MPIComm comm); + /// unpack routines template @@ -330,6 +339,10 @@ void unpack(std::unordered_map& data, std::vector& buffer, in void unpack(char* str, std::size_t length, std::vector& buffer, int& position, Opm::Parallel::MPIComm comm); +template +void unpack(std::bitset& data, std::vector& buffer, int& position, + Opm::Parallel::MPIComm comm); + /// prototypes for complex types #define ADD_PACK_PROTOTYPES(T) \ diff --git a/tests/test_ParallelRestart.cpp b/tests/test_ParallelRestart.cpp index c2052af4c..0514b46e2 100644 --- a/tests/test_ParallelRestart.cpp +++ b/tests/test_ParallelRestart.cpp @@ -573,6 +573,7 @@ TEST_FOR_TYPE(ColumnSchema) TEST_FOR_TYPE(Connection) TEST_FOR_TYPE_NAMED(data::CellData, CellData) TEST_FOR_TYPE_NAMED(data::GroupConstraints, GroupConstraints) +TEST_FOR_TYPE_NAMED(data::GuideRateValue, GuideRateValue) TEST_FOR_TYPE_NAMED(data::NodeData, NodeData) TEST_FOR_TYPE(Deck) TEST_FOR_TYPE(DeckItem)