mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -05:00
#14903: Ignore empty restart files in opm-common reader
This commit is contained in:
1 parent
bdd10d5988
commit
ec9135b658
2 files changed
+30
-1
No files matched your search
@@ -911,6 +911,9 @@ void RifReaderOpmCommon::setupInitAndRestartAccess()
|
||||
|
||||
m_restartFile = std::make_unique<EclIO::ERst>( m_restartFileName );
|
||||
|
||||
// An empty restart file, e.g. while the simulation is starting, reports step 0 without any arrays
|
||||
if ( m_restartFile->size() == 0 ) m_restartFile = nullptr;
|
||||
|
||||
const bool isLoggingEnabled = RiaPreferencesSystem::current()->isLoggingActivatedForKeyword( "RifReaderOpmCommon" );
|
||||
if ( isLoggingEnabled ) RiaLogging::logElapsedTime( "Import of meta data from " + m_restartFileName, startTime );
|
||||
}
|
||||
@@ -1096,7 +1099,7 @@ void RifReaderOpmCommon::buildMetaData( RigEclipseCaseData* eclipseCaseData, caf
|
||||
}
|
||||
|
||||
auto task = progress.task( "Handling well information", 10 );
|
||||
if ( loadWellDataEnabled() && !m_restartFileName.empty() )
|
||||
if ( loadWellDataEnabled() && m_restartFile != nullptr )
|
||||
{
|
||||
auto startTime = RiaLogging::currentTime();
|
||||
|
||||
|
||||
@@ -23,8 +23,13 @@
|
||||
#include "RiaEclipseUnitTools.h"
|
||||
#include "RiaTestDataDirectory.h"
|
||||
|
||||
#include "RigEclipseCaseData.h"
|
||||
|
||||
#include "opm/io/eclipse/ERst.hpp"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
#include <filesystem>
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -91,3 +96,24 @@ TEST( RifReaderOpmCommon, RestartDataSize )
|
||||
EXPECT_EQ( 0, RifReaderOpmCommon::restartDataSize( restartFile, "XXXX", reportStep ) );
|
||||
EXPECT_THROW( RifReaderOpmCommon::restartDataSize( restartFile, "PRESSURE", 99 ), std::invalid_argument );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RifReaderOpmCommon, EmptyRestartFile )
|
||||
{
|
||||
QTemporaryDir tempDir;
|
||||
ASSERT_TRUE( tempDir.isValid() );
|
||||
|
||||
const QString sourceGrid = QString( TEST_MODEL_DIR ) + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID";
|
||||
const QString gridFile = tempDir.filePath( "EMPTY_RESTART.EGRID" );
|
||||
ASSERT_TRUE( QFile::copy( sourceGrid, gridFile ) );
|
||||
|
||||
QFile restartFile( tempDir.filePath( "EMPTY_RESTART.UNRST" ) );
|
||||
ASSERT_TRUE( restartFile.open( QIODevice::WriteOnly ) );
|
||||
restartFile.close();
|
||||
|
||||
cvf::ref<RigEclipseCaseData> caseData = new RigEclipseCaseData( nullptr );
|
||||
cvf::ref<RifReaderOpmCommon> reader = new RifReaderOpmCommon;
|
||||
EXPECT_TRUE( reader->open( gridFile, caseData.p() ) );
|
||||
}
|
||||
Reference in new issue
Block a user