mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
Exclude inactive cells from contour map calculations
* Adds safety check for value index * Filters inactive cells from contour map calculation
This commit is contained in:
@@ -240,7 +240,12 @@ double RigContourMapCalculator::calculateSum( const RigContourMapProjection&
|
||||
double sum = 0.0;
|
||||
for ( auto [cellIdx, weight] : matchingCells )
|
||||
{
|
||||
double cellValue = gridCellValues[contourMapProjection.gridResultIndex( cellIdx )];
|
||||
const auto valueIndex = contourMapProjection.gridResultIndex( cellIdx );
|
||||
|
||||
// Safety check, should not happen
|
||||
if ( valueIndex >= gridCellValues.size() ) continue;
|
||||
|
||||
const double cellValue = gridCellValues[valueIndex];
|
||||
if ( std::abs( cellValue ) != std::numeric_limits<double>::infinity() )
|
||||
{
|
||||
sum += cellValue * weight;
|
||||
@@ -422,6 +427,8 @@ std::vector<RigContourMapCalculator::CellIndexAndResult>
|
||||
auto cellGridIdxVisibility = contourMapProjection.getCellVisibility();
|
||||
for ( size_t globalCellIdx : allCellIndices )
|
||||
{
|
||||
if ( !contourMapProjection.isCellActive( globalCellIdx ) ) continue;
|
||||
|
||||
if ( cellGridIdxVisibility.isNull() || ( *cellGridIdxVisibility )[globalCellIdx] )
|
||||
{
|
||||
auto k = contourMapProjection.kLayer( globalCellIdx );
|
||||
|
||||
@@ -417,6 +417,29 @@ double RigContourMapProjection::calculateValueAtVertex( unsigned int vi, unsigne
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigContourMapProjection::contourMapCellContainsOnlyInactiveCells( unsigned int i, unsigned int j ) const
|
||||
{
|
||||
const std::vector<CellIndexAndResult>& matchingCells = cellsAtIJ( i, j );
|
||||
|
||||
if ( matchingCells.empty() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for ( const auto& cellResult : matchingCells )
|
||||
{
|
||||
if ( isCellActive( cellResult.first ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -84,6 +84,7 @@ public:
|
||||
virtual double calculateRayLengthInCell( size_t globalCellIdx, const cvf::Vec3d& highestPoint, const cvf::Vec3d& lowestPoint ) const = 0;
|
||||
virtual double getParameterWeightForCell( size_t globalCellIdx, const std::vector<double>& parameterWeights ) const = 0;
|
||||
virtual std::vector<bool> getMapCellVisibility( int viewStepIndex, RigContourMapCalculator::ResultAggregationType resultAggregation ) = 0;
|
||||
virtual bool isCellActive( size_t globalCellIdx ) const = 0;
|
||||
|
||||
void setCellVisibility( cvf::ref<cvf::UByteArray> cellVisibility );
|
||||
cvf::ref<cvf::UByteArray> getCellVisibility() const;
|
||||
@@ -116,6 +117,7 @@ protected:
|
||||
double valueInCell( unsigned int i, unsigned int j ) const;
|
||||
bool hasResultInCell( unsigned int i, unsigned int j ) const;
|
||||
double calculateValueAtVertex( unsigned int i, unsigned int j ) const;
|
||||
bool contourMapCellContainsOnlyInactiveCells( unsigned int i, unsigned int j ) const;
|
||||
|
||||
protected:
|
||||
cvf::ref<cvf::UByteArray> m_cellGridIdxVisibility;
|
||||
|
||||
@@ -325,6 +325,19 @@ size_t RigEclipseContourMapProjection::gridResultIndex( size_t globalCellIdx ) c
|
||||
return globalCellIdx;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigEclipseContourMapProjection::isCellActive( size_t globalCellIdx ) const
|
||||
{
|
||||
if ( m_useActiveCellInfo && m_activeCellInfo.notNull() )
|
||||
{
|
||||
return m_activeCellInfo->isActive( globalCellIdx );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -65,6 +65,7 @@ public:
|
||||
RigFloodingSettings& floodingSettings );
|
||||
|
||||
std::vector<bool> getMapCellVisibility( int viewStepIndex, RigContourMapCalculator::ResultAggregationType resultAggregation ) override;
|
||||
bool isCellActive( size_t globalCellIdx ) const override;
|
||||
|
||||
protected:
|
||||
using CellIndexAndResult = RigContourMapProjection::CellIndexAndResult;
|
||||
|
||||
@@ -381,3 +381,12 @@ std::vector<double> RigGeoMechContourMapProjection::gridCellValues( RigFemResult
|
||||
}
|
||||
return gridCellValues;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigGeoMechContourMapProjection::isCellActive( size_t globalCellIdx ) const
|
||||
{
|
||||
// For GeoMech grids, all cells are considered active
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
int viewStepIndex,
|
||||
RigContourMapCalculator::ResultAggregationType resultAggregation );
|
||||
|
||||
bool isCellActive( size_t globalCellIdx ) const override;
|
||||
|
||||
protected:
|
||||
// GeoMech implementation specific data generation methods
|
||||
std::vector<size_t> findIntersectingCells( const cvf::BoundingBox& bbox ) const override;
|
||||
|
||||
@@ -139,3 +139,12 @@ std::vector<std::pair<size_t, double>> RigStatisticsContourMapProjection::cellsA
|
||||
|
||||
return std::vector<std::pair<size_t, double>>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigStatisticsContourMapProjection::isCellActive( size_t globalCellIdx ) const
|
||||
{
|
||||
// For statistics projections, all cells are considered active
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
const std::vector<std::vector<cvf::Vec3d>>& limitToPolygons ) override;
|
||||
|
||||
std::vector<bool> getMapCellVisibility( int viewStepIndex, RigContourMapCalculator::ResultAggregationType resultAggregation ) override;
|
||||
bool isCellActive( size_t globalCellIdx ) const override;
|
||||
|
||||
protected:
|
||||
using CellIndexAndResult = RigContourMapProjection::CellIndexAndResult;
|
||||
|
||||
Reference in New Issue
Block a user