My Project
Loading...
Searching...
No Matches
SegmentMatcher.hpp
1/*
2 Copyright 2022 Equinor 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 SEGMENT_MATCHER_HPP
21#define SEGMENT_MATCHER_HPP
22
23#include <cstddef>
24#include <memory>
25#include <optional>
26#include <string>
27#include <string_view>
28#include <utility>
29#include <vector>
30
32
33namespace Opm {
34 class ScheduleState;
35} // namespace Opm
36
37namespace Opm {
38
39class SegmentMatcher;
40
42class SegmentSet
43{
44public:
46 using WellSegmentRangeIterator = std::vector<int>::const_iterator;
47
50 {
51 public:
53 WellSegmentRangeIterator begin() const { return this->begin_; }
54
56 WellSegmentRangeIterator end() const { return this->end_; }
57
59 std::string_view well() const { return this->well_; }
60
61 friend class SegmentSet;
62
63 private:
65 WellSegmentRangeIterator begin_{};
66
68 WellSegmentRangeIterator end_{};
69
71 std::string_view well_{};
72
78 WellSegmentRange() = default;
79
88 WellSegmentRange(WellSegmentRangeIterator begin,
89 WellSegmentRangeIterator end,
90 std::string_view well)
91 : begin_{ begin }
92 , end_ { end }
93 , well_ { well }
94 {}
95 };
96
98 SegmentSet();
99
103 bool empty() const
104 {
105 return this->segments_.empty();
106 }
107
115 bool isScalar() const
116 {
117 return this->segments_.size() == std::vector<int>::size_type{1};
118 }
119
123 std::vector<std::string_view> wells() const;
124
128 std::size_t numWells() const
129 {
130 return this->wells_.size();
131 }
132
141 WellSegmentRange segments(std::string_view well) const;
142
151 WellSegmentRange segments(const std::size_t well) const;
152
153 friend class SegmentMatcher;
154
155private:
157 std::vector<std::string> wells_{};
158
163 std::vector<std::vector<std::string>::size_type> wellNameIndex_{};
164
166 std::vector<std::vector<int>::size_type> segmentStart_{};
167
170 std::vector<int> segments_{};
171
175 void establishNameLookupIndex();
176
185 void addWellSegments(const std::string& well,
186 const std::vector<int>& segments);
187};
188
212class SegmentMatcher
213{
214public:
218 class SetDescriptor
219 {
220 public:
222 SetDescriptor() = default;
223
231 SetDescriptor& segmentNumber(const int segNum);
232
244 SetDescriptor& segmentNumber(std::string_view segNum);
245
249 const std::optional<int>& segmentNumber() const
250 {
251 return this->segmentNumber_;
252 }
253
259 SetDescriptor& wellNames(std::string_view wellNamePattern);
260
265 const std::optional<std::string>& wellNames() const
266 {
267 return this->wellNamePattern_;
268 }
269
270 private:
273 std::optional<std::string> wellNamePattern_{};
274
277 std::optional<int> segmentNumber_{};
278 };
279
283 SegmentMatcher() = delete;
284
290 explicit SegmentMatcher(const ScheduleState& mswInputData);
291
297 SegmentMatcher(const SegmentMatcher& rhs) = delete;
298
302 SegmentMatcher(SegmentMatcher&& rhs);
303
311 SegmentMatcher& operator=(const SegmentMatcher& rhs) = delete;
312
318 SegmentMatcher& operator=(SegmentMatcher&& rhs);
319
323 ~SegmentMatcher();
324
344 SegmentSet findSegments(const SetDescriptor& segments) const;
345
346private:
348 class Impl;
349
351 std::unique_ptr<Impl> pImpl_{};
352};
353
354} // namespace Opm
355
356#endif // SEGMENT_MATCHER_HPP
Segment Range for Single MS Well.
Definition SegmentMatcher.hpp:50
WellSegmentRangeIterator begin() const
Start of Range.
Definition SegmentMatcher.hpp:53
std::string_view well() const
Name of well to which this segment range is attached.
Definition SegmentMatcher.hpp:59
WellSegmentRangeIterator end() const
End of Range.
Definition SegmentMatcher.hpp:56
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30