24namespace acceleration {
54 template <
typename Derived1,
typename Derived2>
56 const Eigen::MatrixBase<Derived1> &A,
57 const Eigen::MatrixBase<Derived2> &B)
117 Matrix K = Matrix::Zero(
_psi.cols() + R_A.rows(),
_psi.cols() + R_B.rows());
118 Matrix K_A(
_psi.cols() + R_A.rows(), Atil.cols());
119 Matrix K_B(
_phi.cols() + R_B.rows(), Btil.cols());
121 for (
int i = 0; i <
_sigma.size(); i++)
124 K_A.block(0, 0, Atil.rows(), Atil.cols()) = Atil;
125 K_A.block(Atil.rows(), 0, R_A.rows(), R_A.cols()) = R_A;
126 K_B.block(0, 0, Btil.rows(), Btil.cols()) = Btil;
127 K_B.block(Btil.rows(), 0, R_B.rows(), R_B.cols()) = R_B;
128 K += K_A * K_B.transpose();
131 Eigen::JacobiSVD<Matrix> svd(K, Eigen::ComputeThinU | Eigen::ComputeThinV);
132 _sigma = svd.singularValues();
133 auto &psiPrime = svd.matrixU();
134 auto &phiPrime = svd.matrixV();
143 rotLeft.block(0,
_psi.cols(),
_rows, P.cols()) = P;
145 rotRight.block(0,
_phi.cols(),
_rows, Q.cols()) = Q;
148 _psi = rotLeft * psiPrime;
149 _phi = rotRight * phiPrime;
158 for (
int i = 0; i < (int)
_sigma.size(); i++) {
161 waste =
_sigma.size() - i;
171 PRECICE_DEBUG(
"SVD factorization of Jacobian is truncated to {} DOFs. Cut off {} DOFs",
_cols, waste);
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_ASSERT(...)
Class that provides functionality to maintain a SVD decomposition of a matrix via successive rank-1 u...
int _cols
Number of columns, i.e., rank of the truncated svd.
PtrParMatrixOps _parMatrixOps
: object for parallel matrix operations, i.e., parallel mat-mat/ mat-vec multiplications
void setApplyFilterQR(bool b, double eps=1e-3)
: enables or disables an additional QR-2 filter for the QR-decomposition
int _rows
Number of rows (on each proc, i.e., local)
double _truncationEps
Truncation parameter for the updated SVD decomposition.
bool _initialSVD
true, if at least one update has been made, i.e., the number of rows is known and a initial rank is g...
virtual ~SVDFactorization()
Destructor, empty.
double getThreshold()
: returns the truncation threshold for the SVD
bool _preconditionerApplied
true if the preconditioner has been applied appropriate to the updated SVD decomposition
void setThreshold(double eps)
: sets the threshold for the truncation of the SVD factorization
int _globalRows
Number of global rows, i.e., sum of _rows for all procs.
Matrix _psi
: SVD factorization of the matrix J = _psi * _sigma * _phi^T
void setPrecondApplied(bool b)
: applies the preconditioner to the factorized and truncated representation of the Jacobian matrix
Matrix & matrixPhi()
: returns a matrix representation of the orthogonal matrix Phi, A = Psi * Sigma * Phi^T
void initialize(PtrParMatrixOps parMatOps, int globalRows)
: initializes the updated SVD factorization, i.e., sets the object for parallel matrix-matrix operati...
Vector & singularValues()
: returns a matrix representation of the orthogonal matrix Sigma, A = Psi * Sigma * Phi^T
void reset()
: resets the SVD factorization
Rank rank()
: returns the rank of the truncated SVD factorization
double _epsQR2
Threshold for the QR2 filter for the QR decomposition.
void setfstream(std::fstream *stream)
Optional file-stream for logging output.
Matrix & matrixPsi()
: returns a matrix representation of the orthogonal matrix Psi, A = Psi * Sigma * Phi^bs
bool _initialized
true, if ParallelMatrixOperations object is set, i.e., initialized
void update(const Eigen::MatrixBase< Derived1 > &A, const Eigen::MatrixBase< Derived2 > &B)
: updates the SVD decomposition with the rank-1 update A*B^T, i.e., _psi * _sigma * _phi^T + A*B^T an...
int cols()
: returns the number of columns in the QR-decomposition
SVDFactorization(double eps, PtrPreconditioner preconditioner)
Constructor.
int rows()
: returns the number of rows in the QR-decomposition
void computeQRdecomposition(Matrix const &A, Matrix &Q, Matrix &R)
: computes the QR decomposition of a matrix A of type A = PSI^T*A \in R^(rank x n)
PtrPreconditioner _preconditioner
: preconditioner for least-squares system if vectorial system is used.
int getWaste()
: returns the total number of truncated modes since last call to this method
This class provides a lightweight logger.
Main namespace of the precice library.
static std::unique_ptr< precice::Participant > impl