Nested hybrid grid: reject active-cell-only grids and fix setCellResultIndex assert

Active-cell grids report a fixed total cell count, so appended LGR cells overflowed the active cell info array. Return an error instead, and assert on the reservoir cell index.
This commit is contained in:
Magne Sjaastad authored and Kristian Bendiksen committed 2026-10-15 13:21:55 +02:00
1 parent bcfa6e9fea
commit 5d0c011779
2 files changed
+11 -2

No files matched your search

@@ -76,7 +76,7 @@ ActiveCellIndex RigActiveCellInfo::cellResultIndex( ReservoirCellIndex reservoir
//--------------------------------------------------------------------------------------------------
void RigActiveCellInfo::setCellResultIndex( ReservoirCellIndex reservoirCellIndex, ActiveCellIndex reservoirCellResultIndex )
{
CAF_ASSERT( reservoirCellResultIndex.value() < m_reservoirCellToActiveCell.size() );
CAF_ASSERT( reservoirCellIndex.value() < m_reservoirCellToActiveCell.size() );
m_reservoirCellToActiveCell[reservoirCellIndex.value()] = reservoirCellResultIndex;
}
@@ -20,6 +20,7 @@
#include "RiaLogging.h"
#include "RigActiveCellGrid.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "RigCell.h"
@@ -70,7 +71,15 @@ bool RigNestedHybridGridReconstructor::reconstruct( RigEclipseCaseData* caseData
if ( !caseData || !caseData->mainGrid() ) return setError( "No grid data." );
RigMainGrid* grid = caseData->mainGrid();
RigMainGrid* grid = caseData->mainGrid();
// Active-cell-only grids keep cells in a sparse map and report a fixed total cell count, so
// appending LGR cells is not supported and would write out of bounds.
if ( dynamic_cast<RigActiveCellGrid*>( grid ) )
{
return setError( "Reconstruction is not supported for grids with only active cells loaded." );
}
const size_t cellCount = grid->cellCount();
if ( input.refine.size() != cellCount )