Nalu
Nalu: a generalized unstructured massively parallel low Mach flow code designed to support a variety of energy applications of interest (most notably Wind ECP) built on the Sierra Toolkit and Trilinos solver Tpetra/Epetra stack. The open source BSD, clause 3 license model has been chosen for the code base. See LICENSE for more information. http://NaluCFD.org
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sierra::nalu::H5IO Class Reference

Simple wrapper around the HDF5 library to make usage easier. More...

#include <H5IO.h>

Public Member Functions

 H5IO ()
 
 ~H5IO ()
 
void create_file (const std::string &name, int version=1)
 
void open_file (const std::string &name)
 
void close_file ()
 
H5IO create_group (const std::string &name)
 
H5IO open_group (const std::string &name)
 
unsigned int num_attributes ()
 
int file_version () const
 
void write_attribute (const std::string &name, int value)
 
void write_attribute (const std::string &name, unsigned int value)
 
void write_attribute (const std::string &name, double value)
 
void write_attribute (const std::string &name, const std::string &value)
 
void write_attribute (const std::string &name, const std::vector< int > &value)
 
void write_attribute (const std::string &name, const std::vector< unsigned int > &value)
 
void write_attribute (const std::string &name, const std::vector< double > &value)
 
void write_attribute (const std::string &name, const std::vector< std::string > &value)
 
bool has_attribute (const std::string &name)
 
void read_attribute (const std::string &name, int &value)
 
void read_attribute (const std::string &name, unsigned int &value)
 
void read_attribute (const std::string &name, double &value)
 
void read_attribute (const std::string &name, std::string &value)
 
void read_attribute (unsigned int index, std::string &name, std::string &value)
 
void read_attribute (const std::string &name, std::vector< int > &value)
 
void read_attribute (const std::string &name, std::vector< unsigned int > &value)
 
void read_attribute (const std::string &name, std::vector< double > &value)
 
void read_attribute (const std::string &name, std::vector< std::string > &value)
 
void write_dataset (const std::string &name, const std::vector< double > &value)
 
void read_dataset (const std::string &name, std::vector< double > &value)
 

Private Member Functions

void h5io_create_group (const std::string &name)
 
void h5io_open_group (const std::string &name)
 
void h5io_open_group ()
 
void h5io_close_group ()
 
hid_t h5io_create_scalar ()
 
hid_t h5io_create_1D_array (unsigned int size)
 
hid_t h5io_create_attribute (const std::string &name, hid_t type, hid_t space)
 
hid_t h5io_create_dataset (const std::string &name, hid_t type, hid_t space)
 

Private Attributes

std::string fileName_
 
std::string groupName_
 
hid_t file_
 
hid_t group_
 
int fileVersion_
 

Detailed Description

Simple wrapper around the HDF5 library to make usage easier.

This wrapper supports opening a new file for writing or an old file for reading. Once open, the H5IO object allows reading and writing of both attributes (meta-data) and datasets (large blocks of data) to the file. Sub-groups, similar to sub-directories, can be opened inside the file and written to. Typical usage involves passing name/value pairs to the API, and works something like this:

H5IO io;
io.create_file( "fileName.h5" );

io.write_attribute( "attribute1", attribute1 );
io.write_attribute( "attribute2", attribute2 );
io.write_dataset( "data1", data1 );
io.write_dataset( "data2", data2 );

H5IO group = io.create_group( "groupName" );
group.write_attribute( "attribute3", attribute3 );
group.write_dataset( "data3", data3 );

io.close_file();

This data can be read back from disk using a similar procedure. Note that the variables can be read back from the file in a different order (or not at all). The same order is preserved here, for clarity:

H5IO io;
io.open_file( "fileName.h5" );

io.read_attribute( "attribute1", attribute1 );
io.read_attribute( "attribute2", attribute2 );
io.read_dataset( "data1", data1 );
io.read_dataset( "data2", data2 );

H5IO group = io.open_group( "groupName" );
group.read_attribute( "attribute3", attribute3 );
group.read_dataset( "data3", data3 );

io.close_file();

Constructor & Destructor Documentation

sierra::nalu::H5IO::H5IO ( )
sierra::nalu::H5IO::~H5IO ( )

Member Function Documentation

void sierra::nalu::H5IO::close_file ( )
void sierra::nalu::H5IO::create_file ( const std::string &  name,
int  version = 1 
)
H5IO sierra::nalu::H5IO::create_group ( const std::string &  name)
int sierra::nalu::H5IO::file_version ( ) const
inline
void sierra::nalu::H5IO::h5io_close_group ( )
private
hid_t sierra::nalu::H5IO::h5io_create_1D_array ( unsigned int  size)
private

References fileName_, and groupName_.

Referenced by file_version(), write_attribute(), and write_dataset().

hid_t sierra::nalu::H5IO::h5io_create_attribute ( const std::string &  name,
hid_t  type,
hid_t  space 
)
private

References fileName_, group_, and groupName_.

Referenced by file_version(), and write_attribute().

hid_t sierra::nalu::H5IO::h5io_create_dataset ( const std::string &  name,
hid_t  type,
hid_t  space 
)
private

References fileName_, group_, and groupName_.

Referenced by file_version(), and write_dataset().

void sierra::nalu::H5IO::h5io_create_group ( const std::string &  name)
private

References file_, fileName_, group_, groupName_, and h5io_close_group().

Referenced by file_version().

hid_t sierra::nalu::H5IO::h5io_create_scalar ( )
private

References fileName_, and groupName_.

Referenced by file_version(), and write_attribute().

void sierra::nalu::H5IO::h5io_open_group ( const std::string &  name)
private
void sierra::nalu::H5IO::h5io_open_group ( )
private
bool sierra::nalu::H5IO::has_attribute ( const std::string &  name)
unsigned int sierra::nalu::H5IO::num_attributes ( )
void sierra::nalu::H5IO::open_file ( const std::string &  name)
H5IO sierra::nalu::H5IO::open_group ( const std::string &  name)
void sierra::nalu::H5IO::read_attribute ( const std::string &  name,
int &  value 
)
void sierra::nalu::H5IO::read_attribute ( const std::string &  name,
unsigned int &  value 
)
void sierra::nalu::H5IO::read_attribute ( const std::string &  name,
double &  value 
)
void sierra::nalu::H5IO::read_attribute ( const std::string &  name,
std::string &  value 
)
void sierra::nalu::H5IO::read_attribute ( unsigned int  index,
std::string &  name,
std::string &  value 
)
void sierra::nalu::H5IO::read_attribute ( const std::string &  name,
std::vector< int > &  value 
)
void sierra::nalu::H5IO::read_attribute ( const std::string &  name,
std::vector< unsigned int > &  value 
)
void sierra::nalu::H5IO::read_attribute ( const std::string &  name,
std::vector< double > &  value 
)
void sierra::nalu::H5IO::read_attribute ( const std::string &  name,
std::vector< std::string > &  value 
)
void sierra::nalu::H5IO::read_dataset ( const std::string &  name,
std::vector< double > &  value 
)
void sierra::nalu::H5IO::write_attribute ( const std::string &  name,
int  value 
)
void sierra::nalu::H5IO::write_attribute ( const std::string &  name,
unsigned int  value 
)
void sierra::nalu::H5IO::write_attribute ( const std::string &  name,
double  value 
)
void sierra::nalu::H5IO::write_attribute ( const std::string &  name,
const std::string &  value 
)
void sierra::nalu::H5IO::write_attribute ( const std::string &  name,
const std::vector< int > &  value 
)
void sierra::nalu::H5IO::write_attribute ( const std::string &  name,
const std::vector< unsigned int > &  value 
)
void sierra::nalu::H5IO::write_attribute ( const std::string &  name,
const std::vector< double > &  value 
)
void sierra::nalu::H5IO::write_attribute ( const std::string &  name,
const std::vector< std::string > &  value 
)
void sierra::nalu::H5IO::write_dataset ( const std::string &  name,
const std::vector< double > &  value 
)

Member Data Documentation

hid_t sierra::nalu::H5IO::file_
private
std::string sierra::nalu::H5IO::fileName_
private
int sierra::nalu::H5IO::fileVersion_
private
hid_t sierra::nalu::H5IO::group_
private
std::string sierra::nalu::H5IO::groupName_
private

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