mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#9833: Add extra check based on value/cells count
Some models do not have the dual porosity flag set correctly. Add additional check to set the dual porosity flag if the number of active cells is the double of main grid cell count.
This commit is contained in:
parent
2e6268ff0a
commit
de118ddae2
@ -53,7 +53,8 @@ std::vector<std::vector<int>> RifActiveCellsReader::activeCellsFromActnumKeyword
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::vector<int>> RifActiveCellsReader::activeCellsFromPorvKeyword( const ecl_file_type* ecl_file,
|
||||
bool dualPorosity )
|
||||
bool dualPorosity,
|
||||
const int cellCountMainGrid )
|
||||
{
|
||||
CAF_ASSERT( ecl_file );
|
||||
|
||||
@ -64,19 +65,27 @@ std::vector<std::vector<int>> RifActiveCellsReader::activeCellsFromPorvKeyword(
|
||||
//
|
||||
// See documentation of active cells in top of ecl_grid.cpp
|
||||
|
||||
bool divideCellCountByTwo = dualPorosity;
|
||||
|
||||
int porvKeywordCount = ecl_file_get_num_named_kw( ecl_file, PORV_KW );
|
||||
for ( size_t gridIdx = 0; gridIdx < static_cast<size_t>( porvKeywordCount ); gridIdx++ )
|
||||
{
|
||||
std::vector<double> porvValues;
|
||||
RifEclipseOutputFileTools::keywordData( ecl_file, PORV_KW, gridIdx, &porvValues );
|
||||
|
||||
std::vector<int> activeCellsOneGrid;
|
||||
|
||||
size_t activeCellCount = porvValues.size();
|
||||
if ( dualPorosity )
|
||||
|
||||
// For some cases, the dual porosity flag is not interpreted correctly. Add a fallback by checking the number of
|
||||
// cells in the main grid
|
||||
// https://github.com/OPM/ResInsight/issues/9833
|
||||
if ( ( gridIdx == 0 ) && ( activeCellCount == cellCountMainGrid * 2 ) ) divideCellCountByTwo = true;
|
||||
|
||||
if ( divideCellCountByTwo )
|
||||
{
|
||||
activeCellCount /= 2;
|
||||
}
|
||||
|
||||
std::vector<int> activeCellsOneGrid;
|
||||
activeCellsOneGrid.resize( activeCellCount, 0 );
|
||||
|
||||
for ( size_t poreValueIndex = 0; poreValueIndex < porvValues.size(); poreValueIndex++ )
|
||||
@ -129,10 +138,10 @@ void RifActiveCellsReader::applyActiveCellsToAllGrids( ecl_grid_type*
|
||||
currentGrid = ecl_grid_iget_lgr( ecl_main_grid, gridIndex - 1 );
|
||||
}
|
||||
|
||||
auto activeCellsForGrid = activeCellsForAllGrids[gridIndex];
|
||||
const auto& activeCellsForGrid = activeCellsForAllGrids[gridIndex];
|
||||
CAF_ASSERT( ecl_grid_get_global_size( currentGrid ) == static_cast<int>( activeCellsForGrid.size() ) );
|
||||
|
||||
int* actnum_values = activeCellsForGrid.data();
|
||||
auto actnum_values = activeCellsForGrid.data();
|
||||
|
||||
ecl_grid_reset_actnum( currentGrid, actnum_values );
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ class RifActiveCellsReader
|
||||
public:
|
||||
static std::vector<std::vector<int>> activeCellsFromActnumKeyword( const ecl_file_type* ecl_file );
|
||||
|
||||
static std::vector<std::vector<int>> activeCellsFromPorvKeyword( const ecl_file_type* ecl_file, bool dualPorosity );
|
||||
static std::vector<std::vector<int>>
|
||||
activeCellsFromPorvKeyword( const ecl_file_type* ecl_file, bool dualPorosity, const int cellCountMainGrid );
|
||||
|
||||
static void applyActiveCellsToAllGrids( ecl_grid_type* ecl_main_grid,
|
||||
const std::vector<std::vector<int>>& activeCellsForAllGrids );
|
||||
|
@ -840,8 +840,10 @@ bool RifReaderEclipseOutput::readActiveCellInfo()
|
||||
ecl_file_open( RiaStringEncodingTools::toNativeEncoded( initFileName ).data(), ECL_FILE_CLOSE_STREAM );
|
||||
if ( ecl_file )
|
||||
{
|
||||
bool isDualPorosity = m_eclipseCase->mainGrid()->isDualPorosity();
|
||||
actnumValuesPerGrid = RifActiveCellsReader::activeCellsFromPorvKeyword( ecl_file, isDualPorosity );
|
||||
bool isDualPorosity = m_eclipseCase->mainGrid()->isDualPorosity();
|
||||
int cellCountMainGrid = static_cast<int>( m_eclipseCase->mainGrid()->cellCount() );
|
||||
actnumValuesPerGrid =
|
||||
RifActiveCellsReader::activeCellsFromPorvKeyword( ecl_file, isDualPorosity, cellCountMainGrid );
|
||||
ecl_file_close( ecl_file );
|
||||
}
|
||||
}
|
||||
@ -2330,8 +2332,10 @@ ecl_grid_type* RifReaderEclipseOutput::loadAllGrids() const
|
||||
// TODO : ecl_grid_alloc() will automatically read ACTNUM from EGRID file, and reading of active cell
|
||||
// information can be skipped if PORV is available
|
||||
|
||||
bool isDualPorosity = ecl_grid_dual_grid( mainEclGrid );
|
||||
auto activeCells = RifActiveCellsReader::activeCellsFromPorvKeyword( m_ecl_init_file, isDualPorosity );
|
||||
bool isDualPorosity = ecl_grid_dual_grid( mainEclGrid );
|
||||
auto cellCountMainGrid = ecl_grid_get_global_size( mainEclGrid );
|
||||
auto activeCells =
|
||||
RifActiveCellsReader::activeCellsFromPorvKeyword( m_ecl_init_file, isDualPorosity, cellCountMainGrid );
|
||||
|
||||
if ( !activeCells.empty() )
|
||||
{
|
||||
|
@ -65,7 +65,8 @@ TEST( RifActiveCellsReaderTest, BasicTest10k )
|
||||
ecl_file_type* initFile =
|
||||
ecl_file_open( RiaStringEncodingTools::toNativeEncoded( filePath ).data(), ECL_FILE_CLOSE_STREAM );
|
||||
|
||||
activeCellsFromPorv = RifActiveCellsReader::activeCellsFromPorvKeyword( initFile, false );
|
||||
int cellCountMainGrid = 0;
|
||||
activeCellsFromPorv = RifActiveCellsReader::activeCellsFromPorvKeyword( initFile, false, cellCountMainGrid );
|
||||
EXPECT_EQ( 2, (int)activeCellsFromPorv.size() );
|
||||
|
||||
ecl_file_close( initFile );
|
||||
|
Loading…
Reference in New Issue
Block a user