mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add mpi serialization for Runspec
This commit is contained in:
@@ -410,6 +410,18 @@ std::size_t packSize(const UDQParams& data, Dune::MPIHelper::MPICommunicator com
|
||||
packSize(data.cmpEpsilon(), comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const Runspec& data, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.phases(), comm) +
|
||||
packSize(data.tabdims(), comm) +
|
||||
packSize(data.endpointScaling(), comm) +
|
||||
packSize(data.wellDimensions(), comm) +
|
||||
packSize(data.wellSegmentDimensions(), comm) +
|
||||
packSize(data.udqParams(), comm) +
|
||||
packSize(data.hysterPar(), comm) +
|
||||
packSize(data.actdims(), comm);
|
||||
}
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@@ -807,14 +819,17 @@ void pack(const UDQParams& data, std::vector<char>& buffer, int& position,
|
||||
pack(data.cmpEpsilon(), buffer, position, comm);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
void pack(const EclHysterConfig& data, std::vector<char>& buffer, int& position,
|
||||
void pack(const Runspec& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.active(), buffer, position, comm);
|
||||
pack(data.pcHysteresisModel(), buffer, position, comm);
|
||||
pack(data.krHysteresisModel(), buffer, position, comm);
|
||||
pack(data.phases(), buffer, position, comm);
|
||||
pack(data.tabdims(), buffer, position, comm);
|
||||
pack(data.endpointScaling(), buffer, position, comm);
|
||||
pack(data.wellDimensions(), buffer, position, comm);
|
||||
pack(data.wellSegmentDimensions(), buffer, position, comm);
|
||||
pack(data.udqParams(), buffer, position, comm);
|
||||
pack(data.hysterPar(), buffer, position, comm);
|
||||
pack(data.actdims(), buffer, position, comm);
|
||||
}
|
||||
|
||||
/// unpack routines
|
||||
@@ -1307,17 +1322,27 @@ void unpack(UDQParams& data, std::vector<char>& buffer, int& position,
|
||||
data = UDQParams(reseed, rand_seed, range, undefVal, cmp_eps);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
void unpack(EclHysterConfig& data, std::vector<char>& buffer, int& position,
|
||||
void unpack(Runspec& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
bool active;
|
||||
int pc, kr;
|
||||
unpack(active, buffer, position, comm);
|
||||
unpack(pc, buffer, position, comm);
|
||||
unpack(kr, buffer, position, comm);
|
||||
data = EclHysterConfig(active, pc, kr);
|
||||
Phases phases;
|
||||
Tabdims tabdims;
|
||||
EndpointScaling endScale;
|
||||
Welldims wellDims;
|
||||
WellSegmentDims wsegDims;
|
||||
UDQParams udqparams;
|
||||
EclHysterConfig hystPar;
|
||||
Actdims actdims;
|
||||
unpack(phases, buffer, position, comm);
|
||||
unpack(tabdims, buffer, position, comm);
|
||||
unpack(endScale, buffer, position, comm);
|
||||
unpack(wellDims, buffer, position, comm);
|
||||
unpack(wsegDims, buffer, position, comm);
|
||||
unpack(udqparams, buffer, position, comm);
|
||||
unpack(hystPar, buffer, position, comm);
|
||||
unpack(actdims, buffer, position, comm);
|
||||
data = Runspec(phases, tabdims, endScale, wellDims, wsegDims,
|
||||
udqparams, hystPar, actdims);
|
||||
}
|
||||
|
||||
} // end namespace Mpi
|
||||
|
||||
@@ -57,6 +57,7 @@ class RestartConfig;
|
||||
class RestartSchedule;
|
||||
class Rock2dTable;
|
||||
class Rock2dtrTable;
|
||||
class Runspec;
|
||||
class SimulationConfig;
|
||||
class SimpleTable;
|
||||
class Tabdims;
|
||||
@@ -269,6 +270,7 @@ ADD_PACK_PROTOTYPES(RestartSchedule)
|
||||
ADD_PACK_PROTOTYPES(RestartValue)
|
||||
ADD_PACK_PROTOTYPES(Rock2dTable)
|
||||
ADD_PACK_PROTOTYPES(Rock2dtrTable)
|
||||
ADD_PACK_PROTOTYPES(Runspec)
|
||||
ADD_PACK_PROTOTYPES(std::string)
|
||||
ADD_PACK_PROTOTYPES(SimulationConfig)
|
||||
ADD_PACK_PROTOTYPES(SimpleTable)
|
||||
|
||||
@@ -637,6 +637,25 @@ BOOST_AUTO_TEST_CASE(Actdims)
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Runspec)
|
||||
{
|
||||
#if HAVE_MPI
|
||||
Opm::Runspec val1(Opm::Phases(true, true, true, false, true, false, true, false),
|
||||
Opm::Tabdims(1,2,3,4,5,6),
|
||||
Opm::EndpointScaling(std::bitset<4>(13)),
|
||||
Opm::Welldims(1,2,3,4),
|
||||
Opm::WellSegmentDims(1,2,3),
|
||||
Opm::UDQParams(true, 1, 2.0, 3.0, 4.0),
|
||||
Opm::EclHysterConfig(true, 1, 2),
|
||||
Opm::Actdims(1,2,3,4));
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user