Chaste Release::3.1
|
#include <Hdf5DataWriter.hpp>
A concrete HDF5 data writer class.
Definition at line 49 of file Hdf5DataWriter.hpp.
Hdf5DataWriter::Hdf5DataWriter | ( | DistributedVectorFactory & | rVectorFactory, |
const std::string & | rDirectory, | ||
const std::string & | rBaseName, | ||
bool | cleanDirectory = true , |
||
bool | extendData = false |
||
) |
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) |
extendData | whether to try opening an existing file and appending to it. |
The extendData parameter allows us to add to an existing dataset. It only really makes sense if the existing file has an unlimited dimension which we can extend. It also only makes sense if cleanDirectory is false, otherwise there won't be a file there to read...
Definition at line 50 of file Hdf5DataWriter.cpp.
References RelativeTo::Absolute, AdvanceAlongUnlimitedDimension(), ComputeIncompleteOffset(), DATASET_DIMS, EXCEPTION, FileFinder::Exists(), DistributedVectorFactory::GetLocalOwnership(), OutputFileHandler::GetOutputDirectoryFullPath(), mBaseName, mCurrentTimeStep, mDataFixedDimensionSize, mDatasetDims, mDatasetId, mDirectory, mFileFixedDimensionSize, mFileId, mIncompleteNodeIndices, mIsDataComplete, mIsFixedDimensionSet, mIsInDefineMode, mIsUnlimitedDimensionSet, mLo, mNumberOwned, mOffset, mrVectorFactory, mTimeDatasetId, mUnlimitedDimensionName, mUnlimitedDimensionUnit, DataWriterVariable::mVariableName, mVariables, and DataWriterVariable::mVariableUnits.
Hdf5DataWriter::~Hdf5DataWriter | ( | ) | [virtual] |
Destructor.
Definition at line 251 of file Hdf5DataWriter.cpp.
References Close(), PetscTools::Destroy(), mDoubleIncompleteOutputMatrix, mDoublePermutation, mSingleIncompleteOutputMatrix, and mSinglePermutation.
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 987 of file Hdf5DataWriter.cpp.
References EXCEPTION, mCurrentTimeStep, mDatasetDims, mEstimatedUnlimitedLength, mIsUnlimitedDimensionSet, and mNeedExtend.
Referenced by Hdf5DataWriter().
Apply a permutation to all occurences of PutVector Should be called when in define mode
rPermutation | a forward/?reverse permutation |
Definition at line 1046 of file Hdf5DataWriter.cpp.
References EXCEPTION, mDataFixedDimensionSize, mDoublePermutation, mFileFixedDimensionSize, mHi, mIsInDefineMode, mLo, mSinglePermutation, and PetscTools::SetupMat().
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 443 of file Hdf5DataWriter.cpp.
References EXCEPTION.
Referenced by CheckVariableName(), and DefineVariable().
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 434 of file Hdf5DataWriter.cpp.
References CheckUnitsName(), and EXCEPTION.
Referenced by DefineVariable().
void Hdf5DataWriter::Close | ( | ) |
Close any open files.
Definition at line 949 of file Hdf5DataWriter.cpp.
References mDatasetId, mFileId, mIsInDefineMode, mIsUnlimitedDimensionSet, and mTimeDatasetId.
Referenced by ~Hdf5DataWriter().
void Hdf5DataWriter::ComputeIncompleteOffset | ( | ) | [private] |
Compute mOffset and mNumberOwned from mIncompleteNodeIndices when we have incomplete data.
Definition at line 382 of file Hdf5DataWriter.cpp.
References mHi, mIncompleteNodeIndices, mLo, mNumberOwned, and mOffset.
Referenced by DefineFixedDimension(), DefineFixedDimensionUsingMatrix(), and Hdf5DataWriter().
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 273 of file Hdf5DataWriter.cpp.
References EXCEPTION, DistributedVectorFactory::GetHigh(), DistributedVectorFactory::GetLocalOwnership(), DistributedVectorFactory::GetLow(), mDataFixedDimensionSize, mFileFixedDimensionSize, mHi, mIsFixedDimensionSet, mIsInDefineMode, mLo, mNumberOwned, mOffset, and mrVectorFactory.
Referenced by DefineFixedDimension(), DefineFixedDimensionUsingMatrix(), ExtendedBidomainProblem< DIM >::save(), and AbstractCardiacProblem< DIM, DIM, 1 >::save().
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 298 of file Hdf5DataWriter.cpp.
References ComputeIncompleteOffset(), DefineFixedDimension(), EXCEPTION, mFileFixedDimensionSize, mIncompleteNodeIndices, and mIsDataComplete.
void Hdf5DataWriter::DefineFixedDimensionUsingMatrix | ( | const std::vector< unsigned > & | rNodesToOuput, |
long | vecSize | ||
) |
Define the fixed dimension, assuming incomplete data output (subset of the nodes) and using a matrix to convert from full to incomplete output (rather than picking required data values out one at a time).
rNodesToOuput | Node indexes to be output (precondition: to be monotonic increasing) |
vecSize |
Definition at line 323 of file Hdf5DataWriter.cpp.
References ComputeIncompleteOffset(), DefineFixedDimension(), EXCEPTION, mDataFixedDimensionSize, mDoubleIncompleteOutputMatrix, mFileFixedDimensionSize, mHi, mIncompleteNodeIndices, mIsDataComplete, mLo, mNumberOwned, mOffset, mSingleIncompleteOutputMatrix, mUseMatrixForIncompleteData, and PetscTools::SetupMat().
void Hdf5DataWriter::DefineUnlimitedDimension | ( | const std::string & | rVariableName, |
const std::string & | rVariableUnits, | ||
unsigned | estimatedLength = 1 |
||
) |
Define a variable.
rVariableName | The name of the dimension |
rVariableUnits | The physical units of the dimension |
estimatedLength | An estimate of the unlimited dimension length for performance reasons |
Definition at line 967 of file Hdf5DataWriter.cpp.
References EXCEPTION, mEstimatedUnlimitedLength, mIsInDefineMode, mIsUnlimitedDimensionSet, mUnlimitedDimensionName, and mUnlimitedDimensionUnit.
Referenced by VoltageInterpolaterOntoMechanicsMesh< DIM >::VoltageInterpolaterOntoMechanicsMesh().
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 399 of file Hdf5DataWriter.cpp.
References CheckUnitsName(), CheckVariableName(), EXCEPTION, mIsInDefineMode, DataWriterVariable::mVariableName, mVariables, and DataWriterVariable::mVariableUnits.
void Hdf5DataWriter::EndDefineMode | ( | ) | [virtual] |
End the define mode of the DataWriter.
Definition at line 455 of file Hdf5DataWriter.cpp.
References DATASET_DIMS, EXCEPTION, OutputFileHandler::GetOutputDirectoryFullPath(), ChasteBuildInfo::GetProvenanceString(), mBaseName, mCleanDirectory, mDatasetDims, mDatasetId, mDirectory, mEstimatedUnlimitedLength, mFileFixedDimensionSize, mFileId, mFixedChunkSize, mIncompleteNodeIndices, mIsDataComplete, mIsFixedDimensionSet, mIsInDefineMode, mIsUnlimitedDimensionSet, mTimeDatasetId, mUnlimitedDimensionName, mUnlimitedDimensionUnit, mUseOptimalChunkSizeAlgorithm, and mVariables.
int Hdf5DataWriter::GetVariableByName | ( | const std::string & | rVariableName | ) |
Get the id of the given variable, the variable must already exist or an exception will be thrown.
rVariableName | variable name to look up |
Definition at line 1026 of file Hdf5DataWriter.cpp.
References EXCEPTION, and mVariables.
void Hdf5DataWriter::PossiblyExtend | ( | ) |
Extend the dataset to the correct to the correct dimensions if needed.
Definition at line 1016 of file Hdf5DataWriter.cpp.
References mDatasetDims, mDatasetId, mNeedExtend, and mTimeDatasetId.
Referenced by PutStripedVector(), PutUnlimitedVariable(), and PutVector().
void Hdf5DataWriter::PutStripedVector | ( | std::vector< int > | variableIDs, |
Vec | petscVector | ||
) |
Write data for two variables from a PETSc vector to the dataset.
variableIDs | vector of IDs of variables of the columns in the HDF5 file |
petscVector | the data |
Definition at line 779 of file Hdf5DataWriter.cpp.
References PetscTools::CreateVec(), DATASET_DIMS, PetscTools::Destroy(), EXCEPTION, mCurrentTimeStep, mDataFixedDimensionSize, mDatasetId, mDoubleIncompleteOutputMatrix, mDoublePermutation, mFileFixedDimensionSize, mIncompleteNodeIndices, mIsDataComplete, mIsInDefineMode, mLo, mNumberOwned, mOffset, mUseMatrixForIncompleteData, and PossiblyExtend().
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 913 of file Hdf5DataWriter.cpp.
References PetscTools::AmMaster(), EXCEPTION, mCurrentTimeStep, mIsInDefineMode, mIsUnlimitedDimensionSet, mTimeDatasetId, and PossiblyExtend().
void Hdf5DataWriter::PutVector | ( | int | variableID, |
Vec | petscVector | ||
) |
Write data for a given variable from a PETSc vector to the dataset.
variableID | the variable id of the column in the HDF5 file |
petscVector | the data |
Definition at line 674 of file Hdf5DataWriter.cpp.
References PetscTools::CreateVec(), DATASET_DIMS, PetscTools::Destroy(), EXCEPTION, mCurrentTimeStep, mDataFixedDimensionSize, mDatasetId, mFileFixedDimensionSize, mIncompleteNodeIndices, mIsDataComplete, mIsInDefineMode, mLo, mNumberOwned, mOffset, mSingleIncompleteOutputMatrix, mSinglePermutation, mUseMatrixForIncompleteData, and PossiblyExtend().
void Hdf5DataWriter::SetFixedChunkSize | ( | unsigned | chunkSize | ) |
Use a particular chunk size, ignoring the algorithm that figures out the optimal value. Useful for reducing size of checkpoints. USE WITH CAUTION.
chunkSize | user provided chunk size |
Definition at line 1134 of file Hdf5DataWriter.cpp.
References mFixedChunkSize, mIsInDefineMode, and mUseOptimalChunkSizeAlgorithm.
const unsigned Hdf5DataWriter::DATASET_DIMS = 3 [static, private] |
Defined in HDF5 reader too.
Definition at line 83 of file Hdf5DataWriter.hpp.
Referenced by EndDefineMode(), Hdf5DataWriter(), PutStripedVector(), and PutVector().
std::string Hdf5DataWriter::mBaseName [private] |
The base name for the output data files.
Definition at line 56 of file Hdf5DataWriter.hpp.
Referenced by EndDefineMode(), and Hdf5DataWriter().
bool Hdf5DataWriter::mCleanDirectory [private] |
Whether to wipe the output directory
Definition at line 57 of file Hdf5DataWriter.hpp.
Referenced by EndDefineMode().
long Hdf5DataWriter::mCurrentTimeStep [private] |
The current time step.
Definition at line 81 of file Hdf5DataWriter.hpp.
Referenced by AdvanceAlongUnlimitedDimension(), Hdf5DataWriter(), PutStripedVector(), PutUnlimitedVariable(), and PutVector().
The size of the fixed dimension (size of the vector of nodes)
Definition at line 65 of file Hdf5DataWriter.hpp.
Referenced by ApplyPermutation(), DefineFixedDimension(), DefineFixedDimensionUsingMatrix(), Hdf5DataWriter(), PutStripedVector(), and PutVector().
hsize_t Hdf5DataWriter::mDatasetDims[DATASET_DIMS] [private] |
The sizes of each variable data set.
Definition at line 84 of file Hdf5DataWriter.hpp.
Referenced by AdvanceAlongUnlimitedDimension(), EndDefineMode(), Hdf5DataWriter(), and PossiblyExtend().
hid_t Hdf5DataWriter::mDatasetId [private] |
The variables data set ID.
Definition at line 78 of file Hdf5DataWriter.hpp.
Referenced by Close(), EndDefineMode(), Hdf5DataWriter(), PossiblyExtend(), PutStripedVector(), and PutVector().
std::string Hdf5DataWriter::mDirectory [private] |
Directory output files will be stored in.
Definition at line 55 of file Hdf5DataWriter.hpp.
Referenced by EndDefineMode(), and Hdf5DataWriter().
Stores striped nodes to be output as a matrix
Definition at line 90 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimensionUsingMatrix(), PutStripedVector(), and ~Hdf5DataWriter().
Mat Hdf5DataWriter::mDoublePermutation [private] |
Stores a permutation of a striped structure (u_0 v_0 u_1 v_1) as a matrix
Definition at line 87 of file Hdf5DataWriter.hpp.
Referenced by ApplyPermutation(), PutStripedVector(), and ~Hdf5DataWriter().
An estimate of the unlimited dimension length for performance reasons.
Definition at line 63 of file Hdf5DataWriter.hpp.
Referenced by AdvanceAlongUnlimitedDimension(), DefineUnlimitedDimension(), and EndDefineMode().
The size of the fixed dimension (number of rows)
Definition at line 64 of file Hdf5DataWriter.hpp.
Referenced by ApplyPermutation(), DefineFixedDimension(), DefineFixedDimensionUsingMatrix(), EndDefineMode(), Hdf5DataWriter(), PutStripedVector(), and PutVector().
hid_t Hdf5DataWriter::mFileId [private] |
The data file ID.
Definition at line 77 of file Hdf5DataWriter.hpp.
Referenced by Close(), EndDefineMode(), and Hdf5DataWriter().
unsigned Hdf5DataWriter::mFixedChunkSize [private] |
User-provided chunk size
Definition at line 93 of file Hdf5DataWriter.hpp.
Referenced by EndDefineMode(), and SetFixedChunkSize().
unsigned Hdf5DataWriter::mHi [private] |
Local ownership of a PETSc vector of size mFileFixedDimensionSize
Definition at line 67 of file Hdf5DataWriter.hpp.
Referenced by ApplyPermutation(), ComputeIncompleteOffset(), DefineFixedDimension(), and DefineFixedDimensionUsingMatrix().
std::vector<unsigned> Hdf5DataWriter::mIncompleteNodeIndices [private] |
Vector of node indices for which the data file does contain data.
Definition at line 72 of file Hdf5DataWriter.hpp.
Referenced by ComputeIncompleteOffset(), DefineFixedDimension(), DefineFixedDimensionUsingMatrix(), EndDefineMode(), Hdf5DataWriter(), PutStripedVector(), and PutVector().
bool Hdf5DataWriter::mIsDataComplete [private] |
Whether the data file is complete.
Definition at line 70 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension(), DefineFixedDimensionUsingMatrix(), EndDefineMode(), Hdf5DataWriter(), PutStripedVector(), and PutVector().
bool Hdf5DataWriter::mIsFixedDimensionSet [private] |
Is the fixed dimension set
Definition at line 59 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension(), EndDefineMode(), and Hdf5DataWriter().
bool Hdf5DataWriter::mIsInDefineMode [private] |
Is the DataWriter in define mode or not
Definition at line 58 of file Hdf5DataWriter.hpp.
Referenced by ApplyPermutation(), Close(), DefineFixedDimension(), DefineUnlimitedDimension(), DefineVariable(), EndDefineMode(), Hdf5DataWriter(), PutStripedVector(), PutUnlimitedVariable(), PutVector(), and SetFixedChunkSize().
bool Hdf5DataWriter::mIsUnlimitedDimensionSet [private] |
Is the unlimited dimension set
Definition at line 60 of file Hdf5DataWriter.hpp.
Referenced by AdvanceAlongUnlimitedDimension(), Close(), DefineUnlimitedDimension(), EndDefineMode(), Hdf5DataWriter(), and PutUnlimitedVariable().
unsigned Hdf5DataWriter::mLo [private] |
Local ownership of a PETSc vector of size mFileFixedDimensionSize
Definition at line 66 of file Hdf5DataWriter.hpp.
Referenced by ApplyPermutation(), ComputeIncompleteOffset(), DefineFixedDimension(), DefineFixedDimensionUsingMatrix(), Hdf5DataWriter(), PutStripedVector(), and PutVector().
bool Hdf5DataWriter::mNeedExtend [private] |
Used so that the data set is only extended when data is written
Definition at line 71 of file Hdf5DataWriter.hpp.
Referenced by AdvanceAlongUnlimitedDimension(), and PossiblyExtend().
unsigned Hdf5DataWriter::mNumberOwned [private] |
mNumberOwned=mHi-mLo; except with incomplete data
Definition at line 68 of file Hdf5DataWriter.hpp.
Referenced by ComputeIncompleteOffset(), DefineFixedDimension(), DefineFixedDimensionUsingMatrix(), Hdf5DataWriter(), PutStripedVector(), and PutVector().
unsigned Hdf5DataWriter::mOffset [private] |
mOffset=mLo; except with incomplete data
Definition at line 69 of file Hdf5DataWriter.hpp.
Referenced by ComputeIncompleteOffset(), DefineFixedDimension(), DefineFixedDimensionUsingMatrix(), Hdf5DataWriter(), PutStripedVector(), and PutVector().
The factory to use in creating PETSc Vec and DistributedVector objects.
Definition at line 54 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimension(), and Hdf5DataWriter().
Stores nodes to be output as a matrix
Definition at line 89 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimensionUsingMatrix(), PutVector(), and ~Hdf5DataWriter().
Mat Hdf5DataWriter::mSinglePermutation [private] |
Stores a permutation as a matrix
Definition at line 86 of file Hdf5DataWriter.hpp.
Referenced by ApplyPermutation(), PutVector(), and ~Hdf5DataWriter().
hid_t Hdf5DataWriter::mTimeDatasetId [private] |
The time data set ID.
Definition at line 79 of file Hdf5DataWriter.hpp.
Referenced by Close(), EndDefineMode(), Hdf5DataWriter(), PossiblyExtend(), and PutUnlimitedVariable().
std::string Hdf5DataWriter::mUnlimitedDimensionName [private] |
The name of the unlimited dimension.
Definition at line 61 of file Hdf5DataWriter.hpp.
Referenced by DefineUnlimitedDimension(), EndDefineMode(), and Hdf5DataWriter().
std::string Hdf5DataWriter::mUnlimitedDimensionUnit [private] |
The physical units of the unlimited dimension.
Definition at line 62 of file Hdf5DataWriter.hpp.
Referenced by DefineUnlimitedDimension(), EndDefineMode(), and Hdf5DataWriter().
Whether to use a matrix format for incomplete data
Definition at line 73 of file Hdf5DataWriter.hpp.
Referenced by DefineFixedDimensionUsingMatrix(), PutStripedVector(), and PutVector().
Whether to use the built-in algorithm for optimal chunk size
Definition at line 92 of file Hdf5DataWriter.hpp.
Referenced by EndDefineMode(), and SetFixedChunkSize().
std::vector<DataWriterVariable> Hdf5DataWriter::mVariables [private] |
The data variables
Definition at line 75 of file Hdf5DataWriter.hpp.
Referenced by DefineVariable(), EndDefineMode(), GetVariableByName(), and Hdf5DataWriter().