libROM  v1.0
Data-driven physical simulation library
 All Classes Functions Variables Enumerations
Public Member Functions | Protected Attributes | List of all members
CAROM::BasisGenerator Class Reference

#include <BasisGenerator.h>

Public Member Functions

 BasisGenerator (Options options, bool incremental, const std::string &basis_file_name="", Database::formats file_format=Database::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, double time, double dt, 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 loadSamples (const std::string &base_file_name, const std::string &kind="basis", int cut_off=1e9, Database::formats db_format=Database::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 MatrixgetSpatialBasis ()
 Returns the basis vectors for the current time interval as a Matrix. More...
 
const MatrixgetTemporalBasis ()
 Returns the temporal basis vectors for the current time interval as a Matrix. More...
 
const VectorgetSingularValues ()
 Returns the singular values for the current time interval as a Vector. More...
 
const MatrixgetSnapshotMatrix ()
 Returns the snapshot matrix for the current time interval. More...
 
int getNumBasisTimeIntervals () const
 Returns the number of time intervals on which different sets of basis vectors are defined. More...
 
double getBasisIntervalStartTime (int which_interval) const
 Returns the start time for the requested time interval. More...
 
int getNumSamples () const
 Returns the number of samples taken. More...
 

Protected Attributes

BasisWriterd_basis_writer
 Writer of basis vectors.
 
BasisReaderd_basis_reader
 Reader of basis vectors.
 
bool d_write_snapshots
 Whether to write snapshots instead of bases.
 
boost::shared_ptr< SVDd_svd
 Pointer to the abstract SVD algorithm object.
 

Detailed Description

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.

Constructor & Destructor Documentation

CAROM::BasisGenerator::BasisGenerator ( Options  options,
bool  incremental,
const std::string &  basis_file_name = "",
Database::formats  file_format = Database::HDF5 
)

Constructor.

Parameters
[in]optionsThe struct containing the options for this basis generator.
[in]incrementalWhether to conduct static or incremental SVD
[in]basis_file_nameThe 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_formatThe format of the file containing the basis vectors.

Member Function Documentation

double CAROM::BasisGenerator::computeNextSampleTime ( double *  u_in,
double *  rhs_in,
double  time 
)

Computes next time an svd sample is needed.

Precondition
u_in != 0
rhs_in != 0
time >= 0.0
Parameters
[in]u_inThe state at the specified time.
[in]rhs_inThe right hand side at the specified time.
[in]timeThe simulation time for the state.
void CAROM::BasisGenerator::endSamples ( const std::string &  kind = "basis")
inline

Signal that the final sample has been taken.

Parameters
[in]kindA string equal to "basis" or "snapshot", representing which one will be written.
double CAROM::BasisGenerator::getBasisIntervalStartTime ( int  which_interval) const
inline

Returns the start time for the requested time interval.

Precondition
0 <= which_interval
which_interval < getNumBasisTimeIntervals()
Parameters
[in]which_intervalTime interval whose start time is needed.
Returns
The start time for the requested time interval.
int CAROM::BasisGenerator::getNumBasisTimeIntervals ( ) const
inline

Returns the number of time intervals on which different sets of basis vectors are defined.

Returns
The number of time intervals on which there are basis vectors.
int CAROM::BasisGenerator::getNumSamples ( ) const
inline

Returns the number of samples taken.

Returns
The number of samples taken.
const Vector* CAROM::BasisGenerator::getSingularValues ( )
inline

Returns the singular values for the current time interval as a Vector.

Returns
The singular values for the current time interval.
const Matrix* CAROM::BasisGenerator::getSnapshotMatrix ( )
inline

Returns the snapshot matrix for the current time interval.

Returns
The snapshot matrix for the current time interval.
const Matrix* CAROM::BasisGenerator::getSpatialBasis ( )
inline

Returns the basis vectors for the current time interval as a Matrix.

Returns
The basis vectors for the current time interval.
const Matrix* CAROM::BasisGenerator::getTemporalBasis ( )
inline

Returns the temporal basis vectors for the current time interval as a Matrix.

Returns
The temporal basis vectors for the current time interval.
bool CAROM::BasisGenerator::isNextSample ( double  time)

Returns true if it is time for the next svd sample.

Precondition
time >= 0.0
Parameters
[in]timeTime of interest.
Returns
True if it is time for the next sample to be taken.
void CAROM::BasisGenerator::loadSamples ( const std::string &  base_file_name,
const std::string &  kind = "basis",
int  cut_off = 1e9,
Database::formats  db_format = Database::HDF5 
)

Load previously saved sample (basis or state).

Parameters
[in]base_file_nameThe base part of the name of the files holding the basis / snapshot vectors.
[in]kindA string equal to "basis" or "snapshot", representing which kind of data to load.
[in]cut_offThe maximum number of bases or snapshots to read.
[in]db_formatFormat of the file to read.
bool CAROM::BasisGenerator::takeSample ( double *  u_in,
double  time,
double  dt,
bool  add_without_increase = false 
)

Sample the new state, u_in, at the given time.

Precondition
u_in != 0
time >= 0.0
Parameters
[in]u_inThe state at the specified time.
[in]timeThe simulation time for the state.
[in]dtThe current simulation dt.
[in]add_without_increaseIf true, the addLinearlyDependent is invoked. This only applies to incremental SVD.
Returns
True if the sampling was successful.
bool CAROM::BasisGenerator::updateRightSV ( )
inline

Check whether right basis vectors will be updated.

  • Returns
    True if the right basis vectors will be updated.

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