From 48503fb846ba2cf875323afb0890551d55471b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Oberhuber?= <oberhuber.tomas@gmail.com> Date: Wed, 22 Dec 2021 16:23:50 +0100 Subject: [PATCH] Writtin documentation for BICGStab method. --- src/TNL/Solvers/Linear/BICGStab.h | 107 +++++++++++++++++++++++------- 1 file changed, 84 insertions(+), 23 deletions(-) diff --git a/src/TNL/Solvers/Linear/BICGStab.h b/src/TNL/Solvers/Linear/BICGStab.h index 233590ed7a..2d1e7d3a10 100644 --- a/src/TNL/Solvers/Linear/BICGStab.h +++ b/src/TNL/Solvers/Linear/BICGStab.h @@ -10,46 +10,107 @@ #pragma once -#include "LinearSolver.h" +#include <TNL/Solvers/Linear/LinearSolver.h> namespace TNL { -namespace Solvers { -namespace Linear { + namespace Solvers { + namespace Linear { +/** + * \brief Iterative solver of linear systems based on the biconjugate gradient stabilized (BICGStab) method. + * + * This solver can be used for nonsymmetric linear systems. + * + * See [Wikipedia](https://en.wikipedia.org/wiki/Biconjugate_gradient_stabilized_method) for more details. + * + * \tparam Matrix is type of matrix describing the linear system. + */ template< typename Matrix > class BICGStab : public LinearSolver< Matrix > { using Base = LinearSolver< Matrix >; -public: - using RealType = typename Base::RealType; - using DeviceType = typename Base::DeviceType; - using IndexType = typename Base::IndexType; - using VectorViewType = typename Base::VectorViewType; - using ConstVectorViewType = typename Base::ConstVectorViewType; + using VectorType = typename Traits< Matrix >::VectorType; - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ); + public: - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) override; + /** + * \brief Floating point type used for computations. + */ + using RealType = typename Base::RealType; - bool solve( ConstVectorViewType b, VectorViewType x ) override; + /** + * \brief Device where the solver will run on and auxillary data will alloacted on. + * + * See \ref Devices::Host or \ref Devices::Cuda. + */ + using DeviceType = typename Base::DeviceType; -protected: - void compute_residue( VectorViewType r, ConstVectorViewType x, ConstVectorViewType b ); + /** + * \brief Type for indexing. + */ + using IndexType = typename Base::IndexType; - void preconditioned_matvec( ConstVectorViewType src, VectorViewType dst ); + /** + * \brief Type for vector view. + */ + using VectorViewType = typename Base::VectorViewType; - void setSize( const VectorViewType& x ); + /** + * \brief Type for constant vector view. + */ + using ConstVectorViewType = typename Base::ConstVectorViewType; - bool exact_residue = false; + /** + * \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 bicgstab-exact-residue - says whether the BiCGstab should compute the exact residue in + * each step (true) or to use a cheap approximation (false). + * + * \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 = "" ); - typename Traits< Matrix >::VectorType r, r_ast, p, s, Ap, As, M_tmp; + /** + * \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: + void compute_residue( VectorViewType r, ConstVectorViewType x, ConstVectorViewType b ); + + void preconditioned_matvec( ConstVectorViewType src, VectorViewType dst ); + + void setSize( const VectorViewType& x ); + + bool exact_residue = false; + + VectorType r, r_ast, p, s, Ap, As, M_tmp; }; -} // namespace Linear -} // namespace Solvers + } // namespace Linear + } // namespace Solvers } // namespace TNL -#include "BICGStab.hpp" +#include <TNL/Solvers/Linear/BICGStab.hpp> -- GitLab