Loading src/TNL/Solvers/Linear/GMRES.h +209 −132 Original line number Diff line number Diff line Loading @@ -12,12 +12,33 @@ #pragma once #include "LinearSolver.h" #include <TNL/Solvers/Linear/LinearSolver.h> namespace TNL { namespace Solvers { namespace Linear { /** * \brief Iterative solver of linear systems based on the Generalized minimal residual (GMRES) method. * * This method can be used for solving of non-semmetric linear systems. This implementation * offers various methods for the orthogonalization of vectors generated by the Arnoldi algorithm. * The user may choose one of the following: * * \e CGS - Classical Gramm-Schmidt, * * \e CGSR - Classical Gramm-Schmidt with reorthogonalization, * * \e MGS - Modified Gramm-Schmidt, * * \e MGSR - Modified Gramm-Schmidt with reorthogonalization (the default one), * * \e CWY - Compact WY form of the Householder reflections). * * See [Wikipedia](https://en.wikipedia.org/wiki/Generalized_minimal_residual_method) for more details. * * \tparam Matrix is type of matrix describing the linear system. */ template< typename Matrix > class GMRES : public LinearSolver< Matrix > Loading @@ -26,23 +47,79 @@ class GMRES using Traits = Linear::Traits< Matrix >; public: /** * \brief Floating point type used for computations. */ using RealType = typename Base::RealType; /** * \brief Device where the solver will run on and auxillary data will alloacted on. */ using DeviceType = typename Base::DeviceType; /** * \brief Type for indexing. */ using IndexType = typename Base::IndexType; // distributed vectors/views /** * \brief Type for vector view. */ using VectorViewType = typename Base::VectorViewType; /** * \brief Type for constant vector view. */ using ConstVectorViewType = typename Base::ConstVectorViewType; using VectorType = typename Traits::VectorType; /** * \brief This is method defines configuration entries for setup of the linear iterative solver. * * In addition to config entries defined by \ref IterativeSolver::configSetup, this method * defines the following: * * \e gmres-variant - Algorithm used for the orthogonalization - CGS (Classical Gramm-Schmidt), * CGSR(Classical Gramm-Schmidt with reorthogonalization), MGS(Modified Gramm-Schmidt), * MGSR(Modified Gramm-Schmidt with reorthogonalization), CWY(Compact WY form of the Householder reflections). * * \e gmres-restarting-min - minimal number of iterations after which the GMRES restarts. * * \e gmres-restarting-max - maximal number of iterations after which the GMRES restarts. * * \e gmres-restarting-step-min - minimal adjusting step for the adaptivity of the GMRES restarting parameter. * * \e gmres-restarting-step-max - maximal adjusting step for the adaptivity of the GMRES restarting parameter. * * \param config contains description of configuration parameters. * \param prefix is a prefix of particular configuration entries. */ static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ); /** * \brief Method for setup of the linear iterative solver based on configuration parameters. * * \param parameters contains values of the define configuration entries. * \param prefix is a prefix of particular configuration entries. */ bool setup( const Config::ParameterContainer& parameters, const String& prefix = "" ) override; /** * \brief Method for solving of a linear system. * * See \ref LinearSolver::solve for more details. * * \param b vector with the right-hand side of the linear system. * \param x vector for the solution of the linear system. * \return true if the solver converged. * \return false if the solver did not converge. */ bool solve( ConstVectorViewType b, VectorViewType x ) override; protected: using VectorType = typename Traits::VectorType; // local vectors/views using ConstDeviceView = typename Traits::ConstLocalViewType; using DeviceView = typename Traits::LocalViewType; Loading Loading @@ -160,4 +237,4 @@ protected: } // namespace Solvers } // namespace TNL #include "GMRES.hpp" #include <TNL/Solvers/Linear/GMRES.hpp> Loading
src/TNL/Solvers/Linear/GMRES.h +209 −132 Original line number Diff line number Diff line Loading @@ -12,12 +12,33 @@ #pragma once #include "LinearSolver.h" #include <TNL/Solvers/Linear/LinearSolver.h> namespace TNL { namespace Solvers { namespace Linear { /** * \brief Iterative solver of linear systems based on the Generalized minimal residual (GMRES) method. * * This method can be used for solving of non-semmetric linear systems. This implementation * offers various methods for the orthogonalization of vectors generated by the Arnoldi algorithm. * The user may choose one of the following: * * \e CGS - Classical Gramm-Schmidt, * * \e CGSR - Classical Gramm-Schmidt with reorthogonalization, * * \e MGS - Modified Gramm-Schmidt, * * \e MGSR - Modified Gramm-Schmidt with reorthogonalization (the default one), * * \e CWY - Compact WY form of the Householder reflections). * * See [Wikipedia](https://en.wikipedia.org/wiki/Generalized_minimal_residual_method) for more details. * * \tparam Matrix is type of matrix describing the linear system. */ template< typename Matrix > class GMRES : public LinearSolver< Matrix > Loading @@ -26,23 +47,79 @@ class GMRES using Traits = Linear::Traits< Matrix >; public: /** * \brief Floating point type used for computations. */ using RealType = typename Base::RealType; /** * \brief Device where the solver will run on and auxillary data will alloacted on. */ using DeviceType = typename Base::DeviceType; /** * \brief Type for indexing. */ using IndexType = typename Base::IndexType; // distributed vectors/views /** * \brief Type for vector view. */ using VectorViewType = typename Base::VectorViewType; /** * \brief Type for constant vector view. */ using ConstVectorViewType = typename Base::ConstVectorViewType; using VectorType = typename Traits::VectorType; /** * \brief This is method defines configuration entries for setup of the linear iterative solver. * * In addition to config entries defined by \ref IterativeSolver::configSetup, this method * defines the following: * * \e gmres-variant - Algorithm used for the orthogonalization - CGS (Classical Gramm-Schmidt), * CGSR(Classical Gramm-Schmidt with reorthogonalization), MGS(Modified Gramm-Schmidt), * MGSR(Modified Gramm-Schmidt with reorthogonalization), CWY(Compact WY form of the Householder reflections). * * \e gmres-restarting-min - minimal number of iterations after which the GMRES restarts. * * \e gmres-restarting-max - maximal number of iterations after which the GMRES restarts. * * \e gmres-restarting-step-min - minimal adjusting step for the adaptivity of the GMRES restarting parameter. * * \e gmres-restarting-step-max - maximal adjusting step for the adaptivity of the GMRES restarting parameter. * * \param config contains description of configuration parameters. * \param prefix is a prefix of particular configuration entries. */ static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ); /** * \brief Method for setup of the linear iterative solver based on configuration parameters. * * \param parameters contains values of the define configuration entries. * \param prefix is a prefix of particular configuration entries. */ bool setup( const Config::ParameterContainer& parameters, const String& prefix = "" ) override; /** * \brief Method for solving of a linear system. * * See \ref LinearSolver::solve for more details. * * \param b vector with the right-hand side of the linear system. * \param x vector for the solution of the linear system. * \return true if the solver converged. * \return false if the solver did not converge. */ bool solve( ConstVectorViewType b, VectorViewType x ) override; protected: using VectorType = typename Traits::VectorType; // local vectors/views using ConstDeviceView = typename Traits::ConstLocalViewType; using DeviceView = typename Traits::LocalViewType; Loading Loading @@ -160,4 +237,4 @@ protected: } // namespace Solvers } // namespace TNL #include "GMRES.hpp" #include <TNL/Solvers/Linear/GMRES.hpp>