mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#7563 HDF5 Export : Add flag to generated HDF5, default off
Fixes by cmake-format Try to fix copy constructor issues Fix missing initialization Unused variable
This commit is contained in:
@@ -131,29 +131,31 @@ bool RifHdf5Exporter::writeDataset( const std::string& groupName, const std::str
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
H5::Group RifHdf5Exporter::findOrCreateGroup( H5::Group* parentGroup, const std::string& groupName )
|
||||
{
|
||||
H5::Group group;
|
||||
if ( parentGroup )
|
||||
{
|
||||
try
|
||||
{
|
||||
group = parentGroup->openGroup( groupName );
|
||||
auto group = parentGroup->openGroup( groupName );
|
||||
|
||||
return group;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
group = parentGroup->createGroup( groupName );
|
||||
return parentGroup->createGroup( groupName );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
group = m_hdfFile->openGroup( groupName );
|
||||
auto group = m_hdfFile->openGroup( groupName );
|
||||
return group;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
group = m_hdfFile->createGroup( groupName );
|
||||
return m_hdfFile->createGroup( groupName );
|
||||
}
|
||||
}
|
||||
|
||||
return group;
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -18,25 +18,33 @@
|
||||
|
||||
#include "RifHdf5SummaryExporter.h"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
#include "RifHdf5Exporter.h"
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "opm/io/eclipse/ESmry.hpp"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QString>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifHdf5SummaryExporter::writeSummaryDataToHdf( const std::string& hdfFileName, Opm::EclIO::ESmry& sourceSummaryData )
|
||||
bool RifHdf5SummaryExporter::ensureHdf5FileIsCreated( const std::string& smspecFileName, const std::string& h5FileName )
|
||||
{
|
||||
auto timesteps = sourceSummaryData.numberOfTimeSteps();
|
||||
if ( timesteps == 0 ) return false;
|
||||
if ( !QFile::exists( QString::fromStdString( smspecFileName ) ) ) return false;
|
||||
|
||||
RifHdf5Exporter exporter( hdfFileName );
|
||||
// TODO: Use time stamp of file to make sure the smspec file is older than the h5 file
|
||||
if ( !QFile::exists( QString::fromStdString( h5FileName ) ) )
|
||||
{
|
||||
Opm::EclIO::ESmry sourceSummaryData( smspecFileName );
|
||||
|
||||
writeGeneralSection( exporter, sourceSummaryData );
|
||||
writeSummaryVectors( exporter, sourceSummaryData );
|
||||
RifHdf5Exporter exporter( h5FileName );
|
||||
|
||||
writeGeneralSection( exporter, sourceSummaryData );
|
||||
writeSummaryVectors( exporter, sourceSummaryData );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -89,6 +97,8 @@ bool RifHdf5SummaryExporter::writeGeneralSection( RifHdf5Exporter& exporter, Opm
|
||||
|
||||
exporter.writeDataset( "general", "version", values );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace EclIO
|
||||
class RifHdf5SummaryExporter
|
||||
{
|
||||
public:
|
||||
static bool writeSummaryDataToHdf( const std::string& hdfFileName, Opm::EclIO::ESmry& sourceSummaryData );
|
||||
static bool ensureHdf5FileIsCreated( const std::string& smspecFileName, const std::string& h5FileName );
|
||||
|
||||
private:
|
||||
static bool writeGeneralSection( RifHdf5Exporter& exporter, Opm::EclIO::ESmry& sourceSummaryData );
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "RifReaderEclipseOutput.h"
|
||||
|
||||
#ifdef USE_HDF5
|
||||
#include "RifHdf5SummaryExporter.h"
|
||||
#include "RifOpmHdf5Summary.h"
|
||||
#endif
|
||||
|
||||
@@ -162,6 +163,15 @@ bool RifReaderEclipseSummary::open( const QString& headerFileName,
|
||||
if ( RiaPreferences::current()->summaryDataReader() == RiaPreferences::SummaryReaderMode::HDF5_OPM_COMMON )
|
||||
{
|
||||
#ifdef USE_HDF5
|
||||
if ( RiaPreferences::current()->createH5SummaryDataFiles() )
|
||||
{
|
||||
QFileInfo fi( headerFileName );
|
||||
QString h5FilenameCandidate = fi.absolutePath() + "/" + fi.baseName() + ".h5";
|
||||
|
||||
RifHdf5SummaryExporter::ensureHdf5FileIsCreated( headerFileName.toStdString(),
|
||||
h5FilenameCandidate.toStdString() );
|
||||
}
|
||||
|
||||
auto hdfReader = std::make_unique<RifOpmHdf5Summary>();
|
||||
|
||||
isValid = hdfReader->open( headerFileName, false, threadSafeLogger );
|
||||
|
||||
Reference in New Issue
Block a user