Events.hpp
Go to the documentation of this file.
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 <vector>
24 
25 namespace Opm
26 {
27  namespace ScheduleEvents {
28  // These values are used as bitmask - 2^n structure is essential.
29  enum Events {
30  /* The NEW_WELL event is triggered by the WELSPECS
31  keyword. */
32  NEW_WELL = 1,
33 
34  /*
35  The NEW_GROUP event is triggered by the WELSPECS and
36  GRUPTREE keywords.
37  */
38  NEW_GROUP = 2,
39 
40  /*
41  The PRODUCTION_UPDATE event is triggered by the
42  WCONPROD and WCONHIST keywords. The event will be
43  triggered if *any* of the elements in one of keywords
44  is changed. Quite simlar for INJECTION_UPDATE and
45  POLYMER_UPDATE.
46  */
50 
51  /*
52  This event is triggered if the well status is changed
53  between {OPEN,SHUT,STOP,AUTO}. There are many keywords
54  which can trigger a well status change.
55  */
57 
58  /*
59  COMPDAT and WELOPEN
60  */
62 
63  /*
64  The well group topolyg has changed.
65  */
67  };
68  }
69 
70  /*
71  This class implements a simple system for recording when various
72  events happen in the Schedule file. The purpose of the class is
73  that downstream code can query this system whether a certain a
74  event has taken place, and then perform potentially expensive
75  calculations conditionally:
76 
77  auto events = schedule->getEvents();
78  if (events.hasEvent(SchedulEvents::NEW_WELL , reportStep))
79  // Perform expensive calculation which must be performed
80  // when a new well is introduced.
81  ...
82 
83  */
84 
85  class Events {
86  public:
87  Events();
88  void addEvent(ScheduleEvents::Events event, size_t reportStep);
89  bool hasEvent(ScheduleEvents::Events event, size_t reportStep) const;
90  private:
91  std::vector<uint64_t> m_events;
92  };
93 }
94 
95 #endif
Definition: Events.hpp:32
Definition: Events.hpp:85
Events
Definition: Events.hpp:29
Definition: Deck.hpp:29
Definition: Events.hpp:48
Definition: Events.hpp:66
Definition: Events.hpp:38
Definition: Events.hpp:49
void addEvent(ScheduleEvents::Events event, size_t reportStep)
bool hasEvent(ScheduleEvents::Events event, size_t reportStep) const