libROM
v1.0
Data-driven physical simulation library
|
#include <HDFDatabase.h>
Public Member Functions | |
HDFDatabase () | |
Default constructor. | |
virtual | ~HDFDatabase () |
Destructor. | |
virtual bool | create (const std::string &file_name, const MPI_Comm comm=MPI_COMM_NULL) override |
Creates a new HDF5 database file with the supplied name. More... | |
virtual bool | open (const std::string &file_name, const std::string &type, const MPI_Comm comm=MPI_COMM_NULL) override |
Opens an existing HDF5 database file with the supplied name. More... | |
virtual bool | close () |
Closes the currently open HDF5 database file. More... | |
virtual void | putIntegerArray (const std::string &key, const int *const data, int nelements, const bool distributed=false) |
Writes an array of integers associated with the supplied key to the currently open HDF5 database file. More... | |
virtual void | putDoubleArray (const std::string &key, const double *const data, int nelements, const bool distributed=false) |
Writes an array of doubles associated with the supplied key to the currently open HDF5 database file. More... | |
virtual void | putDoubleVector (const std::string &key, const std::vector< double > &data, int nelements, const bool distributed=false) |
Writes a vector of doubles associated with the supplied key to the currently open HDF5 database file. More... | |
virtual void | getIntegerArray (const std::string &key, int *data, int nelements, const bool distributed=false) |
Reads an array of integers associated with the supplied key from the currently open HDF5 database file. More... | |
virtual int | getDoubleArraySize (const std::string &key) |
Count the number of elements in an array of doubles associated with the supplied key from the currently open HDF5 database file. More... | |
virtual void | getDoubleArray (const std::string &key, double *data, int nelements, const bool distributed=false) |
Reads an array of doubles associated with the supplied key from the currently open HDF5 database file. More... | |
virtual void | getDoubleArray (const std::string &key, double *data, int nelements, const std::vector< int > &idx, const bool distributed=false) |
Reads a sub-array of doubles associated with the supplied key from the currently open HDF5 database file. More... | |
virtual void | getDoubleArray (const std::string &key, double *data, int nelements, int offset, int block_size, int stride, const bool distributed=false) |
Reads an array of doubles associated with the supplied key from the currently open HDF5 database file. More... | |
Public Member Functions inherited from CAROM::Database | |
Database () | |
Default constructor. | |
virtual | ~Database () |
Destructor. | |
void | putInteger (const std::string &key, int data) |
Writes an integer associated with the supplied key to currently open database file. More... | |
void | putDouble (const std::string &key, double data) |
Writes a double associated with the supplied key to currently open database file. More... | |
void | getInteger (const std::string &key, int &data) |
Reads an integer associated with the supplied key from the currently open database file. More... | |
void | getDouble (const std::string &key, double &data) |
Reads a double associated with the supplied key from the currently open database file. More... | |
Protected Member Functions | |
bool | isInteger (const std::string &key) |
Returns true if the specified key represents an integer entry. If the key does not exist or if the string is empty then false is returned. More... | |
bool | isDouble (const std::string &key) |
Returns true if the specified key represents a double entry. If the key does not exist or if the string is empty then false is returned. More... | |
virtual void | writeAttribute (int type_key, hid_t dataset_id) |
Write an attribute to the specified dataset. More... | |
int | readAttribute (hid_t dataset_id) |
Read an attribute from the specified dataset. More... | |
Protected Attributes | |
bool | d_is_file |
True if the HDF5 database is mounted to a file. | |
hid_t | d_file_id |
ID of file attached to database or -1 if not mounted to a file. | |
hid_t | d_group_id |
ID of the group attached to the database. | |
int | d_rank |
MPI process rank. | |
Static Protected Attributes | |
static const int | KEY_DOUBLE_ARRAY = 0 |
The key representing a double array. | |
static const int | KEY_INT_ARRAY = 1 |
The key representing an integer array. | |
Additional Inherited Members | |
Public Types inherited from CAROM::Database | |
enum class | formats { HDF5 , CSV , HDF5_MPIO } |
Implemented database file formats. Add to this enum each time a new database format is implemented. | |
HDFDatabase implements the interface of Database for HDF5 database files.
Definition at line 26 of file HDFDatabase.h.
|
virtual |
Closes the currently open HDF5 database file.
Implements CAROM::Database.
Definition at line 118 of file HDFDatabase.cpp.
|
overridevirtual |
Creates a new HDF5 database file with the supplied name.
[in] | file_name | Name of HDF5 database file to create. |
[in] | comm | MPI communicator for distributed data I/O. If not MPI_COMM_NULL, each process creates a file whose name is file_name extended with process rank in 6 digits. |
Reimplemented from CAROM::Database.
Definition at line 45 of file HDFDatabase.cpp.
|
virtual |
Reads an array of doubles associated with the supplied key from the currently open HDF5 database file.
[in] | key | The key associated with the array of values to be read. |
[out] | data | The allocated array of double values to be read. |
[in] | nelements | The number of doubles in the array. |
[in] | distributed | True if data is a distributed double array. HDFDatabase reads the array in file-per-process, where each file is read serially by one process. |
Implements CAROM::Database.
Definition at line 323 of file HDFDatabase.cpp.
|
virtual |
Reads a sub-array of doubles associated with the supplied key from the currently open HDF5 database file.
[in] | key | The key associated with the array of values to be read. |
[out] | data | The allocated sub-array of double values to be read. |
[in] | nelements | The number of doubles in the full array. |
[in] | idx | The set of indices in the sub-array. |
[in] | distributed | True if data is a distributed double array. HDFDatabase reads the array in file-per-process, where each file is read serially by one process. |
Implements CAROM::Database.
Definition at line 366 of file HDFDatabase.cpp.
|
virtual |
Reads an array of doubles associated with the supplied key from the currently open HDF5 database file.
[in] | key | The key associated with the array of values to be read. |
[out] | data | The allocated array of double values to be read. |
[in] | nelements | The number of doubles in the array. |
[in] | offset | The initial offset in the array. Typically, this is a column index of the matrix data. |
[in] | block_size | The block size to read from the HDF5 dataset. Typically, this is a number of columns of the matrix data. |
[in] | stride | The stride to read from the HDF5 dataset. Typically, this is the total number of columns of the matrix data. |
[in] | distributed | True if data is a distributed double array. HDFDatabase reads the array in file-per-process, where each file is read serially by one process. |
Implements CAROM::Database.
Definition at line 398 of file HDFDatabase.cpp.
|
virtual |
Count the number of elements in an array of doubles associated with the supplied key from the currently open HDF5 database file.
[in] | key | The key associated with the array of values to be read. |
Implements CAROM::Database.
Definition at line 294 of file HDFDatabase.cpp.
|
virtual |
Reads an array of integers associated with the supplied key from the currently open HDF5 database file.
[in] | key | The key associated with the array of values to be read. |
[out] | data | The allocated array of integer values to be read. |
[in] | nelements | The number of integers in the array. |
[in] | distributed | True if data is a distributed integer array. HDFDatabase reads the array in file-per-process, where each file is read serially by one process. |
Implements CAROM::Database.
Definition at line 252 of file HDFDatabase.cpp.
|
protected |
Returns true if the specified key represents a double entry. If the key does not exist or if the string is empty then false is returned.
[in] | key | The key associated with the data we are interested in. |
Definition at line 481 of file HDFDatabase.cpp.
|
protected |
Returns true if the specified key represents an integer entry. If the key does not exist or if the string is empty then false is returned.
[in] | key | The key associated with the data we are interested in. |
Definition at line 453 of file HDFDatabase.cpp.
|
overridevirtual |
Opens an existing HDF5 database file with the supplied name.
[in] | file_name | Name of existing HDF5 database file to open. |
[in] | type | Read/write type ("r"/"wr") If not MPI_COMM_NULL, each process opens a file whose name is file_name extended with process rank in 6 digits. |
Reimplemented from CAROM::Database.
Definition at line 76 of file HDFDatabase.cpp.
|
virtual |
Writes an array of doubles associated with the supplied key to the currently open HDF5 database file.
[in] | key | The key associated with the array of values to be written. |
[in] | data | The array of double values to be written. |
[in] | nelements | The number of doubles in the array. |
[in] | distributed | True if data is a distributed double array. HDFDatabase writes the array in file-per-process, where each file is written serially by one process. |
Implements CAROM::Database.
Definition at line 189 of file HDFDatabase.cpp.
|
virtual |
Writes a vector of doubles associated with the supplied key to the currently open HDF5 database file.
[in] | key | The key associated with the vector of values to be written. |
[in] | data | The vector of double values to be written. |
[in] | nelements | The number of doubles in the vector. |
[in] | distributed | True if data is a distributed double array. HDFDatabase writes the array in file-per-process, where each file is written serially by one process. |
Implements CAROM::Database.
Definition at line 242 of file HDFDatabase.cpp.
|
virtual |
Writes an array of integers associated with the supplied key to the currently open HDF5 database file.
[in] | key | The key associated with the array of values to be written. |
[in] | data | The array of integer values to be written. |
[in] | nelements | The number of integers in the array. |
[in] | distributed | True if data is a distributed integer array. HDFDatabase writes the array in file-per-process, where each file is written serially by one process. |
Implements CAROM::Database.
Definition at line 136 of file HDFDatabase.cpp.
|
protected |
Read an attribute from the specified dataset.
[in] | dataset_id | ID of the dataset key will be written to. |
Definition at line 546 of file HDFDatabase.cpp.
|
protectedvirtual |
Write an attribute to the specified dataset.
[in] | type_key | The attribute to be written. |
[in] | dataset_id | ID of the dataset key will be written to. |
Definition at line 509 of file HDFDatabase.cpp.