mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add mpi serialization for Deck
This commit is contained in:
parent
6e8b82ae7d
commit
f461db3316
@ -1509,6 +1509,18 @@ std::size_t packSize(const DeckKeyword& data,
|
||||
packSize(data.isSlashTerminated(), comm);
|
||||
}
|
||||
|
||||
|
||||
std::size_t packSize(const Deck& data,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.keywords(), comm) +
|
||||
packSize(data.getDefaultUnitSystem(), comm) +
|
||||
packSize(data.activeUnitSystem(), comm) +
|
||||
packSize(data.getDataFile(), comm) +
|
||||
packSize(data.getInputPath(), comm) +
|
||||
packSize(data.unitSystemAccessCount(), comm);
|
||||
}
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -3045,6 +3057,18 @@ void pack(const DeckKeyword& data,
|
||||
pack(data.isSlashTerminated(), buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const Deck& data,
|
||||
std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.keywords(), buffer, position, comm);
|
||||
pack(data.getDefaultUnitSystem(), buffer, position, comm);
|
||||
pack(data.activeUnitSystem(), buffer, position, comm);
|
||||
pack(data.getDataFile(), buffer, position, comm);
|
||||
pack(data.getInputPath(), buffer, position, comm);
|
||||
pack(data.unitSystemAccessCount(), buffer, position, comm);
|
||||
}
|
||||
|
||||
/// unpack routines
|
||||
|
||||
template<class T>
|
||||
@ -5205,6 +5229,25 @@ void unpack(DeckKeyword& data,
|
||||
isDataKeyword, isSlashTerminated);
|
||||
}
|
||||
|
||||
void unpack(Deck& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::vector<DeckKeyword> keywords;
|
||||
UnitSystem defaultUnitSystem;
|
||||
std::unique_ptr<UnitSystem> activeUnitSystem;
|
||||
std::string dataFile, inputPath;
|
||||
size_t accessCount;
|
||||
|
||||
unpack(keywords, buffer, position, comm);
|
||||
unpack(defaultUnitSystem, buffer, position, comm);
|
||||
unpack(activeUnitSystem, buffer, position, comm);
|
||||
unpack(dataFile, buffer, position, comm);
|
||||
unpack(inputPath, buffer, position, comm);
|
||||
unpack(accessCount, buffer, position, comm);
|
||||
data = Deck(keywords, defaultUnitSystem,
|
||||
activeUnitSystem.get(), dataFile, inputPath, accessCount);
|
||||
}
|
||||
|
||||
#define INSTANTIATE_PACK_VECTOR(T) \
|
||||
template std::size_t packSize(const std::vector<T>& data, \
|
||||
Dune::MPIHelper::MPICommunicator comm); \
|
||||
|
@ -607,6 +607,7 @@ ADD_PACK_PROTOTYPES(data::Segment)
|
||||
ADD_PACK_PROTOTYPES(data::Solution)
|
||||
ADD_PACK_PROTOTYPES(data::Well)
|
||||
ADD_PACK_PROTOTYPES(data::WellRates)
|
||||
ADD_PACK_PROTOTYPES(Deck)
|
||||
ADD_PACK_PROTOTYPES(DeckItem)
|
||||
ADD_PACK_PROTOTYPES(DeckKeyword)
|
||||
ADD_PACK_PROTOTYPES(DeckRecord)
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp>
|
||||
#include <opm/material/fluidsystems/blackoilpvt/SolventPvt.hpp>
|
||||
#include <opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Edit/EDITNNC.hpp>
|
||||
@ -2053,6 +2054,21 @@ BOOST_AUTO_TEST_CASE(DeckKeyword)
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Deck)
|
||||
{
|
||||
#ifdef HAVE_MPI
|
||||
std::unique_ptr<Opm::UnitSystem> unitSys(new Opm::UnitSystem);
|
||||
Opm::Deck val1({Opm::DeckKeyword("test", {"test",1},
|
||||
{getDeckRecord(), getDeckRecord()}, true, false)},
|
||||
Opm::UnitSystem(), unitSys.get(),
|
||||
"test2", "test3", 2);
|
||||
auto val2 = PackUnpack(val1);
|
||||
BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2));
|
||||
BOOST_CHECK(val1 == std::get<0>(val2));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool init_unit_test_func()
|
||||
{
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user