opm-common
Loading...
Searching...
No Matches
WellSegments.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 SEGMENTSET_HPP_HEADER_INCLUDED
21#define SEGMENTSET_HPP_HEADER_INCLUDED
22
23#include <opm/input/eclipse/Schedule/MSW/Segment.hpp>
24
25#include <cstddef>
26#include <map>
27#include <set>
28#include <string>
29#include <string_view>
30#include <utility>
31#include <vector>
32
33namespace Opm {
34 class AutoICD;
35 class ErrorGuard;
36 class KeywordLocation;
37 class ParseContext;
38 class SICD;
39 class UnitSystem;
40 class Valve;
41 class WellConnections;
42}
43
44namespace Opm {
45
46 enum class WellSegmentCompPressureDrop {
47 HFA = 0,
48 HF_ = 1,
49 H__ = 2
50 };
51
52 class DeckKeyword;
53 class KeywordLocation;
54
55 class WellSegments {
56 public:
57 enum class LengthDepth {
58 INC = 0,
59 ABS = 1
60 };
61 static const std::string LengthDepthToString(LengthDepth enumValue);
62 static LengthDepth LengthDepthFromString(const std::string& stringValue);
63
64 using CompPressureDrop = WellSegmentCompPressureDrop;
65
66 static const std::string CompPressureDropToString(CompPressureDrop enumValue);
67 static CompPressureDrop CompPressureDropFromString(const std::string& stringValue);
68
69
70 enum class MultiPhaseModel {
71 HO = 0,
72 DF = 1
73 };
74 static const std::string MultiPhaseModelToString(MultiPhaseModel enumValue);
75 static MultiPhaseModel MultiPhaseModelFromString(const std::string& stringValue);
76
77 WellSegments() = default;
78 WellSegments(CompPressureDrop compDrop,
79 const std::vector<Segment>& segments);
80 void loadWELSEGS( const DeckKeyword& welsegsKeyword, const UnitSystem& unit_system);
81 void addWellSegmentsFromLengthsAndDepths(const std::string &wname,
82 const std::vector<std::pair<double, double>>& lengths_and_depths,
83 double diameter, const UnitSystem& unit_system);
84
85 static WellSegments serializationTestObject();
86
87 std::size_t size() const;
88 bool empty() const;
89 int maxSegmentID() const;
90 int maxBranchID() const;
91 double depthTopSegment() const;
92 double lengthTopSegment() const;
93 double volumeTopSegment() const;
94
95 CompPressureDrop compPressureDrop() const;
96
97 // mapping the segment number to the index in the vector of segments
98 int segmentNumberToIndex(const int segment_number) const;
99
100 const Segment& getFromSegmentNumber(const int segment_number) const;
101
102 const Segment& operator[](size_t idx) const;
103 void orderSegments();
104
105 bool operator==( const WellSegments& ) const;
106 bool operator!=( const WellSegments& ) const;
107
108 double segmentLength(const int segment_number) const;
109 double segmentDepthChange(const int segment_number) const;
110 std::vector<Segment> branchSegments(int branch) const;
111 std::set<int> branches() const;
112
113 // it returns true if there is no error encountered during the update
114
115 bool updateWSEGAICD(std::string_view well_name,
116 const std::vector<std::pair<int, AutoICD>>& aicd_pairs,
117 const KeywordLocation& location,
118 const ParseContext& parseContext,
119 ErrorGuard& errors);
120
121 bool updateWSEGSICD(std::string_view well_name,
122 const std::vector<std::pair<int, SICD>>& sicd_pairs,
123 const KeywordLocation& location,
124 const ParseContext& parseContext,
125 ErrorGuard& errors);
126
127 bool updateWSEGVALV(std::string_view well_name,
128 const std::vector<std::pair<int, Valve>>& valve_pairs,
129 const KeywordLocation& location,
130 const ParseContext& parseContext,
131 ErrorGuard& errors);
132
133 auto begin() const { return this->m_segments.begin(); }
134 auto end() const { return this->m_segments.end(); }
135
136 void checkSegmentDepthConsistency(const std::string& well_name, const UnitSystem& unit_system) const;
137
138 bool updateICDScalingFactors(const WellConnections& connections);
139
140 template<class Serializer>
141 void serializeOp(Serializer& serializer)
142 {
143 serializer(m_comp_pressure_drop);
144 serializer(m_segments);
145 serializer(segment_number_to_index);
146 }
147
148 private:
149 void processABS();
150 void processINC(double depth_top, double length_top);
151 void process(const std::string& well_name, const UnitSystem& unit_system,
152 LengthDepth length_depth, double depth_top, double length_top);
153 void addSegment(const Segment& new_segment);
154 void addSegment(const int segment_number,
155 const int branch,
156 const int outlet_segment,
157 const double depth,
158 const double length,
159 const double internal_diameter,
160 const double roughness,
161 const double cross_area,
162 const double volume,
163 const bool data_ready,
164 const double node_x,
165 const double node_y);
166 const Segment& topSegment() const;
167
168 // components of the pressure drop to be included
169 CompPressureDrop m_comp_pressure_drop{CompPressureDrop::HFA};
170 // There are other three properties for segment related to thermal conduction,
171 // while they are not supported by the keyword at the moment.
172
173 std::vector< Segment > m_segments{};
174 // the mapping from the segment number to the
175 // storage index in the vector
176 std::map<int, int> segment_number_to_index{};
177 };
178}
179
180#endif
Definition AICD.hpp:44
Definition DeckKeyword.hpp:36
Definition ErrorGuard.hpp:30
Definition KeywordLocation.hpp:27
Control parser behaviour in failure conditions.
Definition ParseContext.hpp:115
Definition SICD.hpp:46
Definition Segment.hpp:39
Class for (de-)serializing.
Definition Serializer.hpp:94
Definition UnitSystem.hpp:34
Definition Valve.hpp:63
Definition WellConnections.hpp:49
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30