opm-common
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 
26 namespace Opm
27 {
28  namespace ScheduleEvents {
29  // These values are used as bitmask - 2^n structure is essential.
30  enum Events : std::uint64_t {
36  NEW_WELL = (UINT64_C(1) << 0),
37 
41  WELL_WELSPECS_UPDATE = (UINT64_C(1) << 1),
42 
43  // WELL_POLYMER_UPDATE = (UINT64_C(1) << 2),
44 
47  NEW_GROUP = (UINT64_C(1) << 3),
48 
54  PRODUCTION_UPDATE = (UINT64_C(1) << 4),
55  INJECTION_UPDATE = (UINT64_C(1) << 5),
56  //POLYMER_UPDATES = (UINT64_C(1) << 6),
57 
61  WELL_STATUS_CHANGE = (UINT64_C(1) << 7),
62 
64  COMPLETION_CHANGE = (UINT64_C(1) << 8),
65 
67  GROUP_CHANGE = (UINT64_C(1) << 9),
68 
70  GEO_MODIFIER = (UINT64_C(1) << 10),
71 
73  TUNING_CHANGE = (UINT64_C(1) << 11),
74 
76  VFPINJ_UPDATE = (UINT64_C(1) << 12),
77  VFPPROD_UPDATE = (UINT64_C(1) << 13),
78 
80  GROUP_PRODUCTION_UPDATE = (UINT64_C(1) << 14),
81  GROUP_INJECTION_UPDATE = (UINT64_C(1) << 15),
82 
84  WELL_PRODUCTIVITY_INDEX = (UINT64_C(1) << 16),
85 
87  WELLGROUP_EFFICIENCY_UPDATE = (UINT64_C(1) << 17),
88 
90  INJECTION_TYPE_CHANGED = (UINT64_C(1) << 18),
91 
93  WELL_SWITCHED_INJECTOR_PRODUCER = (UINT64_C(1) << 19),
94 
96  ACTIONX_WELL_EVENT = (UINT64_C(1) << 20),
97 
103  REQUEST_OPEN_WELL = (UINT64_C(1) << 21),
104 
106  REQUEST_SHUT_WELL = (UINT64_C(1) << 22),
107 
109  TUNINGDP_CHANGE = (UINT64_C(1) << 23),
110  };
111  } // namespace ScheduleEvents
112 
131  class Events
132  {
133  public:
136 
140  void addEvent(ScheduleEvents::Events event);
141 
146  void clearEvent(std::uint64_t eventMask);
147 
149  void reset();
150 
155  void merge(const Events& events);
156 
164  bool hasEvent(std::uint64_t eventMask) const;
165 
173  bool operator==(const Events& data) const;
174 
180  template<class Serializer>
181  void serializeOp(Serializer& serializer)
182  {
183  serializer(m_events);
184  }
185 
186  private:
188  std::uint64_t m_events = 0;
189  };
190 
194  {
195  public:
198 
202  void addWell(const std::string& wname);
203 
208  void addGroup(const std::string& gname);
209 
216  void addEvent(const std::string& wgname, ScheduleEvents::Events event);
217 
226  void clearEvent(const std::string& wgname, std::uint64_t eventMask);
227 
232  void reset();
233 
238  void merge(const WellGroupEvents& events);
239 
247  bool has(const std::string& wgname) const;
248 
259  bool hasEvent(const std::string& wgname, std::uint64_t eventMask) const;
260 
270  const Events& at(const std::string& wgname) const;
271 
279  bool operator==(const WellGroupEvents& data) const;
280 
286  template<class Serializer>
287  void serializeOp(Serializer& serializer)
288  {
289  serializer(m_wellgroup_events);
290  }
291 
292  private:
294  std::unordered_map<std::string, Events> m_wellgroup_events{};
295  };
296 
297 } // namespace Opm
298 
299 #endif // SCHEDULE_EVENTS_HPP
void addGroup(const std::string &gname)
Include a named group in the events collection.
Definition: Events.cpp:88
bool hasEvent(const std::string &wgname, std::uint64_t eventMask) const
Query current collection for one or more specific events associated to a specific well or group...
Definition: Events.cpp:144
void merge(const Events &events)
Merge current event collection with other.
Definition: Events.cpp:55
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition: Events.hpp:181
static WellGroupEvents serializationTestObject()
Create a serialisation test object.
Definition: Events.cpp:72
const Events & at(const std::string &wgname) const
Look up collection of events for named well or group.
Definition: Events.cpp:155
void reset()
Remove all events for all known wells and groups.
Definition: Events.cpp:118
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
void reset()
Remove all events from collection.
Definition: Events.cpp:50
void addEvent(const std::string &wgname, ScheduleEvents::Events event)
Add a single event for a named well or group.
Definition: Events.cpp:96
bool has(const std::string &wgname) const
Check if any events have ever been registered for a named well or group.
Definition: Events.cpp:138
static Events serializationTestObject()
Create a serialisation test object.
Definition: Events.cpp:31
void clearEvent(const std::string &wgname, std::uint64_t eventMask)
Remove one or more individual events from the collection tied to a single named well or group...
Definition: Events.cpp:109
void merge(const WellGroupEvents &events)
Merge current event collection with other.
Definition: Events.cpp:129
void addEvent(ScheduleEvents::Events event)
Incorporate a new event into collection.
Definition: Events.cpp:38
Collection of events tied to a time and associated to specific, named wells or groups.
Definition: Events.hpp:193
bool operator==(const WellGroupEvents &data) const
Equality predicate.
Definition: Events.cpp:167
Events tied to a time and applicable to the simulation or an individual well or group.
Definition: Events.hpp:131
bool operator==(const Events &data) const
Equality predicate.
Definition: Events.cpp:65
void clearEvent(std::uint64_t eventMask)
Remove one or more events from collection.
Definition: Events.cpp:43
void addWell(const std::string &wname)
Include a named well into the events collection.
Definition: Events.cpp:80
bool hasEvent(std::uint64_t eventMask) const
Event existence predicate.
Definition: Events.cpp:60
Class for (de-)serializing.
Definition: Serializer.hpp:94
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition: Events.hpp:287