opm-simulators/opm/simulators/utils/ParallelRestart.hpp

338 lines
11 KiB
C++
Raw Normal View History

/*
Copyright 2019 Equinor AS.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PARALLEL_RESTART_HPP
#define PARALLEL_RESTART_HPP
#if HAVE_MPI
#include <mpi.h>
#endif
#include <opm/output/eclipse/RestartValue.hpp>
#include <opm/output/eclipse/EclipseIO.hpp>
#include <opm/output/eclipse/Summary.hpp>
2019-11-29 08:58:59 -06:00
#include <opm/parser/eclipse/EclipseState/Schedule/DynamicState.hpp>
2019-11-29 08:47:55 -06:00
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
2019-11-29 03:16:05 -06:00
#include <opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp>
#include <dune/common/parallel/mpihelper.hh>
#include <vector>
#include <map>
#include <unordered_map>
namespace Opm
{
2019-12-02 05:30:34 -06:00
class Actdims;
2019-12-03 03:09:43 -06:00
class Aqudims;
2019-11-29 03:18:34 -06:00
class ColumnSchema;
class DENSITYRecord;
2019-12-02 08:52:39 -06:00
class DensityTable;
class EclHysterConfig;
2019-12-02 17:00:08 -06:00
class Eqldims;
class EDITNNC;
class EndpointScaling;
2019-11-29 06:16:00 -06:00
class Equil;
2019-11-29 06:01:43 -06:00
class EquilRecord;
2019-11-29 07:14:13 -06:00
class FoamConfig;
2019-11-29 06:37:35 -06:00
class FoamData;
2019-11-29 07:14:47 -06:00
class InitConfig;
2019-12-02 03:20:28 -06:00
class IOConfig;
2019-12-02 08:13:33 -06:00
class JFunc;
class NNC;
struct NNCdata;
2019-12-02 03:46:58 -06:00
class Phases;
class PlymwinjTable;
2019-12-02 16:00:46 -06:00
class PolyInjTable;
2019-12-02 08:30:15 -06:00
class PVCDORecord;
2019-12-02 08:39:50 -06:00
class PvcdoTable;
2019-12-02 07:49:40 -06:00
class PvtgTable;
class PvtoTable;
2019-12-02 08:30:15 -06:00
class PVTWRecord;
2019-12-02 08:39:50 -06:00
class PvtwTable;
2019-12-02 16:49:10 -06:00
class Regdims;
class RestartConfig;
class RestartSchedule;
2019-12-03 03:18:29 -06:00
class ROCKRecord;
2019-11-28 08:46:13 -06:00
class Rock2dTable;
class Rock2dtrTable;
2019-12-02 05:47:48 -06:00
class Runspec;
class SimulationConfig;
2019-11-29 04:19:34 -06:00
class SimpleTable;
class SkprpolyTable;
2019-12-02 16:34:31 -06:00
class SkprwatTable;
2019-12-02 04:10:34 -06:00
class Tabdims;
2019-11-29 04:19:16 -06:00
class TableColumn;
class TableContainer;
2019-11-29 03:18:48 -06:00
class TableSchema;
class ThresholdPressure;
2019-12-02 05:08:27 -06:00
class UDQParams;
class VISCREFRecord;
2019-12-02 08:52:39 -06:00
class ViscrefTable;
class WATDENTRecord;
2019-12-02 08:52:39 -06:00
class WatdentTable;
2019-12-02 04:32:28 -06:00
class Welldims;
class WellSegmentDims;
namespace Mpi
{
template<class T>
std::size_t packSize(const T*, std::size_t, Dune::MPIHelper::MPICommunicator,
std::integral_constant<bool, false>);
template<class T>
std::size_t packSize(const T*, std::size_t l, Dune::MPIHelper::MPICommunicator comm,
std::integral_constant<bool, true>);
template<class T>
std::size_t packSize(const T* data, std::size_t l, Dune::MPIHelper::MPICommunicator comm);
template<class T>
std::size_t packSize(const T&, Dune::MPIHelper::MPICommunicator,
std::integral_constant<bool, false>);
template<class T>
std::size_t packSize(const T&, Dune::MPIHelper::MPICommunicator comm,
std::integral_constant<bool, true>);
template<class T>
std::size_t packSize(const T& data, Dune::MPIHelper::MPICommunicator comm);
template<class T1, class T2>
std::size_t packSize(const std::pair<T1,T2>& data, Dune::MPIHelper::MPICommunicator comm);
template<class T, class A>
std::size_t packSize(const std::vector<T,A>& data, Dune::MPIHelper::MPICommunicator comm);
template<class A>
std::size_t packSize(const std::vector<bool,A>& data, Dune::MPIHelper::MPICommunicator comm);
std::size_t packSize(const char* str, Dune::MPIHelper::MPICommunicator comm);
std::size_t packSize(const std::string& str, Dune::MPIHelper::MPICommunicator comm);
template<class T1, class T2, class C, class A>
std::size_t packSize(const std::map<T1,T2,C,A>& data, Dune::MPIHelper::MPICommunicator comm);
template<class T1, class T2, class H, class P, class A>
std::size_t packSize(const std::unordered_map<T1,T2,H,P,A>& data, Dune::MPIHelper::MPICommunicator comm);
2019-11-29 03:16:05 -06:00
template<class Key, class Value>
std::size_t packSize(const OrderedMap<Key,Value>& data, Dune::MPIHelper::MPICommunicator comm);
2019-11-29 08:58:59 -06:00
template<class T>
std::size_t packSize(const DynamicState<T>& data, Dune::MPIHelper::MPICommunicator comm);
////// pack routines
template<class T>
void pack(const T*, std::size_t, std::vector<char>&, int&,
Dune::MPIHelper::MPICommunicator, std::integral_constant<bool, false>);
template<class T>
void pack(const T* data, std::size_t l, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm, std::integral_constant<bool, true>);
template<class T>
void pack(const T* data, std::size_t l, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class T>
void pack(const T&, std::vector<char>&, int&,
Dune::MPIHelper::MPICommunicator, std::integral_constant<bool, false>);
template<class T>
void pack(const T& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm, std::integral_constant<bool, true>);
template<class T>
void pack(const T& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class T1, class T2>
void pack(const std::pair<T1,T2>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class T, class A>
void pack(const std::vector<T,A>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class A>
void pack(const std::vector<bool,A>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class T1, class T2, class C, class A>
void pack(const std::map<T1,T2,C,A>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class T1, class T2, class H, class P, class A>
void pack(const std::unordered_map<T1,T2,H,P,A>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
2019-11-29 03:16:05 -06:00
template<class Key, class Value>
void pack(const OrderedMap<Key,Value>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
2019-11-29 08:58:59 -06:00
template<class T>
void pack(const DynamicState<T>& data, std::vector<char>& buffer,
int& position, Dune::MPIHelper::MPICommunicator comm);
void pack(const char* str, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
/// unpack routines
template<class T>
void unpack(T*, const std::size_t&, std::vector<char>&, int&,
Dune::MPIHelper::MPICommunicator, std::integral_constant<bool, false>);
template<class T>
void unpack(T* data, const std::size_t& l, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm,
std::integral_constant<bool, true>);
template<class T>
void unpack(T* data, const std::size_t& l, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class T>
void unpack(T&, std::vector<char>&, int&,
Dune::MPIHelper::MPICommunicator, std::integral_constant<bool, false>);
template<class T>
void unpack(T& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm, std::integral_constant<bool, true>);
template<class T>
void unpack(T& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class T1, class T2>
void unpack(std::pair<T1,T2>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class T, class A>
void unpack(std::vector<T,A>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class A>
void unpack(std::vector<bool,A>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class T1, class T2, class C, class A>
void unpack(std::map<T1,T2,C,A>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
template<class T1, class T2, class H, class P, class A>
void unpack(std::unordered_map<T1,T2,H,P,A>& data, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
2019-11-29 03:16:05 -06:00
template<class Key, class Value>
void unpack(OrderedMap<Key,Value>& data, std::vector<char>& buffer, int& position,
2019-11-29 08:58:59 -06:00
Dune::MPIHelper::MPICommunicator comm);
template<class T>
void unpack(DynamicState<T>& data, std::vector<char>& buffer, int& position,
2019-11-29 03:16:05 -06:00
Dune::MPIHelper::MPICommunicator comm);
void unpack(char* str, std::size_t length, std::vector<char>& buffer, int& position,
Dune::MPIHelper::MPICommunicator comm);
/// prototypes for complex types
#define ADD_PACK_PROTOTYPES(T) \
std::size_t packSize(const T& data, Dune::MPIHelper::MPICommunicator comm); \
void pack(const T& data, std::vector<char>& buffer, int& position, \
Dune::MPIHelper::MPICommunicator comm); \
void unpack(T& data, std::vector<char>& buffer, int& position, \
Dune::MPIHelper::MPICommunicator comm);
2019-12-02 05:30:34 -06:00
ADD_PACK_PROTOTYPES(Actdims)
2019-12-03 03:09:43 -06:00
ADD_PACK_PROTOTYPES(Aqudims)
2019-11-29 03:18:34 -06:00
ADD_PACK_PROTOTYPES(ColumnSchema)
ADD_PACK_PROTOTYPES(data::CellData)
ADD_PACK_PROTOTYPES(data::Connection)
ADD_PACK_PROTOTYPES(data::Rates)
ADD_PACK_PROTOTYPES(data::Segment)
ADD_PACK_PROTOTYPES(data::Solution)
ADD_PACK_PROTOTYPES(data::Well)
ADD_PACK_PROTOTYPES(data::WellRates)
ADD_PACK_PROTOTYPES(DENSITYRecord)
2019-12-02 08:52:39 -06:00
ADD_PACK_PROTOTYPES(DensityTable)
ADD_PACK_PROTOTYPES(EDITNNC)
ADD_PACK_PROTOTYPES(EndpointScaling)
2019-11-29 06:16:00 -06:00
ADD_PACK_PROTOTYPES(Equil)
2019-11-29 06:01:43 -06:00
ADD_PACK_PROTOTYPES(EquilRecord)
2019-11-29 07:14:13 -06:00
ADD_PACK_PROTOTYPES(FoamConfig)
2019-11-29 06:37:35 -06:00
ADD_PACK_PROTOTYPES(FoamData)
ADD_PACK_PROTOTYPES(EclHysterConfig)
2019-12-02 17:00:08 -06:00
ADD_PACK_PROTOTYPES(Eqldims)
2019-11-29 07:14:47 -06:00
ADD_PACK_PROTOTYPES(InitConfig)
2019-12-02 03:20:28 -06:00
ADD_PACK_PROTOTYPES(IOConfig)
2019-12-02 08:13:33 -06:00
ADD_PACK_PROTOTYPES(JFunc)
ADD_PACK_PROTOTYPES(NNC)
ADD_PACK_PROTOTYPES(NNCdata)
2019-12-02 03:46:58 -06:00
ADD_PACK_PROTOTYPES(Phases)
ADD_PACK_PROTOTYPES(PlymwinjTable)
2019-12-02 16:00:46 -06:00
ADD_PACK_PROTOTYPES(PolyInjTable)
2019-12-02 08:30:15 -06:00
ADD_PACK_PROTOTYPES(PVCDORecord)
2019-12-02 08:39:50 -06:00
ADD_PACK_PROTOTYPES(PvcdoTable)
2019-12-02 07:49:40 -06:00
ADD_PACK_PROTOTYPES(PvtgTable)
ADD_PACK_PROTOTYPES(PvtoTable)
2019-12-02 08:30:15 -06:00
ADD_PACK_PROTOTYPES(PVTWRecord)
2019-12-02 08:39:50 -06:00
ADD_PACK_PROTOTYPES(PvtwTable)
2019-12-02 16:49:10 -06:00
ADD_PACK_PROTOTYPES(Regdims)
ADD_PACK_PROTOTYPES(RestartConfig)
ADD_PACK_PROTOTYPES(RestartKey)
ADD_PACK_PROTOTYPES(RestartSchedule)
ADD_PACK_PROTOTYPES(RestartValue)
2019-12-03 03:18:29 -06:00
ADD_PACK_PROTOTYPES(ROCKRecord)
2019-11-28 08:46:13 -06:00
ADD_PACK_PROTOTYPES(Rock2dTable)
ADD_PACK_PROTOTYPES(Rock2dtrTable)
2019-12-02 05:47:48 -06:00
ADD_PACK_PROTOTYPES(Runspec)
ADD_PACK_PROTOTYPES(std::string)
ADD_PACK_PROTOTYPES(SimulationConfig)
2019-11-29 04:19:34 -06:00
ADD_PACK_PROTOTYPES(SimpleTable)
ADD_PACK_PROTOTYPES(SkprpolyTable)
2019-12-02 16:34:31 -06:00
ADD_PACK_PROTOTYPES(SkprwatTable)
2019-12-02 04:10:34 -06:00
ADD_PACK_PROTOTYPES(Tabdims)
2019-11-29 04:19:16 -06:00
ADD_PACK_PROTOTYPES(TableColumn)
ADD_PACK_PROTOTYPES(TableContainer)
2019-11-29 03:18:48 -06:00
ADD_PACK_PROTOTYPES(TableSchema)
ADD_PACK_PROTOTYPES(ThresholdPressure)
2019-11-29 08:47:55 -06:00
ADD_PACK_PROTOTYPES(TimeMap)
ADD_PACK_PROTOTYPES(TimeMap::StepData)
2019-12-02 05:08:27 -06:00
ADD_PACK_PROTOTYPES(UDQParams)
ADD_PACK_PROTOTYPES(VISCREFRecord)
2019-12-02 08:52:39 -06:00
ADD_PACK_PROTOTYPES(ViscrefTable)
ADD_PACK_PROTOTYPES(WATDENTRecord)
2019-12-02 08:52:39 -06:00
ADD_PACK_PROTOTYPES(WatdentTable)
2019-12-02 04:32:28 -06:00
ADD_PACK_PROTOTYPES(Welldims)
ADD_PACK_PROTOTYPES(WellSegmentDims)
} // end namespace Mpi
RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,
const std::vector<Opm::RestartKey>& solutionKeys,
const std::vector<Opm::RestartKey>& extraKeys,
Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator> comm);
} // end namespace Opm
#endif // PARALLEL_RESTART_HPP