libROM
v1.0
Data-driven physical simulation library
|
#include <Database.h>
Public Types | |
enum class | formats { HDF5 , CSV , HDF5_MPIO } |
Implemented database file formats. Add to this enum each time a new database format is implemented. | |
Public Member Functions | |
Database () | |
Default constructor. | |
virtual | ~Database () |
Destructor. | |
virtual bool | create (const std::string &file_name, const MPI_Comm comm=MPI_COMM_NULL) |
Creates a new 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) |
Opens an existing database file with the supplied name. More... | |
virtual bool | close ()=0 |
Closes the currently open database file. More... | |
void | putInteger (const std::string &key, int data) |
Writes an integer associated with the supplied key to currently open database file. More... | |
virtual void | putIntegerArray (const std::string &key, const int *const data, int nelements, const bool distributed=false)=0 |
Writes an array of integers associated with the supplied key to the 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... | |
virtual void | putDoubleArray (const std::string &key, const double *const data, int nelements, const bool distributed=false)=0 |
Writes an array of doubles associated with the supplied key to the currently open database file. More... | |
virtual void | putDoubleVector (const std::string &key, const std::vector< double > &data, int nelements, const bool distributed=false)=0 |
Writes a vector of doubles associated with the supplied key to the 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... | |
virtual void | getIntegerArray (const std::string &key, int *data, int nelements, const bool distributed=false)=0 |
Reads an array of integers 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... | |
virtual int | getDoubleArraySize (const std::string &key)=0 |
Count the number of elements in an array of doubles associated with the supplied key from the currently open database file. More... | |
virtual void | getDoubleArray (const std::string &key, double *data, int nelements, const bool distributed=false)=0 |
Reads an array of doubles associated with the supplied key from the currently open database file. More... | |
virtual void | getDoubleArray (const std::string &key, double *data, int nelements, const std::vector< int > &idx, const bool distributed=false)=0 |
Reads a sub-array of doubles associated with the supplied key from the currently open 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)=0 |
Reads an array of doubles associated with the supplied key from the currently open database file. More... | |
Class Database is an abstract base class that provides basic ability to write to and read from a file. It's capabilities are limited to what the SVD algorithm needs to read and write its basis vectors.
Definition at line 30 of file Database.h.
|
pure virtual |
Closes the currently open database file.
Implemented in CAROM::HDFDatabase, and CAROM::CSVDatabase.
|
virtual |
Creates a new database file with the supplied name.
[in] | file_name | Name of database file to create. |
[in] | comm | MPI communicator for distributed data I/O. If MPI_COMM_NULL, the file will be created serially. The behavior for distributed I/O will vary by classes. |
Reimplemented in CAROM::HDFDatabase, and CAROM::CSVDatabase.
Definition at line 35 of file Database.cpp.
|
inline |
Reads a double associated with the supplied key from the currently open database file.
[in] | key | The key associated with the value to be read. |
[out] | data | The double value read. |
Definition at line 216 of file Database.h.
|
pure virtual |
Reads an array of doubles associated with the supplied key from the currently open 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 | If true, distributed double array will be read. the distributed I/O behavior varies with classes. |
Implemented in CAROM::HDFDatabase, and CAROM::CSVDatabase.
|
pure virtual |
Reads a sub-array of doubles associated with the supplied key from the currently open 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 | If true, distributed double array will be read. the distributed I/O behavior varies with classes. |
Implemented in CAROM::HDFDatabase, and CAROM::CSVDatabase.
|
pure virtual |
Reads an array of doubles associated with the supplied key from the currently open 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 zero-based 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 | If true, distributed double array will be read. the distributed I/O behavior varies with classes. |
Implemented in CAROM::HDFDatabase, and CAROM::CSVDatabase.
|
pure virtual |
Count the number of elements in an array of doubles associated with the supplied key from the currently open database file.
[in] | key | The key associated with the array of values to be read. |
Implemented in CAROM::HDFDatabase, and CAROM::CSVDatabase.
|
inline |
Reads an integer associated with the supplied key from the currently open database file.
[in] | key | The key associated with the value to be read. |
[out] | data | The integer value read. |
Definition at line 182 of file Database.h.
|
pure virtual |
Reads an array of integers associated with the supplied key from the currently open 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 | If true, distributed integer array will be read. the distributed I/O behavior varies with classes. |
Implemented in CAROM::HDFDatabase, and CAROM::CSVDatabase.
|
virtual |
Opens an existing database file with the supplied name.
[in] | file_name | Name of existing database file to open. |
[in] | type | Read/write type ("r"/"wr") |
[in] | comm | MPI communicator for distributed data I/O. If MPI_COMM_NULL, the file will be opened serially. The behavior for distributed I/O will vary by classes. |
Reimplemented in CAROM::HDFDatabase, and CAROM::CSVDatabase.
Definition at line 44 of file Database.cpp.
|
inline |
Writes a double associated with the supplied key to currently open database file.
[in] | key | The key associated with the value to be written. |
[in] | data | The double value to be written. |
Definition at line 129 of file Database.h.
|
pure virtual |
Writes an array of doubles associated with the supplied key to the currently open 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 | If true, distributed double array will be written. the distributed I/O behavior varies with classes. |
Implemented in CAROM::HDFDatabase, and CAROM::CSVDatabase.
|
pure virtual |
Writes a vector of doubles associated with the supplied key to the currently open 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 | If true, distributed double vector will be written. the distributed I/O behavior varies with classes. |
Implemented in CAROM::HDFDatabase, and CAROM::CSVDatabase.
|
inline |
Writes an integer associated with the supplied key to currently open database file.
[in] | key | The key associated with the value to be written. |
[in] | data | The integer value to be written. |
Definition at line 95 of file Database.h.
|
pure virtual |
Writes an array of integers associated with the supplied key to the currently open 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 | If true, distributed integer array will be written. the distributed I/O behavior varies with classes. |
Implemented in CAROM::HDFDatabase, and CAROM::CSVDatabase.