mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00:17 -05:00
Do not read NNC geometry out of bounds on INIT and grid file mismatch
transferStaticNNCData() takes the connection count from the INIT file using ecl_nnc_data_get_size(), but iterates the geometry from the grid file using ecl_nnc_geometry_iget(). The two counts were only compared in an assert, which is compiled out in release builds, so an INIT file out of sync with the grid reads past the end of the geometry vector inside resdata. Compare the counts at run time, log a warning and iterate the smaller of the two. Both nncConnections and transmissibilityValuesTemp are filled in the same loop and stay aligned.
This commit is contained in:
1 parent
240df658ee
commit
55fb8105e2
1 file changed
+13
-1
@@ -62,6 +62,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
@@ -719,7 +720,18 @@ void RifReaderEclipseOutput::transferStaticNNCData( const ecl_grid_type* mainEcl
|
||||
{
|
||||
int numNNC = ecl_nnc_data_get_size( tran_data );
|
||||
int geometrySize = ecl_nnc_geometry_size( nnc_geo );
|
||||
CAF_ASSERT( numNNC == geometrySize );
|
||||
|
||||
if ( numNNC != geometrySize )
|
||||
{
|
||||
// The transmissibility data is read from the INIT file, the geometry from the grid file. If the two files are out of
|
||||
// sync, iterating the geometry using the data count reads out of bounds. Use the smallest count.
|
||||
RiaLogging::warning( std::format( "NNC data count ({}) does not match NNC geometry count ({}), importing {} connections.",
|
||||
numNNC,
|
||||
geometrySize,
|
||||
std::min( numNNC, geometrySize ) ) );
|
||||
|
||||
numNNC = std::min( numNNC, geometrySize );
|
||||
}
|
||||
|
||||
if ( numNNC > 0 )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user