ParallelEclipseState.hpp
Go to the documentation of this file.
1/*
2 Copyright 2019 Equinor AS.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef PARALLEL_ECLIPSE_STATE_HPP
20#define PARALLEL_ECLIPSE_STATE_HPP
21
22#include <dune/common/version.hh>
23#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
24#include <opm/input/eclipse/EclipseState/Grid/TranCalculator.hpp>
25#include <dune/common/parallel/mpihelper.hh>
26
28
29#include <functional>
30
31namespace Opm {
32
33
42class ParallelFieldPropsManager : public FieldPropsManager {
43public:
44 friend class ParallelEclipseState;
46 template<class Grid>
47 friend class PropsDataHandle;
48
51 explicit ParallelFieldPropsManager(FieldPropsManager& manager);
52
55 ParallelFieldPropsManager(FieldPropsManager& manager, Parallel::Communication comm);
56
59 std::vector<int> actnum() const override;
60
63 void reset_actnum(const std::vector<int>& actnum) override;
64
66 std::vector<double> porv(bool global = false) const override;
67
70 const std::vector<int>& get_int(const std::string& keyword) const override;
71
74 const std::vector<double>& get_double(const std::string& keyword) const override;
75
79 std::vector<int> get_global_int(const std::string& keyword) const override;
80
84 std::vector<double> get_global_double(const std::string& keyword) const override;
85
88 bool has_int(const std::string& keyword) const override;
89
92 bool has_double(const std::string& keyword) const override;
93
95 std::vector<std::string> fip_regions() const override;
96
102 template<class T>
103 void resetCartesianMapper(const T* mapper)
104 {
105 // Note: mapper would usually be a CartesianIndexMapper. However, to support also
106 // the case of a distributed level zero grid in a CpGrid with LGRs, mapper will be
107 // Opm::LevelCartesianIndexMapper. This change allows access to the Cartesian indices
108 // of the distributed level zero grid, where the field properties are given - for now.
109 // In case of supporting LGR field properties, this need to be adapted, to access instead
110 // each local/level Cartesian index set.
111 m_activeSize = [mapper]() { return mapper->compressedSize(/*level = */ 0); };
112 m_local2Global = [mapper](int localIdx) { return mapper->cartesianIndex(localIdx, /* level = */ 0); };
113 }
114
115 bool tran_active(const std::string& keyword) const override;
116
117 void apply_tran(const std::string& keyword, std::vector<double>& trans) const override;
118
119 void copyTran(const FieldPropsManager& from)
120 {
121 m_tran = from.getTran();
122 }
123
124 template<class Serializer>
125 void serializeOp(Serializer& serializer)
126 {
127 serializer(m_tran);
128 }
129
130protected:
131 std::map<std::string, Fieldprops::FieldData<int>> m_intProps;
132 std::map<std::string, Fieldprops::FieldData<double>> m_doubleProps;
133 FieldPropsManager& m_manager;
135 std::function<int(void)> m_activeSize;
136 std::function<int(const int)> m_local2Global;
137 std::unordered_map<std::string, Fieldprops::TranCalculator> m_tran;
138};
139
140
152class ParallelEclipseState : public EclipseState {
154 template<class Grid>
155 friend class PropsDataHandle;
156public:
159
163 ParallelEclipseState(const Deck& deck);
164
170
174
179
181 const FieldPropsManager& fieldProps() const override;
182
185 const FieldPropsManager& globalFieldProps() const override;
186
192
195 const EclipseGrid& getInputGrid() const override;
196
202 template<class T>
203 void resetCartesianMapper(const T* mapper)
204 {
205 m_fieldProps.resetCartesianMapper(mapper);
206 }
207private:
208 bool m_parProps = false;
209 ParallelFieldPropsManager m_fieldProps;
211};
212
213
214} // end namespace Opm
215#endif // PARALLEL_ECLIPSE_STATE_HPP
Parallel frontend to the EclipseState.
Definition: ParallelEclipseState.hpp:152
ParallelEclipseState(const Deck &deck)
Construct from a deck instance.
void switchToGlobalProps()
Switch to global field properties.
const EclipseGrid & getInputGrid() const override
Returns a const ref to the eclipse grid.
const FieldPropsManager & fieldProps() const override
Returns a const ref to current field properties.
ParallelEclipseState(Parallel::Communication comm)
Default constructor.
void computeFipRegionStatistics() override
Compute basic descriptive statistics about all FIP region sets.
void switchToDistributedProps()
Switch to distributed field properies.
const FieldPropsManager & globalFieldProps() const override
Returns a const ref to global field properties.
ParallelEclipseState(const Deck &deck, Parallel::Communication comm)
Construct from a deck instance.
void resetCartesianMapper(const T *mapper)
Resets the underlying cartesian mapper \detail This has to be the cartesian mapper of the distributed...
Definition: ParallelEclipseState.hpp:203
Parallel frontend to the field properties.
Definition: ParallelEclipseState.hpp:42
void resetCartesianMapper(const T *mapper)
Resets the underlying cartesian mapper \detail This has to be the cartesian mapper of the distributed...
Definition: ParallelEclipseState.hpp:103
std::unordered_map< std::string, Fieldprops::TranCalculator > m_tran
calculators map
Definition: ParallelEclipseState.hpp:137
std::map< std::string, Fieldprops::FieldData< int > > m_intProps
Map of integer properties in process-local compressed indices.
Definition: ParallelEclipseState.hpp:131
bool has_double(const std::string &keyword) const override
Check if a double property is available.
bool tran_active(const std::string &keyword) const override
std::vector< std::string > fip_regions() const override
Returns a list of registered FIP regions.
std::vector< int > actnum() const override
Returns actnum vector.
std::vector< double > porv(bool global=false) const override
Returns the pore volume vector.
std::vector< double > get_global_double(const std::string &keyword) const override
Returns a double property using global cartesian indices.
ParallelFieldPropsManager(FieldPropsManager &manager)
Constructor.
void serializeOp(Serializer &serializer)
Definition: ParallelEclipseState.hpp:125
bool has_int(const std::string &keyword) const override
Check if an integer property is available.
std::function< int(const int)> m_local2Global
mapping from local to global cartesian indices
Definition: ParallelEclipseState.hpp:136
void copyTran(const FieldPropsManager &from)
Definition: ParallelEclipseState.hpp:119
void apply_tran(const std::string &keyword, std::vector< double > &trans) const override
std::vector< int > get_global_int(const std::string &keyword) const override
Returns an int property using global cartesian indices.
const std::vector< double > & get_double(const std::string &keyword) const override
Returns a double property using compressed indices.
ParallelFieldPropsManager(FieldPropsManager &manager, Parallel::Communication comm)
Constructor.
void reset_actnum(const std::vector< int > &actnum) override
Reset the actnum vector.
FieldPropsManager & m_manager
Underlying field property manager (only used on root process).
Definition: ParallelEclipseState.hpp:133
std::map< std::string, Fieldprops::FieldData< double > > m_doubleProps
Map of double properties in process-local compressed indices.
Definition: ParallelEclipseState.hpp:132
Parallel::Communication m_comm
Collective communication handler.
Definition: ParallelEclipseState.hpp:134
const std::vector< int > & get_int(const std::string &keyword) const override
Returns an int property using compressed indices.
std::function< int(void)> m_activeSize
active size function of the grid
Definition: ParallelEclipseState.hpp:135
A Data handle to communicate the field properties during load balance.
Definition: PropsDataHandle.hpp:54
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: blackoilboundaryratevector.hh:39