|
libROM
v1.0
Data-driven physical simulation library
|
#include <CSVDatabase.h>
Public Member Functions | |
| CSVDatabase () | |
| Default constructor. | |
| virtual | ~CSVDatabase () |
| Destructor. | |
| bool | create (const std::string &file_name, const MPI_Comm comm=MPI_COMM_NULL) override |
| Creates a new CSV database file with the supplied name. NOTE: CSVDatabase does not actually create a file with this. This function will only print out the file_name. More... | |
| bool | open (const std::string &file_name, const std::string &type, const MPI_Comm comm=MPI_COMM_NULL) override |
| Opens an existing CSV database file with the supplied name. NOTE: CSVDatabase does not actually open a file with this. This function will only print out the file_name. More... | |
| bool | close () override |
| Closes the currently open CSV database file. More... | |
| void | putIntegerArray (const std::string &file_name, const int *const data, int nelements, const bool distributed=false) override |
| Writes an array of integers associated with the supplied filename. More... | |
| void | putDoubleArray (const std::string &file_name, const double *const data, int nelements, const bool distributed=false) override |
| Writes an array of doubles associated with the supplied filename. More... | |
| void | putDoubleVector (const std::string &file_name, const std::vector< double > &data, int nelements, const bool distributed=false) override |
| Writes a vector of doubles associated with the supplied filename to the currently open CSV database file. More... | |
| void | putComplexVector (const std::string &file_name, const std::vector< std::complex< double >> &data, int nelements) |
| Writes a vector of complex doubles associated with the supplied filename. More... | |
| void | putStringVector (const std::string &file_name, const std::vector< std::string > &data, int nelements) |
| Writes a vector of strings associated with the supplied filename. More... | |
| void | getIntegerArray (const std::string &file_name, int *data, int nelements, const bool distributed=false) override |
| Reads an array of integers associated with the supplied filename. More... | |
| void | getIntegerVector (const std::string &file_name, std::vector< int > &data, bool append=false) |
| Reads a vector of integers associated with the supplied filename. More... | |
| int | getDoubleArraySize (const std::string &file_name) override |
| Count the number of elements in an array of doubles associated with the supplied filename. More... | |
| void | getDoubleArray (const std::string &file_name, double *data, int nelements, const bool distributed=false) override |
| Reads an array of doubles associated with the supplied filename. More... | |
| void | getDoubleArray (const std::string &file_name, double *data, int nelements, const std::vector< int > &idx, const bool distributed=false) override |
| Reads a sub-array of doubles associated with the supplied filename. More... | |
| void | getDoubleArray (const std::string &file_name, double *data, int nelements, int offset, int block_size, int stride, const bool distributed=false) override |
| Reads an array of doubles associated with the supplied filename. More... | |
| void | getDoubleVector (const std::string &file_name, std::vector< double > &data, bool append=false) |
| Reads a vector of doubles associated with the supplied filename. More... | |
| void | getStringVector (const std::string &file_name, std::vector< std::string > &data, bool append=false) |
| Reads a vector of strings associated with the supplied filename. More... | |
| int | getLineCount (const std::string &file_name) |
| Count the number of lines of CSV 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... | |
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. | |
CSVDatabase implements the interface of Database for CSV database files.
Definition at line 26 of file CSVDatabase.h.
|
overridevirtual |
Closes the currently open CSV database file.
Implements CAROM::Database.
Definition at line 49 of file CSVDatabase.cpp.
|
overridevirtual |
Creates a new CSV database file with the supplied name. NOTE: CSVDatabase does not actually create a file with this. This function will only print out the file_name.
| [in] | file_name | Name of CSV database file to create. |
| [in] | comm | MPI communicator for distributed data I/O. CSVDatabase I/O is always performed serially, regardless. |
Reimplemented from CAROM::Database.
Definition at line 30 of file CSVDatabase.cpp.
|
overridevirtual |
Reads an array of doubles associated with the supplied filename.
| [in] | file_name | The filename 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. CSVDatabase reads the array serially whether or not distributed. |
Implements CAROM::Database.
Definition at line 194 of file CSVDatabase.cpp.
|
overridevirtual |
Reads a sub-array of doubles associated with the supplied filename.
| [in] | file_name | The filename 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 integer array. CSVDatabase reads the array serially whether or not distributed. |
Implements CAROM::Database.
Definition at line 217 of file CSVDatabase.cpp.
|
overridevirtual |
Reads an array of doubles associated with the supplied filename.
| [in] | file_name | The filename 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. |
| [in] | block_size | The block size to read from the CSV dataset. |
| [in] | stride | The stride to read from the CSV dataset. |
| [in] | distributed | True if data is a distributed integer array. CSVDatabase reads the array serially whether or not distributed. |
Implements CAROM::Database.
Definition at line 257 of file CSVDatabase.cpp.
|
inlineoverridevirtual |
Count the number of elements in an array of doubles associated with the supplied filename.
| [in] | file_name | The filename associated with the array of values to be read. |
Implements CAROM::Database.
Definition at line 228 of file CSVDatabase.h.
| void CAROM::CSVDatabase::getDoubleVector | ( | const std::string & | file_name, |
| std::vector< double > & | data, | ||
| bool | append = false |
||
| ) |
Reads a vector of doubles associated with the supplied filename.
| [in] | file_name | The filename associated with the vector of values to be read. |
| [out] | data | The allocated vector of double values to be read. |
| [in] | append | If true, append to the vector, otherwise overwrite. |
Definition at line 301 of file CSVDatabase.cpp.
|
overridevirtual |
Reads an array of integers associated with the supplied filename.
| [in] | file_name | The filename 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. CSVDatabase reads the array serially whether or not distributed. |
Implements CAROM::Database.
Definition at line 151 of file CSVDatabase.cpp.
| void CAROM::CSVDatabase::getIntegerVector | ( | const std::string & | file_name, |
| std::vector< int > & | data, | ||
| bool | append = false |
||
| ) |
Reads a vector of integers associated with the supplied filename.
| [in] | file_name | The filename associated with the vector of values to be read. |
| [out] | data | The allocated vector of integer values to be read. |
| [in] | append | If true, append to the vector, otherwise overwrite. |
Definition at line 176 of file CSVDatabase.cpp.
| int CAROM::CSVDatabase::getLineCount | ( | const std::string & | file_name | ) |
Count the number of lines of CSV database file.
| [in] | file_name | The filename associated with the vector of strings to be read. |
Definition at line 337 of file CSVDatabase.cpp.
| void CAROM::CSVDatabase::getStringVector | ( | const std::string & | file_name, |
| std::vector< std::string > & | data, | ||
| bool | append = false |
||
| ) |
Reads a vector of strings associated with the supplied filename.
| [in] | file_name | The filename associated with the vector of strings to be read. |
| [out] | data | The allocated vector of strings to be read. |
| [in] | append | If true, append to the vector, otherwise overwrite. |
Definition at line 319 of file CSVDatabase.cpp.
|
overridevirtual |
Opens an existing CSV database file with the supplied name. NOTE: CSVDatabase does not actually open a file with this. This function will only print out the file_name.
| [in] | file_name | Name of existing CSV database file to open. |
| [in] | type | Read/write type ("r"/"wr") |
| [in] | comm | MPI communicator for distributed data I/O. CSVDatabase I/O is always performed serially, regardless. |
Reimplemented from CAROM::Database.
Definition at line 39 of file CSVDatabase.cpp.
| void CAROM::CSVDatabase::putComplexVector | ( | const std::string & | file_name, |
| const std::vector< std::complex< double >> & | data, | ||
| int | nelements | ||
| ) |
Writes a vector of complex doubles associated with the supplied filename.
| [in] | file_name | The filename associated with the vector of values to be written. |
| [in] | data | The vector of complex double values to be written. |
| [in] | nelements | The number of complex doubles in the vector. |
Definition at line 114 of file CSVDatabase.cpp.
|
overridevirtual |
Writes an array of doubles associated with the supplied filename.
| [in] | file_name | The filename 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. CSVDatabase writes the array serially whether or not distributed. |
Implements CAROM::Database.
Definition at line 74 of file CSVDatabase.cpp.
|
overridevirtual |
Writes a vector of doubles associated with the supplied filename to the currently open CSV database file.
| [in] | file_name | The filename 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 vector. CSVDatabase writes the vector serially whether or not distributed. |
Implements CAROM::Database.
Definition at line 94 of file CSVDatabase.cpp.
|
overridevirtual |
Writes an array of integers associated with the supplied filename.
| [in] | file_name | The filename 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. CSVDatabase writes the array serially whether or not distributed. |
Implements CAROM::Database.
Definition at line 55 of file CSVDatabase.cpp.
| void CAROM::CSVDatabase::putStringVector | ( | const std::string & | file_name, |
| const std::vector< std::string > & | data, | ||
| int | nelements | ||
| ) |
Writes a vector of strings associated with the supplied filename.
| [in] | file_name | The filename associated with the vector of values to be written. |
| [in] | data | The vector of strings to be written. |
| [in] | nelements | The number of strings in the vector. |
Definition at line 133 of file CSVDatabase.cpp.