mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-19 16:32:56 -06:00
add mpi serialization for TableContainer
This commit is contained in:
parent
ec95a19f4c
commit
f837a5f7eb
@ -30,6 +30,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/Rock2dtrTable.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/SimpleTable.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableContainer.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp>
|
||||
#include <dune/common/parallel/mpitraits.hh>
|
||||
|
||||
@ -293,6 +294,18 @@ std::size_t packSize(const SimpleTable& data, Dune::MPIHelper::MPICommunicator c
|
||||
packSize(data.jfunc(), comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const TableContainer& data, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
size_t res = 2*packSize(data.max(), comm);
|
||||
for (const auto& it : data.tables()) {
|
||||
if (it.second) {
|
||||
res += packSize(it.first, comm) + packSize(*it.second, comm);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -571,6 +584,25 @@ void pack(const SimpleTable& data, std::vector<char>& buffer, int& position,
|
||||
pack(data.jfunc(), buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const TableContainer& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.max(), buffer, position, comm);
|
||||
size_t entries = 0;
|
||||
for (const auto& it : data.tables()) {
|
||||
if (it.second) {
|
||||
++entries;
|
||||
}
|
||||
}
|
||||
pack(entries, buffer, position, comm);
|
||||
for (const auto& it : data.tables()) {
|
||||
if (it.second) {
|
||||
pack(it.first, buffer, position, comm);
|
||||
pack(*it.second, buffer, position, comm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// unpack routines
|
||||
|
||||
template<class T>
|
||||
@ -897,6 +929,23 @@ void unpack(SimpleTable& data, std::vector<char>& buffer, int& position,
|
||||
data = SimpleTable(schema, columns, jf);
|
||||
}
|
||||
|
||||
void unpack(TableContainer& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
size_t max;
|
||||
unpack(max, buffer, position, comm);
|
||||
data = TableContainer(max);
|
||||
size_t entries;
|
||||
unpack(entries, buffer, position, comm);
|
||||
for (size_t i = 0; i < entries; ++i) {
|
||||
size_t id;
|
||||
unpack(id, buffer, position, comm);
|
||||
SimpleTable table;
|
||||
unpack(table, buffer, position, comm);
|
||||
data.addTable(id, std::make_shared<const SimpleTable>(table));
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace Mpi
|
||||
RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,
|
||||
const std::vector<Opm::RestartKey>& solutionKeys,
|
||||
|
@ -45,6 +45,7 @@ class Rock2dTable;
|
||||
class Rock2dtrTable;
|
||||
class SimpleTable;
|
||||
class TableColumn;
|
||||
class TableContainer;
|
||||
class TableSchema;
|
||||
class ThresholdPressure;
|
||||
|
||||
@ -229,6 +230,7 @@ ADD_PACK_PROTOTYPES(Rock2dtrTable)
|
||||
ADD_PACK_PROTOTYPES(std::string)
|
||||
ADD_PACK_PROTOTYPES(SimpleTable)
|
||||
ADD_PACK_PROTOTYPES(TableColumn)
|
||||
ADD_PACK_PROTOTYPES(TableContainer)
|
||||
ADD_PACK_PROTOTYPES(TableSchema)
|
||||
ADD_PACK_PROTOTYPES(ThresholdPressure)
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/Rock2dtrTable.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/SimpleTable.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableContainer.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp>
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
|
||||
@ -376,6 +377,22 @@ BOOST_AUTO_TEST_CASE(SimpleTable)
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TableContainer)
|
||||
{
|
||||
#if HAVE_MPI
|
||||
Opm::OrderedMap<std::string, Opm::TableColumn> data;
|
||||
data.insert({"test3", getTableColumn()});
|
||||
Opm::SimpleTable tab1(getTableSchema(), data, true);
|
||||
Opm::TableContainer val1(2);
|
||||
val1.addTable(0, std::make_shared<const Opm::SimpleTable>(tab1));
|
||||
val1.addTable(1, std::make_shared<const Opm::SimpleTable>(tab1));
|
||||
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