libROM
v1.0
Data-driven physical simulation library
|
#include <BasisGenerator.h>
Public Member Functions | |
BasisGenerator (Options options, bool incremental, const std::string &basis_file_name="", Database::formats file_format=Database::formats::HDF5) | |
Constructor. More... | |
~BasisGenerator () | |
Destructor. | |
bool | isNextSample (double time) |
Returns true if it is time for the next svd sample. More... | |
bool | updateRightSV () |
Check whether right basis vectors will be updated. More... | |
bool | takeSample (double *u_in, bool add_without_increase=false) |
Sample the new state, u_in, at the given time. More... | |
void | endSamples (const std::string &kind="basis") |
Signal that the final sample has been taken. More... | |
void | writeSnapshot () |
Write current snapshot matrix. | |
void | loadSampleRange (const std::string &base_file_name, const std::string &kind="basis", int col_min=0, int col_max=1e9, Database::formats db_format=Database::formats::HDF5) |
Load previously saved sample (basis or state) within a column range. More... | |
void | loadSamples (const std::string &base_file_name, const std::string &kind="basis", int cut_off=1e9, Database::formats db_format=Database::formats::HDF5) |
Load previously saved sample (basis or state). More... | |
double | computeNextSampleTime (double *u_in, double *rhs_in, double time) |
Computes next time an svd sample is needed. More... | |
const Matrix * | getSpatialBasis () |
Returns the basis vectors for the current time interval as a Matrix. More... | |
const Matrix * | getTemporalBasis () |
Returns the temporal basis vectors for the current time interval as a Matrix. More... | |
const Vector * | getSingularValues () |
Returns the singular values for the current time interval as a Vector. More... | |
const Matrix * | getSnapshotMatrix () |
Returns the snapshot matrix for the current time interval. More... | |
int | getNumSamples () const |
Returns the number of samples taken. More... | |
void | finalSummary (const double energyFractionThreshold, int &cutoff, const std::string &cutoffOutputPath="", const int first_sv=0) |
Prints the summary of recommended numbers of basis vectors. More... | |
Protected Attributes | |
BasisWriter * | d_basis_writer |
Writer of basis vectors. | |
BasisReader * | d_basis_reader |
Reader of basis vectors. | |
bool | d_write_snapshots |
Whether to write snapshots instead of bases. | |
boost::shared_ptr< SVD > | d_svd |
Pointer to the abstract SVD algorithm object. | |
Class BasisGenerator defines the interface for the generation of basis vectors via the SVD method. This class wraps the SVD algorithm and sampler and controls all aspects of basis vector generation.
Definition at line 47 of file BasisGenerator.h.
CAROM::BasisGenerator::BasisGenerator | ( | Options | options, |
bool | incremental, | ||
const std::string & | basis_file_name = "" , |
||
Database::formats | file_format = Database::formats::HDF5 |
||
) |
Constructor.
[in] | options | The struct containing the options for this basis generator. |
[in] | incremental | Whether to conduct static or incremental SVD |
[in] | basis_file_name | The base part of the name of the file containing the basis vectors. Each process will append its process ID to this base name. |
[in] | file_format | The format of the file containing the basis vectors. |
Definition at line 29 of file BasisGenerator.cpp.
double CAROM::BasisGenerator::computeNextSampleTime | ( | double * | u_in, |
double * | rhs_in, | ||
double | time | ||
) |
Computes next time an svd sample is needed.
[in] | u_in | The state at the specified time. |
[in] | rhs_in | The right hand side at the specified time. |
[in] | time | The simulation time for the state. |
Definition at line 205 of file BasisGenerator.cpp.
|
inline |
Signal that the final sample has been taken.
[in] | kind | A string equal to "basis" or "snapshot", representing which one will be written. |
Definition at line 123 of file BasisGenerator.h.
void CAROM::BasisGenerator::finalSummary | ( | const double | energyFractionThreshold, |
int & | cutoff, | ||
const std::string & | cutoffOutputPath = "" , |
||
const int | first_sv = 0 |
||
) |
Prints the summary of recommended numbers of basis vectors.
[in] | energyFractionThreshold | Energy Fraction threshold (energy fraction = 1.0 - energyFractionThreshold). |
[in] | cutoff | Number of basis vectors selected. |
[in] | cutoffOutputPath | Path of the summary file. |
[in] | first_sv | First singular vector in the calculaton of energy. |
Definition at line 311 of file BasisGenerator.cpp.
|
inline |
Returns the number of samples taken.
Definition at line 245 of file BasisGenerator.h.
|
inline |
Returns the singular values for the current time interval as a Vector.
Definition at line 224 of file BasisGenerator.h.
|
inline |
Returns the snapshot matrix for the current time interval.
Definition at line 235 of file BasisGenerator.h.
|
inline |
Returns the basis vectors for the current time interval as a Matrix.
Definition at line 200 of file BasisGenerator.h.
|
inline |
Returns the temporal basis vectors for the current time interval as a Matrix.
Definition at line 212 of file BasisGenerator.h.
bool CAROM::BasisGenerator::isNextSample | ( | double | time | ) |
Returns true if it is time for the next svd sample.
[in] | time | Time of interest. |
Definition at line 116 of file BasisGenerator.cpp.
void CAROM::BasisGenerator::loadSampleRange | ( | const std::string & | base_file_name, |
const std::string & | kind = "basis" , |
||
int | col_min = 0 , |
||
int | col_max = 1e9 , |
||
Database::formats | db_format = Database::formats::HDF5 |
||
) |
Load previously saved sample (basis or state) within a column range.
[in] | base_file_name | The base part of the name of the files holding the basis/snapshot vectors. |
[in] | kind | A string equal to "basis" or "snapshot", representing which kind of data to load. |
[in] | col_min | The first basis/snapshot vector to read. |
[in] | col_max | The last basis/snapshot vector to read. |
[in] | db_format | Format of the file to read. |
Definition at line 150 of file BasisGenerator.cpp.
void CAROM::BasisGenerator::loadSamples | ( | const std::string & | base_file_name, |
const std::string & | kind = "basis" , |
||
int | cut_off = 1e9 , |
||
Database::formats | db_format = Database::formats::HDF5 |
||
) |
Load previously saved sample (basis or state).
[in] | base_file_name | The base part of the name of the files holding the basis/snapshot vectors. |
[in] | kind | A string equal to "basis" or "snapshot", representing which kind of data to load. |
[in] | cutoff | The maximum number of basis/snapshot vectors to read. |
[in] | db_format | Format of the file to read. |
Definition at line 196 of file BasisGenerator.cpp.
bool CAROM::BasisGenerator::takeSample | ( | double * | u_in, |
bool | add_without_increase = false |
||
) |
Sample the new state, u_in, at the given time.
[in] | u_in | The state at the specified time. |
[in] | add_without_increase | If true, the addLinearlyDependent is invoked. This only applies to incremental SVD. |
Definition at line 132 of file BasisGenerator.cpp.
|
inline |
Check whether right basis vectors will be updated.
Definition at line 93 of file BasisGenerator.h.