13 #if !defined(KRATOS_IBQN_MVQN_CONVERGENCE_ACCELERATOR)
14 #define KRATOS_IBQN_MVQN_CONVERGENCE_ACCELERATOR
51 template<
class TSparseSpace,
class TDenseSpace>
52 class MVQNFullJacobianConvergenceAccelerator;
59 template<
class TSparseSpace,
class TDenseSpace>
95 mInitialOmega = rParameters[
"w_0"].
GetDouble();
99 const double abs_cut_off_tol = rParameters[
"abs_cut_off_tol"].
GetDouble();
100 mpConvergenceAcceleratorLeft = Kratos::make_unique<MVQNType>(abs_cut_off_tol);
101 mpConvergenceAcceleratorRight = Kratos::make_unique<MVQNType>(abs_cut_off_tol);
127 mpConvergenceAcceleratorLeft->Initialize();
128 mpConvergenceAcceleratorRight->Initialize();
141 mConvergenceAcceleratorIteration = 0;
143 mpConvergenceAcceleratorLeft->InitializeSolutionStep();
144 mpConvergenceAcceleratorRight->InitializeSolutionStep();
153 mpConvergenceAcceleratorLeft->InitializeNonLinearIteration();
154 mpConvergenceAcceleratorRight->InitializeNonLinearIteration();
172 KRATOS_ERROR <<
"The UpdateSolution() method cannot be called in the interface block Newton case. Use either \'UpdateSolutionLeft\' or \'UpdateSolutionRight\'" << std::endl;
186 auto p_uncor_disp_aux = Kratos::make_shared<VectorType>(rDisplacementOutputVector);
187 std::swap(mpUncorrectedDisplacementVector, p_uncor_disp_aux);
190 mpConvergenceAcceleratorRight->UpdateInverseJacobianApproximation(rForceInputVector, rDisplacementOutputVector);
193 if (!mFirstRightCorrectionPerformed) {
195 TSparseSpace::SetToZero(right_correction);
199 mFirstRightCorrectionPerformed =
true;
222 auto p_uncor_force_aux = Kratos::make_shared<VectorType>(rForceOutputVector);
223 std::swap(mpUncorrectedForceVector, p_uncor_force_aux);
226 mpConvergenceAcceleratorLeft->UpdateInverseJacobianApproximation(rDisplacementInputVector, rForceOutputVector);
229 if (!mFirstLeftCorrectionPerformed) {
232 left_correction = rForceOutputVector - rIterationGuess;
235 mFirstLeftCorrectionPerformed =
true;
257 mConvergenceAcceleratorIteration += 1;
259 mpConvergenceAcceleratorLeft->FinalizeNonLinearIteration();
260 mpConvergenceAcceleratorRight->FinalizeNonLinearIteration();
273 mpConvergenceAcceleratorLeft->FinalizeSolutionStep();
274 mpConvergenceAcceleratorRight->FinalizeSolutionStep();
283 mpConvergenceAcceleratorLeft->Finalize();
284 mpConvergenceAcceleratorRight->Finalize();
293 mpConvergenceAcceleratorLeft->Clear();
294 mpConvergenceAcceleratorRight->Clear();
307 "solver_type" : "IBQN_MVQN",
309 "abs_cut_off_tol" : 1e-8
312 return ibqn_mvqn_default_parameters;
352 std::size_t problem_size = mpConvergenceAcceleratorLeft->GetProblemSize();
355 auto p_inv_jac_left = mpConvergenceAcceleratorLeft->pGetInverseJacobianApproximation();
356 auto p_inv_jac_right = mpConvergenceAcceleratorRight->pGetInverseJacobianApproximation();
359 VectorType aux_RHS = rForceOutputVector - rIterationGuess;
361 VectorType displacement_iteration_update = *mpUncorrectedDisplacementVector - rDisplacementInputVector;
362 TSparseSpace::Mult(*p_inv_jac_left, displacement_iteration_update, aux_left_onto_right);
369 [&aux_LHS, &p_inv_jac_left, &p_inv_jac_right, &problem_size](std::size_t Col,
VectorType& rAuxColumnTLS)
371 TDenseSpace::GetColumn(Col, *p_inv_jac_right, rAuxColumnTLS);
372 for (std::size_t
row = 0;
row < problem_size; ++
row) {
373 aux_LHS(
row,Col) -= TDenseSpace::RowDot(
row, *p_inv_jac_left, rAuxColumnTLS);
380 qr_decomposition.
Compute(aux_LHS);
381 qr_decomposition.
Solve(aux_RHS, rLeftCorrection);
391 std::size_t problem_size = mpConvergenceAcceleratorRight->GetProblemSize();
394 auto p_inv_jac_right = mpConvergenceAcceleratorRight->pGetInverseJacobianApproximation();
395 auto p_inv_jac_left = mpConvergenceAcceleratorLeft->pGetInverseJacobianApproximation();
398 VectorType aux_RHS = rDisplacementOutputVector - rIterationGuess;
400 VectorType force_iteration_update = *mpUncorrectedForceVector - rForceInputVector;
408 [&aux_LHS, &p_inv_jac_right, &p_inv_jac_left, &problem_size](std::size_t Col,
VectorType& rAuxColumnTLS)
410 TDenseSpace::GetColumn(Col, *p_inv_jac_left, rAuxColumnTLS);
411 for (std::size_t
row = 0;
row < problem_size; ++
row) {
412 aux_LHS(
row,Col) -= TDenseSpace::RowDot(
row, *p_inv_jac_right, rAuxColumnTLS);
419 qr_decomposition.
Compute(aux_LHS);
420 qr_decomposition.
Solve(aux_RHS, rRightCorrection);
429 mInitialOmega = Omega;
434 mpConvergenceAcceleratorLeft = pConvergenceAcceleratorLeft;
439 mpConvergenceAcceleratorRight = pConvergenceAcceleratorRight;
444 return mpUncorrectedForceVector;
449 return mpUncorrectedDisplacementVector;
454 return mpConvergenceAcceleratorLeft;
459 return mpConvergenceAcceleratorRight;
487 double mInitialOmega;
489 bool mFirstLeftCorrectionPerformed =
false;
490 bool mFirstRightCorrectionPerformed =
false;
491 unsigned int mConvergenceAcceleratorIteration = 0;
Base class for convergence accelerators This class is intended to be the base of any convergence acce...
Definition: convergence_accelerator.h:43
Definition: dense_householder_qr_decomposition.h:45
void Compute(MatrixType &rInputMatrix) override
Compute the QR Computes the QR Decomposition (QR) of the given imput matrix Note that the input matri...
Definition: dense_householder_qr_decomposition.h:92
void Solve(MatrixType &rB, MatrixType &rX) const override
Solves the problem Ax=b Being A the input matrix, this method solves the problem Ax = b.
Definition: dense_householder_qr_decomposition.h:148
Interface Block Newton convergence accelerator Interface Block Newton equations convergence accelerat...
Definition: ibqn_mvqn_convergence_accelerator.h:61
BaseType::DenseMatrixType MatrixType
Definition: ibqn_mvqn_convergence_accelerator.h:74
ConvergenceAccelerator< TSparseSpace, TDenseSpace > BaseType
Definition: ibqn_mvqn_convergence_accelerator.h:68
virtual Parameters GetDefaultParameters() const
Definition: ibqn_mvqn_convergence_accelerator.h:304
virtual void UpdateSolutionLeft(const VectorType &rDisplacementInputVector, const VectorType &rForceOutputVector, VectorType &rIterationGuess)
Definition: ibqn_mvqn_convergence_accelerator.h:214
void SetLeftConvergenceAcceleratorPointer(MVQNPointerType pConvergenceAcceleratorLeft)
Definition: ibqn_mvqn_convergence_accelerator.h:432
VectorPointerType pGetUncorrectedForceVector()
Definition: ibqn_mvqn_convergence_accelerator.h:442
MVQNFullJacobianConvergenceAccelerator< TSparseSpace, TDenseSpace > MVQNType
Definition: ibqn_mvqn_convergence_accelerator.h:77
VectorPointerType pGetUncorrectedDisplacementVector()
Definition: ibqn_mvqn_convergence_accelerator.h:447
bool IsBlockNewton() const override
Checks if the update direction is unique or double For the current convergence accelerator,...
Definition: ibqn_mvqn_convergence_accelerator.h:299
BaseType::DenseVectorType VectorType
Definition: ibqn_mvqn_convergence_accelerator.h:71
IBQNMVQNConvergenceAccelerator(const IBQNMVQNConvergenceAccelerator &rOther)=delete
IBQNMVQNConvergenceAccelerator()=default
virtual void SolveInterfaceBlockQuasiNewtonRightUpdate(const VectorType &rForceInputVector, const VectorType &rDisplacementOutputVector, const VectorType &rIterationGuess, VectorType &rRightCorrection)
Definition: ibqn_mvqn_convergence_accelerator.h:384
KRATOS_CLASS_POINTER_DEFINITION(IBQNMVQNConvergenceAccelerator)
void FinalizeNonLinearIteration() override
Do the MVQN variables update Updates the MVQN iteration variables for the next non-linear iteration.
Definition: ibqn_mvqn_convergence_accelerator.h:253
void UpdateSolution(const VectorType &rResidualVector, VectorType &rIterationGuess) override
Performs the solution update This method computes the solution update using a Jacobian approximation....
Definition: ibqn_mvqn_convergence_accelerator.h:166
void InitializeSolutionStep() override
Initialize the internal iteration counter This method initializes the convergence acceleratior iterat...
Definition: ibqn_mvqn_convergence_accelerator.h:137
MVQNType::Pointer MVQNPointerType
Definition: ibqn_mvqn_convergence_accelerator.h:78
void SetInitialRelaxationOmega(const double Omega)
Definition: ibqn_mvqn_convergence_accelerator.h:427
void SetRightConvergenceAcceleratorPointer(MVQNPointerType pConvergenceAcceleratorRight)
Definition: ibqn_mvqn_convergence_accelerator.h:437
IBQNMVQNConvergenceAccelerator(Parameters rParameters)
Construct a new IBQNMVQNConvergenceAccelerator object MVQN convergence accelerator Json settings cons...
Definition: ibqn_mvqn_convergence_accelerator.h:92
void InitializeNonLinearIteration() override
Operations before each non-linear iteration Performs all the required operations that should be done ...
Definition: ibqn_mvqn_convergence_accelerator.h:149
MVQNPointerType pGetConvergenceAcceleratorRight()
Definition: ibqn_mvqn_convergence_accelerator.h:457
void Clear() override
Clear the internal storage Clears all the internal data (e.g. previous observation matrices)
Definition: ibqn_mvqn_convergence_accelerator.h:289
BaseType::Pointer BaseTypePointer
Definition: ibqn_mvqn_convergence_accelerator.h:69
virtual void UpdateSolutionRight(const VectorType &rForceInputVector, const VectorType &rDisplacementOutputVector, VectorType &rIterationGuess)
Definition: ibqn_mvqn_convergence_accelerator.h:178
virtual void SolveInterfaceBlockQuasiNewtonLeftUpdate(const VectorType &rDisplacementInputVector, const VectorType &rForceOutputVector, const VectorType &rIterationGuess, VectorType &rLeftCorrection)
Definition: ibqn_mvqn_convergence_accelerator.h:345
BaseType::DenseMatrixPointerType MatrixPointerType
Definition: ibqn_mvqn_convergence_accelerator.h:75
void FinalizeSolutionStep() override
Save the current step Jacobian This method saves the current step Jacobian as previous step Jacobian ...
Definition: ibqn_mvqn_convergence_accelerator.h:269
MVQNPointerType pGetConvergenceAcceleratorLeft()
Definition: ibqn_mvqn_convergence_accelerator.h:452
BaseType::DenseVectorPointerType VectorPointerType
Definition: ibqn_mvqn_convergence_accelerator.h:72
void Initialize() override
Initialize the convergence accelerator Operations that are required to be done once before the resolu...
Definition: ibqn_mvqn_convergence_accelerator.h:123
void Finalize() override
Finalize the convergence accelerator Perform all the operations required after the resolution of the ...
Definition: ibqn_mvqn_convergence_accelerator.h:279
virtual ~IBQNMVQNConvergenceAccelerator()
Definition: ibqn_mvqn_convergence_accelerator.h:112
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
MVQN acceleration scheme MultiVectorQuasiNewton convergence accelerator from Bogaers et al....
Definition: mvqn_convergence_accelerator.hpp:58
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
double GetDouble() const
This method returns the double contained in the current Parameter.
Definition: kratos_parameters.cpp:657
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
TDenseSpace::VectorType DenseVectorType
Definition: convergence_accelerator.h:56
TSparseSpace::VectorType VectorType
Definition: convergence_accelerator.h:50
#define KRATOS_ERROR
Definition: exception.h:161
TDenseSpace::MatrixPointerType DenseMatrixPointerType
Definition: convergence_accelerator.h:59
TDenseSpace::MatrixType DenseMatrixType
Definition: convergence_accelerator.h:57
TSparseSpace::VectorPointerType VectorPointerType
Definition: convergence_accelerator.h:53
TDenseSpace::VectorPointerType DenseVectorPointerType
Definition: convergence_accelerator.h:60
TSparseSpace::MatrixType MatrixType
Definition: convergence_accelerator.h:51
TSpaceType::IndexType Size(TSpaceType &dummy, typename TSpaceType::VectorType const &rV)
Definition: add_strategies_to_python.cpp:111
void Mult(TSpaceType &dummy, typename TSpaceType::MatrixType &rA, typename TSpaceType::VectorType &rX, typename TSpaceType::VectorType &rY)
Definition: add_strategies_to_python.cpp:98
void UnaliasedAdd(TSpaceType &dummy, typename TSpaceType::VectorType &x, const double A, const typename TSpaceType::VectorType &rY)
Definition: add_strategies_to_python.cpp:170
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
AMatrix::IdentityMatrix< double > IdentityMatrix
Definition: amatrix_interface.h:564
AMatrix::MatrixRow< const TExpressionType > row(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t RowIndex)
Definition: amatrix_interface.h:649