My Project
Loading...
Searching...
No Matches
ActionValue.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 ACTION_VALUE_HPP
21#define ACTION_VALUE_HPP
22
23#include <opm/input/eclipse/Schedule/Action/ActionResult.hpp>
24
25#include <string>
26#include <string_view>
27#include <utility>
28#include <vector>
29
30namespace Opm::Action {
31
33enum class TokenType
34{
36 number, // 0
37
40 ecl_expr, // 1
41
43 open_paren, // 2
44
46 close_paren, // 3
47
49 op_gt, // 4
50
52 op_ge, // 5
53
55 op_lt, // 6
56
58 op_le, // 7
59
61 op_eq, // 8
62
64 op_ne, // 9
65
67 op_and, // 10
68
70 op_or, // 11
71
73 end, // 12
74
76 error, // 13
77};
78
80enum class FuncType
81{
83 none, // 0
84
87 time, // 1
88
90 time_month, // 2
91
93 region, // 3
94
96 field, // 4
97
99 group, // 5
100
102 well, // 6
103
105 well_segment, // 7
106
108 well_connection, // 8
109
111 Well_lgr, // 9
112
114 aquifer, // 10
115
117 block, // 11
118};
119
121class Value
122{
123public:
128 Value() = default;
129
135 explicit Value(double value);
136
140 Value(std::string_view wname, double value);
141
164 Result eval_cmp(TokenType op, const Value& rhs) const;
165
175 void add_well(std::string_view well, double value);
176
181 double scalar() const;
182
183private:
187 double scalar_value_{};
188
190 double is_scalar_{false};
191
193 std::vector<std::pair<std::string, double>> well_values_{};
194
207 Result evalWellComparisons(TokenType op, double rhs) const;
208};
209
210} // namespace Opm::Action
211
212#endif // ACTION_VALUE_HPP
Class Action::Result holds the boolean result of a ACTIONX condition like.
Definition ActionResult.hpp:69
Numeric value of an AST sub-expression.
Definition ActionValue.hpp:122
void add_well(std::string_view well, double value)
Incorporate well level function value into Value object.
Definition ActionValue.cpp:128
double scalar() const
Retrieve scalar function value.
Definition ActionValue.cpp:140
Value()=default
Default constructor.
Result eval_cmp(TokenType op, const Value &rhs) const
Compare current Value to another Value.
Definition ActionValue.cpp:104