Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.5.1/v0.9.0/cpp
DOLFINx  0.5.1
DOLFINx C++ interface
Static Public Member Functions | List of all members
HDF5Interface Class Reference

This class provides an interface to some HDF5 functionality. More...

#include <HDF5Interface.h>

Static Public Member Functions

static hid_t open_file (MPI_Comm comm, const std::filesystem::path &filename, const std::string &mode, const bool use_mpi_io)
 Open HDF5 and return file descriptor. More...
 
static void close_file (const hid_t handle)
 Close HDF5 file. More...
 
static void flush_file (const hid_t handle)
 Flush data to file to improve data integrity after interruption. More...
 
static std::filesystem::path get_filename (hid_t handle)
 Get filename. More...
 
template<typename T >
static void write_dataset (const hid_t handle, const std::string &dataset_path, const T *data, const std::array< std::int64_t, 2 > &range, const std::vector< std::int64_t > &global_size, bool use_mpi_io, bool use_chunking)
 Write data to existing HDF file as defined by range blocks on each process. More...
 
template<typename T >
static std::vector< T > read_dataset (const hid_t handle, const std::string &dataset_path, const std::array< std::int64_t, 2 > &range)
 Read data from a HDF5 dataset "dataset_path" as defined by range blocks on each process. More...
 
static bool has_dataset (const hid_t handle, const std::string &dataset_path)
 Check for existence of dataset in HDF5 file. More...
 
static std::vector< std::int64_t > get_dataset_shape (const hid_t handle, const std::string &dataset_path)
 Get dataset shape (size of each dimension) More...
 
static void set_mpi_atomicity (const hid_t handle, const bool atomic)
 Set MPI atomicity. See https://support.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-SetMpiAtomicity and https://www.open-mpi.org/doc/v2.0/man3/MPI_File_set_atomicity.3.php Writes must be followed by an MPI_Barrier on the communicator before any subsequent reads are guaranteed to return the same data.
 
static bool get_mpi_atomicity (const hid_t handle)
 Get MPI atomicity. See https://support.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-GetMpiAtomicity and https://www.open-mpi.org/doc/v2.0/man3/MPI_File_get_atomicity.3.php.
 

Detailed Description

This class provides an interface to some HDF5 functionality.

Member Function Documentation

◆ close_file()

void close_file ( const hid_t  handle)
static

Close HDF5 file.

Parameters
[in]handleHDF5 file handle

◆ flush_file()

void flush_file ( const hid_t  handle)
static

Flush data to file to improve data integrity after interruption.

Parameters
[in]handleHDF5 file handle

◆ get_dataset_shape()

std::vector< std::int64_t > get_dataset_shape ( const hid_t  handle,
const std::string &  dataset_path 
)
static

Get dataset shape (size of each dimension)

Parameters
[in]handleHDF5 file handle
[in]dataset_pathDataset path
Returns
The shape of the dataset (row-major)

◆ get_filename()

std::filesystem::path get_filename ( hid_t  handle)
static

Get filename.

Parameters
[in]handleHDF5 file handle return The filename

◆ has_dataset()

bool has_dataset ( const hid_t  handle,
const std::string &  dataset_path 
)
static

Check for existence of dataset in HDF5 file.

Parameters
[in]handleHDF5 file handle
[in]dataset_pathData set path
Returns
True if dataset_path is in the file

◆ open_file()

hid_t open_file ( MPI_Comm  comm,
const std::filesystem::path &  filename,
const std::string &  mode,
const bool  use_mpi_io 
)
static

Open HDF5 and return file descriptor.

Parameters
[in]commMPI communicator
[in]filenameName of the HDF5 file to open
[in]modeMode in which to open the file (w, r, a)
[in]use_mpi_ioTrue if MPI-IO should be used

◆ read_dataset()

static std::vector<T> read_dataset ( const hid_t  handle,
const std::string &  dataset_path,
const std::array< std::int64_t, 2 > &  range 
)
static

Read data from a HDF5 dataset "dataset_path" as defined by range blocks on each process.

Parameters
[in]handleHDF5 file handle
[in]dataset_pathPath for the dataset in the HDF5 file
[in]rangeThe local range on this processor
Returns
Flattened 1D array of values. If range = {-1, -1}, then all data is read on this process.

◆ write_dataset()

static void write_dataset ( const hid_t  handle,
const std::string &  dataset_path,
const T *  data,
const std::array< std::int64_t, 2 > &  range,
const std::vector< std::int64_t > &  global_size,
bool  use_mpi_io,
bool  use_chunking 
)
static

Write data to existing HDF file as defined by range blocks on each process.

Parameters
[in]handleHDF5 file handle
[in]dataset_pathPath for the dataset in the HDF5 file
[in]dataData to be written, flattened into 1D vector (row-major storage)
[in]rangeThe local range on this processor
[in]global_sizeThe global shape shape of the array
[in]use_mpi_ioTrue if MPI-IO should be used
[in]use_chunkingTrue if chunking should be used

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