My Project
Loading...
Searching...
No Matches
Events.hpp
1/*
2 Copyright 2015 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#ifndef SCHEDULE_EVENTS_HPP
20#define SCHEDULE_EVENTS_HPP
21
22#include <cstdint>
23#include <string>
24#include <unordered_map>
25
26namespace Opm
27{
28 namespace ScheduleEvents {
29 // These values are used as bitmask - 2^n structure is essential.
30 enum Events {
31 /*
32 The NEW_WELL event is triggered by the WELSPECS
33 keyword. For wells the event is triggered the first
34 time the well is mentioned in the WELSPECS keyword, for
35 the Schedule object the NEW_WELL event is triggered
36 every time a WELSPECS keyword is encountered.
37 */
38 NEW_WELL = (1 << 0),
39
40 /*
41 WHen the well data is updated with the WELSPECS keyword
42 this event is triggered. Only applies to individual
43 wells, and not the global Schedule object.
44 */
45 WELL_WELSPECS_UPDATE = (1 << 1),
46
47
48 //WELL_POLYMER_UPDATE = (1 << 2),
49 /*
50 The NEW_GROUP event is triggered by the WELSPECS and
51 GRUPTREE keywords.
52 */
53 NEW_GROUP = (1 << 3),
54
55 /*
56 The PRODUCTION_UPDATE event is triggered by the
57 WCONPROD, WCONHIST, WELTARG, WEFAC keywords. The event will be
58 triggered if *any* of the elements in one of keywords
59 is changed. Quite simlar for INJECTION_UPDATE and
60 POLYMER_UPDATE.
61 */
62 PRODUCTION_UPDATE = (1 << 4),
63 INJECTION_UPDATE = (1 << 5),
64 //POLYMER_UPDATES = (1 << 6),
65
66 /*
67 This event is triggered if the well status is changed
68 between {OPEN,SHUT,STOP,AUTO}. There are many keywords
69 which can trigger a well status change.
70 */
71 WELL_STATUS_CHANGE = (1 << 7),
72
73 /*
74 COMPDAT and WELOPEN
75 */
76 COMPLETION_CHANGE = (1 << 8),
77
78 /*
79 The well group topolyg has changed.
80 */
81 GROUP_CHANGE = (1 << 9),
82
83
84 /*
85 Geology modifier.
86 */
87 GEO_MODIFIER = (1 << 10),
88
89 /*
90 TUNING has changed
91 */
92 TUNING_CHANGE = (1 << 11),
93
94 /* The VFP tables have changed */
95 VFPINJ_UPDATE = (1 << 12),
96 VFPPROD_UPDATE = (1 << 13),
97
98
99 /*
100 GROUP production or injection targets has changed
101 */
102 GROUP_PRODUCTION_UPDATE = (1 << 14),
103 GROUP_INJECTION_UPDATE = (1 << 15),
104
105 /*
106 * New explicit well productivity/injectivity assignment.
107 */
108 WELL_PRODUCTIVITY_INDEX = (1 << 16),
109
110 /*
111 * Well/group efficiency factor has changed
112 */
113 WELLGROUP_EFFICIENCY_UPDATE = (1 << 17),
114
115 /*
116 * Injection type changed
117 */
118 INJECTION_TYPE_CHANGED = (1 << 18),
119
120 /*
121 * Well switched between injector and producer
122 */
123 WELL_SWITCHED_INJECTOR_PRODUCER = (1 << 19),
124
125 /*
126 * The well has been affected in an ACTIONX keyword.
127 */
128 ACTIONX_WELL_EVENT = (1 << 20),
129
130 /*
131 * Some SCHEDULE keywords can set a well to be OPEN to open a previously STOPped or SHUT well.
132 * The well is SHUT/STOP due to various causes (SCHEDULE, economical, physical, etc.)
133 * For now, the WELOPEN, WCONPROD and WCONINJE keywords are considered with this event
134 */
135 REQUEST_OPEN_WELL = (1 << 21),
136 };
137 }
138
139 /*
140 This class implements a simple system for recording when various
141 events happen in the Schedule file. The purpose of the class is
142 that downstream code can query this system whether a certain a
143 event has taken place, and then perform potentially expensive
144 calculations conditionally:
145
146 auto events = schedule->getEvents();
147 if (events.hasEvent(SchedulEvents::NEW_WELL , reportStep))
148 // Perform expensive calculation which must be performed
149 // when a new well is introduced.
150 ...
151
152 */
153
154 class Events {
155 public:
156 static Events serializationTestObject();
157
158 void addEvent(ScheduleEvents::Events event);
159 bool hasEvent(uint64_t eventMask) const;
160 void clearEvent(uint64_t eventMask);
161 void reset();
162
163 bool operator==(const Events& data) const;
164
165 template<class Serializer>
166 void serializeOp(Serializer& serializer)
167 {
168 serializer(m_events);
169 }
170
171 private:
172 uint64_t m_events = 0;
173 };
174
175
177 public:
178 static WellGroupEvents serializationTestObject();
179
180 void addWell(const std::string& wname);
181 void addGroup(const std::string& gname);
182 void addEvent(const std::string& wgname, ScheduleEvents::Events event);
183 bool hasEvent(const std::string& wgname, uint64_t eventMask) const;
184 bool has(const std::string& wgname) const;
185 void clearEvent(const std::string& wgname, uint64_t eventMask);
186 void reset();
187 const Events& at(const std::string& wgname) const;
188 bool operator==(const WellGroupEvents& data) const;
189
190 template<class Serializer>
191 void serializeOp(Serializer& serializer)
192 {
193 serializer(m_wellgroup_events);
194 }
195 private:
196 std::unordered_map<std::string, Events> m_wellgroup_events;
197 };
198
199
200}
201
202#endif
Definition Events.hpp:154
Class for (de-)serializing.
Definition Serializer.hpp:84
Definition Events.hpp:176
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30