preCICE v3.2.0
Loading...
Searching...
No Matches
IQNIMVJAcceleration.hpp
Go to the documentation of this file.
1#ifndef PRECICE_NO_MPI
2
3#pragma once
4
5#include <Eigen/Core>
6#include <deque>
7#include <vector>
13#include "com/SharedPointer.hpp"
14
15// ----------------------------------------------------------- CLASS DEFINITION
16
17namespace precice::acceleration {
18
33public:
34 static const int NO_RESTART = 0;
35 static const int RS_ZERO = 1;
36 static const int RS_LS = 2;
37 static const int RS_SVD = 3;
38 static const int RS_SLIDE = 4;
39
44 double initialRelaxation,
45 bool forceInitialRelaxation,
46 int maxIterationsUsed,
47 int pastTimeWindowsReused,
48 int filter,
49 double singularityLimit,
50 std::vector<int> dataIDs,
51 const impl::PtrPreconditioner &preconditioner,
52 bool alwaysBuildJacobian,
53 int imvjRestartType,
54 int chunkSize,
55 int RSLSreusedTimeWindows,
56 double RSSVDtruncationEps,
57 bool reducedTimeGrid);
58
63
70 void specializedIterationsConverged(const DataMap &cplData) override;
71
72private:
74 Eigen::MatrixXd _invJacobian;
75
77 Eigen::MatrixXd _oldInvJacobian;
78
80 Eigen::MatrixXd _Wtil;
81
84
87
89 Eigen::MatrixXd _matrixV_RSLS;
90
92 Eigen::MatrixXd _matrixW_RSLS;
93
96
99
102
108
116
121 const bool _imvjRestart;
122
125
128
131
132 // DEBUG
133 // std::fstream _info2;
134 double _avgRank;
135
139 void computeQNUpdate(Eigen::VectorXd &xUpdate) override;
140
142 void updateDifferenceMatrices(const DataMap &cplData) override;
143
151 void computeNewtonUpdate(Eigen::VectorXd &update);
152
161 void computeNewtonUpdateEfficient(Eigen::VectorXd &update);
162
165 void pseudoInverse(Eigen::MatrixXd &pseudoInverse);
166
169 void buildJacobian();
170
173 void buildWtil();
174
181 void restartIMVJ();
182
184 void removeMatrixColumn(int columnIndex) override;
185
187 void specializedInitializeVectorsAndPreconditioner(const DataMap &cplData) final override;
188
190 void removeMatrixColumnRSLS(int columnINdex);
191};
192} // namespace precice::acceleration
193
194#endif /* PRECICE_NO_MPI */
std::map< int, cplscheme::PtrCouplingData > DataMap
Map from data ID to data values.
BaseQNAcceleration(double initialRelaxation, bool forceInitialRelaxation, int maxIterationsUsed, int timeWindowsReused, int filter, double singularityLimit, std::vector< int > dataIDs, impl::PtrPreconditioner preconditioner, bool reducedTimeGrid)
const bool _imvjRestart
: If true, the imvj method is used with the restart chunk based approach that avoids to explicitly bu...
int _RSLSreusedTimeWindows
: Number of reused time windows at restart if restart-mode = RS-LS
const int _imvjRestartType
: Indicates the type of the imvj restart-mode:
void updateDifferenceMatrices(const DataMap &cplData) override
: updates the V, W matrices (as well as the matrices for the secondary data)
void pseudoInverse(Eigen::MatrixXd &pseudoInverse)
: computes the pseudo inverse of V multiplied with V^T, i.e., Z = (V^TV)^-1V^T via QR-dec
~IQNIMVJAcceleration() override
Destructor, empty.
Eigen::MatrixXd _matrixW_RSLS
stores columns from previous _RSLSreusedTimeWindows time windows if RS-LS restart-mode is active
int _nbRestarts
tracks the number of restarts of IMVJ
void computeQNUpdate(Eigen::VectorXd &xUpdate) override
: computes the IQNIMVJ update using QR decomposition of V, furthermore it updates the inverse of the ...
Eigen::MatrixXd _invJacobian
stores the approximation of the inverse Jacobian of the system at current time window.
void removeMatrixColumn(int columnIndex) override
: Removes one iteration from V,W matrices and adapts _matrixCols.
void specializedInitializeVectorsAndPreconditioner(const DataMap &cplData) final override
impl::PtrParMatrixOps _parMatrixOps
encapsulates matrix-matrix and matrix-vector multiplications for serial and parallel execution
int _chunkSize
: Number of time windows between restarts for the imvj method in restart mode
void computeNewtonUpdate(Eigen::VectorXd &update)
: computes the quasi-Newton update vector based on the matrices V and W using a QR decomposition of V...
Eigen::MatrixXd _Wtil
stores the sub result (W-J_prev*V) for the current iteration
void removeMatrixColumnRSLS(int columnINdex)
: Removes one column form the V_RSLS and W_RSLS matrices and adapts _matrixCols_RSLS
void buildWtil()
: re-computes the matrix _Wtil = ( W - J_prev * V) instead of updating it according to V
void specializedIterationsConverged(const DataMap &cplData) override
Marks a iteration sequence as converged.
IQNIMVJAcceleration(double initialRelaxation, bool forceInitialRelaxation, int maxIterationsUsed, int pastTimeWindowsReused, int filter, double singularityLimit, std::vector< int > dataIDs, const impl::PtrPreconditioner &preconditioner, bool alwaysBuildJacobian, int imvjRestartType, int chunkSize, int RSLSreusedTimeWindows, double RSSVDtruncationEps, bool reducedTimeGrid)
Constructor.
bool _alwaysBuildJacobian
If true, the less efficient method to compute the quasi-Newton update is used, that explicitly builds...
void restartIMVJ()
: restarts the imvj method, i.e., drops all stored matrices Wtil and Z and computes a initial guess o...
void buildJacobian()
: computes a explicit representation of the Jacobian, i.e., n x n matrix
void computeNewtonUpdateEfficient(Eigen::VectorXd &update)
: computes the quasi-Newton update vector based on the same numerics as above. However,...
std::vector< Eigen::MatrixXd > _pseudoInverseChunk
stores all pseudo inverses within the current chunk of the imvj restart mode, disabled if _imvjRestar...
Eigen::MatrixXd _oldInvJacobian
stores the approximation of the inverse Jacobian from the previous time window.
Eigen::MatrixXd _matrixV_RSLS
stores columns from previous _RSLSreusedTimeWindows time windows if RS-LS restart-mode is active
std::deque< int > _matrixCols_RSLS
number of cols per time window
std::vector< Eigen::MatrixXd > _WtilChunk
stores all Wtil matrices within the current chunk of the imvj restart mode, disabled if _imvjRestart ...
impl::SVDFactorization _svdJ
holds and maintains a truncated SVD decomposition of the Jacobian matrix
Class that provides functionality to maintain a SVD decomposition of a matrix via successive rank-1 u...
std::shared_ptr< Preconditioner > PtrPreconditioner
std::shared_ptr< ParallelMatrixOperations > PtrParMatrixOps
contains implementations of acceleration schemes.