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
76enum class UDQTokenType
77{
78 error = 0,
79 number = 1,
80 open_paren = 2,
81 close_paren = 3,
82 comp_expr = 6,
83 ecl_expr = 7,
84 //
85 binary_op_add = 8,
86 binary_op_sub = 9,
87 binary_op_div = 10,
88 binary_op_mul = 11,
89 binary_op_pow = 12,
90 binary_op_uadd = 13,
91 binary_op_umul = 14,
92 binary_op_umin = 15,
93 binary_op_umax = 16,
94 binary_cmp_eq = 17,
95 binary_cmp_ne = 18,
96 binary_cmp_le = 19,
97 binary_cmp_ge = 20,
98 binary_cmp_lt = 21,
99 binary_cmp_gt = 22,
100 //
101 elemental_func_randn = 23,
102 elemental_func_randu = 24,
103 elemental_func_rrandn = 25,
104 elemental_func_rrandu = 26,
105 elemental_func_abs = 27,
106 elemental_func_def = 28,
107 elemental_func_exp = 29,
108 elemental_func_idv = 30,
109 elemental_func_ln = 31,
110 elemental_func_log = 32,
111 elemental_func_nint = 33,
112 elemental_func_sorta = 34,
113 elemental_func_sortd = 35,
114 elemental_func_undef = 36,
115 //
116 scalar_func_sum = 37,
117 scalar_func_avea = 38,
118 scalar_func_aveg = 39,
119 scalar_func_aveh = 40,
120 scalar_func_max = 41,
121 scalar_func_min = 42,
122 scalar_func_norm1 = 43,
123 scalar_func_norm2 = 44,
124 scalar_func_normi = 45,
125 scalar_func_prod = 46,
126 //
127 table_lookup = 47,
128 table_lookup_start = 48,
129 table_lookup_end = 49,
130 //
131 end = 100,
132};
133
134enum class UDQAction
135{
136 ASSIGN,
137 DEFINE,
138 UNITS,
139 UPDATE,
140};
141
142enum class UDQUpdate
143{
144 ON,
145 OFF,
146 NEXT,
147};
148
149enum class UDAControl
150{
151 WCONPROD_ORAT,
152 WCONPROD_WRAT,
153 WCONPROD_GRAT,
154 WCONPROD_LRAT,
155 WCONPROD_RESV,
156 WCONPROD_BHP,
157 WCONPROD_THP,
158 WCONPROD_LIFT,
159 //
160 WCONINJE_RATE,
161 WCONINJE_RESV,
162 WCONINJE_BHP,
163 WCONINJE_THP,
164 //
165 GCONPROD_OIL_TARGET,
166 GCONPROD_WATER_TARGET,
167 GCONPROD_GAS_TARGET,
168 GCONPROD_LIQUID_TARGET,
169 //
170 GCONINJE_SURFACE_MAX_RATE,
171 GCONINJE_RESV_MAX_RATE,
172 GCONINJE_TARGET_REINJ_FRACTION,
173 GCONINJE_TARGET_VOID_FRACTION,
174 //
175 WELTARG_ORAT,
176 WELTARG_WRAT,
177 WELTARG_GRAT,
178 WELTARG_LRAT,
179 WELTARG_RESV,
180 WELTARG_BHP,
181 WELTARG_THP,
182 WELTARG_LIFT,
183};
184
185enum class UDAKeyword
186{
187 WCONPROD,
188 WCONINJE,
189 WELTARG,
190 GCONINJE,
191 GCONPROD,
192};
193
194namespace UDQ {
195
196 UDQVarType targetType(const std::string& keyword, const std::vector<std::string>& selector);
197 UDQVarType targetType(const std::string& keyword);
198 UDQVarType varType(const std::string& keyword);
199 UDQVarType coerce(UDQVarType t1, UDQVarType t2);
200
201 UDQAction actionType(const std::string& action_string);
202
203 UDQUpdate updateType(const std::string& update_string);
204 UDQUpdate updateType(int int_value);
205
206 UDQTokenType tokenType(const std::string& func_name);
207 UDQTokenType funcType(const std::string& func_name);
208
209 bool binaryFunc(UDQTokenType token_type);
210 bool elementalUnaryFunc(UDQTokenType token_type);
211 bool scalarFunc(UDQTokenType token_type);
212 bool cmpFunc(UDQTokenType token_type);
213 bool setFunc(UDQTokenType token_type);
214 bool trailingSpace(UDQTokenType token_type);
215 bool leadingSpace(UDQTokenType token_type);
216 bool group_control(UDAControl control);
217 bool well_control(UDAControl control);
218 bool is_well_injection_control(UDAControl control, const bool isInjector);
219 bool is_well_production_control(UDAControl control, const bool isProducer);
220 bool is_group_injection_control(UDAControl control);
221 bool is_group_production_control(UDAControl control);
222
223 std::string typeName(UDQVarType var_type);
224 std::string controlName(UDAControl control);
225
226 UDAKeyword keyword(UDAControl control);
227 int udaCode(UDAControl control);
228 UDAControl udaControl(int uda_code);
229
230 constexpr double restart_default = -0.3E+21;
231
232} // namespace UDQ
233
234} // namespace Opm
235
236#endif // UDQ_ENUMS_HPP
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30