My Project
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;
39 class FieldPropsManager;
40 class KeywordLocation;
41 class ScheduleGrid;
42 class WDFAC;
43} // namespace Opm
44
45namespace Opm {
46
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 loadCOMPDATX(const DeckRecord& record,
91 const ScheduleGrid& grid,
92 const std::string& wname,
93 const WDFAC& wdfac,
94 const KeywordLocation& location,
95 std::optional<std::string> lgr_label);
96
97 void loadCOMPDAT(const DeckRecord& record,
98 const ScheduleGrid& grid,
99 const std::string& wname,
100 const WDFAC& wdfac,
101 const KeywordLocation& location);
102
103 void loadCOMPDATL(const DeckRecord& record,
104 const ScheduleGrid& grid,
105 const std::string& wname,
106 const WDFAC& wdfac,
107 const KeywordLocation& location);
108
109 void loadCOMPTRAJ(const DeckRecord& record,
110 const ScheduleGrid& grid,
111 const std::string& wname,
112 const KeywordLocation& location,
113 external::cvf::ref<external::cvf::BoundingBoxTree>& cellSearchTree);
114
115 void loadWELTRAJ(const DeckRecord& record,
116 const ScheduleGrid& grid,
117 const std::string& wname,
118 const KeywordLocation& location);
119
120 void applyDFactorCorrelation(const ScheduleGrid& grid,
121 const WDFAC& wdfac);
122
123 int getHeadI() const;
124 int getHeadJ() const;
125 const std::vector<double>& getMD() const;
126 std::size_t size() const;
127 bool empty() const;
128 std::size_t num_open() const;
129 const Connection& operator[](size_t index) const;
130 const Connection& get(size_t index) const;
131 const Connection& getFromIJK(const int i, const int j, const int k) const;
132 const Connection& getFromGlobalIndex(std::size_t global_index) const;
133 const Connection& lowest() const;
134 Connection& getFromIJK(const int i, const int j, const int k);
135 Connection* maybeGetFromGlobalIndex(const std::size_t global_index);
136 bool hasGlobalIndex(std::size_t global_index) const;
137 double segment_perf_length(int segment) const;
138
139 const_iterator begin() const { return this->m_connections.begin(); }
140 const_iterator end() const { return this->m_connections.end(); }
141 auto begin() { return this->m_connections.begin(); }
142 auto end() { return this->m_connections.end(); }
143 void filter(const ActiveGridCells& grid);
144 bool allConnectionsShut() const;
157 void order();
158
159 bool operator==( const WellConnections& ) const;
160 bool operator!=( const WellConnections& ) const;
161
162 Connection::Order ordering() const { return this->m_ordering; }
163 std::vector<const Connection *> output(const EclipseGrid& grid) const;
164
174
182 void applyWellPIScaling(const double scaleFactor,
183 std::vector<bool>& scalingApplicable);
184
185 template <class Serializer>
186 void serializeOp(Serializer& serializer)
187 {
188 serializer(this->m_ordering);
189 serializer(this->headI);
190 serializer(this->headJ);
191 serializer(this->m_connections);
192 serializer(this->coord);
193 serializer(this->md);
194 }
195
196 private:
197 Connection::Order m_ordering { Connection::Order::TRACK };
198 int headI{0};
199 int headJ{0};
200 std::vector<Connection> m_connections{};
201
202 std::array<std::vector<double>, 3> coord{};
203 std::vector<double> md{};
204
205 void addConnection(const int i, const int j, const int k,
206 const std::size_t global_index,
207 const int complnum,
208 const Connection::State state,
209 const double depth,
210 const Connection::CTFProperties& ctf_props,
211 const int satTableId,
212 const Connection::Direction direction,
213 const Connection::CTFKind ctf_kind,
214 const std::size_t seqIndex,
215 int lgr_grid_number,
216 const bool defaultSatTabId);
217
218 size_t findClosestConnection(int oi, int oj, double oz, size_t start_pos);
219 void orderTRACK();
220 void orderMSW();
221 void orderDEPTH();
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:62
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:939
void applyWellPIScaling(const double scaleFactor, std::vector< bool > &scalingApplicable)
Scale pertinent connections' CF value by supplied value.
Definition WellConnections.cpp:303
bool prepareWellPIScaling()
Activate or reactivate WELPI scaling for this connection set.
Definition WellConnections.cpp:293
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:90