WellPerformanceEventTracker.hpp
Go to the documentation of this file.
1/*
2 Copyright 2026 Equinor 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 OPM_WELL_PERFORMANCE_EVENT_TRACKER_HEADER_INCLUDED
21#define OPM_WELL_PERFORMANCE_EVENT_TRACKER_HEADER_INCLUDED
22
23#include <opm/input/eclipse/Schedule/Well/Well.hpp>
24
25#include <opm/output/data/Wells.hpp>
26
27#include <map>
28#include <string>
29#include <utility>
30#include <vector>
31
32namespace Opm
33{
34
35class Schedule;
36
46 using ConnectionID = std::pair<int, std::size_t>;
47
48 struct Entry {
49 WellStatus status {WellStatus::SHUT};
50
58 std::vector<ConnectionID> openConnections {};
59
64 std::vector<ConnectionID> closedBelowOffender {};
65
70 std::vector<int> openCompletions {};
71
77
78 bool operator==(const Entry& rhs) const
79 {
80 return (this->status == rhs.status)
81 && (this->openConnections == rhs.openConnections)
83 && (this->openCompletions == rhs.openCompletions)
84 && (this->topCompletion == rhs.topCompletion);
85 }
86
87 template <class Serializer>
88 void serializeOp(Serializer& serializer)
89 {
90 serializer(status);
91 serializer(openConnections);
92 serializer(closedBelowOffender);
93 serializer(openCompletions);
94 serializer(topCompletion);
95 }
96 };
97
98 std::map<std::string, Entry> wells {};
99
100 bool operator==(const WellStatusSnapshot& rhs) const
101 {
102 return this->wells == rhs.wells;
103 }
104
105 template <class Serializer>
106 void serializeOp(Serializer& serializer)
107 {
108 serializer(wells);
109 }
110};
111
136{
137public:
150 void beginTimeStep(const Schedule& schedule,
151 int reportStep,
152 WellStatusSnapshot snapshot);
153
159 void commitTimeStep(const Schedule& schedule, int reportStep);
160
167
175 void recordWellStatusChangeForRetry(const std::string& wellName, WellStatus status);
176
182
186 const data::WellPerformanceEvents& events(const std::string& wellName) const;
187
189
191 {
192 return (this->events_ == rhs.events_) && (this->previous_ == rhs.previous_)
193 && (this->lastAccepted_ == rhs.lastAccepted_)
194 && (this->hasLastAccepted_ == rhs.hasLastAccepted_)
195 && (this->injector_ == rhs.injector_)
196 && (this->pendingStatusEvents_ == rhs.pendingStatusEvents_);
197 }
198
199 template <class Serializer>
200 void serializeOp(Serializer& serializer)
201 {
202 serializer(events_);
203 serializer(previous_);
204 serializer(lastAccepted_);
205 serializer(hasLastAccepted_);
206 serializer(injector_);
207 serializer(pendingStatusEvents_);
208 }
209
210private:
212 std::map<std::string, data::WellPerformanceEvents> events_ {};
213
215 WellStatusSnapshot previous_ {};
216
219 WellStatusSnapshot lastAccepted_ {};
220
221 bool hasLastAccepted_ {false};
222
224 std::map<std::string, bool> injector_ {};
225
227 std::map<std::string, data::WellPerformanceEvents> pendingStatusEvents_ {};
228
230 void accumulate(WellStatusSnapshot current, bool trackStatus);
231};
232
233} // namespace Opm
234
235#endif // OPM_WELL_PERFORMANCE_EVENT_TRACKER_HEADER_INCLUDED
Definition: WellPerformanceEventTracker.hpp:136
void applyDeckChanges(WellStatusSnapshot snapshot)
const data::WellPerformanceEvents & events(const std::string &wellName) const
void recordWellStatusChangeForRetry(const std::string &wellName, WellStatus status)
void serializeOp(Serializer &serializer)
Definition: WellPerformanceEventTracker.hpp:200
void accumulate(WellStatusSnapshot current)
static WellPerformanceEventTracker serializationTestObject()
void commitTimeStep(const Schedule &schedule, int reportStep)
bool operator==(const WellPerformanceEventTracker &rhs) const
Definition: WellPerformanceEventTracker.hpp:190
void beginTimeStep(const Schedule &schedule, int reportStep, WellStatusSnapshot snapshot)
Definition: blackoilbioeffectsmodules.hh:45
Definition: WellPerformanceEventTracker.hpp:48
std::vector< ConnectionID > openConnections
Definition: WellPerformanceEventTracker.hpp:58
WellStatus status
Definition: WellPerformanceEventTracker.hpp:49
std::vector< int > openCompletions
Definition: WellPerformanceEventTracker.hpp:70
std::vector< ConnectionID > closedBelowOffender
Definition: WellPerformanceEventTracker.hpp:64
bool operator==(const Entry &rhs) const
Definition: WellPerformanceEventTracker.hpp:78
int topCompletion
Definition: WellPerformanceEventTracker.hpp:76
void serializeOp(Serializer &serializer)
Definition: WellPerformanceEventTracker.hpp:88
Definition: WellPerformanceEventTracker.hpp:42
bool operator==(const WellStatusSnapshot &rhs) const
Definition: WellPerformanceEventTracker.hpp:100
std::pair< int, std::size_t > ConnectionID
Definition: WellPerformanceEventTracker.hpp:46
std::map< std::string, Entry > wells
Definition: WellPerformanceEventTracker.hpp:98
void serializeOp(Serializer &serializer)
Definition: WellPerformanceEventTracker.hpp:106