From b6973a3644296c9e74914e16d1d6a08ce229b862 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 22 Aug 2022 10:56:33 +0200 Subject: [PATCH] RFT: Add connection data as segment results --- .../FileInterface/RifReaderOpmRft.cpp | 49 ++++++++++++++----- .../FileInterface/RifRftSegment.cpp | 17 +++++++ .../FileInterface/RifRftSegment.h | 2 + 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp b/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp index 97990d3835..5a030f4773 100644 --- a/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderOpmRft.cpp @@ -124,12 +124,43 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto auto key = std::make_pair( wellName, RftDate{ y, m, d } ); auto segment = m_rftWellDateSegments[key]; - auto indices = - segment.indicesForBranchIndex( rftAddress.segmentBranchIndex(), rftAddress.segmentBranchType() ); - for ( const auto& i : indices ) + if ( resultName.find( "CON" ) == 0 ) { - CAF_ASSERT( i < data.size() ); - values->push_back( data[i] ); + // Connection results with size equal to length of result CONSEGNO. CONSEGNO defines the segment + // numbers the connection is connected to. + + const std::string consegResultName = "CONSEGNO"; + auto connnectionSegmentNumbers = m_opm_rft->getRft( consegResultName, wellName, y, m, d ); + if ( connnectionSegmentNumbers.empty() ) return; + + auto segmentNumbers = segment.segmentNumbersForBranchIndex( rftAddress.segmentBranchIndex(), + rftAddress.segmentBranchType() ); + + size_t resultDataIndex = 0; + for ( int segmentNumber : segmentNumbers ) + { + if ( std::find( connnectionSegmentNumbers.begin(), connnectionSegmentNumbers.end(), segmentNumber ) != + connnectionSegmentNumbers.end() ) + { + values->push_back( data[resultDataIndex++] ); + } + else + { + // The number of values must be equal to the number of segments, use infinity for segments + // with no data + values->push_back( std::numeric_limits::infinity() ); + } + } + } + else + { + auto indices = + segment.indicesForBranchIndex( rftAddress.segmentBranchIndex(), rftAddress.segmentBranchType() ); + for ( const auto& i : indices ) + { + CAF_ASSERT( i < data.size() ); + values->push_back( data[i] ); + } } } else @@ -356,14 +387,8 @@ void RifReaderOpmRft::buildMetaData() m_rftSegmentTimeSteps.insert( dt ); - auto segmentCount = segmentData.topology().size(); - for ( const auto& resultNameAndSize : resultNameAndSizes ) { - auto resultValueCount = std::get<2>( resultNameAndSize ); - - if ( static_cast( resultValueCount ) != segmentCount ) continue; - auto resultName = std::get<0>( resultNameAndSize ); auto adr = RifEclipseRftAddress::createSegmentAddress( QString::fromStdString( wellName ), dt, @@ -441,7 +466,7 @@ void RifReaderOpmRft::buildSegmentData() for ( const auto& rftResultMetaData : arraysAtWellDate ) { auto [name, arrayType, size] = rftResultMetaData; - if ( name.find( "SEG" ) == 0 ) + if ( ( name.find( "SEG" ) == 0 ) || ( name.find( "CON" ) == 0 ) ) { segment.addResultNameAndSize( rftResultMetaData ); } diff --git a/ApplicationLibCode/FileInterface/RifRftSegment.cpp b/ApplicationLibCode/FileInterface/RifRftSegment.cpp index 6969e55228..2392702fc7 100644 --- a/ApplicationLibCode/FileInterface/RifRftSegment.cpp +++ b/ApplicationLibCode/FileInterface/RifRftSegment.cpp @@ -285,3 +285,20 @@ std::vector RifRftSegment::indicesForBranchIndex( int branchIndex, RiaDe return v; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifRftSegment::segmentNumbersForBranchIndex( int oneBasedBranchIndex, + RiaDefines::RftBranchType branchType ) const +{ + std::vector v; + + auto indices = indicesForBranchIndex( oneBasedBranchIndex, branchType ); + for ( auto index : indices ) + { + v.push_back( m_topology[index].segNo() ); + } + + return v; +} diff --git a/ApplicationLibCode/FileInterface/RifRftSegment.h b/ApplicationLibCode/FileInterface/RifRftSegment.h index f8194f5815..6276a0953f 100644 --- a/ApplicationLibCode/FileInterface/RifRftSegment.h +++ b/ApplicationLibCode/FileInterface/RifRftSegment.h @@ -72,6 +72,8 @@ public: std::vector indicesForBranchNumber( int branchNumber ) const; std::vector indicesForBranchIndex( int branchIndex, RiaDefines::RftBranchType branchType ) const; + std::vector segmentNumbersForBranchIndex( int oneBasedBranchIndex, RiaDefines::RftBranchType branchType ) const; + private: std::vector m_topology; std::vector m_resultNameAndSize;