15 #ifndef included_BasisGenerator_h
16 #define included_BasisGenerator_h
18 #include "BasisWriter.h"
19 #include "BasisReader.h"
28 #if __cplusplus >= 201103L
31 #include <boost/shared_ptr.hpp>
66 const std::string& basis_file_name =
"",
95 return d_update_right_SV;
114 bool add_without_increase =
false);
155 const std::string& kind =
"basis",
172 const std::string& kind =
"basis",
202 return d_svd->getSpatialBasis();
214 return d_svd->getTemporalBasis();
226 return d_svd->getSingularValues();
237 return d_svd->getSnapshotMatrix();
247 return d_svd->getNumSamples();
260 const double energyFractionThreshold,
262 const std::string & cutoffOutputPath =
"",
263 const int first_sv = 0);
284 #if __cplusplus >= 201103L
285 std::shared_ptr<SVD>
d_svd;
336 bool d_update_right_SV;
348 double d_max_time_between_samples;
353 double d_min_sampling_time_step_scale;
358 double d_sampling_time_step_scale;
363 double d_max_sampling_time_step_scale;
373 double d_next_sample_time;
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.
void writeSnapshot()
Write current snapshot matrix.
const Matrix * getSnapshotMatrix()
Returns the snapshot matrix for the current time interval.
int getNumSamples() const
Returns the number of samples taken.
bool d_write_snapshots
Whether to write snapshots instead of bases.
bool updateRightSV()
Check whether right basis vectors will be updated.
BasisReader * d_basis_reader
Reader of basis vectors.
bool isNextSample(double time)
Returns true if it is time for the next svd sample.
void endSamples(const std::string &kind="basis")
Signal that the final sample has been taken.
const Matrix * getTemporalBasis()
Returns the temporal basis vectors for the current time interval as a Matrix.
BasisWriter * d_basis_writer
Writer of basis vectors.
const Matrix * getSpatialBasis()
Returns the basis vectors for the current time interval as a Matrix.
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).
boost::shared_ptr< SVD > d_svd
Pointer to the abstract SVD algorithm object.
~BasisGenerator()
Destructor.
double computeNextSampleTime(double *u_in, double *rhs_in, double time)
Computes next time an svd sample is needed.
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.
const Vector * getSingularValues()
Returns the singular values for the current time interval as a Vector.
bool takeSample(double *u_in, bool add_without_increase=false)
Sample the new state, u_in, at the given time.
void writeBasis(const std::string &kind="basis")
Write basis or state vectors generated by d_basis_generator.
formats
Implemented database file formats. Add to this enum each time a new database format is implemented.