Incomplete import of Restart data from 6X (#5767)

* #5763 Incomplete import of Restart data from 6X

6X simulator can report multiple keywords per time step. These additional keywords do not contain any data possible to import into ResInsight, but must be used when accessing the correct result keyword based on index in file.
This commit is contained in:
Magne Sjaastad 2020-04-06 12:15:28 +02:00 committed by Gaute Lindkvist
parent d26c736042
commit 42b0c1c357
10 changed files with 68 additions and 9 deletions

View File

@ -122,7 +122,8 @@ void getDayMonthYear( const ecl_kw_type* intehead_kw, int* day, int* month, int*
//--------------------------------------------------------------------------------------------------
void RifEclipseOutputFileTools::timeSteps( const ecl_file_type* ecl_file,
std::vector<QDateTime>* timeSteps,
std::vector<double>* daysSinceSimulationStart )
std::vector<double>* daysSinceSimulationStart,
size_t* perTimeStepHeaderKeywordCount )
{
if ( !ecl_file ) return;
@ -243,6 +244,16 @@ void RifEclipseOutputFileTools::timeSteps( const ecl_file_type* ecl_file,
daysSinceSimulationStart->push_back( dayDoubleValue );
}
}
if ( perTimeStepHeaderKeywordCount )
{
// 6X simulator can report more then one keyword block per time step. Report the total number of keywords per
// time steps to be able to read data from correct index
//
// See https://github.com/OPM/ResInsight/issues/5763
//
*perTimeStepHeaderKeywordCount = numINTEHEAD / timeSteps->size();
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -63,7 +63,8 @@ public:
static void timeSteps( const ecl_file_type* ecl_file,
std::vector<QDateTime>* timeSteps,
std::vector<double>* daysSinceSimulationStart );
std::vector<double>* daysSinceSimulationStart,
size_t* perTimeStepHeaderKeywordCount );
static bool isValidEclipseFileName( const QString& fileName );
static QByteArray md5sum( const QString& fileName );

View File

@ -110,4 +110,6 @@ public:
virtual int readUnitsType() = 0;
virtual std::set<RiaDefines::PhaseType> availablePhases() const = 0;
virtual void updateFromGridCount( size_t gridCount ){};
};

View File

@ -136,7 +136,8 @@ void RifEclipseRestartFilesetAccess::timeSteps( std::vector<QDateTime>* timeStep
openTimeStep( i );
RifEclipseOutputFileTools::timeSteps( m_ecl_files[i], &stepTime, &stepDays );
size_t perTimeStepEmptyKeywords = 0;
RifEclipseOutputFileTools::timeSteps( m_ecl_files[i], &stepTime, &stepDays, &perTimeStepEmptyKeywords );
if ( stepTime.size() == 1 )
{
@ -196,13 +197,16 @@ bool RifEclipseRestartFilesetAccess::results( const QString& resultName,
if ( fileGridCount == 0 ) return true;
// Result handling depends on presents of result values for all grids
if ( gridCount != fileGridCount )
if ( fileGridCount < gridCount )
{
return false;
}
size_t i;
for ( i = 0; i < fileGridCount; i++ )
// NB : 6X simulator can report multiple keywords for one time step. The additional keywords do not contain and
// data imported by ResInsight. We read all blocks of data, also empty to simplify the logic.
// See https://github.com/OPM/ResInsight/issues/5763
for ( size_t i = 0; i < fileGridCount; i++ )
{
std::vector<double> gridValues;

View File

@ -43,8 +43,10 @@
//--------------------------------------------------------------------------------------------------
RifEclipseUnifiedRestartFileAccess::RifEclipseUnifiedRestartFileAccess()
: RifEclipseRestartDataAccess()
, m_ecl_file( nullptr )
, m_perTimeStepHeaderCount( 0 )
, m_noDataGridCount( 0 )
{
m_ecl_file = nullptr;
}
//--------------------------------------------------------------------------------------------------
@ -163,7 +165,7 @@ void RifEclipseUnifiedRestartFileAccess::extractTimestepsFromEclipse()
if ( openFile() )
{
RifEclipseOutputFileTools::timeSteps( m_ecl_file, &m_timeSteps, &m_daysSinceSimulationStart );
RifEclipseOutputFileTools::timeSteps( m_ecl_file, &m_timeSteps, &m_daysSinceSimulationStart, &m_perTimeStepHeaderCount );
// Taken from well_info_add_UNRST_wells
@ -256,7 +258,7 @@ bool RifEclipseUnifiedRestartFileAccess::results( const QString& resultNam
for ( size_t i = 0; i < gridCount; i++ )
{
ecl_file_select_block( m_ecl_file, INTEHEAD_KW, static_cast<int>( timeStep * gridCount + i ) );
ecl_file_select_block( m_ecl_file, INTEHEAD_KW, static_cast<int>( timeStep * ( gridCount + m_noDataGridCount ) + i ) );
int namedKeywordCount = ecl_file_get_num_named_kw( m_ecl_file, resultName.toLatin1().data() );
for ( int iOcc = 0; iOcc < namedKeywordCount; iOcc++ )
@ -340,6 +342,21 @@ std::set<RiaDefines::PhaseType> RifEclipseUnifiedRestartFileAccess::availablePha
return m_availablePhases;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseUnifiedRestartFileAccess::updateFromGridCount( size_t gridCount )
{
if ( m_perTimeStepHeaderCount > gridCount )
{
// 6x simulator can report multiple keywords per time step. Use the keyword count to
// find correct index in the restart file
// https://github.com/OPM/ResInsight/issues/5763
//
m_noDataGridCount = m_perTimeStepHeaderCount - gridCount;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -61,6 +61,8 @@ public:
std::set<RiaDefines::PhaseType> availablePhases() const override;
void updateFromGridCount( size_t gridCount ) override;
private:
bool openFile();
bool useResultIndexFile() const;
@ -69,6 +71,8 @@ private:
private:
QString m_filename;
ecl_file_type* m_ecl_file;
size_t m_perTimeStepHeaderCount;
size_t m_noDataGridCount;
std::vector<QDateTime> m_timeSteps;
std::vector<double> m_daysSinceSimulationStart;

View File

@ -2343,6 +2343,17 @@ ecl_grid_type* RifReaderEclipseOutput::loadAllGrids() const
return mainEclGrid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::updateFromGridCount( size_t gridCount )
{
if ( m_dynamicResultsAccess.notNull() )
{
m_dynamicResultsAccess->updateFromGridCount( gridCount );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -97,6 +97,8 @@ public:
//
ecl_grid_type* loadAllGrids() const;
void updateFromGridCount( size_t gridCount ) override;
private:
bool readActiveCellInfo();
void buildMetaData( ecl_grid_type* grid );

View File

@ -69,6 +69,8 @@ public:
virtual std::set<RiaDefines::PhaseType> availablePhases() const;
virtual void updateFromGridCount( size_t gridCount ){};
protected:
bool isTimeStepIncludedByFilter( size_t timeStepIndex ) const;
size_t timeStepIndexOnFile( size_t timeStepIndex ) const;

View File

@ -2802,6 +2802,11 @@ void RigCaseCellResultsData::computeMobilePV()
void RigCaseCellResultsData::setReaderInterface( RifReaderInterface* readerInterface )
{
m_readerInterface = readerInterface;
if ( m_ownerMainGrid )
{
m_readerInterface->updateFromGridCount( m_ownerMainGrid->gridCount() );
}
}
//--------------------------------------------------------------------------------------------------