Loading...
Searching...
No Matches
SegmentMatcher.hpp
/*
Copyright 2022 Equinor ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SEGMENT_MATCHER_HPP
#define SEGMENT_MATCHER_HPP
#include <cstddef>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
namespace Opm {
class ScheduleState;
} // namespace Opm
namespace Opm {
class SegmentMatcher;
class SegmentSet
{
public:
using WellSegmentRangeIterator = std::vector<int>::const_iterator;
class WellSegmentRange
{
public:
WellSegmentRangeIterator begin() const { return this->begin_; }
WellSegmentRangeIterator end() const { return this->end_; }
std::string_view well() const { return this->well_; }
friend class SegmentSet;
private:
WellSegmentRangeIterator begin_{};
WellSegmentRangeIterator end_{};
std::string_view well_{};
WellSegmentRange() = default;
WellSegmentRange(WellSegmentRangeIterator begin,
WellSegmentRangeIterator end,
std::string_view well)
: begin_{ begin }
, end_ { end }
, well_ { well }
{}
};
SegmentSet();
bool empty() const
{
return this->segments_.empty();
}
bool isScalar() const
{
return this->segments_.size() == std::vector<int>::size_type{1};
}
std::vector<std::string_view> wells() const;
std::size_t numWells() const
{
return this->wells_.size();
}
WellSegmentRange segments(std::string_view well) const;
WellSegmentRange segments(const std::size_t well) const;
friend class SegmentMatcher;
private:
std::vector<std::string> wells_{};
std::vector<std::vector<std::string>::size_type> wellNameIndex_{};
std::vector<std::vector<int>::size_type> segmentStart_{};
std::vector<int> segments_{};
void establishNameLookupIndex();
void addWellSegments(const std::string& well,
const std::vector<int>& segments);
};
class SegmentMatcher
{
public:
class SetDescriptor
{
public:
SetDescriptor() = default;
SetDescriptor& segmentNumber(const int segNum);
SetDescriptor& segmentNumber(std::string_view segNum);
const std::optional<int>& segmentNumber() const
{
return this->segmentNumber_;
}
SetDescriptor& wellNames(std::string_view wellNamePattern);
const std::optional<std::string>& wellNames() const
{
return this->wellNamePattern_;
}
private:
std::optional<std::string> wellNamePattern_{};
std::optional<int> segmentNumber_{};
};
SegmentMatcher() = delete;
explicit SegmentMatcher(const ScheduleState& mswInputData);
SegmentMatcher(const SegmentMatcher& rhs) = delete;
SegmentMatcher(SegmentMatcher&& rhs);
SegmentMatcher& operator=(const SegmentMatcher& rhs) = delete;
SegmentMatcher& operator=(SegmentMatcher&& rhs);
~SegmentMatcher();
SegmentSet findSegments(const SetDescriptor& segments) const;
private:
class Impl;
std::unique_ptr<Impl> pImpl_{};
};
} // namespace Opm
#endif // SEGMENT_MATCHER_HPP
Opm::SegmentSet::WellSegmentRange
Segment Range for Single MS Well.
Definition SegmentMatcher.hpp:50
Opm::SegmentSet::WellSegmentRange::begin
WellSegmentRangeIterator begin() const
Start of Range.
Definition SegmentMatcher.hpp:53
Opm::SegmentSet::WellSegmentRange::well
std::string_view well() const
Name of well to which this segment range is attached.
Definition SegmentMatcher.hpp:59
Opm::SegmentSet::WellSegmentRange::end
WellSegmentRangeIterator end() const
End of Range.
Definition SegmentMatcher.hpp:56
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30