mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add mpi serialization for TableColumn
This commit is contained in:
parent
b33611077b
commit
443cb4402f
@ -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/TableColumn.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp>
|
||||
#include <dune/common/parallel/mpitraits.hh>
|
||||
|
||||
@ -275,6 +276,15 @@ std::size_t packSize(const TableSchema& data, Dune::MPIHelper::MPICommunicator c
|
||||
return packSize(data.getColumns(), comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const TableColumn& data, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.schema(), comm) +
|
||||
packSize(data.name(), comm) +
|
||||
packSize(data.values(), comm) +
|
||||
packSize(data.defaults(), comm) +
|
||||
packSize(data.defaultCount(), comm);
|
||||
}
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -535,6 +545,16 @@ void pack(const TableSchema& data, std::vector<char>& buffer, int& position,
|
||||
pack(data.getColumns(), buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const TableColumn& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.schema(), buffer, position, comm);
|
||||
pack(data.name(), buffer, position, comm);
|
||||
pack(data.values(), buffer, position, comm);
|
||||
pack(data.defaults(), buffer, position, comm);
|
||||
pack(data.defaultCount(), buffer, position, comm);
|
||||
}
|
||||
|
||||
/// unpack routines
|
||||
|
||||
template<class T>
|
||||
@ -833,6 +853,22 @@ void unpack(TableSchema& data, std::vector<char>& buffer, int& position,
|
||||
data = TableSchema(columns);
|
||||
}
|
||||
|
||||
void unpack(TableColumn& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
ColumnSchema schema;
|
||||
std::string name;
|
||||
std::vector<double> values;
|
||||
std::vector<bool> defaults;
|
||||
size_t defaultCount;
|
||||
unpack(schema, buffer, position, comm);
|
||||
unpack(name, buffer, position, comm);
|
||||
unpack(values, buffer, position, comm);
|
||||
unpack(defaults, buffer, position, comm);
|
||||
unpack(defaultCount, buffer, position, comm);
|
||||
data = TableColumn(schema, name, values, defaults, defaultCount);
|
||||
}
|
||||
|
||||
} // end namespace Mpi
|
||||
RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,
|
||||
const std::vector<Opm::RestartKey>& solutionKeys,
|
||||
|
@ -43,6 +43,7 @@ class NNC;
|
||||
struct NNCdata;
|
||||
class Rock2dTable;
|
||||
class Rock2dtrTable;
|
||||
class TableColumn;
|
||||
class TableSchema;
|
||||
class ThresholdPressure;
|
||||
|
||||
@ -225,6 +226,7 @@ ADD_PACK_PROTOTYPES(RestartValue)
|
||||
ADD_PACK_PROTOTYPES(Rock2dTable)
|
||||
ADD_PACK_PROTOTYPES(Rock2dtrTable)
|
||||
ADD_PACK_PROTOTYPES(std::string)
|
||||
ADD_PACK_PROTOTYPES(TableColumn)
|
||||
ADD_PACK_PROTOTYPES(TableSchema)
|
||||
ADD_PACK_PROTOTYPES(ThresholdPressure)
|
||||
|
||||
|
@ -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/TableColumn.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp>
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
|
||||
@ -130,6 +131,14 @@ Opm::TableSchema getTableSchema()
|
||||
}
|
||||
|
||||
|
||||
Opm::TableColumn getTableColumn()
|
||||
{
|
||||
return Opm::TableColumn(Opm::ColumnSchema("test1", Opm::Table::INCREASING,
|
||||
Opm::Table::DEFAULT_LINEAR),
|
||||
"test2", {1.0, 2.0}, {false, true}, 2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -336,6 +345,17 @@ BOOST_AUTO_TEST_CASE(TableSchema)
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TableColumn)
|
||||
{
|
||||
#if HAVE_MPI
|
||||
Opm::TableColumn val1 = getTableColumn();
|
||||
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