Skip to content

Commit 913eab2

Browse files
committed
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.
1 parent 058918a commit 913eab2

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,37 @@ QString Rim3dOverlayInfoConfig::caseInfoText( RimEclipseView* eclipseView )
340340
}
341341
else if ( eclipseView->mainGrid() )
342342
{
343-
QString totCellCount = localeWithSpaceAsGroupSeparator.toString( static_cast<int>( eclipseView->mainGrid()->totalCellCount() ) );
344-
345-
size_t mxActCellCount =
346-
eclipseView->eclipseCase()->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL )->reservoirActiveCellCount();
347-
size_t frActCellCount = eclipseView->eclipseCase()
348-
->eclipseCaseData()
349-
->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL )
350-
->reservoirActiveCellCount();
343+
auto mainGrid = eclipseView->mainGrid();
344+
size_t cellCount = mainGrid->totalCellCount();
345+
if ( mainGrid->isRadial() )
346+
{
347+
cellCount -= mainGrid->totalTemporaryGridCellCount();
348+
}
349+
QString totCellCount = localeWithSpaceAsGroupSeparator.toString( static_cast<int>( cellCount ) );
350+
351+
auto activeCellInfoMatrix =
352+
eclipseView->eclipseCase()->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
353+
auto activeCellInfoFracture =
354+
eclipseView->eclipseCase()->eclipseCaseData()->activeCellInfo( RiaDefines::PorosityModelType::FRACTURE_MODEL );
355+
356+
size_t mxActCellCount = activeCellInfoMatrix->reservoirActiveCellCount();
357+
size_t frActCellCount = activeCellInfoFracture->reservoirActiveCellCount();
358+
359+
if ( mainGrid->isRadial() )
360+
{
361+
// Exclude active cells from temporary grids
362+
for ( size_t i = 0; i < mainGrid->gridCount(); i++ )
363+
{
364+
if ( mainGrid->gridByIndex( i )->isTempGrid() )
365+
{
366+
size_t mxTempCount = activeCellInfoMatrix->gridActiveCellCounts( i );
367+
size_t frTempCount = activeCellInfoFracture->gridActiveCellCounts( i );
368+
369+
if ( mxTempCount != cvf::UNDEFINED_SIZE_T ) mxActCellCount -= mxTempCount;
370+
if ( frTempCount != cvf::UNDEFINED_SIZE_T ) frActCellCount -= frTempCount;
371+
}
372+
}
373+
}
351374

352375
QString activeCellCountText;
353376
if ( frActCellCount > 0 ) activeCellCountText += "Matrix : ";

ApplicationLibCode/ReservoirDataModel/RigActiveCellInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ const RigBoundingBoxIjk<caf::VecIjk0>& RigActiveCellInfo::ijkBoundingBox() const
155155
//--------------------------------------------------------------------------------------------------
156156
size_t RigActiveCellInfo::gridActiveCellCounts( size_t gridIndex ) const
157157
{
158+
if ( gridIndex >= m_perGridActiveCellInfo.size() ) return 0;
159+
158160
return m_perGridActiveCellInfo[gridIndex].activeCellCount();
159161
}
160162

0 commit comments

Comments
 (0)