opm-common
VFPProdTable.hpp
1 /*
2  Copyright 2015 SINTEF ICT, Applied Mathematics.
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 
20 #ifndef OPM_PARSER_ECLIPSE_ECLIPSESTATE_TABLES_VFPPRODTABLE_HPP_
21 #define OPM_PARSER_ECLIPSE_ECLIPSESTATE_TABLES_VFPPRODTABLE_HPP_
22 
23 #include <opm/common/OpmLog/KeywordLocation.hpp>
24 
25 #include <opm/input/eclipse/Units/Dimension.hpp>
26 
27 #include <array>
28 #include <cstddef>
29 #include <utility>
30 #include <vector>
31 
32 namespace Opm {
33 
34  class DeckItem;
35  class DeckKeyword;
36  class UnitSystem;
37 
38 } // namespace Opm
39 
40 namespace Opm {
41 
45 class VFPProdTable {
46 public:
47 
48  enum class FLO_TYPE {
49  FLO_OIL=1,
50  FLO_LIQ,
51  FLO_GAS
52  };
53 
54  enum class WFR_TYPE {
55  WFR_WOR=11,
56  WFR_WCT,
57  WFR_WGR
58  };
59 
60  enum class GFR_TYPE {
61  GFR_GOR=21,
62  GFR_GLR,
63  GFR_OGR
64  };
65 
66  enum class ALQ_TYPE {
67  ALQ_GRAT=31,
68  ALQ_IGLR,
69  ALQ_TGLR,
70  ALQ_PUMP,
71  ALQ_COMP,
72  ALQ_BEAN,
73  ALQ_UNDEF
74  };
75 
76  VFPProdTable();
77  VFPProdTable( const DeckKeyword& table, bool gaslift_opt_active, const UnitSystem& deck_unit_system);
78  VFPProdTable(int table_num,
79  double datum_depth,
80  FLO_TYPE flo_type,
81  WFR_TYPE wfr_type,
82  GFR_TYPE gfr_type,
83  ALQ_TYPE alq_type,
84  const std::vector<double>& flo_data,
85  const std::vector<double>& thp_data,
86  const std::vector<double>& wfr_data,
87  const std::vector<double>& gfr_data,
88  const std::vector<double>& alq_data,
89  const std::vector<double>& data);
90 
91  static Dimension ALQDimension(const ALQ_TYPE& alq_type, const UnitSystem& unit_system);
92 
93  static std::pair<int, ALQ_TYPE>
94  getALQType(const DeckKeyword& inputTable, bool gaslift_opt_active);
95 
96  static VFPProdTable serializationTestObject();
97 
98  inline int getTableNum() const {
99  return m_table_num;
100  }
101 
102  inline const KeywordLocation& location() const {
103  return this->m_location;
104  }
105 
106  // The name() method is added to simplify serialization.
107  inline int name() const {
108  return m_table_num;
109  }
110 
111  inline double getDatumDepth() const {
112  return m_datum_depth;
113  }
114 
115  inline FLO_TYPE getFloType() const {
116  return m_flo_type;
117  }
118 
119  inline WFR_TYPE getWFRType() const {
120  return m_wfr_type;
121  }
122 
123  inline GFR_TYPE getGFRType() const {
124  return m_gfr_type;
125  }
126 
127  inline ALQ_TYPE getALQType() const {
128  return m_alq_type;
129  }
130 
131  inline const std::vector<double>& getFloAxis() const {
132  return m_flo_data;
133  }
134 
135  inline const std::vector<double>& getTHPAxis() const {
136  return m_thp_data;
137  }
138 
139  inline const std::vector<double>& getWFRAxis() const {
140  return m_wfr_data;
141  }
142 
143  inline const std::vector<double>& getGFRAxis() const {
144  return m_gfr_data;
145  }
146 
147  inline const std::vector<double>& getALQAxis() const {
148  return m_alq_data;
149  }
150 
165  inline const std::vector<double>& getTable() const {
166  return m_data;
167  }
168 
169  bool operator==(const VFPProdTable& data) const;
170 
171  std::array<std::size_t,5> shape() const;
172 
173  double operator()(std::size_t thp_idx, std::size_t wfr_idx, std::size_t gfr_idx, std::size_t alq_idx, std::size_t flo_idx) const;
174 
175  template<class Serializer>
176  void serializeOp(Serializer& serializer)
177  {
178  serializer(m_table_num);
179  serializer(m_datum_depth);
180  serializer(m_flo_type);
181  serializer(m_wfr_type);
182  serializer(m_gfr_type);
183  serializer(m_alq_type);
184  serializer(m_flo_data);
185  serializer(m_thp_data);
186  serializer(m_wfr_data);
187  serializer(m_gfr_data);
188  serializer(m_alq_data);
189  serializer(m_data);
190  serializer(m_location);
191  }
192 
193 private:
194  int m_table_num{};
195  double m_datum_depth{};
196  FLO_TYPE m_flo_type{};
197  WFR_TYPE m_wfr_type{};
198  GFR_TYPE m_gfr_type{};
199  ALQ_TYPE m_alq_type{};
200 
201  std::vector<double> m_flo_data{};
202  std::vector<double> m_thp_data{};
203  std::vector<double> m_wfr_data{};
204  std::vector<double> m_gfr_data{};
205  std::vector<double> m_alq_data{};
206 
207  std::vector<double> m_data{};
208  KeywordLocation m_location{};
209 
210  void check();
211 
212  double& mutableData(std::size_t thp_idx, std::size_t wfr_idx, std::size_t gfr_idx, std::size_t alq_idx, std::size_t flo_idx);
213 
214  static void scaleValues(std::vector<double>& values,
215  const double& scaling_factor);
216 
217  static void convertFloToSI(const FLO_TYPE& type,
218  std::vector<double>& values,
219  const UnitSystem& unit_system);
220  static void convertTHPToSI(std::vector<double>& values,
221  const UnitSystem& unit_system);
222  static void convertWFRToSI(const WFR_TYPE& type,
223  std::vector<double>& values,
224  const UnitSystem& unit_system);
225  static void convertGFRToSI(const GFR_TYPE& type,
226  std::vector<double>& values,
227  const UnitSystem& unit_system);
228  static void convertAlqToSI(const ALQ_TYPE& type,
229  std::vector<double>& values,
230  const UnitSystem& unit_system);
231 };
232 
233 } // namespace Opm
234 
235 #endif // OPM_PARSER_ECLIPSE_ECLIPSESTATE_TABLES_VFPPRODTABLE_HPP_
Definition: KeywordLocation.hpp:27
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
const std::vector< double > & getTable() const
Returns the data of the table itself.
Definition: VFPProdTable.hpp:165
Class for reading data from a VFPPROD (vertical flow performance production) table.
Definition: VFPProdTable.hpp:45
Definition: UnitSystem.hpp:34
Class for (de-)serializing.
Definition: Serializer.hpp:95
Definition: Dimension.hpp:27
Definition: DeckKeyword.hpp:38