My Project
Segment.hpp
1 /*
2  Copyright 2015 SINTEF ICT, Applied Mathematics.
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 SEGMENT_HPP_HEADER_INCLUDED
21 #define SEGMENT_HPP_HEADER_INCLUDED
22 
23 #include <optional>
24 #include <variant>
25 #include <vector>
26 
27 #include <opm/input/eclipse/Schedule/MSW/Valve.hpp>
28 #include <opm/input/eclipse/Schedule/MSW/SICD.hpp>
29 #include <opm/input/eclipse/Schedule/MSW/AICD.hpp>
30 
31 
32 namespace Opm {
33  namespace RestartIO {
34  struct RstSegment;
35  }
36 }
37 
38 namespace Opm {
39 
40  /*
41  The current serialization of std::variant<> requires that all the types in
42  the variant have serializeOp() method, that is why this RegularSegment
43  type is introduced, ideally the icd variant should just have
44  std::monostate to represent the regular non ICD segment.
45  */
46  struct RegularSegment : std::monostate {
47 
48  template<class Serializer>
49  void serializeOp(Serializer&) {
50  }
51 
52  static RegularSegment serializationTestObject() {
53  return RegularSegment();
54  }
55 
56 
57  bool operator==(const RegularSegment& ) {
58  return true;
59  }
60  };
61 
62 
63  class Segment {
64  public:
65 
66  enum class SegmentType {
67  REGULAR,
68  SICD,
69  AICD, // Not really supported - just included to complete the enum
70  VALVE,
71  };
72 
73  Segment();
74 
75  Segment(const Segment& src, double new_depth, double new_length, double new_volume, double new_x, double new_y);
76  Segment(const Segment& src, double new_depth, double new_length, double new_x, double new_y);
77  Segment(const Segment& src, double new_depth, double new_length, double new_volume);
78  Segment(const Segment& src, double new_depth, double new_length);
79  Segment(const Segment& src, double new_volume);
80  Segment(const int segment_number_in,
81  const int branch_in,
82  const int outlet_segment_in,
83  const double length_in,
84  const double depth_in,
85  const double internal_diameter_in,
86  const double roughness_in,
87  const double cross_area_in,
88  const double volume_in,
89  const bool data_ready_in,
90  const double x_in,
91  const double y_in);
92 
93  Segment(const RestartIO::RstSegment& rst_segment);
94 
95  static Segment serializationTestObject();
96 
97  int segmentNumber() const;
98  int branchNumber() const;
99  int outletSegment() const;
100  double perfLength() const;
101  double totalLength() const;
102  double node_X() const;
103  double node_Y() const;
104  double depth() const;
105  double internalDiameter() const;
106  double roughness() const;
107  double crossArea() const;
108  double volume() const;
109  bool dataReady() const;
110 
111  SegmentType segmentType() const;
112  int ecl_type_id() const;
113 
114 
115  const std::vector<int>& inletSegments() const;
116 
117  static double invalidValue();
118  static SegmentType type_from_int(int ecl_id);
119 
120  bool operator==( const Segment& ) const;
121  bool operator!=( const Segment& ) const;
122 
123  const SICD& spiralICD() const;
124  const AutoICD& autoICD() const;
125  const Valve& valve() const;
126 
127  void updatePerfLength(double perf_length);
128  void updateSpiralICD(const SICD& spiral_icd);
129  void updateAutoICD(const AutoICD& aicd);
130  void updateValve(const Valve& valve, const double segment_length);
131  void updateValve(const Valve& valve);
132  void addInletSegment(const int segment_number);
133 
134  bool isRegular() const
135  {
136  return std::holds_alternative<RegularSegment>(this->m_icd);
137  }
138 
139  inline bool isSpiralICD() const
140  {
141  return std::holds_alternative<SICD>(this->m_icd);
142  }
143 
144  inline bool isAICD() const
145  {
146  return std::holds_alternative<AutoICD>(this->m_icd);
147  }
148 
149  inline bool isValve() const
150  {
151  return std::holds_alternative<Valve>(this->m_icd);
152  }
153 
154  template<class Serializer>
155  void serializeOp(Serializer& serializer)
156  {
157  serializer(m_segment_number);
158  serializer(m_branch);
159  serializer(m_outlet_segment);
160  serializer(m_inlet_segments);
161  serializer(m_total_length);
162  serializer(m_depth);
163  serializer(m_internal_diameter);
164  serializer(m_roughness);
165  serializer(m_cross_area);
166  serializer(m_volume);
167  serializer(m_data_ready);
168  serializer(m_x);
169  serializer(m_y);
170  serializer(m_perf_length);
171  serializer(m_icd);
172  }
173 
174  private:
175  void updateValve__(Valve& valve, const double segment_length);
176  // segment number
177  // it should work as a ID.
178  int m_segment_number;
179  // branch number
180  // for top segment, it should always be 1
181  int m_branch;
182  // the outlet junction segment
183  // for top segment, it should be -1
184  int m_outlet_segment;
185  // the segments whose outlet segments are the current segment
186  std::vector<int> m_inlet_segments;
187  // length of the segment node to the bhp reference point.
188  // when reading in from deck, with 'INC',
189  // it will be incremental length before processing.
190  // After processing and in the class Well, it always stores the 'ABS' value.
191  // which means the total_length
192  double m_total_length;
193  // depth of the nodes to the bhp reference point
194  // when reading in from deck, with 'INC',
195  // it will be the incremental depth before processing.
196  // in the class Well, it always stores the 'ABS' value.
197  // TODO: to check if it is good to use 'ABS' always.
198  double m_depth;
199  // tubing internal diameter
200  // or the equivalent diameter for annular cross-sections
201  // for top segment, it is UNDEFINED
202  // we use invalid_value for the top segment
203  double m_internal_diameter;
204  // effective roughness of the tubing
205  // used to calculate the Fanning friction factor
206  // for top segment, it is UNDEFINED
207  // we use invalid_value for the top segment
208  double m_roughness;
209  // cross-sectional area for fluid flow
210  // not defined for the top segment,
211  // we use invalid_value for the top segment.
212  double m_cross_area;
213  // valume of the segment;
214  // it is defined for top segment.
215  // TODO: to check if the definition is the same with other segments.
216  double m_volume;
217  // indicate if the data related to 'INC' or 'ABS' is ready
218  // the volume will be updated at a final step.
219  bool m_data_ready;
220  // Length of segment projected onto the X axis. Not used in
221  // simulations, but needed for the SEG option in WRFTPLT.
222  double m_x{};
223  // Length of segment projected onto the Y axis. Not used in
224  // simulations, but needed for the SEG option in WRFTPLT.
225  double m_y{};
226 
227  std::optional<double> m_perf_length;
228  std::variant<RegularSegment, SICD, AutoICD, Valve> m_icd;
229 
230  // There are three other properties for the segment pertaining to
231  // thermal conduction. These are not currently supported.
232  };
233 
234 }
235 
236 #endif
Definition: AICD.hpp:35
Definition: SICD.hpp:37
Definition: Segment.hpp:63
Class for (de-)serializing.
Definition: Serializer.hpp:75
Definition: Valve.hpp:37
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: Segment.hpp:46
Definition: segment.hpp:33