My Project
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 
37 namespace Opm {
38 class DeckKeyword;
39 class WellMatcher;
40 class Actdims;
41 
42 namespace RestartIO {
43 struct RstAction;
44 }
45 
46 
47 namespace Action {
48 class 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 
74 class ActionX {
75 public:
76  ActionX();
77  ActionX(const std::string& name, size_t max_run, double max_wait, std::time_t start_time);
78  ActionX(const DeckKeyword& kw, const Actdims& actimds, std::time_t start_time);
79  ActionX(const DeckRecord& record, std::time_t start_time);
80  explicit ActionX(const RestartIO::RstAction& rst_action);
81 
82  static ActionX serializeObject();
83 
84  void addKeyword(const DeckKeyword& kw);
85  bool ready(const State& state, std::time_t sim_time) const;
86  Action::Result eval(const Action::Context& context) const;
87 
88  std::vector<std::string> wellpi_wells(const WellMatcher& well_matcher, const std::vector<std::string>& matching_wells) const;
89  void required_summary(std::unordered_set<std::string>& required_summary) const;
90  std::string name() const { return this->m_name; }
91  size_t max_run() const { return this->m_max_run; }
92  double min_wait() const { return this->m_min_wait; }
93  std::size_t id() const;
94  void update_id(std::size_t id);
95  std::time_t start_time() const { return this->m_start_time; }
96  std::vector<DeckKeyword>::const_iterator begin() const;
97  std::vector<DeckKeyword>::const_iterator end() const;
98  static bool valid_keyword(const std::string& keyword);
99 
100  /*
101  The conditions() and keyword_strings() methods, and their underlying data
102  members are only present to support writing formatted restart files.
103  */
104  const std::vector<Condition>& conditions() const;
105  std::vector<std::string> keyword_strings() const;
106 
107  bool operator==(const ActionX& data) const;
108 
109  template<class Serializer>
110  void serializeOp(Serializer& serializer)
111  {
112  serializer(m_name);
113  serializer(m_max_run);
114  serializer(m_min_wait);
115  serializer(m_start_time);
116  serializer(m_id);
117  serializer.vector(keywords);
118  condition.serializeOp(serializer);
119  serializer.vector(m_conditions);
120  }
121 
122 private:
123  std::string m_name;
124  size_t m_max_run = 0;
125  double m_min_wait = 0.0;
126  std::time_t m_start_time;
127  std::size_t m_id = 0;
128 
129  std::vector<DeckKeyword> keywords;
130  Action::AST condition;
131  std::vector<Condition> m_conditions;
132 };
133 
134 }
135 }
136 #endif /* WELL_HPP_ */
Definition: Actdims.hpp:30
Definition: ActionAST.hpp:44
Definition: ActionX.hpp:74
Definition: ActionContext.hpp:39
Definition: ActionResult.hpp:99
Definition: State.hpp:40
Definition: DeckKeyword.hpp:36
Definition: DeckRecord.hpp:32
Definition: Serializer.hpp:38
Definition: WellMatcher.hpp:32
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: action.hpp:35