deal.II version GIT relicensing-2165-gc91f007519 2024-11-20 01:40:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Types | Protected Attributes | Private Member Functions | List of all members
HDF5::File Class Reference

#include <deal.II/base/hdf5.h>

Inheritance diagram for HDF5::File:
Inheritance graph
[legend]

Public Types

enum class  FileAccessMode { open , create }
 

Public Member Functions

 File (const std::string &name, const FileAccessMode mode)
 
 File (const std::string &name, const FileAccessMode mode, const MPI_Comm mpi_communicator)
 
Group open_group (const std::string &name) const
 
Group create_group (const std::string &name) const
 
DataSet open_dataset (const std::string &name) const
 
template<typename number >
DataSet create_dataset (const std::string &name, const std::vector< hsize_t > &dimensions) const
 
template<typename Container >
void write_dataset (const std::string &name, const Container &data) const
 
template<typename T >
get_attribute (const std::string &attr_name) const
 
template<>
std::string get_attribute (const std::string &attr_name) const
 
template<typename T >
void set_attribute (const std::string &attr_name, const T value)
 
template<>
void set_attribute (const std::string &attr_name, const std::string value)
 
std::string get_name () const
 

Protected Types

enum class  GroupAccessMode { open , create }
 

Protected Attributes

const std::string name
 
std::shared_ptr< hid_t > hdf5_reference
 
const bool mpi
 

Private Member Functions

 File (const std::string &name, const FileAccessMode mode, const bool mpi, const MPI_Comm mpi_communicator)
 

Detailed Description

This class implements an HDF5 File

Definition at line 1073 of file hdf5.h.

Member Enumeration Documentation

◆ FileAccessMode

enum class HDF5::File::FileAccessMode
strong

File access mode

Enumerator
open 

Read/write, file must exist

create 

Create file, truncate if exists

Definition at line 1079 of file hdf5.h.

◆ GroupAccessMode

enum class HDF5::Group::GroupAccessMode
strongprotectedinherited

Group access mode

Enumerator
open 

Opens an existing group

create 

Creates a new group

Definition at line 982 of file hdf5.h.

Constructor & Destructor Documentation

◆ File() [1/3]

HDF5::File::File ( const std::string &  name,
const FileAccessMode  mode 
)

Creates or opens an HDF5 file for serial operations. This call does not require MPI support. It creates or opens an HDF5 file depending on the value of mode.

Definition at line 390 of file hdf5.cc.

◆ File() [2/3]

HDF5::File::File ( const std::string &  name,
const FileAccessMode  mode,
const MPI_Comm  mpi_communicator 
)

Creates or opens an HDF5 file in parallel using MPI. This requires that deal.II and HDF5 were compiled with MPI support. It creates or opens a HDF5 file depending on the value of mode. mpi_communicator defines the processes that participate in this call; MPI_COMM_WORLD is a common value for the MPI communicator.

Definition at line 404 of file hdf5.cc.

◆ File() [3/3]

HDF5::File::File ( const std::string &  name,
const FileAccessMode  mode,
const bool  mpi,
const MPI_Comm  mpi_communicator 
)
private

Delegation internal constructor. File(const std::string &, const MPI_Comm , const Mode); and File(const std::string &, const Mode) should be used to open or create HDF5 files.

Definition at line 412 of file hdf5.cc.

Member Function Documentation

◆ open_group()

Group HDF5::Group::open_group ( const std::string &  name) const
inherited

Opens a sub-group of the current Group or File.

Definition at line 367 of file hdf5.cc.

◆ create_group()

Group HDF5::Group::create_group ( const std::string &  name) const
inherited

Creates a sub-group in the current Group or File.

Definition at line 375 of file hdf5.cc.

◆ open_dataset()

DataSet HDF5::Group::open_dataset ( const std::string &  name) const
inherited

Opens a dataset.

Definition at line 383 of file hdf5.cc.

◆ create_dataset()

template<typename number >
DataSet HDF5::Group::create_dataset ( const std::string &  name,
const std::vector< hsize_t > &  dimensions 
) const
inherited

Creates a dataset. number can be float, double, std::complex<float>, std::complex<double>, int or unsigned int.

Datatype conversion takes place at the time of a read or write and is automatic. See the Data Transfer: Datatype Conversion and Selection section in the HDF5 User's Guide.

Definition at line 2233 of file hdf5.h.

◆ write_dataset()

template<typename Container >
void HDF5::Group::write_dataset ( const std::string &  name,
const Container &  data 
) const
inherited

Create and write data to a dataset. number can be float, double, std::complex<float>, std::complex<double>, int or unsigned int.

Datatype conversion takes place at the time of a read or write and is automatic. See the Data Transfer: Datatype Conversion and Selection section in the HDF5 User's Guide.

Container can be std::vector<float>, std::vector<double>, std::vector<std::complex<float>>, std::vector<std::complex<double>>, std::vector<int>, std::vector<unsigned int>, Vector<float>, Vector<double>, Vector<std::complex<float>>, Vector<std::complex<double>>, FullMatrix<float>, FullMatrix<double>, FullMatrix<std::complex<float>> or FullMatrix<std::complex<double>>.

Definition at line 2244 of file hdf5.h.

◆ get_attribute() [1/2]

template<typename T >
T HDF5::HDF5Object::get_attribute ( const std::string &  attr_name) const
inherited

Reads an attribute. T can be float, double, std::complex<float>, std::complex<double>, int, unsigned int, bool or std::string. Note that the encoding of std::string is UTF8 in order to be compatible with python3.

Datatype conversion takes place at the time of a read or write and is automatic. See the Data Transfer: Datatype Conversion and Selection section in the HDF5 User's Guide.

Definition at line 1597 of file hdf5.h.

◆ get_attribute() [2/2]

template<>
std::string HDF5::HDF5Object::get_attribute ( const std::string &  attr_name) const
inlineinherited

Definition at line 1620 of file hdf5.h.

◆ set_attribute() [1/2]

template<typename T >
void HDF5::HDF5Object::set_attribute ( const std::string &  attr_name,
const T  value 
)
inherited

Writes an attribute. T can be float, double, std::complex<float>, std::complex<double>, int, unsigned int, bool or std::string. Note that the encoding of std::string is UTF8 in order to be compatible with python3.

Datatype conversion takes place at the time of a read or write and is automatic. See the Data Transfer: Datatype Conversion and Selection section in the HDF5 User's Guide.

Definition at line 1674 of file hdf5.h.

◆ set_attribute() [2/2]

template<>
void HDF5::HDF5Object::set_attribute ( const std::string &  attr_name,
const std::string  value 
)
inlineinherited

Definition at line 1714 of file hdf5.h.

◆ get_name()

std::string HDF5::HDF5Object::get_name ( ) const
inherited

Returns the name of the object. In the case of File, name corresponds to the file name. In the case of Group and DataSet, name corresponds to the name of the object in the HDF5 file.

Definition at line 76 of file hdf5.cc.

Member Data Documentation

◆ name

const std::string HDF5::HDF5Object::name
protectedinherited

Name of the HDF5Object. In the case of File, name corresponds to the file name. In the case of Group and DataSet name corresponds to the name of the object in the HDF5 file.

Definition at line 405 of file hdf5.h.

◆ hdf5_reference

std::shared_ptr<hid_t> HDF5::HDF5Object::hdf5_reference
protectedinherited

HDF5 identifier for the objects File, Group and DataSet. The std::shared_ptr<> pointer allows the object to be copied. For example several parts of the program can share and access the same group; when all the functions that access the group are closed, the HDF5 resources of the group will be automatically released.

Definition at line 414 of file hdf5.h.

◆ mpi

const bool HDF5::HDF5Object::mpi
protectedinherited

If true use parallel HDF5, if false use serial HDF5.

Definition at line 419 of file hdf5.h.


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