My Project
ParallelEclipseState.hpp
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 
27 #include <opm/simulators/utils/ParallelCommunication.hpp>
28 
29 #include <functional>
30 
31 namespace Opm {
32 
33 
42 class ParallelFieldPropsManager : public FieldPropsManager {
43 public:
44  friend class ParallelEclipseState;
46  template<class Grid>
48 
51  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 
99  template<class T>
100  void resetCartesianMapper(const T* mapper)
101  {
102  m_activeSize = std::bind(&T::compressedSize, mapper);
103  m_local2Global = std::bind(&T::cartesianIndex, mapper,
104  std::placeholders::_1);
105  }
106 
107  bool tran_active(const std::string& keyword) const override;
108 
109  void apply_tran(const std::string& keyword, std::vector<double>& trans) const override;
110 
111  void deserialize_tran(const std::vector<char>& buffer) override;
112 protected:
113  std::map<std::string, Fieldprops::FieldData<int>> m_intProps;
114  std::map<std::string, Fieldprops::FieldData<double>> m_doubleProps;
115  FieldPropsManager& m_manager;
116  Parallel::Communication m_comm;
117  std::function<int(void)> m_activeSize;
118  std::function<int(const int)> m_local2Global;
119  std::unordered_map<std::string, Fieldprops::TranCalculator> m_tran;
120 };
121 
122 
134 class ParallelEclipseState : public EclipseState {
136  template<class Grid>
138 public:
140  ParallelEclipseState(Parallel::Communication comm);
141 
145  ParallelEclipseState(const Deck& deck);
146 
151  ParallelEclipseState(const Deck& deck, Parallel::Communication comm);
152 
155  void switchToGlobalProps();
156 
161 
163  const FieldPropsManager& fieldProps() const override;
164 
167  const FieldPropsManager& globalFieldProps() const override;
168 
171  const EclipseGrid& getInputGrid() const override;
172 
178  template<class T>
179  void resetCartesianMapper(const T* mapper)
180  {
181  m_fieldProps.resetCartesianMapper(mapper);
182  }
183 private:
184  bool m_parProps = false;
185  ParallelFieldPropsManager m_fieldProps;
186  Parallel::Communication m_comm;
187 };
188 
189 
190 } // end namespace Opm
191 #endif // PARALLEL_ECLIPSE_STATE_HPP
Parallel frontend to the EclipseState.
Definition: ParallelEclipseState.hpp:134
void switchToGlobalProps()
Switch to global field properties.
Definition: ParallelEclipseState.cpp:266
const EclipseGrid & getInputGrid() const override
Returns a const ref to the eclipse grid.
Definition: ParallelEclipseState.cpp:258
const FieldPropsManager & fieldProps() const override
Returns a const ref to current field properties.
Definition: ParallelEclipseState.cpp:238
ParallelEclipseState(Parallel::Communication comm)
Default constructor.
Definition: ParallelEclipseState.cpp:218
friend class PropsCentroidsDataHandle
Friend to set up props.
Definition: ParallelEclipseState.hpp:137
void switchToDistributedProps()
Switch to distributed field properies.
Definition: ParallelEclipseState.cpp:272
const FieldPropsManager & globalFieldProps() const override
Returns a const ref to global field properties.
Definition: ParallelEclipseState.cpp:250
void resetCartesianMapper(const T *mapper)
Resets the underlying cartesian mapper \detail This has to be the cartesian mapper of the distributed...
Definition: ParallelEclipseState.hpp:179
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:100
std::unordered_map< std::string, Fieldprops::TranCalculator > m_tran
calculators map
Definition: ParallelEclipseState.hpp:119
std::map< std::string, Fieldprops::FieldData< int > > m_intProps
Map of integer properties in process-local compressed indices.
Definition: ParallelEclipseState.hpp:113
bool has_double(const std::string &keyword) const override
Check if a double property is available.
Definition: ParallelEclipseState.cpp:211
std::vector< int > actnum() const override
Returns actnum vector.
Definition: ParallelEclipseState.cpp:42
std::vector< double > porv(bool global=false) const override
Returns the pore volume vector.
Definition: ParallelEclipseState.cpp:59
std::vector< double > get_global_double(const std::string &keyword) const override
Returns a double property using global cartesian indices.
Definition: ParallelEclipseState.cpp:157
friend class PropsCentroidsDataHandle
Friend to set up props.
Definition: ParallelEclipseState.hpp:47
ParallelFieldPropsManager(FieldPropsManager &manager)
Constructor.
Definition: ParallelEclipseState.cpp:28
bool has_int(const std::string &keyword) const override
Check if an integer property is available.
Definition: ParallelEclipseState.cpp:200
std::function< int(const int)> m_local2Global
mapping from local to global cartesian indices
Definition: ParallelEclipseState.hpp:118
std::vector< int > get_global_int(const std::string &keyword) const override
Returns an int property using global cartesian indices.
Definition: ParallelEclipseState.cpp:103
const std::vector< double > & get_double(const std::string &keyword) const override
Returns a double property using compressed indices.
Definition: ParallelEclipseState.cpp:135
void reset_actnum(const std::vector< int > &actnum) override
Reset the actnum vector.
Definition: ParallelEclipseState.cpp:51
FieldPropsManager & m_manager
Underlying field property manager (only used on root process).
Definition: ParallelEclipseState.hpp:115
std::map< std::string, Fieldprops::FieldData< double > > m_doubleProps
Map of double properties in process-local compressed indices.
Definition: ParallelEclipseState.hpp:114
Parallel::Communication m_comm
Collective communication handler.
Definition: ParallelEclipseState.hpp:116
const std::vector< int > & get_int(const std::string &keyword) const override
Returns an int property using compressed indices.
Definition: ParallelEclipseState.cpp:81
std::function< int(void)> m_activeSize
active size function of the grid
Definition: ParallelEclipseState.hpp:117
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27