ActionX.hpp
Go to the documentation of this file.
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 <string>
25#include <vector>
26#include <ctime>
27
32
33
34
35namespace Opm {
36class DeckKeyword;
37
38namespace Action {
39
40/*
41 The ActionX class internalizes the ACTIONX keyword. This keyword represents a
42 small in-deck programming language for the SCHEDULE section. In the deck the
43 ACTIONX keyword comes together with a 'ENDACTIO' kewyord and then a list of
44 regular keywords in the between. The principle is then that ACTIONX represents
45 a condition, and when that condition is satisfied the keywords are applied. In
46 the example below the ACTIONX keyword defines a condition whether well OPX has
47 watercut above 0.75, when the condition is met the WELOPEN keyword is applied
48 - and the well is shut.
49
50 ACTIONX
51 'NAME' /
52 WWCT OPX > 0.50 /
53 /
54
55 WELOPEN
56 'OPX' OPEN /
57 /
58
59 ENDACTION
60
61
62*/
63
64class ActionX {
65public:
67 ActionX(const std::string& name, size_t max_run, double max_wait, std::time_t start_time);
68 ActionX(const DeckKeyword& kw, std::time_t start_time);
69 ActionX(const DeckRecord& record, std::time_t start_time);
70
72
73 void addKeyword(const DeckKeyword& kw);
74 bool ready(std::time_t sim_time) const;
75 Action::Result eval(std::time_t sim_time, const Action::Context& context) const;
76
77
78 std::string name() const { return this->m_name; }
79 size_t max_run() const { return this->m_max_run; }
80 double min_wait() const { return this->m_min_wait; }
81 std::time_t start_time() const { return this->m_start_time; }
82 std::vector<DeckKeyword>::const_iterator begin() const;
83 std::vector<DeckKeyword>::const_iterator end() const;
84 static bool valid_keyword(const std::string& keyword);
85
86 /*
87 The conditions() and keyword_strings() methods, and their underlying data
88 members are only present to support writing formatted restart files.
89 */
90 const std::vector<Condition>& conditions() const;
91 std::vector<std::string> keyword_strings() const;
92
93 bool operator==(const ActionX& data) const;
94
95 template<class Serializer>
96 void serializeOp(Serializer& serializer)
97 {
98 serializer(m_name);
99 serializer(m_max_run);
100 serializer(m_min_wait);
101 serializer(m_start_time);
102 serializer.vector(keywords);
103 condition.serializeOp(serializer);
104 serializer.vector(m_conditions);
105 serializer(run_count);
106 serializer(last_run);
107 }
108
109private:
110 std::string m_name;
111 size_t m_max_run = 0;
112 double m_min_wait = 0.0;
113 std::time_t m_start_time;
114
115 std::vector<DeckKeyword> keywords;
116 Action::AST condition;
117 std::vector<Condition> m_conditions;
118 mutable size_t run_count = 0;
119 mutable std::time_t last_run = 0;
120};
121
122}
123}
124#endif /* WELL_HPP_ */
const char *const string
Definition: cJSON.h:170
Definition: ActionAST.hpp:43
void serializeOp(Serializer &serializer)
Definition: ActionAST.hpp:55
Definition: ActionX.hpp:64
ActionX(const std::string &name, size_t max_run, double max_wait, std::time_t start_time)
bool ready(std::time_t sim_time) const
std::vector< std::string > keyword_strings() const
std::vector< DeckKeyword >::const_iterator end() const
ActionX(const DeckKeyword &kw, std::time_t start_time)
void serializeOp(Serializer &serializer)
Definition: ActionX.hpp:96
std::vector< DeckKeyword >::const_iterator begin() const
Action::Result eval(std::time_t sim_time, const Action::Context &context) const
size_t max_run() const
Definition: ActionX.hpp:79
bool operator==(const ActionX &data) const
ActionX(const DeckRecord &record, std::time_t start_time)
void addKeyword(const DeckKeyword &kw)
static ActionX serializeObject()
static bool valid_keyword(const std::string &keyword)
double min_wait() const
Definition: ActionX.hpp:80
std::string name() const
Definition: ActionX.hpp:78
const std::vector< Condition > & conditions() const
std::time_t start_time() const
Definition: ActionX.hpp:81
Definition: ActionContext.hpp:38
Definition: ActionResult.hpp:89
Definition: DeckKeyword.hpp:38
Definition: DeckRecord.hpp:32
Definition: Serializer.hpp:38
Action
Definition: InputErrorAction.hpp:36
UDAKeyword keyword(UDAControl control)
Definition: A.hpp:4
static std::string data()
Definition: exprtk.hpp:40022