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 copyTran(const FieldPropsManager& from)
112  {
113  m_tran = from.getTran();
114  }
115 
116  template<class Serializer>
117  void serializeOp(Serializer& serializer)
118  {
119  serializer(m_tran);
120  }
121 
122 protected:
123  std::map<std::string, Fieldprops::FieldData<int>> m_intProps;
124  std::map<std::string, Fieldprops::FieldData<double>> m_doubleProps;
125  FieldPropsManager& m_manager;
126  Parallel::Communication m_comm;
127  std::function<int(void)> m_activeSize;
128  std::function<int(const int)> m_local2Global;
129  std::unordered_map<std::string, Fieldprops::TranCalculator> m_tran;
130 };
131 
132 
144 class ParallelEclipseState : public EclipseState {
146  template<class Grid>
148 public:
150  ParallelEclipseState(Parallel::Communication comm);
151 
155  ParallelEclipseState(const Deck& deck);
156 
161  ParallelEclipseState(const Deck& deck, Parallel::Communication comm);
162 
165  void switchToGlobalProps();
166 
171 
173  const FieldPropsManager& fieldProps() const override;
174 
177  const FieldPropsManager& globalFieldProps() const override;
178 
181  const EclipseGrid& getInputGrid() const override;
182 
188  template<class T>
189  void resetCartesianMapper(const T* mapper)
190  {
191  m_fieldProps.resetCartesianMapper(mapper);
192  }
193 private:
194  bool m_parProps = false;
195  ParallelFieldPropsManager m_fieldProps;
196  Parallel::Communication m_comm;
197 };
198 
199 
200 } // end namespace Opm
201 #endif // PARALLEL_ECLIPSE_STATE_HPP
Parallel frontend to the EclipseState.
Definition: ParallelEclipseState.hpp:144
void switchToGlobalProps()
Switch to global field properties.
Definition: ParallelEclipseState.cpp:261
const EclipseGrid & getInputGrid() const override
Returns a const ref to the eclipse grid.
Definition: ParallelEclipseState.cpp:253
const FieldPropsManager & fieldProps() const override
Returns a const ref to current field properties.
Definition: ParallelEclipseState.cpp:233
ParallelEclipseState(Parallel::Communication comm)
Default constructor.
Definition: ParallelEclipseState.cpp:213
friend class PropsCentroidsDataHandle
Friend to set up props.
Definition: ParallelEclipseState.hpp:147
void switchToDistributedProps()
Switch to distributed field properies.
Definition: ParallelEclipseState.cpp:267
const FieldPropsManager & globalFieldProps() const override
Returns a const ref to global field properties.
Definition: ParallelEclipseState.cpp:245
void resetCartesianMapper(const T *mapper)
Resets the underlying cartesian mapper \detail This has to be the cartesian mapper of the distributed...
Definition: ParallelEclipseState.hpp:189
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:129
std::map< std::string, Fieldprops::FieldData< int > > m_intProps
Map of integer properties in process-local compressed indices.
Definition: ParallelEclipseState.hpp:123
bool has_double(const std::string &keyword) const override
Check if a double property is available.
Definition: ParallelEclipseState.cpp:206
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:128
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:125
std::map< std::string, Fieldprops::FieldData< double > > m_doubleProps
Map of double properties in process-local compressed indices.
Definition: ParallelEclipseState.hpp:124
Parallel::Communication m_comm
Collective communication handler.
Definition: ParallelEclipseState.hpp:126
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:127
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27