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
132 /*
133 This class implements a simple system for recording when various
134 events happen in the Schedule file. The purpose of the class is
135 that downstream code can query this system whether a certain a
136 event has taken place, and then perform potentially expensive
137 calculations conditionally:
138
139 auto events = schedule->getEvents();
140 if (events.hasEvent(SchedulEvents::NEW_WELL , reportStep))
141 // Perform expensive calculation which must be performed
142 // when a new well is introduced.
143 ...
144
145 */
146
147 class Events {
148 public:
149 static Events serializationTestObject();
150
151 void addEvent(ScheduleEvents::Events event);
152 bool hasEvent(uint64_t eventMask) const;
153 void clearEvent(uint64_t eventMask);
154 void reset();
155
156 bool operator==(const Events& data) const;
157
158 template<class Serializer>
159 void serializeOp(Serializer& serializer)
160 {
161 serializer(m_events);
162 }
163
164 private:
165 uint64_t m_events = 0;
166 };
167
168
170 public:
171 static WellGroupEvents serializationTestObject();
172
173 void addWell(const std::string& wname);
174 void addGroup(const std::string& gname);
175 void addEvent(const std::string& wgname, ScheduleEvents::Events event);
176 bool hasEvent(const std::string& wgname, uint64_t eventMask) const;
177 bool has(const std::string& wgname) const;
178 void clearEvent(const std::string& wgname, uint64_t eventMask);
179 void reset();
180 const Events& at(const std::string& wgname) const;
181 bool operator==(const WellGroupEvents& data) const;
182
183 template<class Serializer>
184 void serializeOp(Serializer& serializer)
185 {
186 serializer(m_wellgroup_events);
187 }
188 private:
189 std::unordered_map<std::string, Events> m_wellgroup_events;
190 };
191
192
193}
194
195#endif
Definition Events.hpp:147
Class for (de-)serializing.
Definition Serializer.hpp:84
Definition Events.hpp:169
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30