| kspaceFirstOrder3D-CUDA 1.1 The CUDA/C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
THDF5_File Class Reference

Class wrapping the HDF5 routines. More...

`#include <HDF5_File.h>`

Collaboration diagram for THDF5_File:
[legend]

## Public Types
enum | TMatrixDataType { FLOAT = 0, LONG = 1 }
| HDF5 matrix data type (float or uint64). More...
enum | TMatrixDomainType { REAL = 0, COMPLEX = 1 }
| HDF5 Matrix domain type (real or complex). More...

## Public Member Functions
| THDF5_File ()
| Constructor of the class. More...
virtual | ~THDF5_File ()
| Destructor. More...
void | Create (const std::string &fileName, unsigned int flags=H5F_ACC_TRUNC)
| Create a file. More...
void | Open (const std::string &fileName, unsigned int flags=H5F_ACC_RDONLY)
| Open a file. More...
bool | IsOpen () const
| Is the file opened? More...
void | Close ()
| Close file. More...
hid_t | CreateGroup (const hid_t parentGroup, TMatrixName &groupName)
| Create a HDF5 group at a specified place in the file tree. More...
hid_t | OpenGroup (const hid_t parentGroup, TMatrixName &groupName)
| Open a HDF5 group at a specified place in the file tree. More...
void | CloseGroup (const hid_t group)
| Close group. More...
hid_t | GetRootGroup () const
| Get handle to the root group. More...
hid_t | OpenDataset (const hid_t parentGroup, TMatrixName &datasetName)
| Open the HDF5 dataset at a specified place in the file tree. More...
hid_t | CreateFloatDataset (const hid_t parentGroup, TMatrixName &datasetName, const TDimensionSizes &dimensionSizes, const TDimensionSizes &chunkSizes, const size_t compressionLevel)
| Create a float HDF5 dataset at a specified place in the file tree (3D/4D). More...
hid_t | CreateIndexDataset (const hid_t parentGroup, TMatrixName &datasetName, const TDimensionSizes &dimensionSizes, const TDimensionSizes &chunkSizes, const size_t compressionLevel)
| Create an index HDF5 dataset at a specified place in the file tree (3D only). More...
void | CloseDataset (const hid_t dataset)
| Close the HDF5 dataset. More...
void | WriteHyperSlab (const hid_t dataset, const TDimensionSizes &position, const TDimensionSizes &size, const float *data)
| Write a hyper-slab into the dataset - float dataset. More...
void | WriteHyperSlab (const hid_t dataset, const TDimensionSizes &position, const TDimensionSizes &size, const size_t *data)
| Write a hyper-slab into the dataset - long dataset. More...
void | WriteCuboidToHyperSlab (const hid_t dataset, const TDimensionSizes &hyperslabPosition, const TDimensionSizes &cuboidPosition, const TDimensionSizes &cuboidSize, const TDimensionSizes &matrixDimensions, const float *mMatrixData)
| Write a cuboid selected within the matrixData into a hyperslab. More...
void | WriteDataByMaskToHyperSlab (const hid_t dataset, const TDimensionSizes &hyperslabPosition, const size_t indexSensorSize, const size_t *indexSensorData, const TDimensionSizes &matrixDimensions, const float *matrixData)
| Write sensor data selected by the sensor mask - Occasionally very slow, do not use! More...
void | WriteScalarValue (const hid_t parentGroup, TMatrixName &datasetName, const float value)
| Write the scalar value under a specified group, float value. More...
void | WriteScalarValue (const hid_t parentGroup, TMatrixName &datasetName, const size_t value)
| Write the scalar value under a specified group, index value. More...
void | ReadScalarValue (const hid_t parentGroup, TMatrixName &datasetName, float &value)
| Read the scalar value under a specified group, float value. More...
void | ReadScalarValue (const hid_t parentGroup, TMatrixName &datasetName, size_t &value)
| Read the scalar value under a specified group, index value. More...
void | ReadCompleteDataset (const hid_t parentGroup, TMatrixName &datasetName, const TDimensionSizes &dimensionSizes, float *data)
| Read data from the dataset under a specified group, float dataset. More...
void | ReadCompleteDataset (const hid_t parentGroup, TMatrixName &datasetName, const TDimensionSizes &dimensionSizes, size_t *data)
| Read data from the dataset under a specified group, index dataset. More...
TDimensionSizes | GetDatasetDimensionSizes (const hid_t parentGroup, TMatrixName &datasetName)
| Get dimension sizes of the dataset under a specified group. More...
size_t | GetDatasetNumberOfDimensions (const hid_t parentGroup, TMatrixName &datasetName)
| Get number of dimensions of the dataset under a specified group. More...
size_t | GetDatasetElementCount (const hid_t parentGroup, TMatrixName &datasetName)
| Get dataset element count under a specified group. More...
void | WriteMatrixDataType (const hid_t parentGroup, TMatrixName &datasetName, const TMatrixDataType &matrixDataType)
| Write matrix data type into the dataset under a specified group. More...
void | WriteMatrixDomainType (const hid_t parentGroup, TMatrixName &datasetName, const TMatrixDomainType &matrixDomainType)
| Write matrix domain type into the dataset under the root group. More...
THDF5_File::TMatrixDataType | ReadMatrixDataType (const hid_t parentGroup, TMatrixName &datasetName)
| Read matrix data type from the dataset. More...
THDF5_File::TMatrixDomainType | ReadMatrixDomainType (const hid_t parentGroup, TMatrixName &datasetName)
| Read matrix domain type from the dataset under a specified group. More...
void | WriteStringAttribute (const hid_t parentGroup, TMatrixName &datasetName, TMatrixName &attributeName, const std::string &value)
| Write string attribute into the dataset under the root group. More...
std::string | ReadStringAttribute (const hid_t parentGroup, TMatrixName &datasetName, TMatrixName &attributeName)
| Read string attribute from the dataset under the root group. More...

## Static Public Member Functions
static bool | IsHDF5 (const std::string &fileName)
| Does the file exist? More...

## Protected Member Functions
| THDF5_File (const THDF5_File &src)
| Copy constructor is not allowed for public.
THDF5_File & | operator= (const THDF5_File &src)
| Operator = is not allowed for public.

## Private Attributes
hid_t | file
| HDF file handle.
std::string | fileName
| File name.

## Static Private Attributes
static const std::string | matrixDomainTypeName = "domain_type"
| String representation of the Domain type in the HDF5 file.
static const std::string | matrixDataTypeName = "data_type"
| String representation of the Data type in the HDF5 file.
static const std::string | matrixDomainTypeNames [] = {"real","complex"}
| String representation of different domain types.
static const std::string | matrixDataTypeNames [] = {"float","long"}
| String representation of different data types.

## Detailed Description

This class is responsible for working with HDF5 files. It offers routines to manage files (create, open, close) as well as creating, reading and modifying the contents (groups and datasets).

Definition at line 500 of file HDF5_File.h.

## Member Enumeration Documentation

enum THDF5_File::TMatrixDataType

HDF5 matrix data type (float or uint64).

Definition at line 509 of file HDF5_File.h.

enum THDF5_File::TMatrixDomainType

HDF5 Matrix domain type (real or complex).

Definition at line 520 of file HDF5_File.h.

## Constructor & Destructor Documentation

THDF5_File::THDF5_File | ( |  | ) |

Constructor.

Definition at line 82 of file HDF5_File.cpp.

THDF5_File::~THDF5_File | ( |  | ) |
| virtual

Destructor.

Definition at line 193 of file HDF5_File.cpp.

Here is the call graph for this function:

## Member Function Documentation

void THDF5_File::Close | ( |  | ) |

Close the HDF5 file.

Exceptions

  ios::failure |

Definition at line 175 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::CloseDataset | ( | const hid_t | dataset | ) |

Close dataset.

Parameters

  [in] | dataset | - Dataset to close

Definition at line 457 of file HDF5_File.cpp.

Here is the caller graph for this function:

void THDF5_File::CloseGroup | ( | const hid_t | group | ) |

Close a group.

Parameters

  [in] | group | - Group to close

Definition at line 254 of file HDF5_File.cpp.

Here is the caller graph for this function:

void THDF5_File::Create | ( | const std::string & | fileName,
|  | unsigned int | flags = `H5F_ACC_TRUNC`
| ) |  |

Create the HDF5 file.

Parameters

  [in] | fileName | - File name
  [in] | flags | - Flags for the HDF5 runtime

Exceptions

  ios:failure | if error happened.

Definition at line 97 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

hid_t THDF5_File::CreateFloatDataset | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName,
|  | const TDimensionSizes & | dimensionSizes,
|  | const TDimensionSizes & | chunkSizes,
|  | const size_t | compressionLevel
| ) |  |

Create a float HDF5 dataset at a specified place in the file tree.

Parameters

  [in] | parentGroup | - Parent group Id
  [in] | datasetName | - Dataset name
  [in] | dimensionSizes | - Dimension sizes
  [in] | chunkSizes | - Chunk sizes
  [in] | compressionLevel | - Compression level

Returns
  A handle to the new dataset

Exceptions

  ios::failure |

Definition at line 296 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

hid_t THDF5_File::CreateGroup | ( | const hid_t | parentGroup,
|  | TMatrixName & | groupName
| ) |  |

Create a HDF5 group at a specified place in the file tree.

Parameters

  [in] | parentGroup | - Where to link the group at
  [in] | groupName | - Group name

Returns
  A handle to the new group

Exceptions

  ios::failure |

Definition at line 208 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

hid_t THDF5_File::CreateIndexDataset | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName,
|  | const TDimensionSizes & | dimensionSizes,
|  | const TDimensionSizes & | chunkSizes,
|  | const size_t | compressionLevel
| ) |  |

Create an index HDF5 dataset at a specified place in the file tree (always 3D).

Parameters

  [in] | parentGroup | - Parent group
  [in] | datasetName | - Dataset name
  [in] | dimensionSizes | - Dimension sizes
  [in] | chunkSizes | - Chunk sizes
  [in] | compressionLevel | - Compression level

Returns
  A handle to the new dataset

Exceptions

  ios::failure |

Definition at line 392 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

TDimensionSizes THDF5_File::GetDatasetDimensionSizes | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName
| ) |  |

Get dimension sizes of the dataset at a specified place in the file tree.

Parameters

  [in] | parentGroup | - Where the dataset is
  [in] | datasetName | - Dataset name

Returns
  Dimension sizes of the dataset

Exceptions

  ios::failure |

Definition at line 949 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

size_t THDF5_File::GetDatasetElementCount | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName
| ) |  |

Get dataset element count at a specified place in the file tree.

Parameters

  [in] | parentGroup | - Where the dataset is
  [in] | datasetName | - Dataset name

Returns
  Number of elements

Exceptions

  ios::failure |

Definition at line 1006 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

size_t THDF5_File::GetDatasetNumberOfDimensions | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName
| ) |  |

Get number of dimensions of the dataset under a specified group.

Parameters

  [in] | parentGroup | - Where the dataset is
  [in] | datasetName | - Dataset name

Returns
  Number of dimensions

Exceptions

  ios::failure |

Definition at line 982 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

hid_t THDF5_File::GetRootGroup | ( |  | ) | const
| inline

Get handle to the root group.

Returns
  handle to the root group

Definition at line 573 of file HDF5_File.h.

Here is the caller graph for this function:

bool THDF5_File::IsHDF5 | ( | const std::string & | fileName | ) |
| static

Check if the file exist.

Parameters

  [in] | fileName |

Returns
  true if the file exists.

Is a HDF5 file (can I access it)

Parameters

  [in] | fileName | - Filename

Returns
  true if I can access the file

Definition at line 158 of file HDF5_File.cpp.

Here is the caller graph for this function:

bool THDF5_File::IsOpen | ( |  | ) | const
| inline

Is the file opened?

Returns
  true if the file is opened.

Definition at line 545 of file HDF5_File.h.

Here is the caller graph for this function:

void THDF5_File::Open | ( | const std::string & | fileName,
|  | unsigned int | flags = `H5F_ACC_RDONLY`
| ) |  |

Open the HDF5 file.

Parameters

  [in] | fileName | - File name
  [in] | flags | - Flags for the HDF5 runtime

Exceptions

  ios:failure | if error happened.

Definition at line 127 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

hid_t THDF5_File::OpenDataset | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName
| ) |  |

Open a dataset at a specified place in the file tree.

Parameters

  [in] | parentGroup | - Parent group Id (can be the file Id for root).
  [in] | datasetName | - Dataset name

Returns
  A handle to open dataset

Exceptions

  ios::failure |

Definition at line 268 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

hid_t THDF5_File::OpenGroup | ( | const hid_t | parentGroup,
|  | TMatrixName & | groupName
| ) |  |

Open a HDF5 group at a specified place in the file tree.

Parameters

  [in] | parentGroup | - Parent group
  [in] | groupName | - Group name

Returns
  A handle to the group

Exceptions

  ios::failure |

Definition at line 232 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::ReadCompleteDataset | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName,
|  | const TDimensionSizes & | dimensionSizes,
|  | float * | data
| ) |  |

Read data from the dataset at a specified place in the file tree, float version.

Parameters

  [in] | parentGroup | - Where is the dataset situated
  [in] | datasetName | - Dataset name
  [in] | dimensionSizes | - Dimension sizes
  [out] | data | - Pointer to data

Exceptions

  ios::failure |

Definition at line 887 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::ReadCompleteDataset | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName,
|  | const TDimensionSizes & | dimensionSizes,
|  | size_t * | data
| ) |  |

Read data from the dataset at a specified place in the file tree, index version.

Parameters

  [in] | parentGroup | - Where is the dataset situated
  [in] | datasetName | - Dataset name
  [in] | dimensionSizes | - Dimension sizes
  [out] | data | - Pointer to data

Exceptions

  ios::failure |

Definition at line 919 of file HDF5_File.cpp.

Here is the call graph for this function:

THDF5_File::TMatrixDataType THDF5_File::ReadMatrixDataType | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName
| ) |  |

Read matrix data type from the dataset at a specified place in the file tree.

Parameters

  [in] | parentGroup | - Where the dataset is
  [in] | datasetName | - Dataset name

Returns
  Matrix data type

Exceptions

  ios::failure |

Definition at line 1068 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

THDF5_File::TMatrixDomainType THDF5_File::ReadMatrixDomainType | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName
| ) |  |

Read matrix dataset domain type at a specified place in the file tree.

Parameters

  [in] | parentGroup | - Where the dataset is
  [in] | datasetName | - Dataset name

Returns
  Matrix domain type

Exceptions

  ios::failure |

Definition at line 1101 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::ReadScalarValue | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName,
|  | float & | value
| ) |  |

Read the scalar value under a specified group, float value.

Parameters

  [in] | parentGroup | - Where to link the scalar dataset
  [in] | datasetName | - HDF5 dataset name
  [out] | value | - Data to be read

Definition at line 855 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::ReadScalarValue | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName,
|  | size_t & | value
| ) |  |

Read the scalar value under a specified group, index value.

Parameters

  [in] | parentGroup | - Where to link the scalar dataset
  [in] | datasetName | - HDF5 dataset name
  [out] | value | - Data to be read

Definition at line 870 of file HDF5_File.cpp.

Here is the call graph for this function:

string THDF5_File::ReadStringAttribute | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName,
|  | TMatrixName & | attributeName
| ) |  |
| inline

Read integer attribute at a specified place in the file tree.

Parameters

  [in] | parentGroup | - Where the dataset is
  [in] | datasetName | - Dataset name
  [in] | attributeName | - Attribute name

Returns
  Attribute value

Exceptions

  ios::failure |

Definition at line 1163 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::WriteCuboidToHyperSlab | ( | const hid_t | dataset,
|  | const TDimensionSizes & | hyperslabPosition,
|  | const TDimensionSizes & | cuboidPosition,
|  | const TDimensionSizes & | cuboidSize,
|  | const TDimensionSizes & | matrixDimensions,
|  | const float * | matrixData
| ) |  |

Write a cuboid selected within the matrixData into a hyperslab. The routine writes 3D cuboid into a 4D dataset (only intended for raw time series).

Parameters

  [in] | dataset | - Dataset to write MatrixData into
  [in] | hyperslabPosition | - Position in the dataset (hyperslab) - may be 3D/4D
  [in] | cuboidPosition | - Position of the cuboid in MatrixData (what to sample) - must be 3D
  [in] | cuboidSize | - Cuboid size (size of data being sampled) - must by 3D
  [in] | matrixDimensions | - Size of the original matrix (the sampled one)
  [in] | matrixData | - C array of MatrixData

Exceptions

  ios::failure |

Definition at line 618 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::WriteDataByMaskToHyperSlab | ( | const hid_t | dataset,
|  | const TDimensionSizes & | hyperslabPosition,
|  | const size_t | indexSensorSize,
|  | const size_t * | indexSensorData,
|  | const TDimensionSizes & | matrixDimensions,
|  | const float * | matrixData
| ) |  |

Write sensor data selected by the sensor mask. A routine pick elements from the MatixData based on the sensor data and store. them into a single hyperslab of size [Nsens, 1, 1].

Parameters

  [in] | dataset | - Dataset to write MaatrixData into
  [in] | hyperslabPosition | - 3D position in the dataset (hyperslab)
  [in] | indexSensorSize | - Size of the index based sensor mask
  [in] | indexSensorData | - Index based sensor mask
  [in] | matrixDimensions | - Size of the sampled matrix
  [in] | matrixData | - Matrix data

Warning
  - Very slow at this version of HDF5 for orthogonal planes-> DO NOT USE

Exceptions

  ios::failure |

Definition at line 686 of file HDF5_File.cpp.

Here is the call graph for this function:

void THDF5_File::WriteHyperSlab | ( | const hid_t | dataset,
|  | const TDimensionSizes & | position,
|  | const TDimensionSizes & | size,
|  | const float * | data
| ) |  |

Write a hyperslab into the dataset, float version.

Parameters

  [in] | dataset | - Dataset id
  [in] | position | - Position in the dataset
  [in] | size | - Size of the hyperslab
  [in] | data | - Data to be written

Exceptions

  ios::failure |

Definition at line 473 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::WriteHyperSlab | ( | const hid_t | dataset,
|  | const TDimensionSizes & | position,
|  | const TDimensionSizes & | size,
|  | const size_t * | data
| ) |  |

Write a hyperslab into the dataset, index version.

Parameters

  [in] | dataset | - Dataset id
  [in] | position | - Position in the dataset
  [in] | size | - Size of the hyperslab
  [in] | data | - Data to be written

Exceptions

  ios::failure |

Definition at line 544 of file HDF5_File.cpp.

Here is the call graph for this function:

void THDF5_File::WriteMatrixDataType | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName,
|  | const TMatrixDataType & | matrixDataType
| ) |  |

Write matrix data type into the dataset at a specified place in the file tree.

Parameters

  [in] | parentGroup | - Where the dataset is
  [in] | datasetName | - Dataset name
  [in] | matrixDataType | - Matrix data type in the file

Definition at line 1029 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::WriteMatrixDomainType | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName,
|  | const TMatrixDomainType & | matrixDomainType
| ) |  |

Write matrix data type into the dataset at a specified place in the file tree.

Parameters

  [in] | parentGroup | - Where the dataset is
  [in] | datasetName | - Dataset name
  [in] | matrixDomainType | - Matrix domain type

Definition at line 1048 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::WriteScalarValue | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName,
|  | const float | value
| ) |  |

Write a scalar value at a specified place in the file tree (no chunks, no compression). Float value.

Parameters

  [in] | parentGroup | - Where to link the scalar dataset
  [in] | datasetName | - HDF5 dataset name
  [in] | value | - data to be written

Exceptions

  ios::failure |

Definition at line 748 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void THDF5_File::WriteScalarValue | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName,
|  | const size_t | value
| ) |  |

Write a scalar value at a specified place in the file tree (no chunks, no compression). Index value.

Parameters

  [in] | parentGroup | - Where to link the scalar dataset
  [in] | datasetName | - HDF5 dataset name
  [in] | value | - Data to be written

Exceptions

  ios::failure |

Definition at line 803 of file HDF5_File.cpp.

Here is the call graph for this function:

void THDF5_File::WriteStringAttribute | ( | const hid_t | parentGroup,
|  | TMatrixName & | datasetName,
|  | TMatrixName & | attributeName,
|  | const std::string & | value
| ) |  |
| inline

Write integer attribute at a specified place in the file tree.

Parameters

  [in] | parentGroup | - Where the dataset is
  [in] | datasetName | - Dataset name
  [in] | attributeName | - Attribute name
  [in] | value | - Data to write

Exceptions

  ios::failure |

Definition at line 1135 of file HDF5_File.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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

- HDF5/HDF5_File.h
- HDF5/HDF5_File.cpp