My Project
Loading...
Searching...
No Matches
Connection.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 COMPLETION_HPP_
21#define COMPLETION_HPP_
22
23#include <opm/input/eclipse/Schedule/Well/FilterCake.hpp>
24#include <opm/input/eclipse/Schedule/Well/WINJMULT.hpp>
25
26#include <array>
27#include <cstddef>
28#include <optional>
29#include <string>
30#include <string_view>
31#include <vector>
32
33namespace Opm {
34 class DeckKeyword;
35 class DeckRecord;
36 class ScheduleGrid;
37 class FieldPropsManager;
38} // namespace Opm
39
40namespace Opm { namespace RestartIO {
41 struct RstConnection;
42}} // namespace Opm::RestartIO
43
44namespace Opm {
45
46 enum class ConnectionOrder {
47 DEPTH,
48 INPUT,
49 TRACK,
50 };
51
53 {
54 public:
55 enum class State {
56 OPEN = 1,
57 SHUT = 2,
58 AUTO = 3, // Seems like the AUTO state can not be serialized to restart files.
59 };
60
61 static std::string State2String(State enumValue);
62 static State StateFromString(std::string_view stringValue);
63
64
65 enum class Direction {
66 X = 1,
67 Y = 2,
68 Z = 3,
69 };
70
71 static std::string Direction2String(const Direction enumValue);
72 static Direction DirectionFromString(std::string_view stringValue);
73
74
75 using Order = ConnectionOrder;
76
77 static std::string Order2String(Order enumValue);
78 static Order OrderFromString(std::string_view comporderStringValue);
79
80
81 enum class CTFKind {
83 Defaulted,
84 };
85
86
90 {
93 double CF{};
94
96 double Kh{};
97
99 double Ke{};
100
102 double rw{};
103
105 double r0{};
106
109 double re{};
110
113
115 double skin_factor{};
116
119 double d_factor{};
120
124
127
130
134 bool operator==(const CTFProperties& that) const;
135
139 bool operator!=(const CTFProperties& that) const
140 {
141 return ! (*this == that);
142 }
143
151 template <class Serializer>
152 void serializeOp(Serializer& serializer)
153 {
154 serializer(this->CF);
155 serializer(this->Kh);
156 serializer(this->Ke);
157 serializer(this->rw);
158 serializer(this->r0);
159 serializer(this->re);
160 serializer(this->connection_length);
161 serializer(this->skin_factor);
162 serializer(this->d_factor);
163 serializer(this->static_dfac_corr_coeff);
164 serializer(this->peaceman_denom);
165 }
166 };
167
168
169 Connection() = default;
170 Connection(int i, int j, int k,
171 std::size_t global_index,
172 int complnum,
173 State state,
174 Direction direction,
175 CTFKind ctf_kind,
176 const int satTableId,
177 double depth,
178 const CTFProperties& ctf_properties,
179 const std::size_t sort_value,
180 const bool defaultSatTabId);
181
182 Connection(const RestartIO::RstConnection& rst_connection,
183 const ScheduleGrid& grid,
184 const FieldPropsManager& fp);
185
186 static Connection serializationTestObject();
187
188 bool attachedToSegment() const;
189 bool sameCoordinate(const int i, const int j, const int k) const;
190 int getI() const;
191 int getJ() const;
192 int getK() const;
193 std::size_t global_index() const;
194 State state() const;
195 Direction dir() const;
196 double depth() const;
197 int satTableId() const;
198 int complnum() const;
199 int segment() const;
200 double wpimult() const;
201 double CF() const;
202 double Kh() const;
203 double Ke() const;
204 double rw() const;
205 double r0() const;
206 double re() const;
207 double connectionLength() const;
208 double skinFactor() const;
209 double dFactor() const;
210 CTFKind kind() const;
211 const InjMult& injmult() const;
212 bool activeInjMult() const;
213 const FilterCake& getFilterCake() const;
214 bool filterCakeActive() const;
215 double getFilterCakeRadius() const;
216 double getFilterCakeArea() const;
217
218 const CTFProperties& ctfProperties() const
219 {
220 return this->ctf_properties_;
221 }
222
223 std::size_t sort_value() const;
224 bool getDefaultSatTabId() const;
225 const std::optional<std::pair<double, double>>& perf_range() const;
226 std::string str() const;
227
228 bool ctfAssignedFromInput() const
229 {
230 return this->m_ctfkind == CTFKind::DeckValue;
231 }
232
233 bool operator==(const Connection&) const;
234 bool operator!=(const Connection& that) const
235 {
236 return ! (*this == that);
237 }
238
239 void setInjMult(const InjMult& inj_mult);
240 void setFilterCake(const FilterCake& filter_cake);
241 void setState(State state);
242 void setComplnum(int compnum);
243 void setSkinFactor(double skin_factor);
244 void setDFactor(double d_factor);
245 void setKe(double Ke);
246 void setCF(double CF);
247 void setDefaultSatTabId(bool id);
248 void setStaticDFacCorrCoeff(const double c);
249
250 void scaleWellPi(double wellPi);
251 bool prepareWellPIScaling();
252 bool applyWellPIScaling(const double scaleFactor);
253
254 void updateSegmentRST(int segment_number_arg,
255 double center_depth_arg);
256 void updateSegment(int segment_number_arg,
257 double center_depth_arg,
258 std::size_t compseg_insert_index,
259 const std::optional<std::pair<double,double>>& perf_range);
260
261 template<class Serializer>
262 void serializeOp(Serializer& serializer)
263 {
264 serializer(this->direction);
265 serializer(this->center_depth);
266 serializer(this->open_state);
267 serializer(this->sat_tableId);
268 serializer(this->m_complnum);
269 serializer(this->ctf_properties_);
270 serializer(this->ijk);
271 serializer(this->m_ctfkind);
272 serializer(this->m_global_index);
273 serializer(this->m_injmult);
274 serializer(this->m_sort_value);
275 serializer(this->m_perf_range);
276 serializer(this->m_defaultSatTabId);
277 serializer(this->segment_number);
278 serializer(this->m_wpimult);
279 serializer(this->m_subject_to_welpi);
280 serializer(this->m_filter_cake);
281 }
282
283 private:
284 // Note to maintainer: If you add new members to this list, then
285 // please also update the operator==(), serializeOp(), and
286 // serializationTestObject() member functions.
287 Direction direction { Direction::Z };
288 double center_depth { 0.0 };
289 State open_state { State::SHUT };
290 int sat_tableId { -1 };
291 int m_complnum { -1 };
292 CTFProperties ctf_properties_{};
293
294 std::array<int,3> ijk{};
295 CTFKind m_ctfkind { CTFKind::DeckValue };
296 std::optional<InjMult> m_injmult{};
297 std::size_t m_global_index{};
298
299 /*
300 The sort_value member is a peculiar quantity. The connections are
301 assembled in the WellConnections class. During the lifetime of the
302 connections there are three different sort orders which are all
303 relevant:
304
305 input: This is the ordering implied be the order of the
306 connections in the input deck.
307
308 simulation: This is the ordering the connections have in
309 WellConnections container during the simulation and RFT output.
310
311 restart: This is the ordering the connections have when they are
312 written out to a restart file.
313
314 Exactly what consitutes input, simulation and restart ordering, and
315 how the connections transition between the three during application
316 lifetime is different from MSW and normal wells.
317
318 normal wells: For normal wells the simulation order is given by the
319 COMPORD keyword, and then when the connections are serialized to the
320 restart file they are written in input order; i.e. we have:
321
322 input == restart and simulation given COMPORD
323
324 To recover the input order when creating the restart files the
325 sort_value member corresponds to the insert index for normal wells.
326
327 MSW wells: For MSW wells the wells simulator order[*] is given by
328 COMPSEGS keyword, the COMPORD keyword is ignored. The connections are
329 sorted in WellConnections::order() and then retain that order for all
330 eternity i.e.
331
332 input and simulation == restart
333
334 Now the important point is that the COMPSEGS detail used to perform
335 this sorting is not available when loading from a restart file, but
336 then the connections are already sorted correctly. I.e. *after* a
337 restart we will have:
338
339 input(from restart) == simulation == restart
340
341 The sort_value member is used to sort the connections into restart
342 ordering. In the case of normal wells this corresponds to recovering
343 the input order, whereas for MSW wells this is equivalent to the
344 simulation order.
345
346 [*]: For MSW wells the topology is given by the segments and entered
347 explicitly, so the truth is probably that the storage order
348 during simulation makes no difference?
349 */
350 std::size_t m_sort_value{};
351
352 std::optional<std::pair<double,double>> m_perf_range{};
353 bool m_defaultSatTabId{true};
354
355 // Associate segment number
356 //
357 // 0 means the connection is not associated to a segment.
358 int segment_number { 0 };
359
360 double m_wpimult { 1.0 };
361
362 // Whether or not this Connection is subject to WELPI scaling.
363 bool m_subject_to_welpi { false };
364
365 std::optional<FilterCake> m_filter_cake{};
366
367 static std::string CTFKindToString(const CTFKind);
368 };
369
370} // namespace Opm
371
372#endif // COMPLETION_HPP_
Definition Connection.hpp:53
Definition DeckValue.hpp:30
Definition FieldPropsManager.hpp:42
Definition ScheduleGrid.hpp:37
Class for (de-)serializing.
Definition Serializer.hpp:84
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
double r0
Connection's pressure equivalent radius.
Definition Connection.hpp:105
static CTFProperties serializationTestObject()
Serialisation test object.
Definition Connection.cpp:73
bool operator==(const CTFProperties &that) const
Equality operator.
Definition Connection.cpp:92
void serializeOp(Serializer &serializer)
Serialisation operator.
Definition Connection.hpp:152
double rw
Connection's wellbore radius.
Definition Connection.hpp:102
double peaceman_denom
Denominator in peaceman's formula-i.e., log(r0/rw) + skin.
Definition Connection.hpp:126
double re
Connection's area equivalent radius–mostly for use by the polymer code.
Definition Connection.hpp:109
double d_factor
Connection's D factor-i.e., the flow-dependent skin factor for gas.
Definition Connection.hpp:119
double Kh
Static 'Kh' product.
Definition Connection.hpp:96
bool operator!=(const CTFProperties &that) const
Inequality operator.
Definition Connection.hpp:139
double CF
Static connection transmissibility factor calculated from input quantities.
Definition Connection.hpp:93
double connection_length
Length of connection's perfororation interval.
Definition Connection.hpp:112
double skin_factor
Connection's skin factor.
Definition Connection.hpp:115
double Ke
Effective permeability.
Definition Connection.hpp:99
double static_dfac_corr_coeff
Product of certain static elements of D-factor correlation law (WDFACCOR keyword).
Definition Connection.hpp:123
Definition FilterCake.hpp:31
Definition WINJMULT.hpp:30
Definition connection.hpp:36