ResInsight/ApplicationLibCode/FileInterface/RifHdf5Reader.h
Magne Sjaastad dd97e7741a #7527 HDF Summary Reader : Add first working prototype
HDF5 must be compiled with special options to support multithreading. Disable file object multithreading for HDF5. Some vector types are not supported, as the support in opm-common reader is not complete (region, region_to_region, ...).
2021-04-08 07:13:34 -07:00

67 lines
2.8 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RifHdf5ReaderInterface.h"
#include <QString>
#include "H5Cpp.h"
class RifHdf5ReaderTools
{
public:
static std::vector<std::string> getSubGroupNames( H5::H5File* file, const std::string& baseGroupName );
};
//==================================================================================================
//
//
//==================================================================================================
class RifHdf5Reader : public RifHdf5ReaderInterface
{
public:
explicit RifHdf5Reader( const QString& fileName );
~RifHdf5Reader() override;
std::vector<QDateTime> timeSteps() const override;
QStringList propertyNames() const override;
bool dynamicResult( const QString& result, size_t stepIndex, std::vector<double>* values ) const override;
private:
std::vector<std::string> getSourSimTimeStepFileNames( const QString& fileName ) const;
QDateTime sourSimDateTimeToQDateTime( std::string dateString ) const;
std::string getTimeStepNumberAs5DigitString( std::string fileName ) const;
std::string IntTo5DigitString( int i ) const;
int getIntAttribute( H5::H5File file, std::string groupName, std::string attributeName ) const;
double getDoubleAttribute( H5::H5File file, std::string groupName, std::string attributeName ) const;
std::string getStringAttribute( H5::H5File file, std::string groupName, std::string attributeName ) const;
std::vector<std::string> getSubGroupNames( H5::H5File file, std::string baseGroupName ) const;
std::vector<std::string> getResultNames( H5::H5File file, std::string baseGroupName ) const;
void getElementResultValues( H5::H5File file, std::string groupName, std::vector<double>* resultValues ) const;
private:
QString m_fileName; // name of SourSimRL main file given by user
int m_fileStrategy; // SourSimRL file strategy, fileStrategy == 1 means one time step per file
std::vector<std::string> m_timeStepFileNames; // files containing transient SourSimRL results, one time step per file
};