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