mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add mpi serialization for TimeMap
This commit is contained in:
parent
7aa73eadd2
commit
3e93b3e043
@ -28,6 +28,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Edit/EDITNNC.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/ColumnSchema.hpp>
|
||||
@ -198,6 +199,7 @@ HANDLE_AS_POD(data::Segment)
|
||||
HANDLE_AS_POD(EquilRecord)
|
||||
HANDLE_AS_POD(FoamData)
|
||||
HANDLE_AS_POD(RestartSchedule)
|
||||
HANDLE_AS_POD(TimeMap::StepData)
|
||||
|
||||
std::size_t packSize(const data::Well& data, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
@ -343,6 +345,13 @@ std::size_t packSize(const SimulationConfig& data, Dune::MPIHelper::MPICommunica
|
||||
packSize(data.isThermal(), comm);
|
||||
}
|
||||
|
||||
std::size_t packSize(const TimeMap& data, Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
return packSize(data.timeList(), comm) +
|
||||
packSize(data.firstTimeStepMonths(), comm) +
|
||||
packSize(data.firstTimeStepYears(), comm);
|
||||
}
|
||||
|
||||
////// pack routines
|
||||
|
||||
template<class T>
|
||||
@ -673,6 +682,14 @@ void pack(const SimulationConfig& data, std::vector<char>& buffer, int& position
|
||||
pack(data.isThermal(), buffer, position, comm);
|
||||
}
|
||||
|
||||
void pack(const TimeMap& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
pack(data.timeList(), buffer, position, comm);
|
||||
pack(data.firstTimeStepMonths(), buffer, position, comm);
|
||||
pack(data.firstTimeStepYears(), buffer, position, comm);
|
||||
}
|
||||
|
||||
/// unpack routines
|
||||
|
||||
template<class T>
|
||||
@ -1063,6 +1080,19 @@ void unpack(SimulationConfig& data, std::vector<char>& buffer, int& position,
|
||||
data = SimulationConfig(thresholdPressure, useCPR, DISGAS, VAPOIL, isThermal);
|
||||
}
|
||||
|
||||
void unpack(TimeMap& data, std::vector<char>& buffer, int& position,
|
||||
Dune::MPIHelper::MPICommunicator comm)
|
||||
{
|
||||
std::vector<std::time_t> timeList;
|
||||
std::vector<TimeMap::StepData> firstStepMonths;
|
||||
std::vector<TimeMap::StepData> firstStepYears;
|
||||
unpack(timeList, buffer, position, comm);
|
||||
unpack(firstStepMonths, buffer, position, comm);
|
||||
unpack(firstStepYears, buffer, position, comm);
|
||||
|
||||
data = TimeMap(timeList, firstStepMonths, firstStepYears);
|
||||
}
|
||||
|
||||
} // end namespace Mpi
|
||||
RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,
|
||||
const std::vector<Opm::RestartKey>& solutionKeys,
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
#include <opm/output/eclipse/EclipseIO.hpp>
|
||||
#include <opm/output/eclipse/Summary.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp>
|
||||
|
||||
#include <dune/common/parallel/mpihelper.hh>
|
||||
@ -247,6 +248,8 @@ ADD_PACK_PROTOTYPES(TableColumn)
|
||||
ADD_PACK_PROTOTYPES(TableContainer)
|
||||
ADD_PACK_PROTOTYPES(TableSchema)
|
||||
ADD_PACK_PROTOTYPES(ThresholdPressure)
|
||||
ADD_PACK_PROTOTYPES(TimeMap)
|
||||
ADD_PACK_PROTOTYPES(TimeMap::StepData)
|
||||
|
||||
} // end namespace Mpi
|
||||
RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/ColumnSchema.hpp>
|
||||
@ -167,6 +168,14 @@ Opm::FoamData getFoamData()
|
||||
#endif
|
||||
|
||||
|
||||
Opm::TimeMap getTimeMap()
|
||||
{
|
||||
return Opm::TimeMap({123},
|
||||
{{1, Opm::TimeStampUTC(123)}},
|
||||
{{2, Opm::TimeStampUTC(456)}});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -490,6 +499,28 @@ BOOST_AUTO_TEST_CASE(RestartSchedule)
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StepData)
|
||||
{
|
||||
#if HAVE_MPI
|
||||
Opm::TimeMap::StepData val1{1, Opm::TimeStampUTC(123456)};
|
||||
auto val2 = PackUnpack(val1);
|
||||
BOOST_CHECK(std::get<1>(val2) == std::get<2>(val2));
|
||||
BOOST_CHECK(val1 == std::get<0>(val2));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TimeMap)
|
||||
{
|
||||
#if HAVE_MPI
|
||||
Opm::TimeMap val1 = getTimeMap();
|
||||
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