add mpi serialization for TableManager

This commit is contained in:
Arne Morten Kvarving 2019-12-03 12:31:24 +01:00
parent f9fc843ce2
commit 5b5dddd64c
3 changed files with 169 additions and 0 deletions

View File

@ -50,6 +50,7 @@
#include <opm/parser/eclipse/EclipseState/Tables/SkprwatTable.hpp> #include <opm/parser/eclipse/EclipseState/Tables/SkprwatTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp> #include <opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableContainer.hpp> #include <opm/parser/eclipse/EclipseState/Tables/TableContainer.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp> #include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp>
#include <dune/common/parallel/mpitraits.hh> #include <dune/common/parallel/mpitraits.hh>
@ -517,6 +518,34 @@ std::size_t packSize(const RockTable& data, Dune::MPIHelper::MPICommunicator com
return packSize(static_cast<const std::vector<ROCKRecord>&>(data), comm); return packSize(static_cast<const std::vector<ROCKRecord>&>(data), comm);
} }
std::size_t packSize(const TableManager& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getSimpleTables(), comm) +
packSize(data.getPvtgTables(), comm) +
packSize(data.getPvtoTables(), comm) +
packSize(data.getRock2dTables(), comm) +
packSize(data.getRock2dtrTables(), comm) +
packSize(data.getPvtwTable(), comm) +
packSize(data.getPvcdoTable(), comm) +
packSize(data.getDensityTable(), comm) +
packSize(data.getRockTable(), comm) +
packSize(data.getViscrefTable(), comm) +
packSize(data.getWatdentTable(), comm) +
packSize(data.getPlymwinjTables(), comm) +
packSize(data.getSkprwatTables(), comm) +
packSize(data.getSkprpolyTables(), comm) +
packSize(data.getTabdims(), comm) +
packSize(data.getRegdims(), comm) +
packSize(data.getEqldims(), comm) +
packSize(data.getAqudims(), comm) +
packSize(data.useImptvd(), comm) +
packSize(data.useEnptvd(), comm) +
packSize(data.useEqlnum(), comm) +
packSize(data.useJFunc(), comm) +
(data.useJFunc() ? packSize(data.getJFunc(), comm) : 0) +
packSize(data.rtemp(), comm);
}
////// pack routines ////// pack routines
template<class T> template<class T>
@ -1014,6 +1043,36 @@ void pack(const RockTable& data, std::vector<char>& buffer, int& position,
pack(static_cast<const std::vector<ROCKRecord>&>(data), buffer, position, comm); pack(static_cast<const std::vector<ROCKRecord>&>(data), buffer, position, comm);
} }
void pack(const TableManager& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.getSimpleTables(), buffer, position, comm);
pack(data.getPvtgTables(), buffer, position, comm);
pack(data.getPvtoTables(), buffer, position, comm);
pack(data.getRock2dTables(), buffer, position, comm);
pack(data.getRock2dtrTables(), buffer, position, comm);
pack(data.getPvtwTable(), buffer, position, comm);
pack(data.getPvcdoTable(), buffer, position, comm);
pack(data.getDensityTable(), buffer, position, comm);
pack(data.getRockTable(), buffer, position, comm);
pack(data.getViscrefTable(), buffer, position, comm);
pack(data.getWatdentTable(), buffer, position, comm);
pack(data.getPlymwinjTables(), buffer, position, comm);
pack(data.getSkprwatTables(), buffer, position, comm);
pack(data.getSkprpolyTables(), buffer, position, comm);
pack(data.getTabdims(), buffer, position, comm);
pack(data.getRegdims(), buffer, position, comm);
pack(data.getEqldims(), buffer, position, comm);
pack(data.getAqudims(), buffer, position, comm);
pack(data.useImptvd(), buffer, position, comm);
pack(data.useEnptvd(), buffer, position, comm);
pack(data.useEqlnum(), buffer, position, comm);
pack(data.useJFunc(), buffer, position, comm);
if (data.useJFunc())
pack(data.getJFunc(), buffer, position, comm);
pack(data.rtemp(), buffer, position, comm);
}
/// unpack routines /// unpack routines
template<class T> template<class T>
@ -1640,6 +1699,67 @@ void unpack(RockTable& data, std::vector<char>& buffer, int& position,
data = RockTable(pdata); data = RockTable(pdata);
} }
void unpack(TableManager& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
std::map<std::string, TableContainer> simpleTables;
std::vector<PvtgTable> pvtgTables;
std::vector<PvtoTable> pvtoTables;
std::vector<Rock2dTable> rock2dTables;
std::vector<Rock2dtrTable> rock2dtrTables;
PvtwTable pvtwTable;
PvcdoTable pvcdoTable;
DensityTable densityTable;
RockTable rockTable;
ViscrefTable viscrefTable;
WatdentTable watdentTable;
std::map<int, PlymwinjTable> plymwinjTables;
std::map<int, SkprwatTable> skprwatTables;
std::map<int, SkprpolyTable> skprpolyTables;
Tabdims tabdims;
Regdims regdims;
Eqldims eqldims;
Aqudims aqudims;
bool hasImptvd;
bool hasEntpvd;
bool hasEqlnum;
std::shared_ptr<JFunc> jfunc;
double rtemp;
unpack(simpleTables, buffer, position, comm);
unpack(pvtgTables, buffer, position, comm);
unpack(pvtoTables, buffer, position, comm);
unpack(rock2dTables, buffer, position, comm);
unpack(rock2dtrTables, buffer, position, comm);
unpack(pvtwTable, buffer, position, comm);
unpack(pvcdoTable, buffer, position, comm);
unpack(densityTable, buffer, position, comm);
unpack(rockTable, buffer, position, comm);
unpack(viscrefTable, buffer, position, comm);
unpack(watdentTable, buffer, position, comm);
unpack(plymwinjTables, buffer, position, comm);
unpack(skprwatTables, buffer, position, comm);
unpack(skprpolyTables, buffer, position, comm);
unpack(tabdims, buffer, position, comm);
unpack(regdims, buffer, position, comm);
unpack(eqldims, buffer, position, comm);
unpack(aqudims, buffer, position, comm);
unpack(hasImptvd, buffer, position, comm);
unpack(hasEntpvd, buffer, position, comm);
unpack(hasEqlnum, buffer, position, comm);
bool hasJf;
unpack(hasJf, buffer, position, comm);
if (hasJf) {
jfunc = std::make_shared<JFunc>();
unpack(*jfunc, buffer, position, comm);
}
unpack(rtemp, buffer, position, comm);
data = TableManager(simpleTables, pvtgTables, pvtoTables, rock2dTables,
rock2dtrTables, pvtwTable, pvcdoTable, densityTable,
rockTable, viscrefTable, watdentTable, plymwinjTables,
skprwatTables, skprpolyTables, tabdims, regdims, eqldims,
aqudims, hasImptvd, hasEntpvd, hasEqlnum, jfunc, rtemp);
}
} // end namespace Mpi } // end namespace Mpi
RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState, RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,
const std::vector<Opm::RestartKey>& solutionKeys, const std::vector<Opm::RestartKey>& solutionKeys,

View File

@ -81,6 +81,7 @@ class SkprwatTable;
class Tabdims; class Tabdims;
class TableColumn; class TableColumn;
class TableContainer; class TableContainer;
class TableManager;
class TableSchema; class TableSchema;
class ThresholdPressure; class ThresholdPressure;
class UDQParams; class UDQParams;
@ -317,6 +318,7 @@ ADD_PACK_PROTOTYPES(SkprwatTable)
ADD_PACK_PROTOTYPES(Tabdims) ADD_PACK_PROTOTYPES(Tabdims)
ADD_PACK_PROTOTYPES(TableColumn) ADD_PACK_PROTOTYPES(TableColumn)
ADD_PACK_PROTOTYPES(TableContainer) ADD_PACK_PROTOTYPES(TableContainer)
ADD_PACK_PROTOTYPES(TableManager)
ADD_PACK_PROTOTYPES(TableSchema) ADD_PACK_PROTOTYPES(TableSchema)
ADD_PACK_PROTOTYPES(ThresholdPressure) ADD_PACK_PROTOTYPES(ThresholdPressure)
ADD_PACK_PROTOTYPES(TimeMap) ADD_PACK_PROTOTYPES(TimeMap)

View File

@ -53,6 +53,7 @@
#include <opm/parser/eclipse/EclipseState/Tables/Tabdims.hpp> #include <opm/parser/eclipse/EclipseState/Tables/Tabdims.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp> #include <opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableContainer.hpp> #include <opm/parser/eclipse/EclipseState/Tables/TableContainer.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp> #include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp>
#include <opm/output/eclipse/RestartValue.hpp> #include <opm/output/eclipse/RestartValue.hpp>
@ -209,6 +210,16 @@ Opm::PvtoTable getPvtoTable()
} }
Opm::TableContainer getTableContainer()
{
Opm::OrderedMap<std::string, Opm::TableColumn> data;
data.insert({"test3", getTableColumn()});
Opm::SimpleTable tab1(getTableSchema(), data, true);
Opm::TableContainer result(2);
result.addTable(0, std::make_shared<const Opm::SimpleTable>(tab1));
result.addTable(1, std::make_shared<const Opm::SimpleTable>(tab1));
return result;
}
#endif #endif
@ -921,6 +932,42 @@ BOOST_AUTO_TEST_CASE(RockTable)
} }
BOOST_AUTO_TEST_CASE(TableManager)
{
#if HAVE_MPI
auto jfunc = std::make_shared<Opm::JFunc>(Opm::JFunc::Flag::BOTH,
1.0, 2.0, 3.0, 4.0,
Opm::JFunc::Direction::XY);
Opm::TableManager val1({{"test", getTableContainer()}},
{getPvtgTable()},
{getPvtoTable()},
{Opm::Rock2dTable({{1.0,2.0},{3.0,4.0}}, {1.0, 2.0, 3.0})},
{Opm::Rock2dtrTable({{1.0,2.0},{3.0,4.0}}, {1.0, 2.0, 3.0})},
Opm::PvtwTable({Opm::PVTWRecord{1.0, 2.0, 3.0, 4.0, 5.0}}),
Opm::PvcdoTable({Opm::PVCDORecord{1.0, 2.0, 3.0, 4.0, 5.0}}),
Opm::DensityTable({Opm::DENSITYRecord{1.0, 2.0, 3.0}}),
Opm::RockTable({Opm::ROCKRecord{1.0,2.0}}),
Opm::ViscrefTable({Opm::VISCREFRecord{1.0, 2.0}}),
Opm::WatdentTable({Opm::WATDENTRecord{1.0, 2.0, 3.0}}),
{{1, Opm::PlymwinjTable({1.0}, {2.0}, 1, {{1.0}, {2.0}})}},
{{2, Opm::SkprwatTable({1.0}, {2.0}, 1, {{1.0}, {2.0}})}},
{{3, Opm::SkprpolyTable({1.0}, {2.0}, 1, {{1.0}, {2.0}}, 3.0)}},
Opm::Tabdims(1,2,3,4,5,6),
Opm::Regdims(1,2,3,4,5),
Opm::Eqldims(1,2,3,4,5),
Opm::Aqudims(1,2,3,4,5,6,7,8),
true,
true,
true,
jfunc,
1.0);
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() bool init_unit_test_func()
{ {
return true; return true;