Chaste Release::3.1
Hdf5DataReader Class Reference

#include <Hdf5DataReader.hpp>

Collaboration diagram for Hdf5DataReader:

List of all members.

Public Member Functions

 Hdf5DataReader (const std::string &rDirectory, const std::string &rBaseName, bool makeAbsolute=true)
 Hdf5DataReader (const FileFinder &rDirectory, const std::string &rBaseName)
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)
bool IsDataComplete ()
std::vector< unsignedGetIncompleteNodeMap ()
void Close ()
 ~Hdf5DataReader ()

Private Member Functions

void CommonConstructor (const FileFinder &rDirectory, const std::string &rBaseName)

Private Attributes

std::string mDirectory
std::string mBaseName
hid_t mFileId
hid_t mVariablesDatasetId
unsigned mVariablesDatasetRank
hsize_t mVariablesDatasetSizes [MAX_DATASET_RANK]
bool mIsUnlimitedDimensionSet
hid_t mTimeDatasetId
hsize_t mNumberTimesteps
std::vector< std::string > mVariableNames
std::map< std::string, unsignedmVariableToColumnIndex
std::map< std::string,
std::string > 
mVariableToUnit
bool mIsDataComplete
std::vector< unsignedmIncompleteNodeIndices
bool mClosed

Static Private Attributes

static const unsigned MAX_DATASET_RANK = 3

Detailed Description

Todo:
: magic number

A concrete HDF5 data reader class.

Definition at line 56 of file Hdf5DataReader.hpp.


Constructor & Destructor Documentation

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

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 to convert directory to an absolute path using the OutputFileHandler (defaults to true)

Definition at line 44 of file Hdf5DataReader.cpp.

References RelativeTo::Absolute, RelativeTo::ChasteTestOutput, and CommonConstructor().

Hdf5DataReader::Hdf5DataReader ( const FileFinder rDirectory,
const std::string &  rBaseName 
)

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)

Definition at line 66 of file Hdf5DataReader.cpp.

References CommonConstructor().

Hdf5DataReader::~Hdf5DataReader ( )

Destructor just calls Close.

Definition at line 439 of file Hdf5DataReader.cpp.

References Close().


Member Function Documentation

void Hdf5DataReader::Close ( )

Close any open files.

Definition at line 425 of file Hdf5DataReader.cpp.

References mClosed, mFileId, mIsUnlimitedDimensionSet, mTimeDatasetId, and mVariablesDatasetId.

Referenced by ~Hdf5DataReader().

void Hdf5DataReader::CommonConstructor ( const FileFinder rDirectory,
const std::string &  rBaseName 
) [private]

Contains functionality common to both constructors.

Parameters:
rDirectoryThe directory the files are stored in
rBaseNameThe base name of the files to read (i.e. without the extensions)

Definition at line 77 of file Hdf5DataReader.cpp.

References RelativeTo::Absolute, EXCEPTION, FileFinder::Exists(), FileFinder::GetAbsolutePath(), FileFinder::IsDir(), MAX_DATASET_RANK, mBaseName, mDirectory, mFileId, mIncompleteNodeIndices, mIsDataComplete, mIsUnlimitedDimensionSet, mNumberTimesteps, mTimeDatasetId, mVariableNames, mVariablesDatasetId, mVariablesDatasetRank, mVariablesDatasetSizes, mVariableToColumnIndex, and mVariableToUnit.

Referenced by Hdf5DataReader().

std::vector< unsigned > Hdf5DataReader::GetIncompleteNodeMap ( )

Get method for mIncompleteNodeIndices.

Definition at line 464 of file Hdf5DataReader.cpp.

References mIncompleteNodeIndices.

std::string Hdf5DataReader::GetUnit ( const std::string &  rVariableName)

Get the units in which a given variable is measured.

Parameters:
rVariableNamename of a variable in the data file

Definition at line 454 of file Hdf5DataReader.cpp.

References mVariableToUnit.

void Hdf5DataReader::GetVariableOverNodes ( Vec  data,
const std::string &  rVariableName,
unsigned  timestep = 0 
)

Get 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 339 of file Hdf5DataReader.cpp.

References EXCEPTION, mIsDataComplete, mIsUnlimitedDimensionSet, mNumberTimesteps, mVariablesDatasetId, mVariablesDatasetSizes, and mVariableToColumnIndex.

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

std::vector< double > Hdf5DataReader::GetVariableOverTime ( const std::string &  rVariableName,
unsigned  nodeIndex 
)
std::vector< std::vector< double > > Hdf5DataReader::GetVariableOverTimeOverMultipleNodes ( const std::string &  rVariableName,
unsigned  lowerIndex,
unsigned  upperIndex 
)

Get 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 273 of file Hdf5DataReader.cpp.

References EXCEPTION, mIsDataComplete, mIsUnlimitedDimensionSet, mVariablesDatasetId, mVariablesDatasetSizes, and mVariableToColumnIndex.

Referenced by PropagationPropertiesCalculator::CalculateAllActionPotentialDurationsForNodeRange().

bool Hdf5DataReader::IsDataComplete ( )

Get method for mIsDataComplete.

Definition at line 459 of file Hdf5DataReader.cpp.

References mIsDataComplete.


Member Data Documentation

const unsigned Hdf5DataReader::MAX_DATASET_RANK = 3 [static, private]

Defined in HDF5 writer too.

Todo:
: define it once

Definition at line 60 of file Hdf5DataReader.hpp.

Referenced by CommonConstructor().

std::string Hdf5DataReader::mBaseName [private]

The base name for the output data files.

Definition at line 63 of file Hdf5DataReader.hpp.

Referenced by CommonConstructor().

Whether we've already closed the file.

Definition at line 82 of file Hdf5DataReader.hpp.

Referenced by Close().

std::string Hdf5DataReader::mDirectory [private]

Directory output files will be stored in (absolute path).

Definition at line 62 of file Hdf5DataReader.hpp.

Referenced by CommonConstructor().

hid_t Hdf5DataReader::mFileId [private]

The data file ID.

Definition at line 65 of file Hdf5DataReader.hpp.

Referenced by Close(), and CommonConstructor().

Vector of node indices for which the data file does not contain data.

Definition at line 80 of file Hdf5DataReader.hpp.

Referenced by CommonConstructor(), GetIncompleteNodeMap(), and GetVariableOverTime().

The number of time steps recorded in the data file.

Definition at line 73 of file Hdf5DataReader.hpp.

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

The time data set ID.

Definition at line 72 of file Hdf5DataReader.hpp.

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

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

The variable names.

Definition at line 75 of file Hdf5DataReader.hpp.

Referenced by CommonConstructor(), and GetVariableNames().

The rank of the variables data set.

Definition at line 68 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 76 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 77 of file Hdf5DataReader.hpp.

Referenced by CommonConstructor(), and GetUnit().


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