14 #if !defined(KRATOS_CG_SOLVER_H_INCLUDED )
15 #define KRATOS_CG_SOLVER_H_INCLUDED
54 template<
class TSparseSpaceType,
class TDenseSpaceType,
55 class TPreconditionerType = Preconditioner<TSparseSpaceType, TDenseSpaceType>,
56 class TReordererType = Reorderer<TSparseSpaceType, TDenseSpaceType> >
83 CGSolver(
double NewMaxTolerance,
unsigned int NewMaxIterationsNumber) :
BaseType(NewMaxTolerance, NewMaxIterationsNumber) {}
85 CGSolver(
double NewMaxTolerance,
unsigned int NewMaxIterationsNumber,
typename TPreconditionerType::Pointer pNewPreconditioner) :
86 BaseType(NewMaxTolerance, NewMaxIterationsNumber, pNewPreconditioner) {}
89 BaseType(settings, pNewPreconditioner) {}
94 if(settings.
Has(
"preconditioner_type"))
140 bool is_solved = IterativeSolve(rA,rX,rB);
166 bool is_solved =
true;
171 TDenseSpaceType::GetColumn(
i,rX,
x);
172 TDenseSpaceType::GetColumn(
i,rB,
b);
177 is_solved &= IterativeSolve(rA,
x,
b);
202 std::string
Info()
const override
204 std::stringstream buffer;
305 if(fabs(roh0) < 1.0e-30)
316 if(fabs(
pq) <= 1.0e-30)
326 beta = (roh1 / roh0);
370 template<
class TSparseSpaceType,
class TDenseSpaceType,
371 class TPreconditionerType,
372 class TReordererType>
374 CGSolver<TSparseSpaceType, TDenseSpaceType,
375 TPreconditionerType, TReordererType>& rThis)
381 template<
class TSparseSpaceType,
class TDenseSpaceType,
382 class TPreconditionerType,
383 class TReordererType>
385 const CGSolver<TSparseSpaceType, TDenseSpaceType,
386 TPreconditionerType, TReordererType>& rThis)
388 rThis.PrintInfo(OStream);
389 OStream << std::endl;
390 rThis.PrintData(OStream);
Short class definition.
Definition: cg_solver.h:58
KRATOS_CLASS_POINTER_DEFINITION(CGSolver)
Pointer definition of CGSolver.
CGSolver(double NewMaxTolerance)
Definition: cg_solver.h:81
CGSolver(double NewMaxTolerance, unsigned int NewMaxIterationsNumber)
Definition: cg_solver.h:83
CGSolver()
Default constructor.
Definition: cg_solver.h:79
TSparseSpaceType::VectorType VectorType
Definition: cg_solver.h:70
~CGSolver() override
Destructor.
Definition: cg_solver.h:103
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: cg_solver.h:216
CGSolver(Parameters settings, typename TPreconditionerType::Pointer pNewPreconditioner)
Definition: cg_solver.h:88
TSparseSpaceType::MatrixType SparseMatrixType
Definition: cg_solver.h:68
bool Solve(SparseMatrixType &rA, DenseMatrixType &rX, DenseMatrixType &rB) override
Definition: cg_solver.h:160
bool Solve(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
Definition: cg_solver.h:129
TDenseSpaceType::MatrixType DenseMatrixType
Definition: cg_solver.h:72
CGSolver & operator=(const CGSolver &Other)
Assignment operator.
Definition: cg_solver.h:111
CGSolver(Parameters settings)
Definition: cg_solver.h:91
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: cg_solver.h:210
IterativeSolver< TSparseSpaceType, TDenseSpaceType, TPreconditionerType, TReordererType > BaseType
Definition: cg_solver.h:66
CGSolver(double NewMaxTolerance, unsigned int NewMaxIterationsNumber, typename TPreconditionerType::Pointer pNewPreconditioner)
Definition: cg_solver.h:85
std::string Info() const override
Turn back information as a string.
Definition: cg_solver.h:202
CGSolver(const CGSolver &Other)
Copy constructor.
Definition: cg_solver.h:99
Base class for all the iterative solvers in Kratos.
Definition: iterative_solver.h:68
IndexType mIterationsNumber
Definition: iterative_solver.h:403
virtual bool IterationNeeded()
Definition: iterative_solver.h:331
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: iterative_solver.h:360
double mResidualNorm
Definition: iterative_solver.h:399
void PreconditionedMult(SparseMatrixType &rA, VectorType &rX, VectorType &rY)
Definition: iterative_solver.h:416
double mBNorm
Definition: iterative_solver.h:405
IterativeSolver & operator=(const IterativeSolver &Other)
Assignment operator.
Definition: iterative_solver.h:176
virtual void SetPreconditioner(typename TPreconditionerType::Pointer pNewPreconditioner)
Definition: iterative_solver.h:270
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
virtual bool IsConverged()
Definition: iterative_solver.h:336
virtual double GetResidualNorm()
Definition: iterative_solver.h:322
virtual bool IsNotConsistent(SparseMatrixType &rA, VectorType &rX, VectorType &rB)
This method checks if the dimensions of the system of equations are not consistent.
Definition: linear_solver.h:346
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
bool Has(const std::string &rEntry) const
This method checks if the Parameter contains a certain entry.
Definition: kratos_parameters.cpp:520
Here we add the functions needed for the registration of preconditioners.
Definition: preconditioner_factory.h:62
#define KRATOS_WARNING_IF(label, conditional)
Definition: logger.h:266
Modeler::Pointer Create(const std::string &ModelerName, Model &rModel, const Parameters ModelParameters)
Checks if the modeler is registered.
Definition: modeler_factory.cpp:30
TSpaceType::IndexType Size1(TSpaceType &dummy, typename TSpaceType::MatrixType const &rM)
Definition: add_strategies_to_python.cpp:117
TSpaceType::IndexType Size2(TSpaceType &dummy, typename TSpaceType::MatrixType const &rM)
Definition: add_strategies_to_python.cpp:123
void ScaleAndAdd(TSpaceType &dummy, const double A, const typename TSpaceType::VectorType &rX, const double B, typename TSpaceType::VectorType &rY)
Definition: add_strategies_to_python.cpp:91
double TwoNorm(SparseSpaceType &dummy, SparseSpaceType::VectorType &x)
Definition: add_strategies_to_python.cpp:164
TSpaceType::IndexType Size(TSpaceType &dummy, typename TSpaceType::VectorType const &rV)
Definition: add_strategies_to_python.cpp:111
double Dot(SparseSpaceType &dummy, SparseSpaceType::VectorType &rX, SparseSpaceType::VectorType &rY)
Definition: add_strategies_to_python.cpp:85
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
alpha
Definition: generate_convection_diffusion_explicit_element.py:113
q
Definition: generate_convection_diffusion_explicit_element.py:109
b
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:31
p
Definition: sensitivityMatrix.py:52
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17
subroutine pq(T, p, q)
Definition: TensorModule.f:339