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 int lgr_grid_ = 0);
182
183 Connection(const RestartIO::RstConnection& rst_connection,
184 const ScheduleGrid& grid,
185 const FieldPropsManager& fp);
186
187 static Connection serializationTestObject();
188
189 bool attachedToSegment() const;
190 bool sameCoordinate(const int i, const int j, const int k) const;
191 int getI() const;
192 int getJ() const;
193 int getK() const;
194 std::size_t global_index() const;
195 State state() const;
196 Direction dir() const;
197 double depth() const;
198 int satTableId() const;
199 int complnum() const;
200 int segment() const;
201 double wpimult() const;
202 double CF() const;
203 double Kh() const;
204 double Ke() const;
205 double rw() const;
206 double r0() const;
207 double re() const;
208 double connectionLength() const;
209 double skinFactor() const;
210 double dFactor() const;
211 CTFKind kind() const;
212 const InjMult& injmult() const;
213 bool activeInjMult() const;
214 const FilterCake& getFilterCake() const;
215 bool filterCakeActive() const;
216 double getFilterCakeRadius() const;
217 double getFilterCakeArea() const;
218
219 const CTFProperties& ctfProperties() const
220 {
221 return this->ctf_properties_;
222 }
223
224 std::size_t sort_value() const;
225 bool getDefaultSatTabId() const;
226 const std::optional<std::pair<double, double>>& perf_range() const;
227 std::string str() const;
228
229 bool ctfAssignedFromInput() const
230 {
231 return this->m_ctfkind == CTFKind::DeckValue;
232 }
233
234 bool operator==(const Connection&) const;
235 bool operator!=(const Connection& that) const
236 {
237 return ! (*this == that);
238 }
239
240 void setInjMult(const InjMult& inj_mult);
241 void setFilterCake(const FilterCake& filter_cake);
242 void setState(State state);
243 void setComplnum(int compnum);
244 void setSkinFactor(double skin_factor);
245 void setDFactor(double d_factor);
246 void setKe(double Ke);
247 void setCF(double CF);
248 void setDefaultSatTabId(bool id);
249 void setStaticDFacCorrCoeff(const double c);
250
251 void scaleWellPi(double wellPi);
252 bool prepareWellPIScaling();
253 bool applyWellPIScaling(const double scaleFactor);
254
255 void updateSegmentRST(int segment_number_arg,
256 double center_depth_arg);
257 void updateSegment(int segment_number_arg,
258 double center_depth_arg,
259 std::size_t compseg_insert_index,
260 const std::optional<std::pair<double,double>>& perf_range);
261
262 template<class Serializer>
263 void serializeOp(Serializer& serializer)
264 {
265 serializer(this->direction);
266 serializer(this->center_depth);
267 serializer(this->open_state);
268 serializer(this->sat_tableId);
269 serializer(this->m_complnum);
270 serializer(this->ctf_properties_);
271 serializer(this->ijk);
272 serializer(this->lgr_grid);
273 serializer(this->m_ctfkind);
274 serializer(this->m_global_index);
275 serializer(this->m_injmult);
276 serializer(this->m_sort_value);
277 serializer(this->m_perf_range);
278 serializer(this->m_defaultSatTabId);
279 serializer(this->segment_number);
280 serializer(this->m_wpimult);
281 serializer(this->m_subject_to_welpi);
282 serializer(this->m_filter_cake);
283 }
284
285 private:
286 // Note to maintainer: If you add new members to this list, then
287 // please also update the operator==(), serializeOp(), and
288 // serializationTestObject() member functions.
289 Direction direction { Direction::Z };
290 double center_depth { 0.0 };
291 State open_state { State::SHUT };
292 int sat_tableId { -1 };
293 int m_complnum { -1 };
294 CTFProperties ctf_properties_{};
295
296 std::array<int,3> ijk{};
297 int lgr_grid{0};
298 CTFKind m_ctfkind { CTFKind::DeckValue };
299 std::optional<InjMult> m_injmult{};
300 std::size_t m_global_index{};
301
302 /*
303 The sort_value member is a peculiar quantity. The connections are
304 assembled in the WellConnections class. During the lifetime of the
305 connections there are three different sort orders which are all
306 relevant:
307
308 input: This is the ordering implied be the order of the
309 connections in the input deck.
310
311 simulation: This is the ordering the connections have in
312 WellConnections container during the simulation and RFT output.
313
314 restart: This is the ordering the connections have when they are
315 written out to a restart file.
316
317 Exactly what consitutes input, simulation and restart ordering, and
318 how the connections transition between the three during application
319 lifetime is different from MSW and normal wells.
320
321 normal wells: For normal wells the simulation order is given by the
322 COMPORD keyword, and then when the connections are serialized to the
323 restart file they are written in input order; i.e. we have:
324
325 input == restart and simulation given COMPORD
326
327 To recover the input order when creating the restart files the
328 sort_value member corresponds to the insert index for normal wells.
329
330 MSW wells: For MSW wells the wells simulator order[*] is given by
331 COMPSEGS keyword, the COMPORD keyword is ignored. The connections are
332 sorted in WellConnections::order() and then retain that order for all
333 eternity i.e.
334
335 input and simulation == restart
336
337 Now the important point is that the COMPSEGS detail used to perform
338 this sorting is not available when loading from a restart file, but
339 then the connections are already sorted correctly. I.e. *after* a
340 restart we will have:
341
342 input(from restart) == simulation == restart
343
344 The sort_value member is used to sort the connections into restart
345 ordering. In the case of normal wells this corresponds to recovering
346 the input order, whereas for MSW wells this is equivalent to the
347 simulation order.
348
349 [*]: For MSW wells the topology is given by the segments and entered
350 explicitly, so the truth is probably that the storage order
351 during simulation makes no difference?
352 */
353 std::size_t m_sort_value{};
354
355 std::optional<std::pair<double,double>> m_perf_range{};
356 bool m_defaultSatTabId{true};
357
358 // Associate segment number
359 //
360 // 0 means the connection is not associated to a segment.
361 int segment_number { 0 };
362
363 double m_wpimult { 1.0 };
364
365 // Whether or not this Connection is subject to WELPI scaling.
366 bool m_subject_to_welpi { false };
367
368 std::optional<FilterCake> m_filter_cake{};
369
370 static std::string CTFKindToString(const CTFKind);
371 };
372
373} // namespace Opm
374
375#endif // COMPLETION_HPP_
Definition Connection.hpp:53
Definition DeckValue.hpp:30
Definition FieldPropsManager.hpp:42
Collection of intersected cells and associate properties for all simulation grids,...
Definition ScheduleGrid.hpp:50
Class for (de-)serializing.
Definition Serializer.hpp:94
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