#include <Hdf5DataWriter.hpp>
Public Member Functions | |
Hdf5DataWriter (DistributedVectorFactory &rVectorFactory, const std::string &rDirectory, const std::string &rBaseName, bool cleanDirectory=true) | |
virtual | ~Hdf5DataWriter () |
void | DefineFixedDimension (long dimensionSize) |
void | DefineFixedDimension (const std::vector< unsigned > &rNodesToOuput, long vecSize) |
void | DefineUnlimitedDimension (const std::string &rVariableName, const std::string &rVariableUnits) |
void | AdvanceAlongUnlimitedDimension () |
int | DefineVariable (const std::string &rVariableName, const std::string &rVariableUnits) |
virtual void | EndDefineMode () |
void | PossiblyExtend () |
void | PutVector (int variableID, Vec petscVector) |
void | PutStripedVector (int firstVariableID, int secondVariableID, Vec petscVector) |
void | PutUnlimitedVariable (double value) |
void | Close () |
Private Member Functions | |
void | CheckVariableName (const std::string &rName) |
void | CheckUnitsName (const std::string &rName) |
Private Attributes | |
DistributedVectorFactory & | mrVectorFactory |
std::string | mDirectory |
std::string | mBaseName |
bool | mCleanDirectory |
bool | mIsInDefineMode |
bool | mIsFixedDimensionSet |
bool | mIsUnlimitedDimensionSet |
std::string | mUnlimitedDimensionName |
std::string | mUnlimitedDimensionUnit |
unsigned | mFileFixedDimensionSize |
unsigned | mDataFixedDimensionSize |
unsigned | mLo |
unsigned | mHi |
unsigned | mNumberOwned |
unsigned | mOffset |
bool | mIsDataComplete |
bool | mNeedExtend |
std::vector< unsigned > | mIncompleteNodeIndices |
std::vector< DataWriterVariable > | mVariables |
hid_t | mFileId |
hid_t | mDatasetId |
hid_t | mTimeDatasetId |
long | mCurrentTimeStep |
hsize_t | mDatasetDims [DATASET_DIMS] |
Static Private Attributes | |
static const unsigned | DATASET_DIMS = 3 |
Definition at line 46 of file Hdf5DataWriter.hpp.
Hdf5DataWriter::Hdf5DataWriter | ( | DistributedVectorFactory & | rVectorFactory, | |
const std::string & | rDirectory, | |||
const std::string & | rBaseName, | |||
bool | cleanDirectory = true | |||
) |
Constructor.
rVectorFactory | the factory to use in creating PETSc Vec and DistributedVector objects. | |
rDirectory | the directory in which to write the data to file | |
rBaseName | the name of the file in which to write the data | |
cleanDirectory | whether to clean the directory (defaults to true) |
Definition at line 40 of file Hdf5DataWriter.cpp.
Hdf5DataWriter::~Hdf5DataWriter | ( | ) | [virtual] |
Destructor.
Definition at line 63 of file Hdf5DataWriter.cpp.
void Hdf5DataWriter::CheckVariableName | ( | const std::string & | rName | ) | [private] |
Check name of variable is allowed, i.e. contains only alphanumeric & _, and isn't blank.
rName | variable name |
Definition at line 166 of file Hdf5DataWriter.cpp.
References CheckUnitsName().
Referenced by DefineVariable().
void Hdf5DataWriter::CheckUnitsName | ( | const std::string & | rName | ) | [private] |
Check name of unit is allowed, i.e. contains only alphanumeric & _, and isn't blank.
rName | unit name |
Definition at line 175 of file Hdf5DataWriter.cpp.
Referenced by CheckVariableName(), and DefineVariable().
void Hdf5DataWriter::DefineFixedDimension | ( | long | dimensionSize | ) |
Define the fixed dimension, assuming complete data output (all the nodes).
dimensionSize | The size of the dimension |
Definition at line 67 of file Hdf5DataWriter.cpp.
References DistributedVectorFactory::GetHigh(), DistributedVectorFactory::GetLocalOwnership(), DistributedVectorFactory::GetLow(), mDataFixedDimensionSize, mFileFixedDimensionSize, mHi, mIsFixedDimensionSet, mIsInDefineMode, mLo, mNumberOwned, mOffset, and mrVectorFactory.
Referenced by DefineFixedDimension(), and AbstractCardiacProblem< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::DefineWriterColumns().
void Hdf5DataWriter::DefineFixedDimension | ( | const std::vector< unsigned > & | rNodesToOuput, | |
long | vecSize | |||
) |
Define the fixed dimension, assuming incomplete data output (subset of the nodes).
rNodesToOuput | Node indexes to be output (precondition: to be monotonic increasing) | |
vecSize |
Definition at line 92 of file Hdf5DataWriter.cpp.
References DefineFixedDimension(), mFileFixedDimensionSize, mHi, mIncompleteNodeIndices, mIsDataComplete, mLo, mNumberOwned, and mOffset.
void Hdf5DataWriter::DefineUnlimitedDimension | ( | const std::string & | rVariableName, | |
const std::string & | rVariableUnits | |||
) |
Define a variable.
rVariableName | The name of the dimension | |
rVariableUnits | The physical units of the dimension |
Definition at line 535 of file Hdf5DataWriter.cpp.
References mIsInDefineMode, mIsUnlimitedDimensionSet, mUnlimitedDimensionName, and mUnlimitedDimensionUnit.
Referenced by AbstractCardiacProblem< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::DefineWriterColumns().
void Hdf5DataWriter::AdvanceAlongUnlimitedDimension | ( | ) |
Advance along the unlimited dimension. Normally this will be called when all variables in a row have been input.
Definition at line 553 of file Hdf5DataWriter.cpp.
References mCurrentTimeStep, mDatasetDims, mIsUnlimitedDimensionSet, and mNeedExtend.
Referenced by CardiacElectroMechanicsProblem< DIM >::Solve(), and AbstractCardiacProblem< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::Solve().
int Hdf5DataWriter::DefineVariable | ( | const std::string & | rVariableName, | |
const std::string & | rVariableUnits | |||
) |
Define a variable.
rVariableName | The name of the dimension | |
rVariableUnits | The physical units of the dimension |
Definition at line 131 of file Hdf5DataWriter.cpp.
References CheckUnitsName(), CheckVariableName(), mIsInDefineMode, DataWriterVariable::mVariableName, mVariables, and DataWriterVariable::mVariableUnits.
Referenced by BidomainProblem< DIM >::DefineWriterColumns(), and AbstractCardiacProblem< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::DefineWriterColumns().
void Hdf5DataWriter::EndDefineMode | ( | ) | [virtual] |
End the define mode of the DataWriter.
Definition at line 187 of file Hdf5DataWriter.cpp.
References DATASET_DIMS, OutputFileHandler::GetOutputDirectoryFullPath(), mBaseName, mCleanDirectory, mDatasetDims, mDatasetId, mDirectory, mFileFixedDimensionSize, mFileId, mIncompleteNodeIndices, mIsDataComplete, mIsFixedDimensionSet, mIsInDefineMode, mIsUnlimitedDimensionSet, mTimeDatasetId, mUnlimitedDimensionName, mUnlimitedDimensionUnit, and mVariables.
Referenced by AbstractCardiacProblem< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::InitialiseWriter().
void Hdf5DataWriter::PossiblyExtend | ( | ) |
Extend the dataset to the correct to the correct dimensions if needed.
Definition at line 567 of file Hdf5DataWriter.cpp.
References mDatasetDims, mDatasetId, mNeedExtend, and mTimeDatasetId.
Referenced by PutStripedVector(), PutUnlimitedVariable(), and PutVector().
void Hdf5DataWriter::PutVector | ( | int | variableID, | |
Vec | petscVector | |||
) |
Write data for a given variable from a Petsc vector to the dataset.
variableID | the variable | |
petscVector | the data |
Definition at line 340 of file Hdf5DataWriter.cpp.
References DATASET_DIMS, mCurrentTimeStep, mDataFixedDimensionSize, mDatasetId, mIncompleteNodeIndices, mIsDataComplete, mIsInDefineMode, mLo, mNumberOwned, mOffset, and PossiblyExtend().
Referenced by AbstractCardiacProblem< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::WriteOneStep().
void Hdf5DataWriter::PutStripedVector | ( | int | firstVariableID, | |
int | secondVariableID, | |||
Vec | petscVector | |||
) |
Write data for two variables from a Petsc vector to the dataset.
firstVariableID | the first variable | |
secondVariableID | the first variable | |
petscVector | the data |
Definition at line 405 of file Hdf5DataWriter.cpp.
References DATASET_DIMS, mCurrentTimeStep, mDataFixedDimensionSize, mDatasetId, mIncompleteNodeIndices, mIsDataComplete, mIsInDefineMode, mLo, mNumberOwned, mOffset, and PossiblyExtend().
Referenced by BidomainProblem< DIM >::WriteOneStep().
void Hdf5DataWriter::PutUnlimitedVariable | ( | double | value | ) |
Write a single value for the unlimited variable (e.g. time) to the dataset.
value | the data |
Definition at line 483 of file Hdf5DataWriter.cpp.
References PetscTools::AmMaster(), mCurrentTimeStep, mIsInDefineMode, mIsUnlimitedDimensionSet, mTimeDatasetId, and PossiblyExtend().
Referenced by BidomainProblem< DIM >::WriteOneStep(), and AbstractCardiacProblem< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::WriteOneStep().
void Hdf5DataWriter::Close | ( | ) |
Close any open files.
Definition at line 519 of file Hdf5DataWriter.cpp.
References mDatasetId, mFileId, mIsInDefineMode, mIsUnlimitedDimensionSet, and mTimeDatasetId.
Referenced by AbstractCardiacProblem< ELEM_DIM, SPACE_DIM, PROBLEM_DIM >::CloseFilesAndPostProcess(), and CardiacElectroMechanicsProblem< DIM >::Solve().
The factory to use in creating PETSc Vec and DistributedVector objects.
Definition at line 50 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension().
std::string Hdf5DataWriter::mDirectory [private] |
Directory output files will be stored in.
Definition at line 51 of file Hdf5DataWriter.hpp.
Referenced by EndDefineMode().
std::string Hdf5DataWriter::mBaseName [private] |
The base name for the output data files.
Definition at line 52 of file Hdf5DataWriter.hpp.
Referenced by EndDefineMode().
bool Hdf5DataWriter::mCleanDirectory [private] |
Whether to wipe the output directory
Definition at line 53 of file Hdf5DataWriter.hpp.
Referenced by EndDefineMode().
bool Hdf5DataWriter::mIsInDefineMode [private] |
Is the DataWriter in define mode or not
Definition at line 54 of file Hdf5DataWriter.hpp.
Referenced by Close(), DefineFixedDimension(), DefineUnlimitedDimension(), DefineVariable(), EndDefineMode(), PutStripedVector(), PutUnlimitedVariable(), and PutVector().
bool Hdf5DataWriter::mIsFixedDimensionSet [private] |
Is the fixed dimension set
Definition at line 55 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension(), and EndDefineMode().
bool Hdf5DataWriter::mIsUnlimitedDimensionSet [private] |
Is the unlimited dimension set
Definition at line 56 of file Hdf5DataWriter.hpp.
Referenced by AdvanceAlongUnlimitedDimension(), Close(), DefineUnlimitedDimension(), EndDefineMode(), and PutUnlimitedVariable().
std::string Hdf5DataWriter::mUnlimitedDimensionName [private] |
The name of the unlimited dimension.
Definition at line 57 of file Hdf5DataWriter.hpp.
Referenced by DefineUnlimitedDimension(), and EndDefineMode().
std::string Hdf5DataWriter::mUnlimitedDimensionUnit [private] |
The physical units of the unlimited dimension.
Definition at line 58 of file Hdf5DataWriter.hpp.
Referenced by DefineUnlimitedDimension(), and EndDefineMode().
unsigned Hdf5DataWriter::mFileFixedDimensionSize [private] |
The size of the fixed dimension (number of rows)
Definition at line 59 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension(), and EndDefineMode().
unsigned Hdf5DataWriter::mDataFixedDimensionSize [private] |
The size of the fixed dimension (size of the vector of nodes)
Definition at line 60 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension(), PutStripedVector(), and PutVector().
unsigned Hdf5DataWriter::mLo [private] |
Local ownership of a PETSc vector of size mFileFixedDimensionSize
Definition at line 61 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension(), PutStripedVector(), and PutVector().
unsigned Hdf5DataWriter::mHi [private] |
Local ownership of a PETSc vector of size mFileFixedDimensionSize
Definition at line 62 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension().
unsigned Hdf5DataWriter::mNumberOwned [private] |
mNumberOwned=mHi-mLo; except with incomplete data
Definition at line 63 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension(), PutStripedVector(), and PutVector().
unsigned Hdf5DataWriter::mOffset [private] |
mOffset=mLo; except with incomplete data
Definition at line 64 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension(), PutStripedVector(), and PutVector().
bool Hdf5DataWriter::mIsDataComplete [private] |
Whether the data file is complete.
Definition at line 65 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension(), EndDefineMode(), PutStripedVector(), and PutVector().
bool Hdf5DataWriter::mNeedExtend [private] |
Used so that the data set is only extended when data is written
Definition at line 66 of file Hdf5DataWriter.hpp.
Referenced by AdvanceAlongUnlimitedDimension(), and PossiblyExtend().
std::vector<unsigned> Hdf5DataWriter::mIncompleteNodeIndices [private] |
Vector of node indices for which the data file does not contain data.
Definition at line 67 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension(), EndDefineMode(), PutStripedVector(), and PutVector().
std::vector<DataWriterVariable> Hdf5DataWriter::mVariables [private] |
The data variables
Definition at line 69 of file Hdf5DataWriter.hpp.
Referenced by DefineVariable(), and EndDefineMode().
hid_t Hdf5DataWriter::mFileId [private] |
The data file ID.
Definition at line 85 of file Hdf5DataWriter.hpp.
Referenced by Close(), and EndDefineMode().
hid_t Hdf5DataWriter::mDatasetId [private] |
The variables data set ID.
Definition at line 86 of file Hdf5DataWriter.hpp.
Referenced by Close(), EndDefineMode(), PossiblyExtend(), PutStripedVector(), and PutVector().
hid_t Hdf5DataWriter::mTimeDatasetId [private] |
The time data set ID.
Definition at line 87 of file Hdf5DataWriter.hpp.
Referenced by Close(), EndDefineMode(), PossiblyExtend(), and PutUnlimitedVariable().
long Hdf5DataWriter::mCurrentTimeStep [private] |
The current time step.
Definition at line 89 of file Hdf5DataWriter.hpp.
Referenced by AdvanceAlongUnlimitedDimension(), PutStripedVector(), PutUnlimitedVariable(), and PutVector().
const unsigned Hdf5DataWriter::DATASET_DIMS = 3 [static, private] |
Defined in HDF5 reader too.
Definition at line 91 of file Hdf5DataWriter.hpp.
Referenced by EndDefineMode(), PutStripedVector(), and PutVector().
hsize_t Hdf5DataWriter::mDatasetDims[DATASET_DIMS] [private] |
The sizes of each variable data set.
Definition at line 92 of file Hdf5DataWriter.hpp.
Referenced by AdvanceAlongUnlimitedDimension(), EndDefineMode(), and PossiblyExtend().