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#ifndef ActionX_HPP_
21#define ActionX_HPP_
22
23#include <opm/input/eclipse/Schedule/Action/ActionAST.hpp>
24#include <opm/input/eclipse/Schedule/Action/ActionResult.hpp>
25#include <opm/input/eclipse/Schedule/Action/Condition.hpp>
26
27#include <opm/input/eclipse/Deck/DeckKeyword.hpp>
28
29#include <cstddef>
30#include <ctime>
31#include <string>
32#include <unordered_set>
33#include <utility>
34#include <vector>
35
36namespace Opm {
37class WellMatcher;
38class Actdims;
39} // namespace Opm
40
41namespace Opm::RestartIO {
42struct RstAction;
43} // namespace Opm::RestartIO
44
45namespace Opm::Action {
46class State;
47} // namespace Opm::Action
48
49namespace Opm::Action {
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-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 on well OPX having
57// watercut above 0.75. When the condition is met the WELOPEN keyword is applied,
58// shutting the well.
59//
60// ACTIONX
61// 'NAME' /
62// WWCT OPX > 0.50 /
63// /
64//
65// WELOPEN
66// 'OPX' OPEN /
67// /
68//
69// ENDACTIO
70
72{
73public:
80 static bool valid_keyword(const std::string& keyword);
81
86 ActionX();
87
107 ActionX(const std::string& name,
108 std::size_t max_run,
109 double min_wait,
110 std::time_t start_time);
111
123 ActionX(const DeckRecord& record, std::time_t start_time);
124
131 explicit ActionX(const RestartIO::RstAction& rst_action);
132
162 ActionX(const std::string& name,
163 std::size_t max_run,
164 double min_wait,
165 std::time_t start_time,
166 std::vector<Condition>&& conditions,
167 const std::vector<std::string>& tokens);
168
171
175 void addKeyword(const DeckKeyword& kw);
176
187 bool ready(const State& state, std::time_t sim_time) const;
188
198 Result eval(const Context& context) const;
199
212 std::vector<std::string>
213 wellpi_wells(const WellMatcher& well_matcher,
214 const Result::MatchingEntities& matches) const;
215
223 void required_summary(std::unordered_set<std::string>& required_summary) const;
224
226 std::string name() const { return this->m_name; }
227
229 std::size_t max_run() const { return this->m_max_run; }
230
233 double min_wait() const { return this->m_min_wait; }
234
236 std::size_t id() const { return this->m_id; }
237
242 void update_id(std::size_t id);
243
249 std::time_t start_time() const { return this->m_start_time; }
250
252 auto begin() const { return this->keywords.begin(); }
253
255 auto end() const { return this->keywords.end(); }
256
259 const std::vector<Condition>& conditions() const
260 {
261 return this->m_conditions;
262 }
263
267 std::vector<std::string> keyword_strings() const;
268
275 bool operator==(const ActionX& data) const;
276
282 template<class Serializer>
283 void serializeOp(Serializer& serializer)
284 {
285 serializer(m_name);
286 serializer(m_max_run);
287 serializer(m_min_wait);
288 serializer(m_start_time);
289 serializer(m_id);
290 serializer(keywords);
291 serializer(condition);
292 serializer(m_conditions);
293 }
294
295private:
297 std::string m_name{};
298
300 std::size_t m_max_run = 0;
301
304 double m_min_wait = 0.0;
305
310 std::time_t m_start_time;
311
313 AST condition{};
314
323 std::size_t m_id = 0;
324
326 std::vector<DeckKeyword> keywords{};
327
331 std::vector<Condition> m_conditions{};
332};
333
350std::pair<ActionX, std::vector<std::pair<std::string, std::string>>>
351parseActionX(const DeckKeyword& kw, const Actdims& actimds, std::time_t start_time);
352
353} // namespace Opm::Action
354
355#endif // ActionX_HPP_
Definition ActionX.hpp:72
std::vector< std::string > keyword_strings() const
Textual representation of action block SCHEDULE keywords.
Definition ActionX.cpp:284
void required_summary(std::unordered_set< std::string > &required_summary) const
Export all summary vectors needed to evaluate the conditions of the current ActionX object.
Definition ActionX.cpp:274
static ActionX serializationTestObject()
Create a serialisation test object.
Definition ActionX.cpp:184
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition ActionX.hpp:283
Result eval(const Context &context) const
Evaluate the action's conditions at current dynamic state.
Definition ActionX.cpp:230
void update_id(std::size_t id)
Assign distinguishing numeric ID of this action object.
Definition ActionX.cpp:279
auto begin() const
Start of action block SCHEDULE keyword sequence.
Definition ActionX.hpp:252
bool operator==(const ActionX &data) const
Equality predicate.
Definition ActionX.cpp:315
std::size_t id() const
Retrieve distinguishing numeric ID of this action object.
Definition ActionX.hpp:236
void addKeyword(const DeckKeyword &kw)
Include SCHEDULE section keyword in block executed when action triggers.
Definition ActionX.cpp:207
std::vector< std::string > wellpi_wells(const WellMatcher &well_matcher, const Result::MatchingEntities &matches) const
Retrive list of well names used in action block WELPI keywords.
Definition ActionX.cpp:236
bool ready(const State &state, std::time_t sim_time) const
Query whether or not the current ActionX object is ready to run.
Definition ActionX.cpp:212
std::size_t max_run() const
Retrieve maximum number of times this action can run/trigger.
Definition ActionX.hpp:229
double min_wait() const
Retrieve minimum wait time, in seconds of simulated time, between action triggers.
Definition ActionX.hpp:233
std::string name() const
Retrieve name of action object.
Definition ActionX.hpp:226
const std::vector< Condition > & conditions() const
Intermediate representation of triggering conditions for restart file output purposes.
Definition ActionX.hpp:259
auto end() const
End of action block SCHEDULE keyword sequence.
Definition ActionX.hpp:255
static bool valid_keyword(const std::string &keyword)
Keyword validity predicate.
Definition ActionX.cpp:97
ActionX()
Default constructor.
Definition ActionX.cpp:132
std::time_t start_time() const
Retrieve point in time at which this action object is created.
Definition ActionX.hpp:249
Manager of summary vector values.
Definition ActionContext.hpp:42
Container of matching entities.
Definition ActionResult.hpp:174
Class Action::Result holds the boolean result of a ACTIONX condition like.
Definition ActionResult.hpp:69
Management information about the current run's ACTION system, especially concerning the number of tim...
Definition State.hpp:51
Definition DeckKeyword.hpp:36
Definition DeckRecord.hpp:32
Class for (de-)serializing.
Definition Serializer.hpp:94
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition action.hpp:35