libROM  v1.0
Data-driven physical simulation library
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::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 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 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

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.

Definition at line 47 of file BasisGenerator.h.

Constructor & Destructor Documentation

◆ BasisGenerator()

CAROM::BasisGenerator::BasisGenerator ( Options  options,
bool  incremental,
const std::string &  basis_file_name = "",
Database::formats  file_format = Database::formats::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.

Definition at line 29 of file BasisGenerator.cpp.

Member Function Documentation

◆ computeNextSampleTime()

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.

Definition at line 205 of file BasisGenerator.cpp.

◆ endSamples()

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.

Definition at line 123 of file BasisGenerator.h.

◆ finalSummary()

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.

Parameters
[in]energyFractionThresholdEnergy Fraction threshold (energy fraction = 1.0 - energyFractionThreshold).
[in]cutoffNumber of basis vectors selected.
[in]cutoffOutputPathPath of the summary file.
[in]first_svFirst singular vector in the calculaton of energy.

Definition at line 311 of file BasisGenerator.cpp.

◆ getNumSamples()

int CAROM::BasisGenerator::getNumSamples ( ) const
inline

Returns the number of samples taken.

Returns
The number of samples taken.

Definition at line 245 of file BasisGenerator.h.

◆ getSingularValues()

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.

Definition at line 224 of file BasisGenerator.h.

◆ getSnapshotMatrix()

const Matrix* CAROM::BasisGenerator::getSnapshotMatrix ( )
inline

Returns the snapshot matrix for the current time interval.

Returns
The snapshot matrix for the current time interval.

Definition at line 235 of file BasisGenerator.h.

◆ getSpatialBasis()

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.

Definition at line 200 of file BasisGenerator.h.

◆ getTemporalBasis()

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.

Definition at line 212 of file BasisGenerator.h.

◆ isNextSample()

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.

Definition at line 116 of file BasisGenerator.cpp.

◆ loadSampleRange()

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.

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]col_minThe first basis/snapshot vector to read.
[in]col_maxThe last basis/snapshot vector to read.
[in]db_formatFormat of the file to read.

Definition at line 150 of file BasisGenerator.cpp.

◆ loadSamples()

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).

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]cutoffThe maximum number of basis/snapshot vectors to read.
[in]db_formatFormat of the file to read.

Definition at line 196 of file BasisGenerator.cpp.

◆ takeSample()

bool CAROM::BasisGenerator::takeSample ( double *  u_in,
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]add_without_increaseIf true, the addLinearlyDependent is invoked. This only applies to incremental SVD.
Returns
True if the sampling was successful.

Definition at line 132 of file BasisGenerator.cpp.

◆ updateRightSV()

bool CAROM::BasisGenerator::updateRightSV ( )
inline

Check whether right basis vectors will be updated.

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

Definition at line 93 of file BasisGenerator.h.


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