28 double initialRelaxation,
29 bool forceInitialRelaxation,
30 int maxIterationsUsed,
31 int pastTimeWindowsReused,
33 double singularityLimit,
36 :
BaseQNAcceleration(initialRelaxation, forceInitialRelaxation, maxIterationsUsed, pastTimeWindowsReused,
37 filter, singularityLimit,
std::move(dataIDs),
std::move(preconditioner))
48 for (
const DataMap::value_type &pair : cplData) {
50 int secondaryEntries = pair.second->getSize();
62 PtrCouplingData data = cplData.
at(
id);
64 secResiduals.size(), data->getSize());
65 secResiduals = data->values();
66 secResiduals -= data->previousIteration();
75 if (not columnLimitReached && overdetermined) {
91 PRECICE_ASSERT(secW.rows() == cplData.
at(
id)->getSize(), secW.rows(), cplData.
at(
id)->getSize());
92 secW.col(0) = cplData.
at(
id)->values();
121 PtrCouplingData data = cplData.
at(
id);
122 Eigen::VectorXd &values = data->values();
125 secResiduals = data->previousIteration();
127 values += secResiduals;
150 Eigen::VectorXd _local_b = Eigen::VectorXd::Zero(
_qrV.
cols());
151 Eigen::VectorXd _global_b;
162 utils::append(c, Eigen::VectorXd(Eigen::VectorXd::Zero(_local_b.size())));
168 c = R.triangularView<Eigen::Upper>().solve<Eigen::OnTheLeft>(_local_b);
180 utils::append(_global_b, Eigen::VectorXd(Eigen::VectorXd::Zero(_local_b.size())));
187 c = R.triangularView<Eigen::Upper>().solve<Eigen::OnTheLeft>(_global_b);
205 PRECICE_DEBUG(
" Last time window converged after one iteration. Need to restore the secondaryMatricesW from backup.");
211 PtrCouplingData data = cplData.
at(
id);
212 auto & values = data->values();
215 PRECICE_ASSERT(data->getSize() == data->getPreviousIterationSize(), data->getSize(), data->getPreviousIterationSize());
216 values += data->previousIteration();
262 for (
int i = 0; i < toRemove; i++) {
#define PRECICE_WARN(...)
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_ASSERT(...)
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)
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,...
bool _hasNodesOnInterface
Eigen::MatrixXd _matrixV
Stores residual deltas.
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.
std::deque< int > _matrixCols
Indices (of columns in W, V matrices) of 1st iterations of time windows.
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.
std::vector< int > _dataIDs
Data IDs of data to be involved in the IQN algorithm.
bool _forceInitialRelaxation
virtual void initialize(const DataMap &cplData)
Initializes the acceleration.
std::map< int, Eigen::MatrixXd > _secondaryMatricesWBackup
virtual void initialize(const DataMap &cplData)
Initializes the acceleration.
virtual void updateDifferenceMatrices(const DataMap &cplData)
updates the V, W matrices (as well as the matrices for the secondary data)
virtual void removeMatrixColumn(int columnIndex)
Removes one iteration from V,W matrices and adapts _matrixCols.
virtual void computeUnderrelaxationSecondaryData(const DataMap &cplData)
computes underrelaxation for the secondary data
IQNILSAcceleration(double initialRelaxation, bool forceInitialRelaxation, int maxIterationsUsed, int pastTimeWindowsReused, int filter, double singularityLimit, std::vector< int > dataIDs, impl::PtrPreconditioner preconditioner)
std::map< int, Eigen::MatrixXd > _secondaryMatricesW
virtual void computeQNUpdate(const DataMap &cplData, Eigen::VectorXd &xUpdate)
computes the IQN-ILS update using QR decomposition
std::map< int, Eigen::VectorXd > _secondaryOldXTildes
Secondary data solver output from last iteration.
virtual void specializedIterationsConverged(const DataMap &cplData)
Marks a iteration sequence as converged.
Eigen::MatrixXd & matrixR()
returns a matrix representation of the upper triangular matrix R
Eigen::MatrixXd & matrixQ()
returns a matrix representation of the orthogonal matrix Q
static bool isPrimary()
True if this process is running the primary rank.
static void broadcast(bool &value)
static bool isParallel()
True if this process is running in parallel.
static com::PtrCommunication & getCommunication()
Intra-participant communication.
static void reduceSum(precice::span< const double > sendData, precice::span< double > rcvData)
contains implementations of acceleration schemes.
void removeColumnFromMatrix(Eigen::MatrixXd &A, int col)
bool contained(const ELEMENT_T &element, const std::vector< ELEMENT_T > &vec)
Returns true, if given element is in vector, otherwise false.
void appendFront(Eigen::MatrixXd &A, Eigen::VectorXd &v)
void append(Eigen::VectorXd &v, double value)
void shiftSetFirst(Eigen::MatrixXd &A, const Eigen::VectorXd &v)