add mpi serialization for TableSchema

This commit is contained in:
Arne Morten Kvarving
2019-11-29 10:18:48 +01:00
parent 09554a4c25
commit 6bc3a24762
3 changed files with 44 additions and 0 deletions

View File

@@ -28,6 +28,7 @@
#include <opm/parser/eclipse/EclipseState/Tables/ColumnSchema.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/Rock2dTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/Rock2dtrTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp>
#include <dune/common/parallel/mpitraits.hh>
namespace Opm
@@ -259,6 +260,11 @@ std::size_t packSize(const ColumnSchema& data, Dune::MPIHelper::MPICommunicator
return res;
}
std::size_t packSize(const TableSchema& data, Dune::MPIHelper::MPICommunicator comm)
{
return packSize(data.getColumns(), comm);
}
////// pack routines
template<class T>
@@ -523,6 +529,12 @@ void pack(const ColumnSchema& data, std::vector<char>& buffer, int& position,
pack(data.getDefaultValue(), buffer, position, comm);
}
void pack(const TableSchema& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
pack(data.getColumns(), buffer, position, comm);
}
/// unpack routines
template<class T>
@@ -819,6 +831,14 @@ void unpack(ColumnSchema& data, std::vector<char>& buffer, int& position,
data = ColumnSchema(name, order, action);
}
void unpack(TableSchema& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm)
{
OrderedMap<std::string, ColumnSchema> columns;
unpack(columns, buffer, position, comm);
data = TableSchema(columns);
}
} // end namespace Mpi
RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,
const std::vector<Opm::RestartKey>& solutionKeys,

View File

@@ -43,6 +43,7 @@ class NNC;
struct NNCdata;
class Rock2dTable;
class Rock2dtrTable;
class TableSchema;
class ThresholdPressure;
namespace Mpi
@@ -213,6 +214,7 @@ ADD_PACK_PROTOTYPES(RestartValue)
ADD_PACK_PROTOTYPES(Rock2dTable)
ADD_PACK_PROTOTYPES(Rock2dtrTable)
ADD_PACK_PROTOTYPES(std::string)
ADD_PACK_PROTOTYPES(TableSchema)
ADD_PACK_PROTOTYPES(ThresholdPressure)
} // end namespace Mpi

View File

@@ -31,6 +31,7 @@
#include <opm/parser/eclipse/EclipseState/Tables/ColumnSchema.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/Rock2dTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/Rock2dtrTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp>
#include <opm/output/eclipse/RestartValue.hpp>
@@ -119,6 +120,16 @@ Opm::ThresholdPressure getThresholdPressure()
}
Opm::TableSchema getTableSchema()
{
Opm::OrderedMap<std::string, Opm::ColumnSchema> data;
data.insert({"test1", Opm::ColumnSchema("test1", Opm::Table::INCREASING,
Opm::Table::DEFAULT_LINEAR)});
data.insert({"test2", Opm::ColumnSchema("test2", Opm::Table::INCREASING, 1.0)});
return Opm::TableSchema(data);
}
}
@@ -314,6 +325,17 @@ BOOST_AUTO_TEST_CASE(ColumnSchema)
}
BOOST_AUTO_TEST_CASE(TableSchema)
{
#if HAVE_MPI
Opm::TableSchema val1 = getTableSchema();
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;