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