Skip to content
Snippets Groups Projects
Commit 558a6a99 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Writting documentation on getLinearSolver and getPreconditioner.

parent 00103113
No related branches found
No related tags found
1 merge request!116Documentation for linear solvers and preconditioners
......@@ -16,6 +16,7 @@
#include <string>
#include <memory>
#include <TNL/Solvers/Linear/Jacobi.h>
#include <TNL/Solvers/Linear/SOR.h>
#include <TNL/Solvers/Linear/CG.h>
#include <TNL/Solvers/Linear/BICGStab.h>
......@@ -28,12 +29,18 @@
#include <TNL/Solvers/Linear/Preconditioners/ILUT.h>
namespace TNL {
namespace Solvers {
namespace Solvers {
/**
* \brief Function returning available linear solvers.
*
* \return container with names of available linear solvers.
*/
inline std::vector<std::string>
getLinearSolverOptions()
{
return {
"jacobi",
"sor",
"cg",
"bicgstab",
......@@ -46,6 +53,11 @@ getLinearSolverOptions()
};
}
/**
* \brief Function returning available linear preconditioners.
*
* \return container with names of available linear preconditioners.
*/
inline std::vector<std::string>
getPreconditionerOptions()
{
......@@ -57,10 +69,34 @@ getPreconditionerOptions()
};
}
/**
* \brief Function returning shared pointer with linear solver given by its name in a form of a string.
*
* \tparam MatrixType is a type of matrix defining the system of linear equations.
* \param name of the linear solver. The name can be one of the following:
* 1. `jacobi` - for the Jacobi solver - \ref TNL::Solvers::Linear::Jacobi.
* 2. `sor` - for SOR solver - \ref TNL::Solvers::Linear::SOR.
* 3. `cg` - for CG solver - \ref TNL::Solvers::Linear::CG.
* 4. `bicgstab` - for BICGStab solver - \ref TNL::Solvers::Linear::BICGStab.
* 5. `bicgstabl` - for BICGStabL solver - \ref TNL::Solvers::Linear::BICGStabL.
* 6. `gmres` - for GMRES solver - \ref TNL::Solvers::Linear::GMRES.
* 7. `tfqmr` - for TFQMR solver - \ref TNL::Solvers::Linear::TFQMR.
* \return shared pointer with given linear solver.
*
* The following example shows how to use this function:
*
* \includelineno Solvers/Linear/IterativeLinearSolverWithRuntimeTypesExample.cpp
*
* The result looks as follows:
*
* \include IterativeLinearSolverWithRuntimeTypesExample.out
*/
template< typename MatrixType >
std::shared_ptr< Linear::LinearSolver< MatrixType > >
getLinearSolver( std::string name )
{
if( name == "jacobi" )
return std::make_shared< Linear::Jacobi< MatrixType > >();
if( name == "sor" )
return std::make_shared< Linear::SOR< MatrixType > >();
if( name == "cg" )
......@@ -90,6 +126,23 @@ getLinearSolver( std::string name )
return nullptr;
}
/**
* \brief Function returning shared pointer with linear preconditioner given by its name in a form of a string.
*
* \tparam MatrixType is a type of matrix defining the system of linear equations.
* \param name of the linear preconditioner. The name can be one of the following:
* 1. `none` - for none preconditioner
* 2. `diagonal` - for diagonal/Jacobi preconditioner - \ref TNL::Solvers::Linear::Preconditioners::Diagonal
* 3. `ilu0` - for ILU(0) preconditioner - \ref TNL::Solvers::Linear::Preconditioners::ILU0
* 4. `ilut` - for ILU with thresholding preconditioner - \ref TNL::Solvers::Linear::Preconditioners::ILUT
* \return shared pointer with given linear preconditioner.
*
* \includelineno Solvers/Linear/IterativeLinearSolverWithRuntimeTypesExample.cpp
*
* The result looks as follows:
*
* \include IterativeLinearSolverWithRuntimeTypesExample.out
*/
template< typename MatrixType >
std::shared_ptr< Linear::Preconditioners::Preconditioner< MatrixType > >
getPreconditioner( std::string name )
......@@ -116,5 +169,5 @@ getPreconditioner( std::string name )
return nullptr;
}
} // namespace Solvers
} // namespace Solvers
} // namespace TNL
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment