UDQEnums.hpp
Go to the documentation of this file.
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
21#ifndef UDQ_ENUMS_HPP
22#define UDQ_ENUMS_HPP
23
24namespace Opm {
25
26/*
27 The UDQ variables can be of of many different types. In addition they can be
28 either scalars or vector sets. The arch example of a vector set is well
29 variables - in the expressions:
30
31 UDQ
32 DEFINE WUBHP WBHP * 1.15 /
33 DEFINE WUORAT 1000 /
34 /
35
36 we define two UDQ values 'WUBHP' and 'WUORAT'. Both of these UDQ values will
37 apply to all wells; the WUBHP vector will correspond to the normal BHP scaled
38 up 15%, the WUORAT has the scalar value 1000 for all the wells. The well sets
39 can be qualified with a wellname, if the wellname has a wildcard we will get a
40 well set, if the wellname is fully qualified we have a scalar:
41
42 UDQ
43 DEFINE WUWCT WWCT 'OP*' /
44 DEFINE FUORAT WOPR 'OPX' * 100 /
45 /
46
47 Here the UDQ WUCWT corresponds to the well WWCT for all wells matching the
48 name 'OP*', and it is undefined for the remaing wells. The UDQ FUORAT is a
49 scalar, given by the WOPR of well 'OPX' - multiplied by 100.
50
51 There are clearly rules for how the different variable types can be combined
52 in expressions, and what will be resulting type from an expression -
53 unfortunately that is not yet very well implemented in the opm codebase. In
54 UDQParser.cpp there is a function static_type_check and in UDQDefine there is
55 a function dynamic_type_check - these functions try to verfiy that the type
56 conversions are legitimate, but currently they are woefully inadequate.
57*/
58
59enum class UDQVarType {
60 NONE = 0,
61 SCALAR = 1,
63 FIELD_VAR = 3,
64 REGION_VAR = 4,
65 SEGMENT_VAR = 5,
66 AQUIFER_VAR = 6,
67 BLOCK_VAR = 7,
68 WELL_VAR = 8,
69 GROUP_VAR = 9
70};
71
72
73
74enum class UDQTokenType{
75 error = 0,
76 number = 1,
77 open_paren = 2,
78 close_paren = 3,
79 ecl_expr = 7,
80 //
81 binary_op_add = 8,
82 binary_op_sub = 9,
83 binary_op_div = 10,
84 binary_op_mul = 11,
85 binary_op_pow = 12,
86 binary_op_uadd = 13,
87 binary_op_umul = 14,
88 binary_op_umin = 15,
89 binary_op_umax = 16,
90 binary_cmp_eq = 17,
91 binary_cmp_ne = 18,
92 binary_cmp_le = 19,
93 binary_cmp_ge = 20,
94 binary_cmp_lt = 21,
95 binary_cmp_gt = 22,
96 //
111 //
112 scalar_func_sum = 37,
113 scalar_func_avea = 38,
114 scalar_func_aveg = 39,
115 scalar_func_aveh = 40,
116 scalar_func_max = 41,
117 scalar_func_min = 42,
121 scalar_func_prod = 46,
122 //
123 table_lookup = 47,
124 //
125 end = 100
126};
127
128
129enum class UDQAction {
130 ASSIGN,
131 DEFINE,
132 UNITS,
133 UPDATE
134};
135
136enum class UDAControl {
144 //
149 //
154};
155
156
157enum class UDAKeyword {
158 WCONPROD,
159 WCONINJE,
160 GCONINJE,
162};
163
164
165
166namespace UDQ {
167
168 UDQVarType targetType(const std::string& keyword, const std::vector<std::string>& selector);
172 UDQAction actionType(const std::string& action_string);
174 bool binaryFunc(UDQTokenType token_type);
176 bool scalarFunc(UDQTokenType token_type);
177 bool cmpFunc(UDQTokenType token_type);
178
181 int uadCode(UDAControl control);
182}
183}
184
185#endif
const char *const string
Definition: cJSON.h:170
UDQAction actionType(const std::string &action_string)
bool binaryFunc(UDQTokenType token_type)
UDQVarType coerce(UDQVarType t1, UDQVarType t2)
std::string typeName(UDQVarType var_type)
UDAKeyword keyword(UDAControl control)
bool scalarFunc(UDQTokenType token_type)
UDQVarType targetType(const std::string &keyword, const std::vector< std::string > &selector)
bool cmpFunc(UDQTokenType token_type)
bool elementalUnaryFunc(UDQTokenType token_type)
int uadCode(UDAControl control)
UDQVarType varType(const std::string &keyword)
UDQTokenType funcType(const std::string &func_name)
Definition: A.hpp:4
UDQVarType
Definition: UDQEnums.hpp:59
@ open_paren
Definition: ActionValue.hpp:10
@ error
Definition: ActionValue.hpp:21
@ end
Definition: ActionValue.hpp:20
@ close_paren
Definition: ActionValue.hpp:11
@ number
Definition: ActionValue.hpp:8
@ ecl_expr
Definition: ActionValue.hpp:9
UDQTokenType
Definition: UDQEnums.hpp:74
UDQAction
Definition: UDQEnums.hpp:129
UDAControl
Definition: UDQEnums.hpp:136
UDAKeyword
Definition: UDQEnums.hpp:157