Expose 'OrderSegments' Sorting Predicate

In preparation of defining branches for SEG-type RFT file output.
This commit is contained in:
Bård Skaflestad 2022-10-10 12:49:00 +02:00
parent 8d24dd9d1e
commit a592c05766

View File

@ -725,14 +725,6 @@ namespace {
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
class PLTRecordMSW : public PLTRecord
{
public:
explicit PLTRecordMSW(const std::size_t nconn = 0);
void write(::Opm::EclIO::OutputStream::RFT& rftFile) const override;
private:
class OrderSegments class OrderSegments
{ {
public: public:
@ -746,6 +738,49 @@ namespace {
std::reference_wrapper<const ::Opm::WellSegments> wellSegs_; std::reference_wrapper<const ::Opm::WellSegments> wellSegs_;
}; };
// i1 < i2 if one of the following relations hold
//
// 1) i1's branch number is smaller than i2's branch number
// 2) i1 and i2 are on the same branch, but i1 is i2's outlet segment
// 3) Neither are each other's outlet segments, but i1 is closer to the
// well head along the tubing.
bool OrderSegments::operator()(const int i1, const int i2) const
{
const auto& s1 = this->wellSegs_.get()[i1];
const auto& s2 = this->wellSegs_.get()[i2];
const auto b1 = s1.branchNumber();
const auto b2 = s2.branchNumber();
if (b1 != b2) {
// i1 not on same branch as i2. Order by branch number.
return b1 < b2;
}
if (s2.outletSegment() == s1.segmentNumber()) {
// i1 is i2's outlet
return true;
}
if (s1.outletSegment() == s2.segmentNumber()) {
// i2 is i1's outlet
return false;
}
// Neither is each other's outlet. Order by distance along tubing.
return s1.totalLength() < s2.totalLength();
}
// -----------------------------------------------------------------------
class PLTRecordMSW : public PLTRecord
{
public:
explicit PLTRecordMSW(const std::size_t nconn = 0);
void write(::Opm::EclIO::OutputStream::RFT& rftFile) const override;
private:
class OrderSegConns class OrderSegConns
{ {
public: public:
@ -926,41 +961,6 @@ namespace {
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// i1 < i2 if one of the following relations hold
//
// 1) i1's branch number is smaller than i2's branch number
// 2) i1 and i2 are on the same branch, but i1 is i2's outlet segment
// 3) Neither are each other's outlet segments, but i1 is closer to the
// well head along the tubing.
bool PLTRecordMSW::OrderSegments::operator()(const int i1, const int i2) const
{
const auto& s1 = this->wellSegs_.get()[i1];
const auto& s2 = this->wellSegs_.get()[i2];
const auto b1 = s1.branchNumber();
const auto b2 = s2.branchNumber();
if (b1 != b2) {
// i1 not on same branch as i2. Order by branch number.
return b1 < b2;
}
if (s2.outletSegment() == s1.segmentNumber()) {
// i1 is i2's outlet
return true;
}
if (s1.outletSegment() == s2.segmentNumber()) {
// i2 is i1's outlet
return false;
}
// Neither is each other's outlet. Order by distance along tubing.
return s1.totalLength() < s2.totalLength();
}
// -----------------------------------------------------------------------
// i1 < i2 if one of the following relations hold // i1 < i2 if one of the following relations hold
// //
// 1) i1's branch number is smaller than i2's branch number // 1) i1's branch number is smaller than i2's branch number