mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #2465 from akva2/serialize_internal_eclstate_part2
Internal serialization in EclipseState - part 2
This commit is contained in:
@@ -54,7 +54,10 @@ public:
|
||||
auto handle = [&](auto& d)
|
||||
{
|
||||
for (auto& it : d) {
|
||||
it.serializeOp(*this);
|
||||
if constexpr (is_pair<T>::value)
|
||||
pair(it);
|
||||
else
|
||||
it.serializeOp(*this);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -118,6 +121,30 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
template<class T>
|
||||
struct is_pair {
|
||||
constexpr static bool value = false;
|
||||
};
|
||||
|
||||
template<class T1, class T2>
|
||||
struct is_pair<std::pair<T1,T2>> {
|
||||
constexpr static bool value = true;
|
||||
};
|
||||
|
||||
template<class T1, class T2>
|
||||
void pair(const std::pair<T1,T2>& data)
|
||||
{
|
||||
if constexpr (std::is_pod<T1>::value || std::is_same<T1,std::string>::value)
|
||||
(*this)(data.first);
|
||||
else
|
||||
data.first.serializeOp(*this);
|
||||
|
||||
if constexpr (std::is_pod<T2>::value || std::is_same<T2,std::string>::value)
|
||||
(*this)(data.second);
|
||||
else
|
||||
const_cast<T2&>(data.second).serializeOp(*this);
|
||||
}
|
||||
|
||||
Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator> m_comm;
|
||||
|
||||
Operation m_op = Operation::PACKSIZE;
|
||||
|
||||
@@ -25,11 +25,6 @@
|
||||
#include <opm/common/OpmLog/Location.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/Fault.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/TransMult.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
||||
@@ -1549,27 +1544,6 @@ std::size_t packSize(const GuideRateConfig::GroupTarget& data,
|
||||
packSize(data.target, comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const MULTREGTRecord& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.src_value, comm) +
|
||||
packSize(data.target_value, comm) +
|
||||
packSize(data.trans_mult, comm) +
|
||||
packSize(data.directions, comm) +
|
||||
packSize(data.nnc_behaviour, comm) +
|
||||
packSize(data.region_name, comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const MULTREGTScanner& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.getSize(), comm) +
|
||||
packSize(data.getRecords(), comm) +
|
||||
packSize(data.getSearchMap(), comm) +
|
||||
packSize(data.getRegions(), comm) +
|
||||
packSize(data.getDefaultRegion(), comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const EclipseConfig& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
@@ -1577,36 +1551,6 @@ std::size_t packSize(const EclipseConfig& data,
|
||||
packSize(data.io(), comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const TransMult& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.getSize(), comm) +
|
||||
packSize(data.getTrans(), comm) +
|
||||
packSize(data.getNames(), comm) +
|
||||
packSize(data.getScanner(), comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const FaultFace& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.getIndices(), comm) +
|
||||
packSize(data.getDir(), comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const Fault& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.getName(), comm) +
|
||||
packSize(data.getTransMult(), comm) +
|
||||
packSize(data.getFaceList(), comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const FaultCollection& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.getFaults(), comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const SolventDensityTable& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
@@ -3099,29 +3043,6 @@ void pack(const GuideRateConfig::GroupTarget& data,
|
||||
pack(data.target, buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const MULTREGTRecord& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.src_value, buffer, position, comm);
|
||||
pack(data.target_value, buffer, position, comm);
|
||||
pack(data.trans_mult, buffer, position, comm);
|
||||
pack(data.directions, buffer, position, comm);
|
||||
pack(data.nnc_behaviour, buffer, position, comm);
|
||||
pack(data.region_name, buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const MULTREGTScanner& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.getSize(), buffer, position, comm);
|
||||
pack(data.getRecords(), buffer, position, comm);
|
||||
pack(data.getSearchMap(), buffer, position, comm);
|
||||
pack(data.getRegions(), buffer, position, comm);
|
||||
pack(data.getDefaultRegion(), buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const EclipseConfig& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
@@ -3130,40 +3051,6 @@ void pack(const EclipseConfig& data,
|
||||
pack(data.io(), buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const TransMult& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.getSize(), buffer, position, comm);
|
||||
pack(data.getTrans(), buffer, position, comm);
|
||||
pack(data.getNames(), buffer, position, comm);
|
||||
pack(data.getScanner(), buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const FaultFace& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.getIndices(), buffer, position, comm);
|
||||
pack(data.getDir(), buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const Fault& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.getName(), buffer, position, comm);
|
||||
pack(data.getTransMult(), buffer, position, comm);
|
||||
pack(data.getFaceList(), buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const FaultCollection& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.getFaults(), buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const SolventDensityTable& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
@@ -5275,37 +5162,6 @@ void unpack(GuideRateConfig::GroupTarget& data,
|
||||
unpack(data.target, buffer, position, comm);
|
||||
}
|
||||
|
||||
void unpack(MULTREGTRecord& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
unpack(data.src_value, buffer, position, comm);
|
||||
unpack(data.target_value, buffer, position, comm);
|
||||
unpack(data.trans_mult, buffer, position, comm);
|
||||
unpack(data.directions, buffer, position, comm);
|
||||
unpack(data.nnc_behaviour, buffer, position, comm);
|
||||
unpack(data.region_name, buffer, position, comm);
|
||||
}
|
||||
|
||||
void unpack(MULTREGTScanner& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::array<size_t, 3> size;
|
||||
std::vector<MULTREGTRecord> records;
|
||||
MULTREGTScanner::ExternalSearchMap searchMap;
|
||||
std::map<std::string, std::vector<int>> regions;
|
||||
std::string defaultRegion;
|
||||
|
||||
unpack(size, buffer, position, comm);
|
||||
unpack(records, buffer, position, comm);
|
||||
unpack(searchMap, buffer, position, comm);
|
||||
unpack(regions, buffer, position, comm);
|
||||
unpack(defaultRegion, buffer, position, comm);
|
||||
|
||||
data = MULTREGTScanner(size, records, searchMap, regions, defaultRegion);
|
||||
}
|
||||
|
||||
void unpack(EclipseConfig& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
@@ -5318,58 +5174,6 @@ void unpack(EclipseConfig& data,
|
||||
data = EclipseConfig(init, io);
|
||||
}
|
||||
|
||||
void unpack(TransMult& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::array<size_t, 3> size;
|
||||
std::map<FaceDir::DirEnum, std::vector<double>> trans;
|
||||
std::map<FaceDir::DirEnum, std::string> names;
|
||||
MULTREGTScanner scanner;
|
||||
|
||||
unpack(size, buffer, position, comm);
|
||||
unpack(trans, buffer, position, comm);
|
||||
unpack(names, buffer, position, comm);
|
||||
unpack(scanner, buffer, position, comm);
|
||||
data = TransMult(size, trans, names, scanner);
|
||||
}
|
||||
|
||||
void unpack(FaultFace& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::vector<size_t> indices;
|
||||
FaceDir::DirEnum dir;
|
||||
|
||||
unpack(indices, buffer, position, comm);
|
||||
unpack(dir, buffer, position, comm);
|
||||
data = FaultFace(indices, dir);
|
||||
}
|
||||
|
||||
void unpack(Fault& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::string name;
|
||||
double transMult;
|
||||
std::vector<FaultFace> faceList;
|
||||
|
||||
unpack(name, buffer, position, comm);
|
||||
unpack(transMult, buffer, position, comm);
|
||||
unpack(faceList, buffer, position, comm);
|
||||
data = Fault(name, transMult, faceList);
|
||||
}
|
||||
|
||||
void unpack(FaultCollection& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
OrderedMap<std::string, Fault> faults;
|
||||
|
||||
unpack(faults, buffer, position, comm);
|
||||
data = FaultCollection(faults);
|
||||
}
|
||||
|
||||
void unpack(SolventDensityTable& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
@@ -5476,6 +5280,7 @@ INSTANTIATE_PACK_VECTOR(std::vector<double>)
|
||||
INSTANTIATE_PACK_VECTOR(bool)
|
||||
INSTANTIATE_PACK_VECTOR(char)
|
||||
INSTANTIATE_PACK_VECTOR(int)
|
||||
INSTANTIATE_PACK_VECTOR(size_t)
|
||||
INSTANTIATE_PACK_VECTOR(std::array<double, 3>)
|
||||
INSTANTIATE_PACK_VECTOR(std::pair<bool,double>)
|
||||
INSTANTIATE_PACK_VECTOR(std::shared_ptr<Group>)
|
||||
|
||||
@@ -82,9 +82,6 @@ class EndpointScaling;
|
||||
class Equil;
|
||||
class EquilRecord;
|
||||
class Events;
|
||||
class Fault;
|
||||
class FaultCollection;
|
||||
class FaultFace;
|
||||
class FoamConfig;
|
||||
class FoamData;
|
||||
class InitConfig;
|
||||
@@ -94,8 +91,6 @@ class JFunc;
|
||||
class Location;
|
||||
class MessageLimits;
|
||||
class MLimits;
|
||||
class MULTREGTRecord;
|
||||
class MULTREGTScanner;
|
||||
class OilVaporizationProperties;
|
||||
class Phases;
|
||||
class PlymwinjTable;
|
||||
@@ -141,7 +136,6 @@ class TableSchema;
|
||||
class TimeStampUTC;
|
||||
class TlmixparRecord;
|
||||
class TlmixparTable;
|
||||
class TransMult;
|
||||
class Tuning;
|
||||
class UDAValue;
|
||||
class UDQASTNode;
|
||||
@@ -529,9 +523,6 @@ ADD_PACK_PROTOTYPES(Equil)
|
||||
ADD_PACK_PROTOTYPES(Eqldims)
|
||||
ADD_PACK_PROTOTYPES(EquilRecord)
|
||||
ADD_PACK_PROTOTYPES(Events)
|
||||
ADD_PACK_PROTOTYPES(Fault)
|
||||
ADD_PACK_PROTOTYPES(FaultCollection)
|
||||
ADD_PACK_PROTOTYPES(FaultFace)
|
||||
ADD_PACK_PROTOTYPES(FoamConfig)
|
||||
ADD_PACK_PROTOTYPES(FoamData)
|
||||
ADD_PACK_PROTOTYPES(GConSale)
|
||||
@@ -551,8 +542,6 @@ ADD_PACK_PROTOTYPES(JFunc)
|
||||
ADD_PACK_PROTOTYPES(Location)
|
||||
ADD_PACK_PROTOTYPES(MessageLimits)
|
||||
ADD_PACK_PROTOTYPES(MLimits)
|
||||
ADD_PACK_PROTOTYPES(MULTREGTRecord)
|
||||
ADD_PACK_PROTOTYPES(MULTREGTScanner)
|
||||
ADD_PACK_PROTOTYPES(OilVaporizationProperties)
|
||||
ADD_PACK_PROTOTYPES(Phases)
|
||||
ADD_PACK_PROTOTYPES(PlmixparRecord)
|
||||
@@ -601,7 +590,6 @@ ADD_PACK_PROTOTYPES(TimeMap)
|
||||
ADD_PACK_PROTOTYPES(TimeStampUTC)
|
||||
ADD_PACK_PROTOTYPES(TlmixparRecord)
|
||||
ADD_PACK_PROTOTYPES(TlmixparTable)
|
||||
ADD_PACK_PROTOTYPES(TransMult)
|
||||
ADD_PACK_PROTOTYPES(Tuning)
|
||||
ADD_PACK_PROTOTYPES(UDAValue)
|
||||
ADD_PACK_PROTOTYPES(UDQActive)
|
||||
|
||||
@@ -2232,7 +2232,7 @@ BOOST_AUTO_TEST_CASE(MULTREGTRecord)
|
||||
{
|
||||
#ifdef HAVE_MPI
|
||||
Opm::MULTREGTRecord val1{1, 2, 3.0, 4, Opm::MULTREGT::ALL, "test"};
|
||||
auto val2 = PackUnpack(val1);
|
||||
auto val2 = PackUnpack2(val1);
|
||||
DO_CHECKS(MULTREGTRecord)
|
||||
#endif
|
||||
}
|
||||
@@ -2251,7 +2251,7 @@ BOOST_AUTO_TEST_CASE(MULTREGTScanner)
|
||||
{{"test3", {7,8}}},
|
||||
"test4");
|
||||
|
||||
auto val2 = PackUnpack(val1);
|
||||
auto val2 = PackUnpack2(val1);
|
||||
DO_CHECKS(MULTREGTScanner)
|
||||
#endif
|
||||
}
|
||||
@@ -2290,7 +2290,7 @@ BOOST_AUTO_TEST_CASE(TransMult)
|
||||
{{Opm::FaceDir::YPlus, {4.0, 5.0}}},
|
||||
{{Opm::FaceDir::ZPlus, "test1"}},
|
||||
scanner);
|
||||
auto val2 = PackUnpack(val1);
|
||||
auto val2 = PackUnpack2(val1);
|
||||
DO_CHECKS(TransMult)
|
||||
#endif
|
||||
}
|
||||
@@ -2300,7 +2300,7 @@ BOOST_AUTO_TEST_CASE(FaultFace)
|
||||
{
|
||||
#ifdef HAVE_MPI
|
||||
Opm::FaultFace val1({1,2,3,4,5,6}, Opm::FaceDir::YPlus);
|
||||
auto val2 = PackUnpack(val1);
|
||||
auto val2 = PackUnpack2(val1);
|
||||
DO_CHECKS(FaultFace)
|
||||
#endif
|
||||
}
|
||||
@@ -2310,7 +2310,7 @@ BOOST_AUTO_TEST_CASE(Fault)
|
||||
{
|
||||
#ifdef HAVE_MPI
|
||||
Opm::Fault val1("test", 1.0, {{{1,2,3,4,5,6}, Opm::FaceDir::YPlus}});
|
||||
auto val2 = PackUnpack(val1);
|
||||
auto val2 = PackUnpack2(val1);
|
||||
DO_CHECKS(Fault)
|
||||
#endif
|
||||
}
|
||||
@@ -2340,7 +2340,7 @@ BOOST_AUTO_TEST_CASE(FaultCollection)
|
||||
Opm::OrderedMap<std::string, Opm::Fault> faults;
|
||||
faults.insert({"test2", fault});
|
||||
Opm::FaultCollection val1(faults);
|
||||
auto val2 = PackUnpack(val1);
|
||||
auto val2 = PackUnpack2(val1);
|
||||
DO_CHECKS(FaultCollection)
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user