diff --git a/ApplicationLibCode/Application/RiaRftDefines.cpp b/ApplicationLibCode/Application/RiaRftDefines.cpp index 75f74fbfa7..1d39a5023a 100644 --- a/ApplicationLibCode/Application/RiaRftDefines.cpp +++ b/ApplicationLibCode/Application/RiaRftDefines.cpp @@ -67,14 +67,6 @@ QString RiaDefines::segmentBranchNumberResultName() return "SegmentBranchNumber"; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RiaDefines::segmentOneBasedBranchIndexResultName() -{ - return "SegmentOneBasedBranchIndex"; -} - namespace caf { template <> diff --git a/ApplicationLibCode/Application/RiaRftDefines.h b/ApplicationLibCode/Application/RiaRftDefines.h index 2eb3247e28..de143df071 100644 --- a/ApplicationLibCode/Application/RiaRftDefines.h +++ b/ApplicationLibCode/Application/RiaRftDefines.h @@ -29,7 +29,6 @@ QString segmentNumberResultName(); QString allBranches(); QString segmentBranchNumberResultName(); -QString segmentOneBasedBranchIndexResultName(); enum class RftBranchType { diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp index 5a030f4773..93ec916376 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp @@ -98,15 +98,6 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto } return; } - else if ( rftAddress.segmentResultName() == RiaDefines::segmentOneBasedBranchIndexResultName() ) - { - auto branchIndices = segment.oneBasedBranchIndices(); - for ( const auto& branchNumber : branchIndices ) - { - values->push_back( branchNumber ); - } - return; - } } if ( resultName.empty() ) @@ -295,6 +286,25 @@ void RifReaderOpmRft::cellIndices( const RifEclipseRftAddress& rftAddress, std:: } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map RifReaderOpmRft::branchIdsAndOneBasedIndices( const QString& wellName, const QDateTime& timeStep ) +{ + int y = timeStep.date().year(); + int m = timeStep.date().month(); + int d = timeStep.date().day(); + + auto key = std::make_pair( wellName.toStdString(), RftDate{ y, m, d } ); + if ( m_rftWellDateSegments.count( key ) > 0 ) + { + auto segment = m_rftWellDateSegments[key]; + return segment.branchIdsAndOneBasedBranchIndices(); + } + + return {}; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -538,7 +548,8 @@ void RifReaderOpmRft::buildSegmentBranchTypes( const RftSegmentKey& segmentKey ) // The device segment is connected to a segment on the tubing branch // // Annulus branch - // Layer between device branch and reservoir. The segment connection data is imported from WSEGLINK in the data deck + // Layer between device branch and reservoir. The segment connection data is imported from WSEGLINK in the data + // deck auto wellName = segmentKey.first; auto date = segmentKey.second; diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmRft.h b/ApplicationLibCode/FileInterface/RifReaderOpmRft.h index df716becb6..a94eb96740 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmRft.h +++ b/ApplicationLibCode/FileInterface/RifReaderOpmRft.h @@ -53,6 +53,8 @@ public: void cellIndices( const RifEclipseRftAddress& rftAddress, std::vector* indices ) override; + std::map branchIdsAndOneBasedIndices( const QString& wellName, const QDateTime& timeStep ); + private: // Segment data // RftDate must be synced with definition in Opm::EclIO::ERft::RftDate diff --git a/ApplicationLibCode/FileInterface/RifRftSegment.cpp b/ApplicationLibCode/FileInterface/RifRftSegment.cpp index 2392702fc7..e60e9c5ae6 100644 --- a/ApplicationLibCode/FileInterface/RifRftSegment.cpp +++ b/ApplicationLibCode/FileInterface/RifRftSegment.cpp @@ -149,21 +149,6 @@ std::vector RifRftSegment::branchIds() const return v; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::set RifRftSegment::oneBasedBranchIndices() const -{ - std::set indices; - - for ( auto b : m_oneBasedBranchIndexMap ) - { - indices.insert( b.second ); - } - - return indices; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -174,6 +159,14 @@ int RifRftSegment::oneBasedBranchIndexForBranchId( int branchId ) const return -1; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map RifRftSegment::branchIdsAndOneBasedBranchIndices() const +{ + return m_oneBasedBranchIndexMap; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/FileInterface/RifRftSegment.h b/ApplicationLibCode/FileInterface/RifRftSegment.h index 6276a0953f..45f05a360f 100644 --- a/ApplicationLibCode/FileInterface/RifRftSegment.h +++ b/ApplicationLibCode/FileInterface/RifRftSegment.h @@ -55,10 +55,11 @@ public: void addResultNameAndSize( const Opm::EclIO::EclFile::EclEntry& resultNameAndSize ); std::vector resultNameAndSize() const; - std::vector tubingBranchIds() const; - std::vector branchIds() const; - std::set oneBasedBranchIndices() const; - int oneBasedBranchIndexForBranchId( int branchId ) const; + std::vector tubingBranchIds() const; + std::vector branchIds() const; + int oneBasedBranchIndexForBranchId( int branchId ) const; + std::map branchIdsAndOneBasedBranchIndices() const; + const RifRftSegmentData* segmentData( int segmentNumber ) const; void createDeviceBranch( int deviceBranchFirstSegmentNumber, int oneBasedBranchIndex ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp index a7fbdeba9b..3862e64332 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimRftTools.cpp @@ -24,6 +24,7 @@ #include "RifReaderRftInterface.h" +#include "RifReaderOpmRft.h" #include "cafPdmUiItem.h" //-------------------------------------------------------------------------------------------------- @@ -144,26 +145,36 @@ QList RimRftTools::segmentBranchIndexOptions( RifReaderR const QString& wellName, const QDateTime& timeStep ) { - QList options; - - options.push_front( caf::PdmOptionItemInfo( RiaDefines::allBranches(), -1 ) ); - - if ( readerRft ) + auto opmReader = dynamic_cast( readerRft ); + if ( opmReader ) { - std::vector values; + QList options; + options.push_front( caf::PdmOptionItemInfo( RiaDefines::allBranches(), -1 ) ); - auto adr = RifEclipseRftAddress::createSegmentAddress( wellName, - timeStep, - RiaDefines::segmentOneBasedBranchIndexResultName() ); + auto branchIdIndex = opmReader->branchIdsAndOneBasedIndices( wellName, timeStep ); - readerRft->values( adr, &values ); - for ( const auto& v : values ) + std::set indices; + for ( auto b : branchIdIndex ) { - int intValue = v; - auto txt = QString::number( intValue ); - options.push_back( caf::PdmOptionItemInfo( txt, intValue ) ); + indices.insert( b.second ); } + + for ( auto i : indices ) + { + std::vector branchIds; + for ( auto b : branchIdIndex ) + { + if ( b.second == i ) branchIds.push_back( b.first ); + } + + auto minMax = std::minmax_element( branchIds.begin(), branchIds.end() ); + + auto txt = QString( "%1 (%2-%3)" ).arg( i ).arg( *minMax.first ).arg( *minMax.second ); + options.push_back( caf::PdmOptionItemInfo( txt, i ) ); + } + + return options; } - return options; + return {}; }