opm-common
Loading...
Searching...
No Matches
WellConnections.hpp
1/*
2 Copyright 2013 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
20#ifndef CONNECTIONSET_HPP_
21#define CONNECTIONSET_HPP_
22
23#include <opm/input/eclipse/Schedule/Well/Connection.hpp>
24#include <external/resinsight/LibGeometry/cvfBoundingBoxTree.h>
25
26#include <array>
27#include <cstddef>
28#include <optional>
29#include <string>
30#include <utility>
31#include <vector>
32
33#include <stddef.h>
34
35namespace Opm {
36 class ActiveGridCells;
37 class DeckRecord;
38 class EclipseGrid;
40 class KeywordLocation;
41 class ScheduleGrid;
42 class WDFAC;
43} // namespace Opm
44
45namespace Opm {
46
47 class WellConnections
48 {
49 public:
50 using const_iterator = std::vector<Connection>::const_iterator;
51
52 WellConnections() = default;
53 WellConnections(const Connection::Order ordering, const int headI, const int headJ);
54 WellConnections(const Connection::Order ordering, const int headI, const int headJ,
55 const std::vector<Connection>& connections);
56
57 static WellConnections serializationTestObject();
58
59 // cppcheck-suppress noExplicitConstructor
60 template <class Grid>
61 WellConnections(const WellConnections& src, const Grid& grid)
62 : m_ordering(src.ordering())
63 , headI (src.headI)
64 , headJ (src.headJ)
65 {
66 for (const auto& c : src) {
67 if (grid.isCellActive(c.getI(), c.getJ(), c.getK())) {
68 this->add(c);
69 }
70 }
71 }
72
73 void add(const Connection& conn)
74 {
75 this->m_connections.push_back(conn);
76 }
77
78 void addConnection(const int i, const int j, const int k,
79 const std::size_t global_index,
80 const Connection::State state,
81 const double depth,
82 const Connection::CTFProperties& ctf_props,
83 const int satTableId,
84 const Connection::Direction direction = Connection::Direction::Z,
85 const Connection::CTFKind ctf_kind = Connection::CTFKind::DeckValue,
86 const std::size_t seqIndex = 0,
87 int lgr_grid_number = 0,
88 const bool defaultSatTabId = true);
89
90 void loadCOMPDAT(const DeckRecord& record,
91 const ScheduleGrid& grid,
92 const std::string& wname,
93 const WDFAC& wdfac,
94 const KeywordLocation& location);
95
96 void loadCOMPDATL(const DeckRecord& record,
97 const ScheduleGrid& grid,
98 const std::string& wname,
99 const WDFAC& wdfac,
100 const KeywordLocation& location);
101
102 void loadCOMPTRAJ(const DeckRecord& record,
103 const ScheduleGrid& grid,
104 const std::string& wname,
105 const KeywordLocation& location,
106 external::cvf::ref<external::cvf::BoundingBoxTree>& cellSearchTree);
107
108 void loadWELTRAJ(const DeckRecord& record,
109 const ScheduleGrid& grid,
110 const std::string& wname,
111 const KeywordLocation& location);
112
113 void applyDFactorCorrelation(const ScheduleGrid& grid,
114 const WDFAC& wdfac);
115
116 int getHeadI() const;
117 int getHeadJ() const;
118 const std::vector<double>& getMD() const;
119 std::size_t size() const;
120 bool empty() const;
121 std::size_t num_open() const;
122 const Connection& operator[](size_t index) const;
123 const Connection& get(size_t index) const;
124 const Connection& getFromIJK(const int i, const int j, const int k) const;
125 const Connection& getFromGlobalIndex(std::size_t global_index) const;
126 const Connection& lowest() const;
127 Connection& getFromIJK(const int i, const int j, const int k);
128 Connection* maybeGetFromGlobalIndex(const std::size_t global_index);
129 bool hasGlobalIndex(std::size_t global_index) const;
130 double segment_perf_length(int segment) const;
131
132 const_iterator begin() const { return this->m_connections.begin(); }
133 const_iterator end() const { return this->m_connections.end(); }
134 auto begin() { return this->m_connections.begin(); }
135 auto end() { return this->m_connections.end(); }
136 void filter(const ActiveGridCells& grid);
137 bool allConnectionsShut() const;
150 void order();
151
152 bool operator==( const WellConnections& ) const;
153 bool operator!=( const WellConnections& ) const;
154
155 Connection::Order ordering() const { return this->m_ordering; }
156 std::vector<const Connection *> output(const EclipseGrid& grid) const;
157
167
175 void applyWellPIScaling(const double scaleFactor,
176 std::vector<bool>& scalingApplicable);
177
178 template <class Serializer>
179 void serializeOp(Serializer& serializer)
180 {
181 serializer(this->m_ordering);
182 serializer(this->headI);
183 serializer(this->headJ);
184 serializer(this->m_connections);
185 serializer(this->coord);
186 serializer(this->md);
187 }
188
189 private:
190 Connection::Order m_ordering { Connection::Order::TRACK };
191 int headI{0};
192 int headJ{0};
193 std::vector<Connection> m_connections{};
194
195 std::array<std::vector<double>, 3> coord{};
196 std::vector<double> md{};
197
198 void addConnection(const int i, const int j, const int k,
199 const std::size_t global_index,
200 const int complnum,
201 const Connection::State state,
202 const double depth,
203 const Connection::CTFProperties& ctf_props,
204 const int satTableId,
205 const Connection::Direction direction,
206 const Connection::CTFKind ctf_kind,
207 const std::size_t seqIndex,
208 int lgr_grid_number,
209 const bool defaultSatTabId);
210
211 size_t findClosestConnection(int oi, int oj, double oz, size_t start_pos);
212 void orderTRACK();
213 void orderMSW();
214 void orderDEPTH();
215
216 void loadCOMPDATX(const DeckRecord& record,
217 const ScheduleGrid& grid,
218 const std::string& wname,
219 const WDFAC& wdfac,
220 const KeywordLocation& location,
221 const std::optional<std::string>& lgr_label);
222 };
223
224 std::optional<int>
225 getCompletionNumberFromGlobalConnectionIndex(const WellConnections& connections,
226 const std::size_t global_index);
227} // namespace Opm
228
229#endif // CONNECTIONSET_HPP_
Simple class capturing active cells of a grid.
Definition ActiveGridCells.hpp:36
Definition Connection.hpp:53
Definition DeckRecord.hpp:32
About cell information and dimension: The actual grid information is held in a pointer to an ERT ecl_...
Definition EclipseGrid.hpp:61
Definition FieldPropsManager.hpp:42
Definition KeywordLocation.hpp:27
Collection of intersected cells and associate properties for all simulation grids,...
Definition ScheduleGrid.hpp:50
Class for (de-)serializing.
Definition Serializer.hpp:94
Definition WDFAC.hpp:40
Definition WellConnections.hpp:48
void order()
Order connections irrespective of input order.
Definition WellConnections.cpp:944
void applyWellPIScaling(const double scaleFactor, std::vector< bool > &scalingApplicable)
Scale pertinent connections' CF value by supplied value.
Definition WellConnections.cpp:306
bool prepareWellPIScaling()
Activate or reactivate WELPI scaling for this connection set.
Definition WellConnections.cpp:296
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Quantities that go into calculating the connection transmissibility factor.
Definition Connection.hpp:91