opm-common
VFPInjTable.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_VFPINJTABLE_HPP_
21 #define OPM_PARSER_ECLIPSE_ECLIPSESTATE_TABLES_VFPINJTABLE_HPP_
22 
23 #include <opm/common/OpmLog/KeywordLocation.hpp>
24 
25 #include <array>
26 #include <cstddef>
27 #include <string>
28 #include <vector>
29 
30 namespace Opm {
31 
32 class DeckKeyword;
33 class UnitSystem;
34 
35 class VFPInjTable {
36 public:
37 
38  enum class FLO_TYPE {
39  FLO_OIL=1,
40  FLO_WAT,
41  FLO_GAS,
42  };
43 
44  VFPInjTable();
45  VFPInjTable(const DeckKeyword& table, const UnitSystem& deck_unit_system);
46 
47  static VFPInjTable serializationTestObject();
48 
49  inline const KeywordLocation& location() const {
50  return this->m_location;
51  }
52 
53  inline int getTableNum() const {
54  return m_table_num;
55  }
56 
57  // The name() method is added to simplify serialization.
58  inline int name() const {
59  return m_table_num;
60  }
61 
62  inline double getDatumDepth() const {
63  return m_datum_depth;
64  }
65 
66  inline FLO_TYPE getFloType() const {
67  return m_flo_type;
68  }
69 
70  inline const std::vector<double>& getFloAxis() const {
71  return m_flo_data;
72  }
73 
74  inline const std::vector<double>& getTHPAxis() const {
75  return m_thp_data;
76  }
77 
90  inline const std::vector<double>& getTable() const {
91  return m_data;
92  }
93 
94  bool operator==(const VFPInjTable& data) const;
95 
96  std::array<std::size_t,2> shape() const;
97 
98  double operator()(std::size_t thp_idx, std::size_t flo_idx) const;
99 
100  template<class Serializer>
101  void serializeOp(Serializer& serializer)
102  {
103  serializer(m_table_num);
104  serializer(m_datum_depth);
105  serializer(m_flo_type);
106  serializer(m_flo_data);
107  serializer(m_thp_data);
108  serializer(m_data);
109  serializer(m_location);
110  }
111 
112 private:
113  int m_table_num;
114  double m_datum_depth;
115  FLO_TYPE m_flo_type;
116 
117  std::vector<double> m_flo_data;
118  std::vector<double> m_thp_data;
119 
120  std::vector<double> m_data;
121  KeywordLocation m_location;
122 
123  void check();
124 
125  double& operator()(std::size_t thp_idx, std::size_t flo_idx);
126 
127  static FLO_TYPE getFloType(const std::string& flo_string);
128 
129  static void scaleValues(std::vector<double>& values,
130  const double& scaling_factor);
131 
132  static void convertFloToSI(const FLO_TYPE& type,
133  std::vector<double>& values,
134  const UnitSystem& unit_system);
135  static void convertTHPToSI(std::vector<double>& values,
136  const UnitSystem& unit_system);
137 };
138 
139 }
140 
141 #endif
Definition: VFPInjTable.hpp:35
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: VFPInjTable.hpp:90
Definition: UnitSystem.hpp:34
Class for (de-)serializing.
Definition: Serializer.hpp:95
Definition: DeckKeyword.hpp:38