mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 23:50:19 -05:00
#12472 Fix flaky calculation of contour map top value
This commit is contained in:
1 parent
18ba47c2ab
commit
64ec98b6a4
2 files changed
+26
-2
No files matched your search
@@ -57,7 +57,7 @@ void RimContourMapProjection::ResultAggregation::setUp()
|
||||
addItem( RigContourMapCalculator::GEOMETRIC_MEAN, "GEOM_VALUE", "Geometric Mean" );
|
||||
addItem( RigContourMapCalculator::SUM, "SUM", "Sum" );
|
||||
|
||||
addItem( RigContourMapCalculator::TOP_VALUE, "TOP_VALUE", "Top Value" );
|
||||
addItem( RigContourMapCalculator::TOP_VALUE, "TOP_VALUE", "Top Value" );
|
||||
addItem( RigContourMapCalculator::MIN_VALUE, "MIN_VALUE", "Min Value" );
|
||||
addItem( RigContourMapCalculator::MAX_VALUE, "MAX_VALUE", "Max Value" );
|
||||
|
||||
|
||||
@@ -79,14 +79,38 @@ double RigContourMapCalculator::calculateTopValue( const RigContourMapProjection
|
||||
const std::vector<std::pair<size_t, double>>& matchingCells,
|
||||
const std::vector<double>& gridCellValues )
|
||||
{
|
||||
std::vector<size_t> cellIndices;
|
||||
cellIndices.reserve( matchingCells.size() );
|
||||
for ( auto [cellIdx, weight] : matchingCells )
|
||||
{
|
||||
double cellValue = gridCellValues[contourMapProjection.gridResultIndex( cellIdx )];
|
||||
cellIndices.push_back( cellIdx );
|
||||
}
|
||||
|
||||
// Sort the cells based on k layer as first criteria, then on cell index
|
||||
std::sort( cellIndices.begin(),
|
||||
cellIndices.end(),
|
||||
[&]( size_t a, size_t b )
|
||||
{
|
||||
if ( contourMapProjection.kLayer( a ) == contourMapProjection.kLayer( b ) )
|
||||
{
|
||||
return a < b;
|
||||
}
|
||||
return contourMapProjection.kLayer( a ) < contourMapProjection.kLayer( b );
|
||||
} );
|
||||
|
||||
// Find the first cell with a valid value
|
||||
for ( auto cellIdx : cellIndices )
|
||||
{
|
||||
auto gridResultIndex = contourMapProjection.gridResultIndex( cellIdx );
|
||||
if ( gridResultIndex >= gridCellValues.size() ) continue;
|
||||
|
||||
double cellValue = gridCellValues[gridResultIndex];
|
||||
if ( std::abs( cellValue ) != std::numeric_limits<double>::infinity() )
|
||||
{
|
||||
return cellValue;
|
||||
}
|
||||
}
|
||||
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user