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::ScheduleState
Definition ScheduleState.hpp:101
Opm::SegmentMatcher::Impl
Definition SegmentMatcher.cpp:47
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::SegmentSet::WellSegmentRangeIterator
std::vector< int >::const_iterator WellSegmentRangeIterator
Demarcation of Start/End of Segment Range for Single MS Well.
Definition SegmentMatcher.hpp:46
Opm::SegmentSet::segments
WellSegmentRange segments(std::string_view well) const
Retrive result set's segments for single MS well.
Definition SegmentMatcher.cpp:302
Opm::SegmentSet::empty
bool empty() const
Predicate for whether or not segment set is empty.
Definition SegmentMatcher.hpp:103
Opm::SegmentSet::numWells
std::size_t numWells() const
Retrieve number of (MS) wells covered by this result set.
Definition SegmentMatcher.hpp:128
Opm::SegmentSet::SegmentMatcher
friend class SegmentMatcher
Default constructor.
Definition SegmentMatcher.hpp:153
Opm::SegmentSet::SegmentSet
SegmentSet()
Default Constructor.
Definition SegmentMatcher.cpp:278
Opm::SegmentSet::wells
std::vector< std::string_view > wells() const
Retrieve list of (MS) well names covered by this result set.
Definition SegmentMatcher.cpp:284
Opm::SegmentSet::isScalar
bool isScalar() const
Predicate for whether or not segment set applies to a single segment in a single MS well.
Definition SegmentMatcher.hpp:115
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30