Update cell count logic for radial grids and add bounds check

Refined total and active cell count calculations in Rim3dOverlayInfoConfig to exclude temporary grid cells for radial grids, ensuring overlay info is accurate. Added a bounds check in RigActiveCellInfo::gridActiveCellCounts to prevent out-of-range access.
This commit is contained in:
Magne Sjaastad committed 2026-02-03 20:14:12 +01:00
1 parent 058918a85e
commit 913eab2065
2 files changed
+32 -7

No files matched your search

@@ -340,14 +340,37 @@ QString Rim3dOverlayInfoConfig::caseInfoText( RimEclipseView* eclipseView )
}
else if ( eclipseView->mainGrid() )
{
QString totCellCount = localeWithSpaceAsGroupSeparator.toString( static_cast<int>( eclipseView->mainGrid()->totalCellCount() ) );
auto mainGrid = eclipseView->mainGrid();
size_t cellCount = mainGrid->totalCellCount();
if ( mainGrid->isRadial() )
{
cellCount -= mainGrid->totalTemporaryGridCellCount();
}
QString totCellCount = localeWithSpaceAsGroupSeparator.toString( static_cast<int>( cellCount ) );
size_t mxActCellCount =
eclipseView->eclipseCase()->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL )->reservoirActiveCellCount();
size_t frActCellCount = eclipseView->eclipseCase()
->eclipseCaseData()
->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL )
->reservoirActiveCellCount();
auto activeCellInfoMatrix =
eclipseView->eclipseCase()->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
auto activeCellInfoFracture =
eclipseView->eclipseCase()->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL );
size_t mxActCellCount = activeCellInfoMatrix->reservoirActiveCellCount();
size_t frActCellCount = activeCellInfoFracture->reservoirActiveCellCount();
if ( mainGrid->isRadial() )
{
// Exclude active cells from temporary grids
for ( size_t i = 0; i < mainGrid->gridCount(); i++ )
{
if ( mainGrid->gridByIndex( i )->isTempGrid() )
{
size_t mxTempCount = activeCellInfoMatrix->gridActiveCellCounts( i );
size_t frTempCount = activeCellInfoFracture->gridActiveCellCounts( i );
if ( mxTempCount != cvf::UNDEFINED_SIZE_T ) mxActCellCount -= mxTempCount;
if ( frTempCount != cvf::UNDEFINED_SIZE_T ) frActCellCount -= frTempCount;
}
}
}
QString activeCellCountText;
if ( frActCellCount > 0 ) activeCellCountText += "Matrix : ";
@@ -155,6 +155,8 @@ const RigBoundingBoxIjk<caf::VecIjk0>& RigActiveCellInfo::ijkBoundingBox() const
//--------------------------------------------------------------------------------------------------
size_t RigActiveCellInfo::gridActiveCellCounts( size_t gridIndex ) const
{
if ( gridIndex >= m_perGridActiveCellInfo.size() ) return 0;
return m_perGridActiveCellInfo[gridIndex].activeCellCount();
}