diff --git a/lib/linalg/BasisGenerator.cpp b/lib/linalg/BasisGenerator.cpp index 065f63871..29da23b48 100644 --- a/lib/linalg/BasisGenerator.cpp +++ b/lib/linalg/BasisGenerator.cpp @@ -35,7 +35,7 @@ BasisGenerator::BasisGenerator( d_write_snapshots(options.write_snapshots) { CAROM_VERIFY(options.dim > 0); - CAROM_VERIFY(options.samples_per_time_interval > 0); + CAROM_VERIFY(options.max_num_samples > 0); CAROM_VERIFY(options.singular_value_tol >= 0); CAROM_VERIFY(options.max_time_intervals == -1 || options.max_time_intervals > 0); @@ -135,14 +135,12 @@ BasisGenerator::takeSample( bool add_without_increase) { CAROM_VERIFY(u_in != 0); - CAROM_VERIFY(time >= 0); CAROM_VERIFY(d_svd->getNumSamples() < d_svd->getMaxNumSamples()); // Check that u_in is not non-zero. Vector u_vec(u_in, getDim(), true); if (u_vec.norm() == 0.0) { - printf("WARNING: BasisGenerator::takeSample skipped trivial sample at time %.4E\n", - time); + printf("WARNING: BasisGenerator::takeSample skipped trivial sample.\n"); return false; } @@ -161,16 +159,15 @@ BasisGenerator::loadSamples(const std::string& base_file_name, if (d_basis_reader) delete d_basis_reader; d_basis_reader = new BasisReader(base_file_name, db_format); - double time = 0.0; const Matrix* mat; const Vector* singular_vals; if (kind == "basis") { - mat = d_basis_reader->getSpatialBasis(time); - singular_vals = d_basis_reader->getSingularValues(time); + mat = d_basis_reader->getSpatialBasis(); + singular_vals = d_basis_reader->getSingularValues(); } else if (kind == "snapshot") { - mat = d_basis_reader->getSnapshotMatrix(time); + mat = d_basis_reader->getSnapshotMatrix(); } int num_rows = mat->numRows(); diff --git a/lib/linalg/BasisReader.cpp b/lib/linalg/BasisReader.cpp index d67f6741f..b69f52c68 100644 --- a/lib/linalg/BasisReader.cpp +++ b/lib/linalg/BasisReader.cpp @@ -60,8 +60,7 @@ BasisReader::~BasisReader() } Matrix* -BasisReader::getSpatialBasis( - double time) +BasisReader::getSpatialBasis() { d_last_basis_idx = 0; int num_rows = getDim("basis"); @@ -142,8 +141,7 @@ BasisReader::getSpatialBasis( } Matrix* -BasisReader::getTemporalBasis( - double time) +BasisReader::getTemporalBasis() { d_last_basis_idx = 0; int num_rows = getDim("temporal_basis"); @@ -327,12 +325,11 @@ BasisReader::getNumSamples( } Matrix* -BasisReader::getSnapshotMatrix( - double time) +BasisReader::getSnapshotMatrix() { d_last_basis_idx = 0; - int num_rows = getDim("snapshot",time); - int num_cols = getNumSamples("snapshot",time); + int num_rows = getDim("snapshot"); + int num_cols = getNumSamples("snapshot"); char tmp[100]; Matrix* snapshots = new Matrix(num_rows, num_cols, false); diff --git a/lib/linalg/BasisReader.h b/lib/linalg/BasisReader.h index 3369a2cfd..9e7606838 100644 --- a/lib/linalg/BasisReader.h +++ b/lib/linalg/BasisReader.h @@ -75,10 +75,21 @@ class BasisReader { return (d_last_basis_idx == -1); } + /** + * + * @brief Returns the spatial basis vectors as a Matrix. + * + * @return The spatial basis vectors. + */ + Matrix* + getSpatialBasis(); + /** * * @brief Returns the spatial basis vectors for the requested time as a * Matrix. + * NOTE: this function is obsolete and remains only for backward compatibility. + * Will be removed in future. * * @param[in] time Time for which we want the basis vectors. * NOTE: this argument is obsolete and remains only for backward compatibility. @@ -88,7 +99,8 @@ class BasisReader { */ Matrix* getSpatialBasis( - double time); + double time) + { return getSpatialBasis(); } /** * @@ -155,6 +167,18 @@ class BasisReader { * @brief Returns the temporal basis vectors for the requested time as * a Matrix. * + * @return The temporal basis vectors for the requested time. + */ + Matrix* + getTemporalBasis(); + + /** + * + * @brief Returns the temporal basis vectors for the requested time as + * a Matrix. + * NOTE: this function is obsolete and remains only for backward compatibility. + * Will be removed in future. + * * @param[in] time Time for which we want the basis vectors. * NOTE: this argument is obsolete and remains only for backward compatibility. * Will be removed in future. @@ -163,7 +187,8 @@ class BasisReader { */ Matrix* getTemporalBasis( - double time); + double time) + { return getTemporalBasis(); } /** * @@ -332,6 +357,16 @@ class BasisReader { * * @brief Returns the snapshot matrix for the requested time. * + * @return The snapshot matrix for the requested time. + */ + Matrix* + getSnapshotMatrix(); + + /** + * + * @brief Returns the snapshot matrix for the requested time. + * NOTE: this function is obsolete and remains only for backward compatibility. + * Will be removed in future. * * @param[in] time Time for which we want the basis vectors. * NOTE: this argument is obsolete and remains only for backward compatibility. @@ -341,7 +376,8 @@ class BasisReader { */ Matrix* getSnapshotMatrix( - double time); + double time) + { return getSnapshotMatrix(); } /** * diff --git a/lib/linalg/Options.h b/lib/linalg/Options.h index 3bf20cb36..96a4c25ae 100644 --- a/lib/linalg/Options.h +++ b/lib/linalg/Options.h @@ -30,11 +30,11 @@ class Options * @brief Constructor. * * @pre dim_ > 0 - * @pre samples_per_time_interval_ > 0 + * @pre max_num_samples_ > 0 * @pre max_time_intervals == -1 || max_time_intervals > 0 * * @param[in] dim_ The dimension of the system on this processor. - * @param[in] samples_per_time_interval_ The maximum number of samples in + * @param[in] max_num_samples_ The maximum number of samples in * each time interval. * @param[in] max_time_intervals_ The maximum number of time intervals. * @param[in] update_right_SV_ Whether to update the right SV or not. @@ -43,13 +43,13 @@ class Options * */ Options(int dim_, - int samples_per_time_interval_, + int max_num_samples_, int max_time_intervals_ = 1, bool update_right_SV_ = false, bool write_snapshots_ = false ): dim(dim_), - max_basis_dimension(samples_per_time_interval_), - samples_per_time_interval(samples_per_time_interval_), + max_basis_dimension(max_num_samples_), + max_num_samples(max_num_samples_), max_time_intervals(max_time_intervals_), update_right_SV(update_right_SV_), write_snapshots(write_snapshots_) @@ -226,12 +226,13 @@ class Options int dim = -1; /** - * @brief The number of samples per time interval. + * @brief The maximum number of samples. */ - int samples_per_time_interval = -1; + int max_num_samples = -1; /** * @brief The maximum number of time intervals. + * NOTE: this variable is obsolte and will be removed in future. */ int max_time_intervals = -1; diff --git a/lib/linalg/svd/SVD.cpp b/lib/linalg/svd/SVD.cpp index af5ccabe5..8a63348b7 100644 --- a/lib/linalg/svd/SVD.cpp +++ b/lib/linalg/svd/SVD.cpp @@ -19,7 +19,7 @@ SVD::SVD( Options options) : d_dim(options.dim), d_num_samples(0), - d_max_num_samples(options.samples_per_time_interval), + d_max_num_samples(options.max_num_samples), d_basis(NULL), d_basis_right(NULL), d_U(NULL), @@ -29,7 +29,7 @@ SVD::SVD( d_debug_algorithm(options.debug_algorithm) { CAROM_VERIFY(options.dim > 0); - CAROM_VERIFY(options.samples_per_time_interval > 0); + CAROM_VERIFY(options.max_num_samples > 0); } SVD::~SVD()