My Project
Loading...
Searching...
No Matches
ActionX.hpp
1/*
2 Copyright 2013 Statoil 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 ActionX_HPP_
22#define ActionX_HPP_
23
24#include <ctime>
25#include <string>
26#include <unordered_map>
27#include <unordered_set>
28#include <vector>
29
30#include <opm/input/eclipse/Deck/DeckKeyword.hpp>
31#include <opm/input/eclipse/Schedule/Action/ActionAST.hpp>
32#include <opm/input/eclipse/Schedule/Action/ActionResult.hpp>
33#include <opm/input/eclipse/Schedule/Action/Condition.hpp>
34
35
36
37namespace Opm {
38class DeckKeyword;
39class WellMatcher;
40class Actdims;
41
42namespace RestartIO {
43struct RstAction;
44}
45
46
47namespace Action {
48class State;
49
50/*
51 The ActionX class internalizes the ACTIONX keyword. This keyword represents a
52 small in-deck programming language for the SCHEDULE section. In the deck the
53 ACTIONX keyword comes together with a 'ENDACTIO' kewyord and then a list of
54 regular keywords in the between. The principle is then that ACTIONX represents
55 a condition, and when that condition is satisfied the keywords are applied. In
56 the example below the ACTIONX keyword defines a condition whether well OPX has
57 watercut above 0.75, when the condition is met the WELOPEN keyword is applied
58 - and the well is shut.
59
60 ACTIONX
61 'NAME' /
62 WWCT OPX > 0.50 /
63 /
64
65 WELOPEN
66 'OPX' OPEN /
67 /
68
69 ENDACTION
70
71
72*/
73
74class ActionX {
75public:
76 ActionX();
77 ActionX(const std::string& name, size_t max_run, double max_wait, std::time_t start_time);
78 ActionX(const std::string& name, size_t max_run, double max_wait,
79 std::time_t start_time,
80 const std::vector<Condition>&& conditions,
81 const std::vector<std::string>&& tokens);
82 ActionX(const DeckRecord& record, std::time_t start_time);
83 explicit ActionX(const RestartIO::RstAction& rst_action);
84
85 static ActionX serializationTestObject();
86
87 void addKeyword(const DeckKeyword& kw);
88 bool ready(const State& state, std::time_t sim_time) const;
89 Action::Result eval(const Action::Context& context) const;
90
91 std::vector<std::string> wellpi_wells(const WellMatcher& well_matcher, const std::vector<std::string>& matching_wells) const;
92 void required_summary(std::unordered_set<std::string>& required_summary) const;
93 std::string name() const { return this->m_name; }
94 size_t max_run() const { return this->m_max_run; }
95 double min_wait() const { return this->m_min_wait; }
96 std::size_t id() const;
97 void update_id(std::size_t id);
98 std::time_t start_time() const { return this->m_start_time; }
99 std::vector<DeckKeyword>::const_iterator begin() const;
100 std::vector<DeckKeyword>::const_iterator end() const;
101 static bool valid_keyword(const std::string& keyword);
102
103 /*
104 The conditions() and keyword_strings() methods, and their underlying data
105 members are only present to support writing formatted restart files.
106 */
107 const std::vector<Condition>& conditions() const;
108 std::vector<std::string> keyword_strings() const;
109
110 bool operator==(const ActionX& data) const;
111
112 template<class Serializer>
113 void serializeOp(Serializer& serializer)
114 {
115 serializer(m_name);
116 serializer(m_max_run);
117 serializer(m_min_wait);
118 serializer(m_start_time);
119 serializer(m_id);
120 serializer(keywords);
121 serializer(condition);
122 serializer(m_conditions);
123 }
124
125private:
126 std::string m_name;
127 size_t m_max_run = 0;
128 double m_min_wait = 0.0;
129 std::time_t m_start_time;
130 std::size_t m_id = 0;
131
132 std::vector<DeckKeyword> keywords;
133 Action::AST condition;
134 std::vector<Condition> m_conditions;
135};
136
143std::tuple<ActionX, std::vector<std::pair<std::string, std::string>>>
144parseActionX(const DeckKeyword& kw, const Actdims& actimds, std::time_t start_time);
145
146}
147}
148#endif /* WELL_HPP_ */
Definition Actdims.hpp:30
Definition ActionAST.hpp:44
Definition ActionX.hpp:74
Definition ActionContext.hpp:41
Definition ActionResult.hpp:99
Definition State.hpp:40
Definition DeckKeyword.hpp:36
Definition DeckRecord.hpp:32
Class for (de-)serializing.
Definition Serializer.hpp:84
Definition WellMatcher.hpp:32
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition action.hpp:35