libROM  v1.0
Data-driven physical simulation library
StaticSVD.h
1 
11 // Description: A class implementing interface of SVD for the static SVD
12 // algorithm.
13 
14 #ifndef included_StaticSVD_h
15 #define included_StaticSVD_h
16 
17 #include "SVD.h"
18 #include "linalg/Options.h"
19 #include "linalg/scalapack_wrapper.h"
20 
21 #include <limits>
22 #include <memory>
23 #include <vector>
24 
25 namespace CAROM {
26 
32 class StaticSVD : public SVD
33 {
34 public:
38  ~StaticSVD();
39 
50  virtual
51  bool
52  takeSample(
53  double* u_in,
54  bool add_without_increase = false) override;
55 
64  std::shared_ptr<const Matrix>
65  getSpatialBasis() override;
66 
75  std::shared_ptr<const Matrix>
76  getTemporalBasis() override;
77 
85  std::shared_ptr<const Vector>
86  getSingularValues() override;
87 
93  std::shared_ptr<const Matrix>
94  getSnapshotMatrix() override;
95 
96 protected:
97 
105  StaticSVD(
106  Options options
107  );
108 
113  virtual void
114  computeSVD();
115 
121  bool
123  {
124  return d_basis_is_current;
125  }
126 
130  std::unique_ptr<SLPK_Matrix> d_samples;
131 
135  std::unique_ptr<SVDManager> d_factorizer;
136 
142 
146  int d_rank;
147 
152 
158  std::vector<int> d_istarts;
159 
165  std::vector<int> d_dims;
166 
171 
175  int d_nprow;
176 
180  int d_npcol;
181 
186 
191  void get_global_info();
192 
197 
202 
206  void delete_samples();
210  void delete_factorizer();
211 
215  void broadcast_sample(const double* u_in);
216 
217 private:
218 
219  friend class BasisGenerator;
220 
224  StaticSVD();
225 
229  StaticSVD(
230  const StaticSVD& other);
231 
235  StaticSVD&
236  operator = (
237  const StaticSVD& rhs);
238 
242  bool d_preserve_snapshot;
243 };
244 
245 }
246 
247 #endif
Definition: SVD.h:29
double d_singular_value_tol
The tolerance for singular values below which to drop vectors.
Definition: StaticSVD.h:201
std::shared_ptr< const Matrix > getSpatialBasis() override
Returns the basis vectors for the current time interval as a Matrix.
Definition: StaticSVD.cpp:141
int d_rank
The rank of the process this object belongs to.
Definition: StaticSVD.h:146
int d_nprow
The number of processor rows in the grid.
Definition: StaticSVD.h:175
std::shared_ptr< const Matrix > getTemporalBasis() override
Returns the temporal basis vectors for the current time interval as a Matrix.
Definition: StaticSVD.cpp:156
virtual void computeSVD()
Gathers samples from all other processors to form complete sample of system and computes the SVD.
Definition: StaticSVD.cpp:209
int d_npcol
The number of processor columns in the grid.
Definition: StaticSVD.h:180
void delete_factorizer()
Delete the factorizer from ScaLAPACK.
Definition: StaticSVD.cpp:82
void get_global_info()
Get the system's total row dimension and where my rows sit in the matrix.
Definition: StaticSVD.cpp:359
void delete_samples()
Delete the samples from ScaLAPACK.
Definition: StaticSVD.cpp:74
void broadcast_sample(const double *u_in)
Broadcast the sample to all processors.
Definition: StaticSVD.cpp:349
bool d_basis_is_current
Flag to indicate if the basis vectors for the current time interval are up to date.
Definition: StaticSVD.h:141
std::vector< int > d_istarts
The starting row (0-based) of the matrix that each process owns. Stored to avoid an MPI operation to ...
Definition: StaticSVD.h:158
int d_total_dim
The total dimension of the system (row dimension)
Definition: StaticSVD.h:170
std::shared_ptr< const Vector > getSingularValues() override
Returns the singular values for the current time interval.
Definition: StaticSVD.cpp:171
int d_max_basis_dimension
The max number of basis vectors to return.
Definition: StaticSVD.h:196
virtual bool takeSample(double *u_in, bool add_without_increase=false) override
Collect the new sample, u_in at the supplied time.
Definition: StaticSVD.cpp:101
std::unique_ptr< SLPK_Matrix > d_samples
Current samples of the system.
Definition: StaticSVD.h:130
std::unique_ptr< SVDManager > d_factorizer
Factorization manager object used to compute the SVD.
Definition: StaticSVD.h:135
int d_blocksize
The block size used internally for computing the SVD.
Definition: StaticSVD.h:185
bool isBasisCurrent()
Checks if the basis vectors are computed from the current snapshot.
Definition: StaticSVD.h:122
int d_num_procs
The number of processors being run on.
Definition: StaticSVD.h:151
std::vector< int > d_dims
The number of rows that each process owns. Stored to avoid an MPI operation to get this operation eve...
Definition: StaticSVD.h:165
std::shared_ptr< const Matrix > getSnapshotMatrix() override
Returns the snapshot matrix for the current time interval.
Definition: StaticSVD.cpp:188