Chaste  Release::3.4
Hdf5DataReader Class Reference

#include <Hdf5DataReader.hpp>

+ Inheritance diagram for Hdf5DataReader:
+ Collaboration diagram for Hdf5DataReader:

Public Member Functions

 Hdf5DataReader (const std::string &rDirectory, const std::string &rBaseName, bool makeAbsolute=true, std::string datasetName="Data")
 
 Hdf5DataReader (const FileFinder &rDirectory, const std::string &rBaseName, std::string datasetName="Data")
 
std::vector< doubleGetVariableOverTime (const std::string &rVariableName, unsigned nodeIndex)
 
std::vector< std::vector
< double > > 
GetVariableOverTimeOverMultipleNodes (const std::string &rVariableName, unsigned lowerIndex, unsigned upperIndex)
 
void GetVariableOverNodes (Vec data, const std::string &rVariableName, unsigned timestep=0)
 
std::vector< doubleGetUnlimitedDimensionValues ()
 
unsigned GetNumberOfRows ()
 
std::vector< std::string > GetVariableNames ()
 
std::string GetUnit (const std::string &rVariableName)
 
void Close ()
 
 ~Hdf5DataReader ()
 
- Public Member Functions inherited from AbstractHdf5Access
 AbstractHdf5Access (const std::string &rDirectory, const std::string &rBaseName, const std::string &rDatasetName, bool makeAbsolute=true)
 
 AbstractHdf5Access (const FileFinder &rDirectory, const std::string &rBaseName, const std::string &rDatasetName)
 
virtual ~AbstractHdf5Access ()
 
bool IsDataComplete ()
 
std::vector< unsignedGetIncompleteNodeMap ()
 
std::string GetUnlimitedDimensionName ()
 
std::string GetUnlimitedDimensionUnit ()
 

Private Member Functions

void CommonConstructor ()
 

Private Attributes

unsigned mVariablesDatasetRank
 
hsize_t mNumberTimesteps
 
std::vector< std::string > mVariableNames
 
std::map< std::string, unsignedmVariableToColumnIndex
 
std::map< std::string,
std::string > 
mVariableToUnit
 
bool mClosed
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractHdf5Access
bool DoesDatasetExist (const std::string &rDatasetName)
 
void SetUnlimitedDatasetId ()
 
void SetMainDatasetRawChunkCache ()
 
- Protected Attributes inherited from AbstractHdf5Access
std::string mBaseName
 
std::string mDatasetName
 
FileFinder mDirectory
 
bool mIsDataComplete
 
std::string mUnlimitedDimensionName
 
std::string mUnlimitedDimensionUnit
 
bool mIsUnlimitedDimensionSet
 
std::vector< unsignedmIncompleteNodeIndices
 
hid_t mFileId
 
hid_t mUnlimitedDatasetId
 
hid_t mVariablesDatasetId
 
hsize_t mDatasetDims [DATASET_DIMS]
 
- Static Protected Attributes inherited from AbstractHdf5Access
static const unsigned DATASET_DIMS =3
 

Detailed Description

A concrete HDF5 data reader class.

Todo:
Add to documentation whether we can call this in serial/parallel, whether we can call it when file is open already etc...

Definition at line 55 of file Hdf5DataReader.hpp.

Constructor & Destructor Documentation

Hdf5DataReader::Hdf5DataReader ( const std::string &  rDirectory,
const std::string &  rBaseName,
bool  makeAbsolute = true,
std::string  datasetName = "Data" 
)

Read data from the given files into memory.

Parameters
rDirectoryThe directory the files are stored in
rBaseNameThe base name of the files to read (i.e. without the extensions)
makeAbsoluteWhether the h5 file should be treated as relative to Chaste test output, and converted to absolute, the file is otherwise treated as relative to current working directory.
datasetNameThe name of the HDF5 dataset to read, defaults to "Data".

Definition at line 44 of file Hdf5DataReader.cpp.

References CommonConstructor().

Hdf5DataReader::Hdf5DataReader ( const FileFinder rDirectory,
const std::string &  rBaseName,
std::string  datasetName = "Data" 
)

Alternative constructor taking a FileFinder to specify the directory.

Parameters
rDirectoryThe directory the files are stored in
rBaseNameThe base name of the files to read (i.e. without the extensions)
datasetNameThe name of the HDF5 dataset to read, defaults to "Data".

Definition at line 55 of file Hdf5DataReader.cpp.

References CommonConstructor().

Hdf5DataReader::~Hdf5DataReader ( )

Destructor just calls Close.

Definition at line 437 of file Hdf5DataReader.cpp.

References Close().

Member Function Documentation

unsigned Hdf5DataReader::GetNumberOfRows ( )
std::string Hdf5DataReader::GetUnit ( const std::string &  rVariableName)
Returns
the units in which a given variable is measured.
Parameters
rVariableNamename of a variable in the data file

Definition at line 452 of file Hdf5DataReader.cpp.

References mVariableToUnit.

std::vector< std::string > Hdf5DataReader::GetVariableNames ( )
Returns
the variable names.

Definition at line 447 of file Hdf5DataReader.cpp.

References mVariableNames.

void Hdf5DataReader::GetVariableOverNodes ( Vec  data,
const std::string &  rVariableName,
unsigned  timestep = 0 
)
Returns
the values of a given variable at each node at a given time step.
Parameters
dataPETSc vec to hold the data
rVariableNamename of a variable in the data file
timestepthe time step for which the data is obtained (defaults to 0)

Definition at line 343 of file Hdf5DataReader.cpp.

References EXCEPTION, AbstractHdf5Access::mDatasetDims, AbstractHdf5Access::mDatasetName, AbstractHdf5Access::mIsDataComplete, AbstractHdf5Access::mIsUnlimitedDimensionSet, mNumberTimesteps, AbstractHdf5Access::mVariablesDatasetId, mVariableToColumnIndex, and UNUSED_OPT.

Referenced by ExtendedBidomainProblem< DIM >::load(), AbstractCardiacProblem< DIM, DIM, 1 >::load(), and VoltageInterpolaterOntoMechanicsMesh< DIM >::VoltageInterpolaterOntoMechanicsMesh().

std::vector< std::vector< double > > Hdf5DataReader::GetVariableOverTimeOverMultipleNodes ( const std::string &  rVariableName,
unsigned  lowerIndex,
unsigned  upperIndex 
)
Returns
the values of a given variable at each time step over multiple nodes.
Parameters
rVariableNamename of a variable in the data file
lowerIndexthe index of the lower node for which the data is obtained
upperIndexone past the index of the upper node for which the data is obtained

Definition at line 277 of file Hdf5DataReader.cpp.

References EXCEPTION, AbstractHdf5Access::mDatasetDims, AbstractHdf5Access::mDatasetName, AbstractHdf5Access::mIsDataComplete, AbstractHdf5Access::mIsUnlimitedDimensionSet, AbstractHdf5Access::mVariablesDatasetId, and mVariableToColumnIndex.

Referenced by PropagationPropertiesCalculator::CalculateAllActionPotentialDurationsForNodeRange().

Member Data Documentation

bool Hdf5DataReader::mClosed
private

Whether we've already closed the file.

Definition at line 67 of file Hdf5DataReader.hpp.

Referenced by Close().

hsize_t Hdf5DataReader::mNumberTimesteps
private

The number of time steps recorded in the data file.

Definition at line 61 of file Hdf5DataReader.hpp.

Referenced by CommonConstructor(), GetUnlimitedDimensionValues(), and GetVariableOverNodes().

std::vector<std::string> Hdf5DataReader::mVariableNames
private

The variable names.

Definition at line 63 of file Hdf5DataReader.hpp.

Referenced by CommonConstructor(), and GetVariableNames().

unsigned Hdf5DataReader::mVariablesDatasetRank
private

The rank of the variables data set.

Definition at line 59 of file Hdf5DataReader.hpp.

Referenced by CommonConstructor().

std::map<std::string, unsigned> Hdf5DataReader::mVariableToColumnIndex
private

Map between variable names and data column numbers.

Definition at line 64 of file Hdf5DataReader.hpp.

Referenced by CommonConstructor(), GetVariableOverNodes(), GetVariableOverTime(), and GetVariableOverTimeOverMultipleNodes().

std::map<std::string, std::string> Hdf5DataReader::mVariableToUnit
private

Map between variable names and variable units.

Definition at line 65 of file Hdf5DataReader.hpp.

Referenced by CommonConstructor(), and GetUnit().


The documentation for this class was generated from the following files: