KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
|
This is a multigrid solver based on the AMGCL library. More...
#include <amgcl_solver.h>
Public Member Functions | |
Life Cycle | |
AMGCLSolver (Parameters ThisParameters=Parameters(R"({})")) | |
This is the default constructor. More... | |
AMGCLSolver (AMGCLSmoother Smoother, AMGCLIterativeSolverType Solver, double Tolerance, int MaxIterationsNumber, int Verbosity, int GMRESSize=50) | |
Default constructor - uses ILU+GMRES. More... | |
AMGCLSolver (AMGCLSmoother Smoother, AMGCLIterativeSolverType Solver, AMGCLCoarseningType Coarsening, double Tolerance, int MaxIterationsNumber, int Verbosity, int GMRESSize=50, bool ProvideCoordinates=false) | |
~AMGCLSolver () override | |
Operations | |
bool | Solve (SparseMatrixType &rA, VectorType &rX, VectorType &rB) override |
Normal solve method. More... | |
virtual void | SetIterationsNumber (const IndexType IterationsNumber) |
This method sets the current iteration number. More... | |
virtual void | SetResidualNorm (const double ResidualNorm) |
This method sets the current residual norm. More... | |
IndexType | GetIterationsNumber () override |
This method returns the current iteration number. More... | |
virtual double | GetResidualNorm () |
This method returns the current residual norm. More... | |
bool | Solve (SparseMatrixType &rA, DenseMatrixType &rX, DenseMatrixType &rB) override |
Multi solve method for solving a set of linear systems with same coefficient matrix. More... | |
bool | AdditionalPhysicalDataIsNeeded () override |
Some solvers may require a minimum degree of knowledge of the structure of the matrix. To make an example when solving a mixed u-p problem, it is important to identify the row associated to v and p. More... | |
void | ProvideAdditionalData (SparseMatrixType &rA, VectorType &rX, VectorType &rB, DofsArrayType &rDofSet, ModelPart &rModelPart) override |
Some solvers may require a minimum degree of knowledge of the structure of the matrix. More... | |
Input and output | |
void | PrintInfo (std::ostream &rOStream) const override |
void | PrintData (std::ostream &rOStream) const override |
Public Member Functions inherited from Kratos::LinearSolver< TSparseSpaceType, TDenseSpaceType, Reorderer< TSparseSpaceType, TDenseSpaceType > > | |
LinearSolver () | |
Default constructor. More... | |
LinearSolver (Reorderer< TSparseSpaceType, TDenseSpaceType > NewReorderer) | |
Constructor with specific reorderer. More... | |
LinearSolver (const LinearSolver &Other) | |
Copy constructor. More... | |
virtual | ~LinearSolver () |
Destructor. More... | |
LinearSolver & | operator= (const LinearSolver &Other) |
Assignment operator. More... | |
virtual void | Initialize (SparseMatrixType &rA, VectorType &rX, VectorType &rB) |
virtual void | InitializeSolutionStep (SparseMatrixType &rA, VectorType &rX, VectorType &rB) |
virtual void | PerformSolutionStep (SparseMatrixType &rA, VectorType &rX, VectorType &rB) |
virtual void | FinalizeSolutionStep (SparseMatrixType &rA, VectorType &rX, VectorType &rB) |
virtual void | Clear () |
virtual void | Solve (SparseMatrixType &K, SparseMatrixType &M, DenseVectorType &Eigenvalues, DenseMatrixType &Eigenvectors) |
virtual TReordererType::Pointer | GetReorderer () |
virtual void | SetReorderer (typename TReordererType::Pointer pNewReorderer) |
virtual void | SetTolerance (double NewTolerance) |
This method allows to set the tolerance in the linear solver. More... | |
virtual double | GetTolerance () |
This method allows to get the tolerance in the linear solver. More... | |
virtual bool | IsConsistent (SparseMatrixType &rA, VectorType &rX, VectorType &rB) |
This method checks if the dimensions of the system of equations are consistent. More... | |
virtual bool | IsConsistent (SparseMatrixType &rA, DenseMatrixType &rX, DenseMatrixType &rB) |
This method checks if the dimensions of the system of equations are consistent (dense matrix for RHS and unknowns version) More... | |
virtual bool | IsNotConsistent (SparseMatrixType &rA, VectorType &rX, VectorType &rB) |
This method checks if the dimensions of the system of equations are not consistent. More... | |
virtual bool | IsNotConsistent (SparseMatrixType &rA, DenseMatrixType &rX, DenseMatrixType &rB) |
This method checks if the dimensions of the system of equations are not consistent. More... | |
virtual std::string | Info () const |
Turn back information as a string. More... | |
KRATOS_CLASS_POINTER_DEFINITION (LinearSolver) | |
Pointer definition of LinearSolver. More... | |
Protected Member Functions | |
Protected Operations | |
void | CheckIfSelectedOptionIsAvailable (const Parameters ThisParameters, const std::string &rOptionName, const std::set< std::string > &rAvailableOptions) |
Private Operations | |
void | SetSmootherType (const AMGCLSmoother SmootherType) |
This method sets the smother type to be considered. More... | |
void | SetIterativeSolverType (const AMGCLIterativeSolverType SolverType) |
This method sets the iterative solver to be considered. More... | |
void | SetCoarseningType (const AMGCLCoarseningType CoarseningType) |
This method sets the coarsening type to be considered. More... | |
Un accessible methods | |
AMGCLSolver & | operator= (const AMGCLSolver &Other) |
AMGCLSolver (const AMGCLSolver &Other) | |
Protected Attributes | |
Member Variables | |
double | mTolerance |
IndexType | mMaxIterationsNumber |
The tolerance considered. More... | |
int | mVerbosity |
The maximum number of iterations considered. More... | |
int | mBlockSize |
The versoisty level. More... | |
SizeType | mGMRESSize |
The size of the dof block. More... | |
SizeType | mCoarseEnough |
The size of the GMRES. More... | |
bool | mFallbackToGMRES |
The level of coarsening allowed. More... | |
bool | mProvideCoordinates |
Of consider GMRES as fallback (TODO: Local flag?) More... | |
bool | mUseBlockMatricesIfPossible |
If the coordinates are provided (TODO: Local flag?) More... | |
bool | mUseGPGPU |
If use the bloack matrices if possible (TODO: Local flag?) More... | |
std::vector< array_1d< double, 3 > > | mCoordinates |
Use GPGPU if available. More... | |
boost::property_tree::ptree | mAMGCLParameters |
The vector containing the local coordinates. More... | |
double | mResidualNorm = 0.0 |
The configuration parameters of the AMGCl. More... | |
IndexType | mIterationsNumber = 0 |
The current residual norm. More... | |
bool | mUseAMGPreconditioning = true |
The current iteration number. More... | |
Type Definitions | |
typedef LinearSolver< TSparseSpaceType, TDenseSpaceType, TReordererType > | BaseType |
The base class definition. More... | |
typedef TSparseSpaceType::MatrixType | SparseMatrixType |
The sparse matric type. More... | |
typedef TSparseSpaceType::VectorType | VectorType |
Vector type definition. More... | |
typedef TDenseSpaceType::MatrixType | DenseMatrixType |
Dense matrix type. More... | |
typedef ModelPart::DofsArrayType | DofsArrayType |
DofArray type. More... | |
typedef TSparseSpaceType::IndexType | IndexType |
The index type definition to be consistent. More... | |
typedef std::size_t | SizeType |
The size type definition. More... | |
KRATOS_CLASS_POINTER_DEFINITION (AMGCLSolver) | |
Pointer definition of AMGCLSolver. More... | |
Additional Inherited Members | |
Public Types inherited from Kratos::LinearSolver< TSparseSpaceType, TDenseSpaceType, Reorderer< TSparseSpaceType, TDenseSpaceType > > | |
typedef TSparseSpaceType::MatrixType | SparseMatrixType |
typedef TSparseSpaceType::MatrixPointerType | SparseMatrixPointerType |
typedef TSparseSpaceType::VectorType | VectorType |
typedef TSparseSpaceType::VectorPointerType | VectorPointerType |
typedef TDenseSpaceType::MatrixType | DenseMatrixType |
typedef TDenseSpaceType::VectorType | DenseVectorType |
typedef std::size_t | SizeType |
typedef TSparseSpaceType::IndexType | IndexType |
The index type definition to be consistent. More... | |
This is a multigrid solver based on the AMGCL library.
Created by Denis Deminov: https://github.com/ddemidov/amgcl AMGCL is a header-only C++ library for solving large sparse linear systems with algebraic multigrid (AMG) method. AMG is one of the most effective iterative methods for solution of equation systems arising, for example, from discretizing PDEs on unstructured grids. The method can be used as a black-box solver for various computational problems, since it does not require any information about the underlying geometry. AMG is often used not as a standalone solver but as a preconditioner within an iterative solver (e.g. Conjugate Gradients, BiCGStab, or GMRES). AMGCL builds the AMG hierarchy on a CPU and then transfers it to one of the provided backends. This allows for transparent acceleration of the solution phase with help of OpenCL, CUDA, or OpenMP technologies. Users may provide their own backends which enables tight integration between AMGCL and the user code.
typedef LinearSolver<TSparseSpaceType, TDenseSpaceType, TReordererType> Kratos::AMGCLSolver< TSparseSpaceType, TDenseSpaceType, TReordererType >::BaseType |
The base class definition.
typedef TDenseSpaceType::MatrixType Kratos::AMGCLSolver< TSparseSpaceType, TDenseSpaceType, TReordererType >::DenseMatrixType |
Dense matrix type.
typedef ModelPart::DofsArrayType Kratos::AMGCLSolver< TSparseSpaceType, TDenseSpaceType, TReordererType >::DofsArrayType |
DofArray type.
typedef TSparseSpaceType::IndexType Kratos::AMGCLSolver< TSparseSpaceType, TDenseSpaceType, TReordererType >::IndexType |
The index type definition to be consistent.
typedef std::size_t Kratos::AMGCLSolver< TSparseSpaceType, TDenseSpaceType, TReordererType >::SizeType |
The size type definition.
typedef TSparseSpaceType::MatrixType Kratos::AMGCLSolver< TSparseSpaceType, TDenseSpaceType, TReordererType >::SparseMatrixType |
The sparse matric type.
typedef TSparseSpaceType::VectorType Kratos::AMGCLSolver< TSparseSpaceType, TDenseSpaceType, TReordererType >::VectorType |
Vector type definition.
|
inline |
This is the default constructor.
ThisParameters | The configuration parameters |
|
inline |
Default constructor - uses ILU+GMRES.
Smoother | The smoother type considered |
Solver | The solver type considered |
Tolerance | tolerance that will be achieved by the iterative solver |
MaxIterationsNumber | this number represents both the number of iterations AND the size of the krylov space |
Verbosity,a | number from 0 (no output) to 2 (maximal output) |
GMRESSize | The size of the GMRES |
|
inline |
Default constructor - uses ILU+GMRES
Smoother | The smoother type considered |
Solver | The solver type considered |
Coarsening | The coarsening type considered |
Tolerance | tolerance that will be achieved by the iterative solver |
MaxIterationsNumber | this number represents both the number of iterations AND the size of the krylov space |
Verbosity,a | number from 0 (no output) to 2 (maximal output) |
GMRESSize | The size of the GMRES |
|
inlineoverride |
Destructor
|
protected |
Copy constructor.
|
inlineoverridevirtual |
Some solvers may require a minimum degree of knowledge of the structure of the matrix. To make an example when solving a mixed u-p problem, it is important to identify the row associated to v and p.
Another example is the automatic prescription of rotation null-space for smoothed-aggregation solvers which require knowledge on the spatial position of the nodes associated to a given dof. This function tells if the solver requires such data
Reimplemented from Kratos::LinearSolver< TSparseSpaceType, TDenseSpaceType, Reorderer< TSparseSpaceType, TDenseSpaceType > >.
|
inlineprotected |
|
inlineoverridevirtual |
This method returns the current iteration number.
Reimplemented from Kratos::LinearSolver< TSparseSpaceType, TDenseSpaceType, Reorderer< TSparseSpaceType, TDenseSpaceType > >.
|
inlinevirtual |
This method returns the current residual norm.
Kratos::AMGCLSolver< TSparseSpaceType, TDenseSpaceType, TReordererType >::KRATOS_CLASS_POINTER_DEFINITION | ( | AMGCLSolver< TSparseSpaceType, TDenseSpaceType, TReordererType > | ) |
Pointer definition of AMGCLSolver.
|
protected |
Assignment operator.
|
inlineoverridevirtual |
Print object's data.
Reimplemented from Kratos::LinearSolver< TSparseSpaceType, TDenseSpaceType, Reorderer< TSparseSpaceType, TDenseSpaceType > >.
|
inlineoverridevirtual |
Print information about this object.
Reimplemented from Kratos::LinearSolver< TSparseSpaceType, TDenseSpaceType, Reorderer< TSparseSpaceType, TDenseSpaceType > >.
|
inlineoverridevirtual |
Some solvers may require a minimum degree of knowledge of the structure of the matrix.
To make an example when solving a mixed u-p problem, it is important to identify the row associated to v and p. Another example is the automatic prescription of rotation null-space for smoothed-aggregation solvers which require knowledge on the spatial position of the nodes associated to a given dof. This function is the place to eventually provide such data
rA | System matrix |
rX | Solution vector. It's also the initial guess for iterative linear solvers. |
rB | Right hand side vector. |
Reimplemented from Kratos::LinearSolver< TSparseSpaceType, TDenseSpaceType, Reorderer< TSparseSpaceType, TDenseSpaceType > >.
|
inlineprotected |
This method sets the coarsening type to be considered.
CoarseningType | The coarsening type to be considered |
|
inlinevirtual |
This method sets the current iteration number.
IterationsNumber | The current iteration number |
|
inlineprotected |
This method sets the iterative solver to be considered.
SolverType | The iterative solver to be considered |
|
inlinevirtual |
This method sets the current residual norm.
ResidualNorm | The current residual norm |
|
inlineprotected |
This method sets the smother type to be considered.
SmootherType | The smother type to be considered |
|
inlineoverridevirtual |
Multi solve method for solving a set of linear systems with same coefficient matrix.
Solves the linear system Ax=b and puts the result on SystemVector& rX. rVectorx is also th initial guess for iterative methods.
rA | System matrix |
rX | Solution vector. it's also the initial guess for iterative linear solvers. |
rB | Right hand side vector. |
Reimplemented from Kratos::LinearSolver< TSparseSpaceType, TDenseSpaceType, Reorderer< TSparseSpaceType, TDenseSpaceType > >.
|
inlineoverridevirtual |
Normal solve method.
Solves the linear system Ax=b and puts the result on SystemVector& rX. rVectorx is also th initial guess for iterative methods.
rA | System matrix |
rX | Solution vector. it's also the initial guess for iterative linear solvers. |
rB | Right hand side vector. |
Reimplemented from Kratos::LinearSolver< TSparseSpaceType, TDenseSpaceType, Reorderer< TSparseSpaceType, TDenseSpaceType > >.
|
protected |
The vector containing the local coordinates.
|
protected |
The versoisty level.
|
protected |
The size of the GMRES.
|
protected |
Use GPGPU if available.
|
protected |
The level of coarsening allowed.
|
protected |
The size of the dof block.
|
protected |
The current residual norm.
|
protected |
The tolerance considered.
|
protected |
Of consider GMRES as fallback (TODO: Local flag?)
|
protected |
The configuration parameters of the AMGCl.
|
protected |
|
protected |
The current iteration number.
|
protected |
If the coordinates are provided (TODO: Local flag?)
|
protected |
If use the bloack matrices if possible (TODO: Local flag?)
|
protected |
The maximum number of iterations considered.