My Project
UDQEnums.hpp
1 /*
2  Copyright 2019 Equinor ASA.
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 UDQ_ENUMS_HPP
21 #define UDQ_ENUMS_HPP
22 
23 #include <string>
24 #include <vector>
25 
26 namespace Opm {
27 
28 /*
29  The UDQ variables can be of of many different types. In addition they can be
30  either scalars or vector sets. The arch example of a vector set is well
31  variables - in the expressions:
32 
33  UDQ
34  DEFINE WUBHP WBHP * 1.15 /
35  DEFINE WUORAT 1000 /
36  /
37 
38  we define two UDQ values 'WUBHP' and 'WUORAT'. Both of these UDQ values will
39  apply to all wells; the WUBHP vector will correspond to the normal BHP scaled
40  up 15%, the WUORAT has the scalar value 1000 for all the wells. The well sets
41  can be qualified with a wellname, if the wellname has a wildcard we will get a
42  well set, if the wellname is fully qualified we have a scalar:
43 
44  UDQ
45  DEFINE WUWCT WWCT 'OP*' /
46  DEFINE FUORAT WOPR 'OPX' * 100 /
47  /
48 
49  Here the UDQ WUCWT corresponds to the well WWCT for all wells matching the
50  name 'OP*', and it is undefined for the remaing wells. The UDQ FUORAT is a
51  scalar, given by the WOPR of well 'OPX' - multiplied by 100.
52 
53  There are clearly rules for how the different variable types can be combined
54  in expressions, and what will be resulting type from an expression -
55  unfortunately that is not yet very well implemented in the opm codebase. In
56  UDQParser.cpp there is a function static_type_check and in UDQDefine there is
57  a function dynamic_type_check - these functions try to verfiy that the type
58  conversions are legitimate, but currently they are woefully inadequate.
59 */
60 
61 enum class UDQVarType {
62  NONE = 0,
63  SCALAR = 1,
64  CONNECTION_VAR = 2,
65  FIELD_VAR = 3,
66  REGION_VAR = 4,
67  SEGMENT_VAR = 5,
68  AQUIFER_VAR = 6,
69  BLOCK_VAR = 7,
70  WELL_VAR = 8,
71  GROUP_VAR = 9
72 };
73 
74 enum class UDQTokenType{
75  error = 0,
76  number = 1,
77  open_paren = 2,
78  close_paren = 3,
79  comp_expr = 6,
80  ecl_expr = 7,
81  //
82  binary_op_add = 8,
83  binary_op_sub = 9,
84  binary_op_div = 10,
85  binary_op_mul = 11,
86  binary_op_pow = 12,
87  binary_op_uadd = 13,
88  binary_op_umul = 14,
89  binary_op_umin = 15,
90  binary_op_umax = 16,
91  binary_cmp_eq = 17,
92  binary_cmp_ne = 18,
93  binary_cmp_le = 19,
94  binary_cmp_ge = 20,
95  binary_cmp_lt = 21,
96  binary_cmp_gt = 22,
97  //
98  elemental_func_randn = 23,
99  elemental_func_randu = 24,
100  elemental_func_rrandn = 25,
101  elemental_func_rrandu = 26,
102  elemental_func_abs = 27,
103  elemental_func_def = 28,
104  elemental_func_exp = 29,
105  elemental_func_idv = 30,
106  elemental_func_ln = 31,
107  elemental_func_log = 32,
108  elemental_func_nint = 33,
109  elemental_func_sorta = 34,
110  elemental_func_sortd = 35,
111  elemental_func_undef = 36,
112  //
113  scalar_func_sum = 37,
114  scalar_func_avea = 38,
115  scalar_func_aveg = 39,
116  scalar_func_aveh = 40,
117  scalar_func_max = 41,
118  scalar_func_min = 42,
119  scalar_func_norm1 = 43,
120  scalar_func_norm2 = 44,
121  scalar_func_normi = 45,
122  scalar_func_prod = 46,
123  //
124  table_lookup = 47,
125  //
126  end = 100
127 };
128 
129 enum class UDQAction {
130  ASSIGN,
131  DEFINE,
132  UNITS,
133  UPDATE
134 };
135 
136 enum class UDQUpdate {
137  ON,
138  OFF,
139  NEXT
140 };
141 
142 enum class UDAControl {
143  WCONPROD_ORAT,
144  WCONPROD_WRAT,
145  WCONPROD_GRAT,
146  WCONPROD_LRAT,
147  WCONPROD_RESV,
148  WCONPROD_BHP,
149  WCONPROD_THP,
150  //
151  WCONINJE_RATE,
152  WCONINJE_RESV,
153  WCONINJE_BHP,
154  WCONINJE_THP,
155  //
156  GCONPROD_OIL_TARGET,
157  GCONPROD_WATER_TARGET,
158  GCONPROD_GAS_TARGET,
159  GCONPROD_LIQUID_TARGET,
160  //
161  GCONINJE_SURFACE_MAX_RATE,
162  GCONINJE_RESV_MAX_RATE,
163  GCONINJE_TARGET_REINJ_FRACTION,
164  GCONINJE_TARGET_VOID_FRACTION,
165  //
166  WELTARG_ORAT,
167  WELTARG_WRAT,
168  WELTARG_GRAT,
169  WELTARG_LRAT,
170  WELTARG_RESV,
171  WELTARG_BHP,
172  WELTARG_THP,
173  WELTARG_LIFT,
174 };
175 
176 enum class UDAKeyword {
177  WCONPROD,
178  WCONINJE,
179  WELTARG,
180  GCONINJE,
181  GCONPROD,
182 };
183 
184 namespace UDQ {
185 
186  UDQVarType targetType(const std::string& keyword, const std::vector<std::string>& selector);
187  UDQVarType targetType(const std::string& keyword);
188  UDQVarType varType(const std::string& keyword);
189  UDQVarType coerce(UDQVarType t1, UDQVarType t2);
190  UDQAction actionType(const std::string& action_string);
191  UDQUpdate updateType(const std::string& update_string);
192  UDQUpdate updateType(int int_value);
193  UDQTokenType tokenType(const std::string& func_name);
194  UDQTokenType funcType(const std::string& func_name);
195  bool binaryFunc(UDQTokenType token_type);
196  bool elementalUnaryFunc(UDQTokenType token_type);
197  bool scalarFunc(UDQTokenType token_type);
198  bool cmpFunc(UDQTokenType token_type);
199  bool setFunc(UDQTokenType token_type);
200  bool trailingSpace(UDQTokenType token_type);
201  bool leadingSpace(UDQTokenType token_type);
202  bool group_control(UDAControl control);
203  bool well_control(UDAControl control);
204  bool is_well_injection_control(UDAControl control, const bool isInjector);
205  bool is_well_production_control(UDAControl control, const bool isProducer);
206  bool is_group_injection_control(UDAControl control);
207  bool is_group_production_control(UDAControl control);
208 
209  std::string typeName(UDQVarType var_type);
210  std::string controlName(UDAControl control);
211  UDAKeyword keyword(UDAControl control);
212  int udaCode(UDAControl control);
213  UDAControl udaControl(int uda_code);
214 
215  constexpr double restart_default = -0.3E+21;
216 } // UDQ
217 } // Opm
218 
219 #endif // UDQ_ENUMS_HPP
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29