My Project
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
21#ifndef COMPLETION_HPP_
22#define COMPLETION_HPP_
23
24#include <array>
25#include <cstddef>
26#include <map>
27#include <memory>
28#include <string>
29#include <vector>
30#include <optional>
31
32namespace Opm {
33
34namespace RestartIO {
35 struct RstConnection;
36}
37
38 class DeckKeyword;
39 class DeckRecord;
40 class ScheduleGrid;
41 class FieldPropsManager;
42
43 class Connection {
44 public:
45 enum class State {
46 OPEN = 1,
47 SHUT = 2,
48 AUTO = 3 // Seems like the AUTO state can not be serialized to restart files.
49 };
50
51 static const std::string State2String( State enumValue );
52 static State StateFromString( const std::string& stringValue );
53
54
55 enum class Direction{
56 X = 1,
57 Y = 2,
58 Z = 3
59 };
60
61 static std::string Direction2String(const Direction enumValue);
62 static Direction DirectionFromString(const std::string& stringValue);
63
64
65 enum class Order {
66 DEPTH,
67 INPUT,
68 TRACK
69 };
70
71 static const std::string Order2String( Order enumValue );
72 static Order OrderFromString(const std::string& comporderStringValue);
73
74 enum class CTFKind {
76 Defaulted,
77 };
78
79
80 Connection();
81 Connection(int i, int j , int k ,
82 std::size_t global_index,
83 int complnum,
84 double depth,
85 State state,
86 double CF,
87 double Kh,
88 double rw,
89 double r0,
90 double re,
91 double connection_length,
92 double skin_factor,
93 const int satTableId,
94 const Direction direction,
95 const CTFKind ctf_kind,
96 const std::size_t sort_value,
97 const bool defaultSatTabId);
98
99 Connection(const RestartIO::RstConnection& rst_connection, const ScheduleGrid& grid, const FieldPropsManager& fp);
100
101 static Connection serializationTestObject();
102
103 bool attachedToSegment() const;
104 bool sameCoordinate(const int i, const int j, const int k) const;
105 int getI() const;
106 int getJ() const;
107 int getK() const;
108 std::size_t global_index() const;
109 State state() const;
110 Direction dir() const;
111 double depth() const;
112 int satTableId() const;
113 int complnum() const;
114 int segment() const;
115 double CF() const;
116 double Kh() const;
117 double rw() const;
118 double r0() const;
119 double re() const;
120 double connectionLength() const;
121 double skinFactor() const;
122 CTFKind kind() const;
123
124 void setState(State state);
125 void setComplnum(int compnum);
126 void scaleWellPi(double wellPi);
127 bool prepareWellPIScaling();
128 bool applyWellPIScaling(const double scaleFactor);
129 void updateSegmentRST(int segment_number_arg,
130 double center_depth_arg);
131 void updateSegment(int segment_number_arg,
132 double center_depth_arg,
133 std::size_t compseg_insert_index,
134 const std::pair<double,double>& perf_range);
135 std::size_t sort_value() const;
136 const bool& getDefaultSatTabId() const;
137 void setDefaultSatTabId(bool id);
138 const std::optional<std::pair<double, double>>& perf_range() const;
139 std::string str() const;
140 bool ctfAssignedFromInput() const
141 {
142 return this->m_ctfkind == CTFKind::DeckValue;
143 }
144
145 bool operator==( const Connection& ) const;
146 bool operator!=( const Connection& ) const;
147
148 template<class Serializer>
149 void serializeOp(Serializer& serializer)
150 {
151 serializer(direction);
152 serializer(center_depth);
153 serializer(open_state);
154 serializer(sat_tableId);
155 serializer(m_complnum);
156 serializer(m_CF);
157 serializer(m_Kh);
158 serializer(m_rw);
159 serializer(m_r0);
160 serializer(m_re);
161 serializer(m_connection_length);
162 serializer(m_skin_factor);
163 serializer(ijk);
164 serializer(m_global_index);
165 serializer(m_ctfkind);
166 serializer(m_sort_value);
167 serializer(m_perf_range);
168 serializer(m_defaultSatTabId);
169 serializer(segment_number);
170 serializer(m_subject_to_welpi);
171 }
172
173 private:
174 Direction direction;
175 double center_depth;
176 State open_state;
177 int sat_tableId;
178 int m_complnum;
179 double m_CF;
180 double m_Kh;
181 double m_rw;
182 double m_r0;
183 double m_re;
184 double m_connection_length;
185 double m_skin_factor;
186
187 std::array<int,3> ijk;
188 CTFKind m_ctfkind;
189 std::size_t m_global_index;
190 /*
191 The sort_value member is a peculiar quantity. The connections are
192 assembled in the WellConnections class. During the lifetime of the
193 connections there are three different sort orders which are all
194 relevant:
195
196 input: This is the ordering implied be the order of the
197 connections in the input deck.
198
199 simulation: This is the ordering the connections have in
200 WellConnections container during the simulation and RFT output.
201
202 restart: This is the ordering the connections have when they are
203 written out to a restart file.
204
205 Exactly what consitutes input, simulation and restart ordering, and
206 how the connections transition between the three during application
207 lifetime is different from MSW and normal wells.
208
209 normal wells: For normal wells the simulation order is given by the
210 COMPORD keyword, and then when the connections are serialized to the
211 restart file they are written in input order; i.e. we have:
212
213 input == restart and simulation given COMPORD
214
215 To recover the input order when creating the restart files the
216 sort_value member corresponds to the insert index for normal wells.
217
218 MSW wells: For MSW wells the wells simulator order[*] is given by
219 COMPSEGS keyword, the COMPORD keyword is ignored. The connections are
220 sorted in WellConnections::order() and then retain that order for all
221 eternity i.e.
222
223 input and simulation == restart
224
225 Now the important point is that the COMPSEGS detail used to perform
226 this sorting is not available when loading from a restart file, but
227 then the connections are already sorted correctly. I.e. *after* a
228 restart we will have:
229
230 input(from restart) == simulation == restart
231
232 The sort_value member is used to sort the connections into restart
233 ordering. In the case of normal wells this corresponds to recovering
234 the input order, whereas for MSW wells this is equivalent to the
235 simulation order.
236
237 [*]: For MSW wells the topology is given by the segments and entered
238 explicitly, so the truth is probably that the storage order
239 during simulation makes no difference?
240 */
241
242 std::size_t m_sort_value;
243 std::optional<std::pair<double,double>> m_perf_range;
244 bool m_defaultSatTabId;
245
246 // related segment number
247 // 0 means the completion is not related to segment
248 int segment_number = 0;
249
250 // Whether or not this Connection is subject to WELPI scaling.
251 bool m_subject_to_welpi = false;
252
253 static std::string CTFKindToString(const CTFKind);
254 };
255}
256
257#endif /* COMPLETION_HPP_ */
258
Definition: Connection.hpp:43
Definition: DeckValue.hpp:30
Definition: FieldPropsManager.hpp:41
Definition: ScheduleGrid.hpp:29
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
Definition: connection.hpp:33