Loading src/TNL/Solvers/LinearSolverTypeResolver.h +55 −2 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -30,10 +31,16 @@ namespace TNL { 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", Loading @@ -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() { Loading @@ -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" ) Loading Loading @@ -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 ) Loading Loading
src/TNL/Solvers/LinearSolverTypeResolver.h +55 −2 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -30,10 +31,16 @@ namespace TNL { 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", Loading @@ -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() { Loading @@ -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" ) Loading Loading @@ -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 ) Loading