Merge pull request #4059 from akva2/guideratevalue_test

Add data::GuideRateValue mpiserializer test
This commit is contained in:
Bård Skaflestad 2022-09-05 12:16:10 +02:00 committed by GitHub
commit d2b3f87540
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 0 deletions

View File

@ -409,6 +409,27 @@ struct Packing<data::Segment>
}
};
template <std::size_t Size>
struct Packing<std::bitset<Size>>
{
static std::size_t packSize(const std::bitset<Size>& data, Opm::Parallel::MPIComm comm)
{
return Mpi::packSize(data.to_ullong(), comm);
}
static void pack(const std::bitset<Size>& data, std::vector<char>& buffer, int& position, Opm::Parallel::MPIComm comm)
{
Mpi::pack(data.to_ullong(), buffer, position, comm);
}
static void unpack(std::bitset<Size>& data, std::vector<char>& buffer, int& position, Opm::Parallel::MPIComm comm)
{
unsigned long long d;
Mpi::unpack(d, buffer, position, comm);
data = std::bitset<Size>(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<data::Segment>::packSize(data, comm);
}
template<std::size_t Size>
std::size_t packSize(const std::bitset<Size>& data, Opm::Parallel::MPIComm comm)
{
return Packing<std::bitset<Size>>::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<char>& buffer, int& position,
Packing<data::Segment>::pack(data, buffer, position, comm);
}
template<std::size_t Size>
void pack(const std::bitset<Size>& data, std::vector<char>& buffer,
int& position, Opm::Parallel::MPIComm comm)
{
Packing<std::bitset<Size>>::pack(data, buffer, position, comm);
}
void pack(const data::GroupAndNetworkValues& data, std::vector<char>& buffer, int& position,
Opm::Parallel::MPIComm comm)
{
@ -1246,6 +1280,13 @@ void unpack(data::Segment& data, std::vector<char>& buffer, int& position,
Packing<data::Segment>::unpack(data, buffer, position, comm);
}
template<std::size_t Size>
void unpack(std::bitset<Size>& data, std::vector<char>& buffer, int& position,
Opm::Parallel::MPIComm comm)
{
Packing<std::bitset<Size>>::unpack(data, buffer, position, comm);
}
void unpack(data::GroupAndNetworkValues& data, std::vector<char>& buffer, int& position,
Opm::Parallel::MPIComm comm)
{
@ -1328,6 +1369,7 @@ INSTANTIATE_PACK(unsigned long long int)
INSTANTIATE_PACK(std::array<short,3>)
INSTANTIATE_PACK(std::array<bool,3>)
INSTANTIATE_PACK(std::array<int,3>)
INSTANTIATE_PACK(std::array<double,4>)
INSTANTIATE_PACK(std::map<std::pair<int,int>,std::pair<bool,double>>)
INSTANTIATE_PACK(std::optional<double>)
INSTANTIATE_PACK(std::optional<std::string>)
@ -1345,6 +1387,8 @@ INSTANTIATE_PACK(std::unordered_map<std::string,size_t,Opm::OrderedMapDetail::Tr
INSTANTIATE_PACK(std::unordered_map<std::string,std::string>)
INSTANTIATE_PACK(std::unordered_set<std::string>)
INSTANTIATE_PACK(std::set<std::string>)
INSTANTIATE_PACK(std::bitset<4>)
#undef INSTANTIATE_PACK

View File

@ -31,7 +31,9 @@
#include <opm/simulators/utils/ParallelCommunication.hpp>
#include <bitset>
#include <chrono>
#include <cstddef>
#include <optional>
#include <map>
#include <set>
@ -153,6 +155,9 @@ std::size_t packSize(const std::map<T1,T2,C,A>& data, Opm::Parallel::MPIComm com
template<class T1, class T2, class H, class P, class A>
std::size_t packSize(const std::unordered_map<T1,T2,H,P,A>& data, Opm::Parallel::MPIComm comm);
template<std::size_t Size>
std::size_t packSize(const std::bitset<Size>& data, Opm::Parallel::MPIComm comm);
////// pack routines
template<class T>
@ -241,6 +246,10 @@ void pack(const std::unordered_map<T1,T2,H,P,A>& data, std::vector<char>& buffer
void pack(const char* str, std::vector<char>& buffer, int& position,
Opm::Parallel::MPIComm comm);
template<size_t Size>
void pack(const std::bitset<Size>& data, std::vector<char>& buffer, int& position,
Opm::Parallel::MPIComm comm);
/// unpack routines
template<class T>
@ -330,6 +339,10 @@ void unpack(std::unordered_map<T1,T2,H,P,A>& data, std::vector<char>& buffer, in
void unpack(char* str, std::size_t length, std::vector<char>& buffer, int& position,
Opm::Parallel::MPIComm comm);
template<size_t Size>
void unpack(std::bitset<Size>& data, std::vector<char>& buffer, int& position,
Opm::Parallel::MPIComm comm);
/// prototypes for complex types
#define ADD_PACK_PROTOTYPES(T) \

View File

@ -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)