32 double initialRelaxation,
33 bool forceInitialRelaxation,
34 int maxIterationsUsed,
35 int pastTimeWindowsReused,
37 double singularityLimit,
40 bool alwaysBuildJacobian,
43 int RSLSreusedTimeWindows,
44 double RSSVDtruncationEps)
45 :
BaseQNAcceleration(initialRelaxation, forceInitialRelaxation, maxIterationsUsed, pastTimeWindowsReused,
46 filter, singularityLimit,
std::move(dataIDs), preconditioner),
52 _pseudoInverseChunk(),
56 _parMatrixOps(nullptr),
57 _svdJ(RSSVDtruncationEps, preconditioner),
58 _alwaysBuildJacobian(alwaysBuildJacobian),
59 _imvjRestartType(imvjRestartType),
61 _chunkSize(chunkSize),
62 _RSLSreusedTimeWindows(RSLSreusedTimeWindows),
84 _parMatrixOps = std::make_shared<impl::ParallelMatrixOperations>();
108 _Wtil = Eigen::MatrixXd::Zero(entries, 0);
122 PtrCouplingData data = cplData.
at(
id);
123 Eigen::VectorXd &values = data->values();
126 secResiduals = data->previousIteration();
128 values += secResiduals;
156 Eigen::VectorXd v =
_matrixV.col(0);
157 Eigen::VectorXd w =
_matrixW.col(0);
164 Eigen::VectorXd wtil = Eigen::VectorXd::Zero(
_matrixV.rows());
173 Eigen::VectorXd Zv = Eigen::VectorXd::Zero(colsLSSystemBackThen);
197 if (not columnLimitReached && overdetermined) {
210 Eigen::VectorXd &xUpdate)
238 Eigen::MatrixXd &pseudoInverse)
261 for (
int i = 0; i < Q.rows(); i++) {
262 Eigen::VectorXd Qrow = Q.row(i);
263 yVec = R.triangularView<Eigen::Upper>().solve<Eigen::OnTheLeft>(Qrow);
293 Eigen::MatrixXd ZV = Eigen::MatrixXd::Zero(colsLSSystemBackThen,
_qrV.
cols());
339 PRECICE_WARN(
" ATTENTION, in buildJacobian call for buildWtill() - this should not be the case except the coupling did only one iteration");
357 Eigen::VectorXd &xUpdate)
406 Eigen::VectorXd negativeResiduals = -
_residuals;
419 xUpdate = Eigen::VectorXd::Zero(
_residuals.size());
420 xUptmp =
_Wtil * r_til;
432 r_til = Eigen::VectorXd::Zero(colsLSSystemBackThen);
449 _Wtil.conservativeResize(0, 0);
485 Eigen::VectorXd negativeResiduals = -
_residuals;
537 Eigen::MatrixXd Z(phi.cols(), phi.rows());
538 for (
int i = 0; i < static_cast<int>(Z.rows()); i++)
539 for (
int j = 0; j < static_cast<int>(Z.cols()); j++)
540 Z(i, j) = phi(j, i) * sigma[i];
555 PRECICE_DEBUG(
"MVJ-RESTART, mode=SVD. Rank of truncated SVD of Jacobian {}, new modes: {}, truncated modes: {} avg rank: {}", rankAfter, rankAfter - rankBefore, waste,
_avgRank /
_nbRestarts);
559 _infostringstream <<
" - MVJ-RESTART " <<
_nbRestarts <<
", mode= SVD -\n new modes: " << rankAfter - rankBefore <<
"\n rank svd: " << rankAfter <<
"\n avg rank: " <<
_avgRank /
_nbRestarts <<
"\n truncated modes: " << waste <<
"\n"
586 for (
int i = 0; i < static_cast<int>(
_matrixV_RSLS.cols()); i++) {
597 for (
int i = delIndices.
size() - 1; i >= 0; i--) {
613 for (
int i = 0; i < Q.rows(); i++) {
614 Eigen::VectorXd Qrow = Q.row(i);
615 yVec = R.triangularView<Eigen::Upper>().solve<Eigen::OnTheLeft>(Qrow);
653 for (
int i =
static_cast<int>(
_WtilChunk.
size()) - 1; i >= 1; i--) {
657 Eigen::MatrixXd ZV = Eigen::MatrixXd::Zero(colsLSSystemBackThen,
_qrV.
cols());
702 for (
int i = 0; i < toRemove; i++) {
758 restartUpdate.
stop();
815 if (cols > columnIndex) {
#define PRECICE_WARN(...)
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_ASSERT(...)
static const int QR2FILTER
static const int NOFILTER
Base Class for quasi-Newton acceleration schemes.
virtual void updateDifferenceMatrices(const DataMap &cplData)
Updates the V, W matrices (as well as the matrices for the secondary data)
int _filter
filter method that is used to maintain good conditioning of the least-squares system Either of two ty...
double _initialRelaxation
Constant relaxation factor used for first iteration.
int _timeWindowsReused
Maximum number of old time windows (with data values) kept.
virtual int getLSSystemCols() const
: computes number of cols in least squares system, i.e, number of cols in _matrixV,...
virtual void applyFilter()
Applies the filter method for the least-squares system, defined in the configuration.
std::ostringstream _infostringstream
write some debug/acceleration info to file
bool _resetLS
If true, the LS system has been modified (reset or recomputed) in such a way, that mere updating of m...
bool _hasNodesOnInterface
Eigen::MatrixXd _matrixV
Stores residual deltas.
std::vector< int > _dimOffsets
Stores the local dimensions, i.e., the offsets in _invJacobian for all processors.
Eigen::VectorXd _residuals
Current iteration residuals of IQN data. Temporary.
virtual void removeMatrixColumn(int columnIndex)
Removes one iteration from V,W matrices and adapts _matrixCols.
Eigen::MatrixXd _matrixW
Stores x tilde deltas, where x tilde are values computed by solvers.
double _singularityLimit
Determines sensitivity when two matrix columns are considered equal.
bool _firstIteration
Indicates the first iteration, where constant relaxation is used.
std::map< int, Eigen::VectorXd > _secondaryResiduals
Current iteration residuals of secondary data.
impl::PtrPreconditioner _preconditioner
Preconditioner for least-squares system if vectorial system is used.
impl::QRFactorization _qrV
Stores the current QR decomposition ov _matrixV, can be updated via deletion/insertion of columns.
int _maxIterationsUsed
Maximum number of old data iterations kept.
std::vector< int > _secondaryDataIDs
Data IDs of data not involved in IQN coefficient computation.
bool _forceInitialRelaxation
virtual void initialize(const DataMap &cplData)
Initializes the acceleration.
static const int RS_SLIDE
int _RSLSreusedTimeWindows
: Number of reused time windows at restart if restart-mode = RS-LS
void computeNewtonUpdateEfficient(const DataMap &cplData, Eigen::VectorXd &update)
: computes the quasi-Newton update vector based on the same numerics as above. However,...
bool _imvjRestart
: If true, the imvj method is used with the restart chunk based approach that avoids to explicitly bu...
virtual void updateDifferenceMatrices(const DataMap &cplData)
: updates the V, W matrices (as well as the matrices for the secondary data)
static const int NO_RESTART
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
virtual void initialize(const DataMap &cplData)
Initializes the acceleration.
virtual void computeQNUpdate(const DataMap &cplData, Eigen::VectorXd &xUpdate)
: computes the IQNIMVJ update using QR decomposition of V, furthermore it updates the inverse of the ...
Eigen::MatrixXd _matrixW_RSLS
stores columns from previous _RSLSreusedTimeWindows time windows if RS-LS restart-mode is active
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)
Constructor.
int _nbRestarts
tracks the number of restarts of IMVJ
int _imvjRestartType
: Indicates the type of the imvj restart-mode:
Eigen::MatrixXd _invJacobian
stores the approximation of the inverse Jacobian of the system at current time window.
virtual void computeUnderrelaxationSecondaryData(const DataMap &cplData)
: computes underrelaxation for the secondary data
virtual void removeMatrixColumn(int columnIndex)
: Removes one iteration from V,W matrices and adapts _matrixCols.
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
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
bool _alwaysBuildJacobian
If true, the less efficient method to compute the quasi-Newton update is used, that explicitly builds...
virtual void specializedIterationsConverged(const DataMap &cplData)
Marks a iteration sequence as converged.
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
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
virtual ~IQNIMVJAcceleration()
Destructor, empty.
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
void computeNewtonUpdate(const DataMap &cplData, Eigen::VectorXd &update)
: computes the quasi-Newton update vector based on the matrices V and W using a QR decomposition of V...
Class that provides functionality for a dynamic QR-decomposition, that can be updated in O(mn) flops ...
void setGlobalRows(int gr)
Eigen::MatrixXd & matrixR()
returns a matrix representation of the upper triangular matrix R
void applyFilter(double singularityLimit, std::vector< int > &delIndices, Eigen::MatrixXd &V)
filters the least squares system, i.e., the decomposition Q*R = V according to the defined filter tec...
void pushBack(const Eigen::VectorXd &v)
inserts a new column at position _cols-1, i.e., appends a column at the end and updates the QR factor...
void reset()
resets the QR factorization zo zero Q(0:0, 0:0)R(0:0, 0:0)
Eigen::MatrixXd & matrixQ()
returns a matrix representation of the orthogonal matrix Q
double getThreshold()
: returns the truncation threshold for the SVD
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
Rank rank()
: returns the rank of the truncated SVD factorization
Matrix & matrixPsi()
: returns a matrix representation of the orthogonal matrix Psi, A = Psi * Sigma * Phi^bs
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 getWaste()
: returns the total number of truncated modes since last call to this method
void stop()
Stops a running event.
static bool isPrimary()
True if this process is running the primary rank.
static bool isParallel()
True if this process is running in parallel.
contains implementations of acceleration schemes.
void removeColumnFromMatrix(Eigen::MatrixXd &A, int col)
void appendFront(Eigen::MatrixXd &A, Eigen::VectorXd &v)
void shiftSetFirst(Eigen::MatrixXd &A, const Eigen::VectorXd &v)