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:
parent
5e3aef5ca9
commit
3bc569e2a6
@ -431,6 +431,15 @@ RiaPreferences::RiaPreferences()
|
|||||||
"" );
|
"" );
|
||||||
m_useOptimizedSummaryDataFile.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
m_useOptimizedSummaryDataFile.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||||
|
|
||||||
|
CAF_PDM_InitField( &m_createH5SummaryDataFile,
|
||||||
|
"createH5SummaryDataFile",
|
||||||
|
false,
|
||||||
|
"Create H5 Summary Data Files [BETA]",
|
||||||
|
"",
|
||||||
|
"If not present, create summary file with extension '*.H5'",
|
||||||
|
"" );
|
||||||
|
m_createH5SummaryDataFile.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
|
||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault( &m_summaryReader, "summaryReaderType", "Summary Data File Reader", "", "", "" );
|
CAF_PDM_InitFieldNoDefault( &m_summaryReader, "summaryReaderType", "Summary Data File Reader", "", "", "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,15 +482,15 @@ void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field,
|
|||||||
|
|
||||||
if ( field == &octaveShowHeaderInfoWhenExecutingScripts || field == &autocomputeDepthRelatedProperties ||
|
if ( field == &octaveShowHeaderInfoWhenExecutingScripts || field == &autocomputeDepthRelatedProperties ||
|
||||||
field == &loadAndShowSoil || field == &m_useShaders || field == &m_showHud ||
|
field == &loadAndShowSoil || field == &m_useShaders || field == &m_showHud ||
|
||||||
field == &m_appendClassNameToUiText || field == &m_appendFieldKeywordToToolTipText ||
|
field == &m_appendClassNameToUiText || field == &m_appendFieldKeywordToToolTipText || field == &m_showTestToolbar ||
|
||||||
field == &m_showTestToolbar || field == &m_includeFractureDebugInfoFile ||
|
field == &m_includeFractureDebugInfoFile || field == &showLasCurveWithoutTvdWarning ||
|
||||||
field == &showLasCurveWithoutTvdWarning || field == &holoLensDisableCertificateVerification ||
|
field == &holoLensDisableCertificateVerification || field == &m_showProjectChangedDialog ||
|
||||||
field == &m_showProjectChangedDialog || field == &m_searchPlotTemplateFoldersRecursively ||
|
field == &m_searchPlotTemplateFoldersRecursively || field == &m_showLegendBackground ||
|
||||||
field == &m_showLegendBackground || field == &m_showSummaryTimeAsLongString ||
|
field == &m_showSummaryTimeAsLongString || field == &m_showViewIdInProjectTree ||
|
||||||
field == &m_showViewIdInProjectTree || field == &m_useMultipleThreadsWhenLoadingSummaryData ||
|
field == &m_useMultipleThreadsWhenLoadingSummaryData || field == &m_enableFaultsByDefault ||
|
||||||
field == &m_enableFaultsByDefault || field == &m_showProgressBar || field == &m_openExportedPdfInViewer ||
|
field == &m_showProgressBar || field == &m_openExportedPdfInViewer || field == &m_showInfoBox ||
|
||||||
field == &m_showInfoBox || field == &m_showGridBox || field == &m_useUndoRedo ||
|
field == &m_showGridBox || field == &m_useUndoRedo || field == &m_createOptimizedSummaryDataFile ||
|
||||||
field == &m_createOptimizedSummaryDataFile || field == &m_useOptimizedSummaryDataFile )
|
field == &m_useOptimizedSummaryDataFile || field == &m_createH5SummaryDataFile )
|
||||||
{
|
{
|
||||||
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>( attribute );
|
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>( attribute );
|
||||||
if ( myAttr )
|
if ( myAttr )
|
||||||
@ -617,6 +626,10 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
|||||||
group->add( &m_createOptimizedSummaryDataFile );
|
group->add( &m_createOptimizedSummaryDataFile );
|
||||||
group->add( &m_useOptimizedSummaryDataFile );
|
group->add( &m_useOptimizedSummaryDataFile );
|
||||||
}
|
}
|
||||||
|
else if ( m_summaryReader == SummaryReaderMode::HDF5_OPM_COMMON )
|
||||||
|
{
|
||||||
|
group->add( &m_createH5SummaryDataFile );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1251,6 +1264,14 @@ bool RiaPreferences::createOptimizedSummaryDataFiles() const
|
|||||||
return m_createOptimizedSummaryDataFile();
|
return m_createOptimizedSummaryDataFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RiaPreferences::createH5SummaryDataFiles() const
|
||||||
|
{
|
||||||
|
return m_createH5SummaryDataFile();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -150,6 +150,7 @@ public:
|
|||||||
SummaryReaderMode summaryDataReader() const;
|
SummaryReaderMode summaryDataReader() const;
|
||||||
bool useOptimizedSummaryDataFiles() const;
|
bool useOptimizedSummaryDataFiles() const;
|
||||||
bool createOptimizedSummaryDataFiles() const;
|
bool createOptimizedSummaryDataFiles() const;
|
||||||
|
bool createH5SummaryDataFiles() const;
|
||||||
|
|
||||||
public: // Pdm Fields
|
public: // Pdm Fields
|
||||||
caf::PdmField<bool> enableGrpcServer;
|
caf::PdmField<bool> enableGrpcServer;
|
||||||
@ -258,6 +259,7 @@ private:
|
|||||||
|
|
||||||
// Summary data
|
// Summary data
|
||||||
caf::PdmField<bool> m_createOptimizedSummaryDataFile;
|
caf::PdmField<bool> m_createOptimizedSummaryDataFile;
|
||||||
|
caf::PdmField<bool> m_createH5SummaryDataFile;
|
||||||
caf::PdmField<bool> m_useOptimizedSummaryDataFile;
|
caf::PdmField<bool> m_useOptimizedSummaryDataFile;
|
||||||
|
|
||||||
caf::PdmField<SummaryReaderModeType> m_summaryReader;
|
caf::PdmField<SummaryReaderModeType> m_summaryReader;
|
||||||
|
@ -232,23 +232,19 @@ list(APPEND RI_LIBRARIES RigGeoMechDataModel)
|
|||||||
#
|
#
|
||||||
if(RESINSIGHT_FOUND_HDF5)
|
if(RESINSIGHT_FOUND_HDF5)
|
||||||
|
|
||||||
set(HDF5_FILES
|
set(HDF5_FILES
|
||||||
FileInterface/RifHdf5Reader.h
|
FileInterface/RifHdf5Reader.h
|
||||||
FileInterface/RifHdf5Reader.cpp
|
FileInterface/RifHdf5Reader.cpp
|
||||||
FileInterface/RifHdf5SummaryReader.h
|
FileInterface/RifHdf5SummaryReader.h
|
||||||
FileInterface/RifHdf5SummaryReader.cpp
|
FileInterface/RifHdf5SummaryReader.cpp
|
||||||
FileInterface/RifOpmHdf5Summary.h
|
FileInterface/RifOpmHdf5Summary.h
|
||||||
FileInterface/RifOpmHdf5Summary.cpp
|
FileInterface/RifOpmHdf5Summary.cpp
|
||||||
FileInterface/RifHdf5Exporter.h
|
FileInterface/RifHdf5Exporter.h
|
||||||
FileInterface/RifHdf5Exporter.cpp
|
FileInterface/RifHdf5Exporter.cpp
|
||||||
FileInterface/RifHdf5SummaryExporter.h
|
FileInterface/RifHdf5SummaryExporter.h
|
||||||
FileInterface/RifHdf5SummaryExporter.cpp
|
FileInterface/RifHdf5SummaryExporter.cpp)
|
||||||
)
|
|
||||||
|
|
||||||
list(
|
list(APPEND CPP_SOURCES ${HDF5_FILES})
|
||||||
APPEND
|
|
||||||
CPP_SOURCES
|
|
||||||
${HDF5_FILES})
|
|
||||||
|
|
||||||
add_definitions(-DUSE_HDF5)
|
add_definitions(-DUSE_HDF5)
|
||||||
|
|
||||||
@ -263,9 +259,7 @@ if(RESINSIGHT_FOUND_HDF5)
|
|||||||
include_directories(${HDF5_INCLUDE_DIRS})
|
include_directories(${HDF5_INCLUDE_DIRS})
|
||||||
endif() # MSVC
|
endif() # MSVC
|
||||||
|
|
||||||
source_group(
|
source_group("FileInterface\\HDF5" FILES ${HDF5_FILES})
|
||||||
"FileInterface\\HDF5"
|
|
||||||
FILES ${HDF5_FILES})
|
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -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 RifHdf5Exporter::findOrCreateGroup( H5::Group* parentGroup, const std::string& groupName )
|
||||||
{
|
{
|
||||||
H5::Group group;
|
|
||||||
if ( parentGroup )
|
if ( parentGroup )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
group = parentGroup->openGroup( groupName );
|
auto group = parentGroup->openGroup( groupName );
|
||||||
|
|
||||||
|
return group;
|
||||||
}
|
}
|
||||||
catch ( ... )
|
catch ( ... )
|
||||||
{
|
{
|
||||||
group = parentGroup->createGroup( groupName );
|
return parentGroup->createGroup( groupName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
group = m_hdfFile->openGroup( groupName );
|
auto group = m_hdfFile->openGroup( groupName );
|
||||||
|
return group;
|
||||||
}
|
}
|
||||||
catch ( ... )
|
catch ( ... )
|
||||||
{
|
{
|
||||||
group = m_hdfFile->createGroup( groupName );
|
return m_hdfFile->createGroup( groupName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return group;
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -18,25 +18,33 @@
|
|||||||
|
|
||||||
#include "RifHdf5SummaryExporter.h"
|
#include "RifHdf5SummaryExporter.h"
|
||||||
|
|
||||||
#include <QDateTime>
|
|
||||||
|
|
||||||
#include "RifHdf5Exporter.h"
|
#include "RifHdf5Exporter.h"
|
||||||
#include "RifSummaryReaderInterface.h"
|
#include "RifSummaryReaderInterface.h"
|
||||||
|
|
||||||
#include "opm/io/eclipse/ESmry.hpp"
|
#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 ( !QFile::exists( QString::fromStdString( smspecFileName ) ) ) return false;
|
||||||
if ( timesteps == 0 ) 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 );
|
RifHdf5Exporter exporter( h5FileName );
|
||||||
writeSummaryVectors( exporter, sourceSummaryData );
|
|
||||||
|
writeGeneralSection( exporter, sourceSummaryData );
|
||||||
|
writeSummaryVectors( exporter, sourceSummaryData );
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -89,6 +97,8 @@ bool RifHdf5SummaryExporter::writeGeneralSection( RifHdf5Exporter& exporter, Opm
|
|||||||
|
|
||||||
exporter.writeDataset( "general", "version", values );
|
exporter.writeDataset( "general", "version", values );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -40,7 +40,7 @@ namespace EclIO
|
|||||||
class RifHdf5SummaryExporter
|
class RifHdf5SummaryExporter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static bool writeSummaryDataToHdf( const std::string& hdfFileName, Opm::EclIO::ESmry& sourceSummaryData );
|
static bool ensureHdf5FileIsCreated( const std::string& smspecFileName, const std::string& h5FileName );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool writeGeneralSection( RifHdf5Exporter& exporter, Opm::EclIO::ESmry& sourceSummaryData );
|
static bool writeGeneralSection( RifHdf5Exporter& exporter, Opm::EclIO::ESmry& sourceSummaryData );
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "RifReaderEclipseOutput.h"
|
#include "RifReaderEclipseOutput.h"
|
||||||
|
|
||||||
#ifdef USE_HDF5
|
#ifdef USE_HDF5
|
||||||
|
#include "RifHdf5SummaryExporter.h"
|
||||||
#include "RifOpmHdf5Summary.h"
|
#include "RifOpmHdf5Summary.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -162,6 +163,15 @@ bool RifReaderEclipseSummary::open( const QString& headerFileName,
|
|||||||
if ( RiaPreferences::current()->summaryDataReader() == RiaPreferences::SummaryReaderMode::HDF5_OPM_COMMON )
|
if ( RiaPreferences::current()->summaryDataReader() == RiaPreferences::SummaryReaderMode::HDF5_OPM_COMMON )
|
||||||
{
|
{
|
||||||
#ifdef USE_HDF5
|
#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>();
|
auto hdfReader = std::make_unique<RifOpmHdf5Summary>();
|
||||||
|
|
||||||
isValid = hdfReader->open( headerFileName, false, threadSafeLogger );
|
isValid = hdfReader->open( headerFileName, false, threadSafeLogger );
|
||||||
|
@ -16,24 +16,21 @@
|
|||||||
#include "opm/io/eclipse/ESmry.hpp"
|
#include "opm/io/eclipse/ESmry.hpp"
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
static const QString H5_TEST_DATA_DIRECTORY = QString( "%1/h5-file/" ).arg( TEST_DATA_DIR );
|
static const QString H5_TEST_DATA_DIRECTORY_2 = QString( "%1/h5-file/" ).arg( TEST_DATA_DIR );
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
TEST( DISABLED_HDFTests, WriteToHdf5SummaryExporter )
|
TEST( DISABLED_HDFTests, WriteToHdf5SummaryExporter )
|
||||||
{
|
{
|
||||||
QString file_path = H5_TEST_DATA_DIRECTORY + "NORNE_ATW2013_RFTPLT_V2.SMSPEC";
|
QString file_path = H5_TEST_DATA_DIRECTORY_2 + "NORNE_ATW2013_RFTPLT_V2.SMSPEC";
|
||||||
|
|
||||||
// RifReaderEclipseSummary eclReader;
|
|
||||||
// eclReader.open( file_path, true, nullptr );
|
|
||||||
|
|
||||||
Opm::EclIO::ESmry esmry( file_path.toStdString() );
|
Opm::EclIO::ESmry esmry( file_path.toStdString() );
|
||||||
|
|
||||||
RifHdf5SummaryExporter exporter;
|
RifHdf5SummaryExporter exporter;
|
||||||
std::string exportFileName = "e:/project/scratch_export/hdf_complete.h5";
|
std::string exportFileName = "e:/project/scratch_export/hdf_complete.h5";
|
||||||
|
|
||||||
exporter.writeSummaryDataToHdf( exportFileName, esmry );
|
exporter.ensureHdf5FileIsCreated( exportFileName, exportFileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -41,7 +38,7 @@ TEST( DISABLED_HDFTests, WriteToHdf5SummaryExporter )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
TEST( DISABLED_HDFTests, WriteDataToH5 )
|
TEST( DISABLED_HDFTests, WriteDataToH5 )
|
||||||
{
|
{
|
||||||
QString file_path = H5_TEST_DATA_DIRECTORY + "NORNE_ATW2013_RFTPLT_V2.SMPEC";
|
QString file_path = H5_TEST_DATA_DIRECTORY_2 + "NORNE_ATW2013_RFTPLT_V2.SMPEC";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -57,13 +54,12 @@ TEST( DISABLED_HDFTests, WriteDataToH5 )
|
|||||||
{
|
{
|
||||||
std::vector<int> values( 7 );
|
std::vector<int> values( 7 );
|
||||||
|
|
||||||
int day = 1;
|
int day = 1;
|
||||||
int month = 2;
|
int month = 2;
|
||||||
int year = 3;
|
int year = 3;
|
||||||
int hour = 4;
|
int hour = 4;
|
||||||
int minute = 5;
|
int minute = 5;
|
||||||
int second = 6;
|
int second = 6;
|
||||||
int unknown = 7;
|
|
||||||
|
|
||||||
values[0] = day;
|
values[0] = day;
|
||||||
values[1] = month;
|
values[1] = month;
|
||||||
|
@ -63,7 +63,7 @@ namespace Opm {
|
|||||||
const Location& location( ) const { return this->loc; }
|
const Location& location( ) const { return this->loc; }
|
||||||
|
|
||||||
operator Opm::EclIO::SummaryNode() const {
|
operator Opm::EclIO::SummaryNode() const {
|
||||||
return { keyword_, category_, type_, name_, number_ };
|
return { keyword_, category_, type_, name_, number_, std::numeric_limits<size_t>::max() };
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Serializer>
|
template<class Serializer>
|
||||||
|
Loading…
Reference in New Issue
Block a user