mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
#7912 Summary Data Import : Update selected opm-common files
This commit is contained in:
@@ -21,10 +21,12 @@
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "opm/io/eclipse/ESmry.hpp"
|
||||
#include "opm/io/eclipse/ExtESmry.hpp"
|
||||
|
||||
#ifdef USE_OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
#include "QFileInfo"
|
||||
|
||||
size_t RifOpmCommonEclipseSummary::sm_createdLodFileCount = 0;
|
||||
|
||||
@@ -83,26 +85,34 @@ bool RifOpmCommonEclipseSummary::open( const QString& headerFileName,
|
||||
bool includeRestartFiles,
|
||||
RiaThreadSafeLogger* threadSafeLogger )
|
||||
{
|
||||
if ( !openESmryFile( headerFileName, includeRestartFiles, threadSafeLogger ) ) return false;
|
||||
|
||||
if ( m_createLodsmryFiles && !includeRestartFiles )
|
||||
if ( m_createLodsmryFiles )
|
||||
{
|
||||
// Create the lodsmry file, no-op if already present.
|
||||
bool hasFileBeenCreated = m_eSmry->make_lodsmry_file();
|
||||
|
||||
if ( hasFileBeenCreated )
|
||||
auto candidateFileName = extendedSummaryFilename( headerFileName );
|
||||
if ( !QFileInfo::exists( candidateFileName ) )
|
||||
{
|
||||
RifOpmCommonEclipseSummary::increaseLodFileCount();
|
||||
try
|
||||
{
|
||||
auto temporarySummaryFile =
|
||||
std::make_unique<Opm::EclIO::ESmry>(headerFileName.toStdString(), includeRestartFiles );
|
||||
|
||||
// If a LODSMRY file has been created, all data for all vectors has now been loaded into the summary file
|
||||
// object. Close the file object to make sure allocated data is released, and create a new file object
|
||||
// that will import only the meta data and no curve data. This is a relatively fast operation.
|
||||
temporarySummaryFile->make_esmry_file();
|
||||
|
||||
if ( !openESmryFile( headerFileName, includeRestartFiles, threadSafeLogger ) ) return false;
|
||||
RifOpmCommonEclipseSummary::increaseLodFileCount();
|
||||
}
|
||||
catch ( std::exception& e )
|
||||
{
|
||||
QString txt = QString( "Failed to create optimized summary file. Error text : %1" ).arg( e.what() );
|
||||
|
||||
if ( threadSafeLogger ) threadSafeLogger->error( txt );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !m_eSmry ) return false;
|
||||
if ( !openESmryFile( headerFileName, includeRestartFiles, threadSafeLogger ) ) return false;
|
||||
|
||||
if ( !m_eSmry && !m_exteSmry ) return false;
|
||||
|
||||
buildMetaData();
|
||||
|
||||
@@ -122,6 +132,20 @@ const std::vector<time_t>& RifOpmCommonEclipseSummary::timeSteps( const RifEclip
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifOpmCommonEclipseSummary::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
{
|
||||
if ( m_exteSmry )
|
||||
{
|
||||
auto it = m_adrToSummaryNodeIndex.find( resultAddress );
|
||||
if ( it != m_adrToSummaryNodeIndex.end() )
|
||||
{
|
||||
// auto index = it->second;
|
||||
// auto node = m_exteSmry->summaryNodeList()[index];
|
||||
// auto fileValues = m_exteSmry->get( node );
|
||||
// values->insert( values->begin(), fileValues.begin(), fileValues.end() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( m_eSmry )
|
||||
{
|
||||
auto it = m_adrToSummaryNodeIndex.find( resultAddress );
|
||||
@@ -195,10 +219,24 @@ bool RifOpmCommonEclipseSummary::openESmryFile( const QString& headerFileN
|
||||
bool includeRestartFiles,
|
||||
RiaThreadSafeLogger* threadSafeLogger )
|
||||
{
|
||||
if ( m_useLodsmryFiles )
|
||||
{
|
||||
try
|
||||
{
|
||||
auto candidateFileName = extendedSummaryFilename( headerFileName );
|
||||
m_exteSmry = std::make_unique<Opm::EclIO::ExtESmry>( candidateFileName.toStdString(), includeRestartFiles );
|
||||
|
||||
return true;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
// Do not do anything here, try to open the file using standard esmy reader
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
m_eSmry =
|
||||
std::make_unique<Opm::EclIO::ESmry>( headerFileName.toStdString(), includeRestartFiles, m_useLodsmryFiles );
|
||||
m_eSmry = std::make_unique<Opm::EclIO::ESmry>( headerFileName.toStdString(), includeRestartFiles );
|
||||
}
|
||||
catch ( std::exception& e )
|
||||
{
|
||||
@@ -222,6 +260,15 @@ void RifOpmCommonEclipseSummary::increaseLodFileCount()
|
||||
sm_createdLodFileCount++;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RifOpmCommonEclipseSummary::extendedSummaryFilename( const QString& headerFileName)
|
||||
{
|
||||
QString s(headerFileName);
|
||||
return s.replace( ".SMSPEC", ".ESMRY" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Opm
|
||||
namespace EclIO
|
||||
{
|
||||
class ESmry;
|
||||
class ExtESmry;
|
||||
struct SummaryNode;
|
||||
} // namespace EclIO
|
||||
} // namespace Opm
|
||||
@@ -81,9 +82,12 @@ private:
|
||||
bool openESmryFile( const QString& headerFileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger );
|
||||
|
||||
static void increaseLodFileCount();
|
||||
static QString extendedSummaryFilename(const QString& headerFileName);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Opm::EclIO::ESmry> m_eSmry;
|
||||
std::unique_ptr<Opm::EclIO::ExtESmry> m_exteSmry;
|
||||
|
||||
std::vector<std::string> m_eSmryKeywords;
|
||||
std::map<RifEclipseSummaryAddress, size_t> m_adrToSummaryNodeIndex;
|
||||
std::vector<time_t> m_timeSteps;
|
||||
|
||||
@@ -180,7 +180,7 @@ bool RifOpmHdf5Summary::openESmryFile( const QString& headerFileName,
|
||||
{
|
||||
try
|
||||
{
|
||||
m_eSmry = std::make_unique<Opm::EclIO::ESmry>( headerFileName.toStdString(), includeRestartFiles, false );
|
||||
m_eSmry = std::make_unique<Opm::EclIO::ESmry>( headerFileName.toStdString(), includeRestartFiles );
|
||||
}
|
||||
catch ( std::exception& e )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user