Simplify some code with C++17

This commit is contained in:
Gaute Lindkvist 2020-09-24 15:51:59 +02:00
parent 6220ff160c
commit b1d9d17ddb
9 changed files with 22 additions and 42 deletions

View File

@ -1677,11 +1677,8 @@ void RicWellPathExportMswCompletionsImpl::writeMainBoreWelsegsSegment( std::shar
prevOutTVD = previousSegment->outputTVD();
}
for ( auto mdPair : subSegments )
for ( const auto& [subStartMD, subEndMD] : subSegments )
{
double subStartMD = mdPair.first;
double subEndMD = mdPair.second;
auto startPoint = exportInfo.wellPath()->wellPathGeometry()->interpolatedPointAlongWellPath( subStartMD );
auto endPoint = exportInfo.wellPath()->wellPathGeometry()->interpolatedPointAlongWellPath( subEndMD );
@ -1749,13 +1746,10 @@ void RicWellPathExportMswCompletionsImpl::writeValveWelsegsSegment( std::shared_
std::vector<std::pair<double, double>> splitSegments = createSubSegmentMDPairs( startMD, endMD, maxSegmentLength );
for ( auto mdPair : splitSegments )
for ( const auto& [subStartMD, subEndMD] : splitSegments )
{
int subSegmentNumber = ( *segmentNumber )++;
double subStartMD = mdPair.first;
double subEndMD = mdPair.second;
auto startPoint = exportInfo.wellPath()->wellPathGeometry()->interpolatedPointAlongWellPath( subStartMD );
auto endPoint = exportInfo.wellPath()->wellPathGeometry()->interpolatedPointAlongWellPath( subEndMD );
@ -1815,13 +1809,10 @@ void RicWellPathExportMswCompletionsImpl::writeCompletionWelsegsSegment( std::sh
std::vector<std::pair<double, double>> splitSegments = createSubSegmentMDPairs( startMD, endMD, maxSegmentLength );
for ( auto mdPair : splitSegments )
for ( const auto& [subStartMD, subEndMD] : splitSegments )
{
int subSegmentNumber = ( *segmentNumber )++;
double subStartMD = mdPair.first;
double subEndMD = mdPair.second;
auto startPoint = exportInfo.wellPath()->wellPathGeometry()->interpolatedPointAlongWellPath( subStartMD );
auto endPoint = exportInfo.wellPath()->wellPathGeometry()->interpolatedPointAlongWellPath( subEndMD );

View File

@ -176,9 +176,9 @@ void RicCreateMultipleFracturesFeature::onActionTriggered( bool isChecked )
{
firstSourceCase = proj->eclipseCases().front();
auto ijkRange = ijkRangeForGrid( firstSourceCase );
int topK = static_cast<int>( ijkRange.first.z() );
int baseK = static_cast<int>( ijkRange.second.z() );
auto [top, base] = ijkRangeForGrid( firstSourceCase );
int topK = static_cast<int>( top.z() );
int baseK = static_cast<int>( base.z() );
double minimumDistanceFromTip = 100.0;
int maxFractureCount = 100;

View File

@ -62,12 +62,7 @@ RicExportContourMapToTextFeature::RicExportContourMapToTextFeature()
//--------------------------------------------------------------------------------------------------
bool RicExportContourMapToTextFeature::isCommandEnabled()
{
RimEclipseContourMapView* existingEclipseContourMap = nullptr;
RimGeoMechContourMapView* existingGeoMechContourMap = nullptr;
auto sourceViews = findContourMapView();
existingEclipseContourMap = sourceViews.first;
existingGeoMechContourMap = sourceViews.second;
auto [existingEclipseContourMap, existingGeoMechContourMap] = findContourMapView();
return existingEclipseContourMap || existingGeoMechContourMap;
}

View File

@ -460,12 +460,12 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult( i
std::map<std::string, std::vector<float>> elementProperties =
m_elementPropertyReader->readAllElementPropertiesInFileContainingField( resVarAddr.fieldName );
for ( std::pair<std::string, std::vector<float>> elem : elementProperties )
for ( auto [addrString, values] : elementProperties )
{
RigFemResultAddress addressForElement( RIG_ELEMENT, elem.first, "" );
RigFemResultAddress addressForElement( RIG_ELEMENT, addrString, "" );
RigFemScalarResultFrames* currentFrames = m_femPartResults[partIndex]->createScalarResult( addressForElement );
currentFrames->enableAsSingleFrameResult();
currentFrames->frameData( 0 ).swap( elem.second );
currentFrames->frameData( 0 ).swap( values );
}
frames = m_femPartResults[partIndex]->findScalarResult( resVarAddr );

View File

@ -1127,9 +1127,9 @@ void RimAnalysisPlot::applyFilter( const RimPlotDataFilterItem* filter,
if ( filter->filterOperation() == RimPlotDataFilterItem::RANGE )
{
std::pair<double, double> minMax = filter->filterRangeMinMax();
auto [min, max] = filter->filterRangeMinMax();
if ( minMax.first <= value && value <= minMax.second )
if ( min <= value && value <= max )
{
casesToKeep.insert( sumCase );
}

View File

@ -304,10 +304,7 @@ cvf::ref<Riv3dWellLogCurveGeometryGenerator> Rim3dWellLogCurve::geometryGenerato
//--------------------------------------------------------------------------------------------------
void Rim3dWellLogCurve::resetMinMaxValues()
{
std::pair<double, double> valueRange = findCurveValueRange();
m_minCurveDataValue = valueRange.first;
m_maxCurveDataValue = valueRange.second;
std::tie( m_minCurveDataValue, m_maxCurveDataValue ) = findCurveValueRange();
m_minCurveUIValue = m_minCurveDataValue;
m_maxCurveUIValue = m_maxCurveDataValue;

View File

@ -466,13 +466,12 @@ double RimContourMapProjection::calculateValueInMapCell( uint i, uint j, const s
case RESULTS_MEAN_VALUE:
{
RiaWeightedMeanCalculator<double> calculator;
for ( auto cellIdxAndWeight : matchingCells )
for ( auto [cellIdx, weight] : matchingCells )
{
size_t cellIdx = cellIdxAndWeight.first;
double cellValue = gridCellValues[cellIdx];
if ( cellValue != std::numeric_limits<double>::infinity() )
{
calculator.addValueAndWeight( cellValue, cellIdxAndWeight.second );
calculator.addValueAndWeight( cellValue, weight );
}
}
if ( calculator.validAggregatedWeight() )
@ -484,9 +483,8 @@ double RimContourMapProjection::calculateValueInMapCell( uint i, uint j, const s
case RESULTS_GEOM_VALUE:
{
RiaWeightedGeometricMeanCalculator calculator;
for ( auto cellIdxAndWeight : matchingCells )
for ( auto [cellIdx, weight] : matchingCells )
{
size_t cellIdx = cellIdxAndWeight.first;
double cellValue = gridCellValues[cellIdx];
if ( cellValue < 1.0e-8 )
{
@ -494,7 +492,7 @@ double RimContourMapProjection::calculateValueInMapCell( uint i, uint j, const s
}
if ( cellValue != std::numeric_limits<double>::infinity() )
{
calculator.addValueAndWeight( cellValue, cellIdxAndWeight.second );
calculator.addValueAndWeight( cellValue, weight );
}
}
if ( calculator.validAggregatedWeight() )

View File

@ -125,9 +125,9 @@ void RimEclipseContourMapProjection::updateLegend()
double minVal = minValue( m_aggregatedResults );
double maxVal = maxValue( m_aggregatedResults );
std::pair<double, double> minmaxValAllTimeSteps = minmaxValuesAllTimeSteps();
auto [minValAllTimeSteps, maxValAllTimeSteps] = minmaxValuesAllTimeSteps();
legendConfig()->setAutomaticRanges( minmaxValAllTimeSteps.first, minmaxValAllTimeSteps.second, minVal, maxVal );
legendConfig()->setAutomaticRanges( minValAllTimeSteps, maxValAllTimeSteps, minVal, maxVal );
if ( m_resultAggregation() == RESULTS_OIL_COLUMN || m_resultAggregation() == RESULTS_GAS_COLUMN ||
m_resultAggregation() == RESULTS_HC_COLUMN )

View File

@ -142,12 +142,11 @@ QList<caf::PdmOptionItemInfo>
if ( curveSet )
{
auto params = curveSet->correlationSortedEnsembleParameters();
for ( const auto& paramCorrPair : params )
for ( const auto& [param, corr] : params )
{
QString name = paramCorrPair.first.name;
double corr = paramCorrPair.second;
options.push_back(
caf::PdmOptionItemInfo( QString( "%1 (Avg. correlation: %2)" ).arg( name ).arg( corr ), name ) );
caf::PdmOptionItemInfo( QString( "%1 (Avg. correlation: %2)" ).arg( param.name ).arg( corr ),
param.name ) );
}
}
}