#11706 Use connection depths when plotting connection data

The plotting of curve values for connections to a segment fails in some cases. The current implementation finds the segment a connection is attached to, and use the depth (both MD and TVD) information from this segment. This method is not working in all cases.

Use the reported location of connections attached to segments based on CONLENST and CONLENEN. When measured depth is requested, use these values. There might be gaps in the reported segment sequence.

Use CONDEPTH when TVD depth is requested.

Use CONBRNO to find the branch number, and then use lookup table branchIdsAndOneBasedBranchIndices to find the branch index. Use the branch index to filter the results for requested branch.

The number of values in CON* result values is different to result values for SEG* results.
This commit is contained in:
Magne Sjaastad
2024-09-17 11:28:50 +02:00
parent e006fe52c9
commit 48070f6539
10 changed files with 362 additions and 118 deletions

View File

@@ -119,6 +119,16 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto
}
return;
}
else if ( rftAddress.segmentResultName() == RiaDefines::segmentConnectionMeasuredDepthResultName() )
{
auto segmentConnectionValues = segmentConnectionStartEndMeasuredDepth( rftAddress );
for ( const auto& [startMD, endMD, isValidSegment] : segmentConnectionValues )
{
values->push_back( endMD );
}
return;
}
}
if ( resultName.empty() )
@@ -137,52 +147,19 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto
auto key = std::make_pair( wellName, RftDate{ y, m, d } );
auto segment = m_rftWellDateSegments[key];
std::vector<size_t> nonContinuousDeviceSegmentIndices;
if ( rftAddress.segmentBranchType() == RiaDefines::RftBranchType::RFT_DEVICE )
{
nonContinuousDeviceSegmentIndices = segment.nonContinuousDeviceSegmentIndices( rftAddress.segmentBranchIndex() );
}
if ( m_connectionResultItemCount.count( wellName ) && data.size() == m_connectionResultItemCount[wellName] )
{
// 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<int>( 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 )
{
auto segmentIndex = segment.segmentIndexFromSegmentNumber( segmentNumber );
if ( std::find( nonContinuousDeviceSegmentIndices.begin(), nonContinuousDeviceSegmentIndices.end(), segmentIndex ) !=
nonContinuousDeviceSegmentIndices.end() )
{
// Insert an extra infinity value for segments that are not continuous. The number of values in the values
// vector must be equal to the number of x-values (measured depths)
values->push_back( std::numeric_limits<double>::infinity() );
}
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<double>::infinity() );
}
}
auto connectionValues = segmentConnectionValues( rftAddress, segment, data );
values->insert( values->end(), connectionValues.begin(), connectionValues.end() );
}
else
{
std::vector<size_t> nonContinuousDeviceSegmentIndices;
if ( rftAddress.segmentBranchType() == RiaDefines::RftBranchType::RFT_DEVICE )
{
nonContinuousDeviceSegmentIndices = segment.nonContinuousDeviceSegmentIndices( rftAddress.segmentBranchIndex() );
}
auto indices = segment.segmentIndicesForBranchIndex( rftAddress.segmentBranchIndex(), rftAddress.segmentBranchType() );
for ( const auto& i : indices )
{
@@ -212,7 +189,7 @@ void RifReaderOpmRft::values( const RifEclipseRftAddress& rftAddress, std::vecto
if ( resultName == "CONFAC" || resultName == "CONKH" )
{
// Replace undefined values with zero to improve readability of plots
std::replace( values->begin(), values->end(), std::numeric_limits<double>::infinity(), 0.0 );
std::replace( data.begin(), data.end(), std::numeric_limits<double>::infinity(), 0.0 );
}
}
else
@@ -335,14 +312,9 @@ std::vector<caf::VecIjk> RifReaderOpmRft::cellIndices( const QString& wellName,
try
{
auto resultNameI = "CONIPOS";
auto dataI = m_opm_rft->getRft<int>( resultNameI, stdWellName, y, m, d );
auto resultNameJ = "CONJPOS";
auto dataJ = m_opm_rft->getRft<int>( resultNameJ, stdWellName, y, m, d );
auto resultNameK = "CONKPOS";
auto dataK = m_opm_rft->getRft<int>( resultNameK, stdWellName, y, m, d );
auto dataI = m_opm_rft->getRft<int>( RiaDefines::segmentConnectionIPos(), stdWellName, y, m, d );
auto dataJ = m_opm_rft->getRft<int>( RiaDefines::segmentConnectionJPos(), stdWellName, y, m, d );
auto dataK = m_opm_rft->getRft<int>( RiaDefines::segmentConnectionKPos(), stdWellName, y, m, d );
if ( !dataI.empty() && ( dataI.size() == dataJ.size() ) && ( dataI.size() == dataK.size() ) )
{
@@ -454,6 +426,134 @@ void RifReaderOpmRft::openFiles( const QString& fileName, const QString& dataDec
m_detectedErrorWhenOpeningRftFile = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RifReaderOpmRft::SegmentConnectionStartEnd>
RifReaderOpmRft::segmentConnectionStartEndMeasuredDepth( const RifEclipseRftAddress& rftAddress )
{
try
{
std::vector<RifReaderOpmRft::SegmentConnectionStartEnd> startEndValues;
if ( !isOpen() ) return startEndValues;
const int y = rftAddress.timeStep().date().year();
const int m = rftAddress.timeStep().date().month();
const int d = rftAddress.timeStep().date().day();
const std::string wellName = rftAddress.wellName().toStdString();
const std::string conbrnoResultName = RiaDefines::segmentConnectionBranchNoResultName();
const std::string conlenstResultName = RiaDefines::segmentConnectionStartDepthResultName();
const std::string conlenenResultName = RiaDefines::segmentConnectionEndDepthResultName();
const auto connnectionBranchNumbers = m_opm_rft->getRft<int>( conbrnoResultName, wellName, y, m, d );
const auto startMD = m_opm_rft->getRft<float>( conlenstResultName, wellName, y, m, d );
const auto endMD = m_opm_rft->getRft<float>( conlenenResultName, wellName, y, m, d );
const size_t size = connnectionBranchNumbers.size();
if ( size == startMD.size() && size == endMD.size() )
{
auto segment = segmentForWell( rftAddress.wellName(), rftAddress.timeStep() );
auto branchIdIndex = segment.branchIdsAndOneBasedBranchIndices( rftAddress.segmentBranchType() );
// Convert the branch number to the branch index
// Filter data based on branch index
bool isFirstSegment = true;
for ( size_t i = 0; i < connnectionBranchNumbers.size(); i++ )
{
if ( branchIdIndex.count( connnectionBranchNumbers[i] ) )
{
auto branchIndex = branchIdIndex[connnectionBranchNumbers[i]];
if ( branchIndex == rftAddress.segmentBranchIndex() )
{
if ( !isFirstSegment && std::fabs( startMD[i] - endMD[i - 1] ) > 0.1 )
{
// Insert a segment representing the connection between the segments. Assign infinity as value to this segment
// to allow discontinuous plotting.
startEndValues.emplace_back( endMD[i - 1], startMD[i], false );
}
startEndValues.emplace_back( startMD[i], endMD[i], true );
isFirstSegment = false;
}
}
}
}
return startEndValues;
}
catch ( ... )
{
}
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<float> RifReaderOpmRft::segmentConnectionValues( const RifEclipseRftAddress& rftAddress,
const RifRftSegment& rftSegment,
const std::vector<float>& nativeValues )
{
std::vector<float> branchValues;
const int y = rftAddress.timeStep().date().year();
const int m = rftAddress.timeStep().date().month();
const int d = rftAddress.timeStep().date().day();
const auto connnectionBranchNumbers =
m_opm_rft->getRft<int>( RiaDefines::segmentConnectionBranchNoResultName(), rftAddress.wellName().toStdString(), y, m, d );
if ( nativeValues.size() == connnectionBranchNumbers.size() )
{
auto branchIdIndex = rftSegment.branchIdsAndOneBasedBranchIndices( rftAddress.segmentBranchType() );
// Convert the branch number to the branch index
// Filter data based on branch index
for ( size_t i = 0; i < connnectionBranchNumbers.size(); i++ )
{
if ( branchIdIndex.count( connnectionBranchNumbers[i] ) )
{
auto branchIndex = branchIdIndex[connnectionBranchNumbers[i]];
if ( branchIndex == rftAddress.segmentBranchIndex() )
{
branchValues.push_back( nativeValues[i] );
}
}
}
}
std::vector<float> allResultValues;
auto segmentConnectionValues = segmentConnectionStartEndMeasuredDepth( rftAddress );
size_t segmentConnectionIndex = 0;
for ( auto branchValue : branchValues )
{
if ( segmentConnectionIndex < segmentConnectionValues.size() )
{
auto [startMD, endMD, isValidSegment] = segmentConnectionValues[segmentConnectionIndex];
if ( !isValidSegment )
{
// Use infinity to make sure no curve is drawn for this segment
allResultValues.push_back( std::numeric_limits<double>::infinity() );
segmentConnectionIndex++;
}
allResultValues.push_back( branchValue );
}
segmentConnectionIndex++;
}
return allResultValues;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -572,11 +672,12 @@ void RifReaderOpmRft::buildSegmentData()
for ( const auto& [name, arrayType, size] : results )
{
if ( ( name.find( "SEG" ) == 0 ) && m_segmentResultItemCount.count( wellName ) == 0 )
if ( ( RiaDefines::isSegmentResult( QString::fromStdString( name ) ) ) && m_segmentResultItemCount.count( wellName ) == 0 )
{
m_segmentResultItemCount[wellName] = size;
}
if ( name.find( "CON" ) == 0 && m_connectionResultItemCount.count( wellName ) == 0 )
if ( RiaDefines::isSegmentConnectionResult( QString::fromStdString( name ) ) &&
m_connectionResultItemCount.count( wellName ) == 0 )
{
m_connectionResultItemCount[wellName] = size;
}

View File

@@ -90,6 +90,13 @@ private:
bool openFiles();
using SegmentConnectionStartEnd = std::tuple<float, float, bool>;
std::vector<SegmentConnectionStartEnd> segmentConnectionStartEndMeasuredDepth( const RifEclipseRftAddress& rftAddress );
std::vector<float> segmentConnectionValues( const RifEclipseRftAddress& rftAddress,
const RifRftSegment& rftSegment,
const std::vector<float>& nativeValues );
private:
std::unique_ptr<Opm::EclIO::ERft> m_opm_rft;