14 #if !defined(KRATOS_ITERATIVE_SOLVER_H_INCLUDED )
15 #define KRATOS_ITERATIVE_SOLVER_H_INCLUDED
64 template<
class TSparseSpaceType,
class TDenseSpaceType,
65 class TPreconditionerType = Preconditioner<TSparseSpaceType, TDenseSpaceType>,
66 class TReordererType = Reorderer<TSparseSpaceType, TDenseSpaceType> >
98 , mpPreconditioner(new TPreconditionerType())
100 , mMaxIterationsNumber(0)
108 , mpPreconditioner(new TPreconditionerType())
109 , mTolerance(NewTolerance)
110 , mMaxIterationsNumber(0)
118 , mpPreconditioner(new TPreconditionerType())
119 , mTolerance(NewTolerance)
120 , mMaxIterationsNumber(NewMaxIterationsNumber) {}
122 IterativeSolver(
double NewTolerance,
unsigned int NewMaxIterationsNumber,
typename TPreconditionerType::Pointer pNewPreconditioner) :
124 mpPreconditioner(pNewPreconditioner),
125 mTolerance(NewTolerance),
126 mMaxIterationsNumber(NewMaxIterationsNumber) {}
129 typename TPreconditionerType::Pointer pNewPreconditioner = Kratos::make_shared<TPreconditionerType>()
134 mpPreconditioner(pNewPreconditioner)
140 "solver_type": "IterativeSolver",
141 "tolerance" : 1.0e-6,
142 "max_iteration" : 200,
143 "preconditioner_type": "none",
150 this->
SetTolerance( settings[
"tolerance"].GetDouble() );
160 mpPreconditioner(Other.mpPreconditioner),
161 mTolerance(Other.mTolerance),
162 mMaxIterationsNumber(Other.mMaxIterationsNumber)
262 return mpPreconditioner;
267 return mpPreconditioner;
272 mpPreconditioner = pNewPreconditioner;
287 mMaxIterationsNumber = NewMaxIterationsNumber;
292 return mMaxIterationsNumber;
307 mTolerance = NewTolerance;
346 std::string
Info()
const override
348 std::stringstream buffer;
364 rOStream <<
" Residual ratio : infinite" << std::endl;
366 rOStream <<
" Residual ratio : 0" << std::endl;
369 rOStream <<
" Initial Residual ratio : " <<
mBNorm << std::endl;
370 rOStream <<
" Final Residual ratio : " <<
mResidualNorm << std::endl;
375 rOStream <<
" Tolerance : " << mTolerance << std::endl;
377 rOStream <<
" Maximum number of iterations : " << mMaxIterationsNumber;
379 rOStream << std::endl <<
"!!!!!!!!!!!! ITERATIVE SOLVER NON CONVERGED !!!!!!!!!!!!" << mMaxIterationsNumber;
453 typename TPreconditionerType::Pointer mpPreconditioner;
503 template<
class TSparseSpaceType,
class TDenseSpaceType,
class TPreconditionerType,
504 class TReordererType>
507 TPreconditionerType, TReordererType>& rThis)
513 template<
class TSparseSpaceType,
class TDenseSpaceType,
class TPreconditionerType,
514 class TReordererType>
517 TPreconditionerType, TReordererType>& rThis)
519 rThis.PrintInfo(OStream);
520 OStream << std::endl;
521 rThis.PrintData(OStream);
Base class for all the iterative solvers in Kratos.
Definition: iterative_solver.h:68
IterativeSolver(Parameters settings, typename TPreconditionerType::Pointer pNewPreconditioner=Kratos::make_shared< TPreconditionerType >())
Definition: iterative_solver.h:128
virtual const TPreconditionerType::Pointer GetPreconditioner(void) const
Definition: iterative_solver.h:265
void SetTolerance(double NewTolerance) override
This method allows to set the tolerance in the linear solver.
Definition: iterative_solver.h:305
IndexType mIterationsNumber
Definition: iterative_solver.h:403
bool AdditionalPhysicalDataIsNeeded() override
Definition: iterative_solver.h:225
virtual bool IterationNeeded()
Definition: iterative_solver.h:331
IterativeSolver(const IterativeSolver &Other)
Copy constructor.
Definition: iterative_solver.h:158
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: iterative_solver.h:360
IndexType GetIterationsNumber() override
Definition: iterative_solver.h:300
double mResidualNorm
Definition: iterative_solver.h:399
double mFirstResidualNorm
Definition: iterative_solver.h:401
void Clear() override
Definition: iterative_solver.h:214
std::string Info() const override
Turn back information as a string.
Definition: iterative_solver.h:346
void PreconditionedMult(SparseMatrixType &rA, VectorType &rX, VectorType &rY)
Definition: iterative_solver.h:416
TSparseSpaceType::MatrixType SparseMatrixType
Definition: iterative_solver.h:78
virtual void SetIterationsNumber(unsigned int NewIterationNumber)
Definition: iterative_solver.h:295
double mBNorm
Definition: iterative_solver.h:405
IterativeSolver()
Default constructor.
Definition: iterative_solver.h:94
virtual void SetMaxIterationsNumber(unsigned int NewMaxIterationsNumber)
Definition: iterative_solver.h:285
KRATOS_CLASS_POINTER_DEFINITION(IterativeSolver)
Pointer definition of IterativeSolver.
IterativeSolver & operator=(const IterativeSolver &Other)
Assignment operator.
Definition: iterative_solver.h:176
virtual IndexType GetMaxIterationsNumber()
Definition: iterative_solver.h:290
void ProvideAdditionalData(SparseMatrixType &rA, VectorType &rX, VectorType &rB, typename ModelPart::DofsArrayType &rdof_set, ModelPart &r_model_part) override
Definition: iterative_solver.h:239
void InitializeSolutionStep(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
Definition: iterative_solver.h:194
void FinalizeSolutionStep(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
Definition: iterative_solver.h:205
TSparseSpaceType::IndexType IndexType
The index type definition to be consistent.
Definition: iterative_solver.h:87
void PreconditionedTransposeMult(SparseMatrixType &rA, VectorType &rX, VectorType &rY)
Definition: iterative_solver.h:421
virtual void SetPreconditioner(typename TPreconditionerType::Pointer pNewPreconditioner)
Definition: iterative_solver.h:270
TPreconditionerType PreconditionerType
Definition: iterative_solver.h:84
LinearSolver< TSparseSpaceType, TDenseSpaceType, TReordererType > BaseType
Definition: iterative_solver.h:76
double GetTolerance() override
This method allows to get the tolerance in the linear solver.
Definition: iterative_solver.h:310
virtual TPreconditionerType::Pointer GetPreconditioner(void)
Definition: iterative_solver.h:260
IterativeSolver(double NewTolerance, unsigned int NewMaxIterationsNumber, typename TPreconditionerType::Pointer pNewPreconditioner)
Definition: iterative_solver.h:122
virtual bool IsConverged()
Definition: iterative_solver.h:336
virtual double GetResidualNorm()
Definition: iterative_solver.h:322
IterativeSolver(double NewTolerance, unsigned int NewMaxIterationsNumber)
Definition: iterative_solver.h:114
TDenseSpaceType::MatrixType DenseMatrixType
Definition: iterative_solver.h:82
TSparseSpaceType::VectorType VectorType
Definition: iterative_solver.h:80
virtual void SetResidualNorm(double NewResidualNorm)
Definition: iterative_solver.h:315
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: iterative_solver.h:354
~IterativeSolver() override
Destructor.
Definition: iterative_solver.h:168
IterativeSolver(double NewTolerance)
Definition: iterative_solver.h:104
Base class for all the linear solvers in Kratos.
Definition: linear_solver.h:65
LinearSolver & operator=(const LinearSolver &Other)
Assignment operator.
Definition: linear_solver.h:112
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
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
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
std::size_t IndexType
Definition: binary_expression.cpp:25
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432