Skip to content

Commit

Permalink
Improve support for network vectors
Browse files Browse the repository at this point in the history
Show all text if summary address contains multiple : for network addresses
Consolidate replace of tokens in summary address
  • Loading branch information
magnesj committed Oct 21, 2024
1 parent 70d7952 commit 3faa4ab
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 44 deletions.
33 changes: 12 additions & 21 deletions ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "RifSummaryReaderInterface.h"

#include "RimSummaryAddressModifier.h"
#include "RimSummaryCase.h"
#include "RimSummaryEnsemble.h"

Expand Down Expand Up @@ -175,29 +176,19 @@ void RiaSummaryCurveDefinition::setIdentifierText( SummaryCategory category, con
{
if ( RifEclipseSummaryAddress::isDependentOnWellName( category ) )
{
m_summaryAddressY.setWellName( name );
m_summaryAddressX.setWellName( name );
m_summaryAddressX =
RimSummaryAddressModifier::replaceTokenForCategory( m_summaryAddressX,
name,
RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_WELL );
m_summaryAddressY =
RimSummaryAddressModifier::replaceTokenForCategory( m_summaryAddressY,
name,
RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_WELL );
}

int id = RiaStdStringTools::toInt( name );

switch ( category )
else
{
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_AQUIFER:
m_summaryAddressY.setAquiferNumber( id );
m_summaryAddressX.setAquiferNumber( id );
break;
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_REGION:
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_REGION_2_REGION:
m_summaryAddressY.setRegion( id );
m_summaryAddressX.setRegion( id );
break;
case RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_GROUP:
m_summaryAddressY.setGroupName( name );
m_summaryAddressX.setGroupName( name );
break;
default:
break;
m_summaryAddressX = RimSummaryAddressModifier::replaceTokenForCategory( m_summaryAddressX, name, m_summaryAddressX.category() );
m_summaryAddressY = RimSummaryAddressModifier::replaceTokenForCategory( m_summaryAddressY, name, m_summaryAddressY.category() );
}
}

Expand Down
15 changes: 13 additions & 2 deletions ApplicationLibCode/FileInterface/RifEclipseSummaryAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,8 +1034,19 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector
break;

case SummaryCategory::SUMMARY_NETWORK:
return networkAddress( vectorName, token1 );
break;
{
auto aggregated = token1;
if ( !token2.empty() )
{
// Network name can contain more than one token. Concatenate tokens using : as separator
// https://github.com/OPM/ResInsight/issues/11785
aggregated += ":";
aggregated += token2;
}

return networkAddress( vectorName, aggregated );
}
break;

case SummaryCategory::SUMMARY_MISC:
return miscAddress( vectorName );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,55 @@ void caf::AppEnum<RimSummaryAddressCollection::CollectionContentType>::setUp()

CAF_PDM_SOURCE_INIT( RimSummaryAddressCollection, "RimSummaryAddressCollection" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddressDefines::SummaryCategory RimSummaryAddressCollection::contentTypeToSummaryCategory( CollectionContentType contentType )
{
switch ( contentType )
{
case CollectionContentType::WELL:
return SummaryCategory::SUMMARY_WELL;
case CollectionContentType::GROUP:
return SummaryCategory::SUMMARY_GROUP;
case CollectionContentType::REGION:
return SummaryCategory::SUMMARY_REGION;
case CollectionContentType::FIELD:
return SummaryCategory::SUMMARY_FIELD;
case CollectionContentType::MISC:
return SummaryCategory::SUMMARY_MISC;
case CollectionContentType::AQUIFER:
return SummaryCategory::SUMMARY_AQUIFER;
case CollectionContentType::NETWORK:
return SummaryCategory::SUMMARY_NETWORK;
case CollectionContentType::REGION_2_REGION:
return SummaryCategory::SUMMARY_REGION_2_REGION;
case CollectionContentType::WELL_COMPLETION:
return SummaryCategory::SUMMARY_WELL_COMPLETION;
case CollectionContentType::WELL_LGR:
return SummaryCategory::SUMMARY_WELL_LGR;
case CollectionContentType::WELL_COMPLETION_LGR:
return SummaryCategory::SUMMARY_WELL_COMPLETION_LGR;
case CollectionContentType::WELL_SEGMENT:
return SummaryCategory::SUMMARY_WELL_SEGMENT;
case CollectionContentType::BLOCK:
return SummaryCategory::SUMMARY_BLOCK;
case CollectionContentType::BLOCK_LGR:
return SummaryCategory::SUMMARY_BLOCK_LGR;
case CollectionContentType::IMPORTED:
return SummaryCategory::SUMMARY_IMPORTED;
case CollectionContentType::CALCULATED:
case CollectionContentType::NOT_DEFINED:
case CollectionContentType::WELL_FOLDER:
case CollectionContentType::GROUP_FOLDER:
case CollectionContentType::REGION_FOLDER:
case CollectionContentType::NETWORK_FOLDER:
case CollectionContentType::SUMMARY_CASE:
default:
return SummaryCategory::SUMMARY_INVALID;
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include "RimNamedObject.h"

#include "RifEclipseSummaryAddressDefines.h"

#include "cafPdmChildArrayField.h"

#include <QString>
Expand Down Expand Up @@ -59,6 +61,8 @@ class RimSummaryAddressCollection : public RimNamedObject
IMPORTED
};

static RifEclipseSummaryAddressDefines::SummaryCategory contentTypeToSummaryCategory( CollectionContentType contentType );

public:
RimSummaryAddressCollection();
~RimSummaryAddressCollection() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,32 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddress RimSummaryAddressModifier::replaceObjectName( const RifEclipseSummaryAddress& sourceAdr,
std::string objectName,
RimSummaryAddressCollection::CollectionContentType contentType )
RifEclipseSummaryAddress RimSummaryAddressModifier::replaceTokenForCategory( const RifEclipseSummaryAddress& sourceAdr,
const std::string& token,
RifEclipseSummaryAddressDefines::SummaryCategory contentType )
{
auto adr = sourceAdr;

if ( contentType == RimSummaryAddressCollection::CollectionContentType::WELL )
if ( contentType == RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_WELL )
{
adr.setWellName( objectName );
adr.setWellName( token );
}
else if ( contentType == RimSummaryAddressCollection::CollectionContentType::GROUP )
else if ( contentType == RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_GROUP )
{
adr.setGroupName( objectName );
adr.setGroupName( token );
}
else if ( contentType == RimSummaryAddressCollection::CollectionContentType::REGION )
else if ( contentType == RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_NETWORK )
{
int intValue = RiaStdStringTools::toInt( objectName );
if ( intValue == -1 )
adr.setNetworkName( token );
}
else if ( contentType == RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_REGION )
{
int intValue = -1;
if ( !RiaStdStringTools::toInt( token, intValue ) )
{
QString errorText = QString( "Failed to convert region text to region integer value "
"for region text : %1" )
.arg( QString::fromStdString( objectName ) );
.arg( QString::fromStdString( token ) );

RiaLogging::error( errorText );
}
Expand All @@ -60,6 +64,38 @@ RifEclipseSummaryAddress RimSummaryAddressModifier::replaceObjectName( const Rif
adr.setRegion( intValue );
}
}
else if ( contentType == RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_REGION_2_REGION )
{
int intValue = -1;
if ( !RiaStdStringTools::toInt( token, intValue ) )
{
QString errorText = QString( "Failed to convert region text to region integer value "
"for region text : %1" )
.arg( QString::fromStdString( token ) );

RiaLogging::error( errorText );
}
else
{
adr.setRegion2( intValue );
}
}
else if ( contentType == RifEclipseSummaryAddressDefines::SummaryCategory::SUMMARY_AQUIFER )
{
int intValue = -1;
if ( !RiaStdStringTools::toInt( token, intValue ) )
{
QString errorText = QString( "Failed to convert aquifer text to aquifer integer value "
"for aquifer text : %1" )
.arg( QString::fromStdString( token ) );

RiaLogging::error( errorText );
}
else
{
adr.setAquiferNumber( intValue );
}
}

return adr;
}
Expand Down Expand Up @@ -151,18 +187,20 @@ void RimSummaryAddressModifier::updateAddressesByObjectName( const std::vector<C
const std::string& objectName,
RimSummaryAddressCollection::CollectionContentType contentType )
{
auto category = RimSummaryAddressCollection::contentTypeToSummaryCategory( contentType );

for ( auto& provider : curveAddressProviders )
{
std::visit(
[objectName, contentType]( auto&& arg )
[objectName, category]( auto&& arg )
{
const auto sourceAdr = RimSummaryAddressModifier::curveAddress( arg );

const auto sourceX = sourceAdr.summaryAddressX();
const auto sourceY = sourceAdr.summaryAddressY();

const auto newAdrX = RimSummaryAddressModifier::replaceObjectName( sourceX, objectName, contentType );
const auto newAdrY = RimSummaryAddressModifier::replaceObjectName( sourceY, objectName, contentType );
const auto newAdrX = RimSummaryAddressModifier::replaceTokenForCategory( sourceX, objectName, category );
const auto newAdrY = RimSummaryAddressModifier::replaceTokenForCategory( sourceY, objectName, category );

RimSummaryAddressModifier::setCurveAddress( arg, RiaSummaryCurveAddress( newAdrX, newAdrY ) );
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ class RimSummaryAddressModifier
const std::string& objectName,
RimSummaryAddressCollection::CollectionContentType contentType );

static RifEclipseSummaryAddress replaceTokenForCategory( const RifEclipseSummaryAddress& sourceAdr,
const std::string& token,
RifEclipseSummaryAddressDefines::SummaryCategory contentType );

private:
static RiaSummaryCurveAddress curveAddress( RimSummaryCurve* curve );
static RiaSummaryCurveAddress curveAddress( RimEnsembleCurveSet* curveSet );
static void setCurveAddress( RimEnsembleCurveSet* curveSet, const RiaSummaryCurveAddress& curveAdr );
static void setCurveAddress( RimSummaryCurve* curve, const RiaSummaryCurveAddress& curveAdr );
static RifEclipseSummaryAddress replaceObjectName( const RifEclipseSummaryAddress& sourceAdr,
std::string objectName,
RimSummaryAddressCollection::CollectionContentType contentType );
static RiaSummaryCurveAddress curveAddress( RimSummaryCurve* curve );
static RiaSummaryCurveAddress curveAddress( RimEnsembleCurveSet* curveSet );
static void setCurveAddress( RimEnsembleCurveSet* curveSet, const RiaSummaryCurveAddress& curveAdr );
static void setCurveAddress( RimSummaryCurve* curve, const RiaSummaryCurveAddress& curveAdr );
};

0 comments on commit 3faa4ab

Please sign in to comment.