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 serializeObject() {
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);
76  Segment(const Segment& src, double new_depth, double new_length);
77  Segment(const Segment& src, double new_volume);
78  Segment(int segment_number_in, int branch_in, int outlet_segment_in, double length_in, double depth_in,
79  double internal_diameter_in, double roughness_in, double cross_area_in, double volume_in, bool data_ready_in);
80  Segment(const RestartIO::RstSegment& rst_segment);
81 
82  static Segment serializeObject();
83 
84  int segmentNumber() const;
85  int branchNumber() const;
86  int outletSegment() const;
87  double perfLength() const;
88  double totalLength() const;
89  double depth() const;
90  double internalDiameter() const;
91  double roughness() const;
92  double crossArea() const;
93  double volume() const;
94  bool dataReady() const;
95 
96  SegmentType segmentType() const;
97  int ecl_type_id() const;
98 
99 
100  const std::vector<int>& inletSegments() const;
101 
102  static double invalidValue();
103  static SegmentType type_from_int(int ecl_id);
104 
105  bool operator==( const Segment& ) const;
106  bool operator!=( const Segment& ) const;
107 
108  const SICD& spiralICD() const;
109  const AutoICD& autoICD() const;
110  const Valve& valve() const;
111 
112  void updatePerfLength(double perf_length);
113  void updateSpiralICD(const SICD& spiral_icd);
114  void updateAutoICD(const AutoICD& aicd);
115  void updateValve(const Valve& valve, const double segment_length);
116  void updateValve(const Valve& valve);
117  void addInletSegment(const int segment_number);
118 
119  bool isRegular() const
120  {
121  return std::holds_alternative<RegularSegment>(this->m_icd);
122  }
123 
124  inline bool isSpiralICD() const
125  {
126  return std::holds_alternative<SICD>(this->m_icd);
127  }
128 
129  inline bool isAICD() const
130  {
131  return std::holds_alternative<AutoICD>(this->m_icd);
132  }
133 
134  inline bool isValve() const
135  {
136  return std::holds_alternative<Valve>(this->m_icd);
137  }
138 
139  template<class Serializer>
140  void serializeOp(Serializer& serializer)
141  {
142  serializer(m_segment_number);
143  serializer(m_branch);
144  serializer(m_outlet_segment);
145  serializer(m_inlet_segments);
146  serializer(m_total_length);
147  serializer(m_depth);
148  serializer(m_internal_diameter);
149  serializer(m_roughness);
150  serializer(m_cross_area);
151  serializer(m_volume);
152  serializer(m_data_ready);
153  serializer(m_perf_length);
154  serializer(m_icd);
155  }
156 
157  private:
158  void updateValve__(Valve& valve, const double segment_length);
159  // segment number
160  // it should work as a ID.
161  int m_segment_number;
162  // branch number
163  // for top segment, it should always be 1
164  int m_branch;
165  // the outlet junction segment
166  // for top segment, it should be -1
167  int m_outlet_segment;
168  // the segments whose outlet segments are the current segment
169  std::vector<int> m_inlet_segments;
170  // length of the segment node to the bhp reference point.
171  // when reading in from deck, with 'INC',
172  // it will be incremental length before processing.
173  // After processing and in the class Well, it always stores the 'ABS' value.
174  // which means the total_length
175  double m_total_length;
176  // depth of the nodes to the bhp reference point
177  // when reading in from deck, with 'INC',
178  // it will be the incremental depth before processing.
179  // in the class Well, it always stores the 'ABS' value.
180  // TODO: to check if it is good to use 'ABS' always.
181  double m_depth;
182  // tubing internal diameter
183  // or the equivalent diameter for annular cross-sections
184  // for top segment, it is UNDEFINED
185  // we use invalid_value for the top segment
186  double m_internal_diameter;
187  // effective roughness of the tubing
188  // used to calculate the Fanning friction factor
189  // for top segment, it is UNDEFINED
190  // we use invalid_value for the top segment
191  double m_roughness;
192  // cross-sectional area for fluid flow
193  // not defined for the top segment,
194  // we use invalid_value for the top segment.
195  double m_cross_area;
196  // valume of the segment;
197  // it is defined for top segment.
198  // TODO: to check if the definition is the same with other segments.
199  double m_volume;
200  // indicate if the data related to 'INC' or 'ABS' is ready
201  // the volume will be updated at a final step.
202  bool m_data_ready;
203 
204  std::optional<double> m_perf_length;
205  std::variant<RegularSegment, SICD, AutoICD, Valve> m_icd;
206 
207  // We are not handling the length of segment projected onto the X-axis and Y-axis.
208  // They are not used in the simulations and we are not supporting the plotting.
209  // There are other three properties for segment related to thermal conduction,
210  // while they are not supported by the keyword at the moment.
211  };
212 
213 }
214 
215 #endif
Definition: AICD.hpp:35
Definition: SICD.hpp:37
Definition: Segment.hpp:63
Definition: Serializer.hpp:38
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