Discontinuous Galerkin Library
#include "dg/algorithm.h"
dg::BICGSTABl< ContainerType > Class Template Reference

Preconditioned BICGSTAB(l) method to solve \( Ax=b\). More...

Public Types

using container_type = ContainerType
 
using value_type = dg::get_value_type< ContainerType >
 

Public Member Functions

 BICGSTABl ()=default
 Allocate nothing, Call construct method before usage. More...
 
 BICGSTABl (const ContainerType &copyable, unsigned max_iterations, unsigned l_input)
 Allocate memory for the preconditioned BICGSTABl method. More...
 
template<class ... Params>
void construct (Params &&...ps)
 Perfect forward parameters to one of the constructors. More...
 
void set_max (unsigned new_max)
 Set the maximum number of iterations. More...
 
unsigned get_max () const
 Get the current maximum number of iterations. More...
 
const ContainerType & copyable () const
 Return an object of same size as the object used for construction. More...
 
void set_verbose (bool verbose)
 Set or unset debugging output during iterations. More...
 
void set_throw_on_fail (bool throw_on_fail)
 Set or unset a throw on failure-to-converge. More...
 
template<class MatrixType0 , class ContainerType0 , class ContainerType1 , class MatrixType1 , class ContainerType2 >
unsigned solve (MatrixType0 &&A, ContainerType0 &x, const ContainerType1 &b, MatrixType1 &&P, const ContainerType2 &W, value_type eps=1e-12, value_type nrmb_correction=1)
 Solve \( Ax = b\) using a preconditioned BICGSTABl method. More...
 

Detailed Description

template<class ContainerType>
class dg::BICGSTABl< ContainerType >

Preconditioned BICGSTAB(l) method to solve \( Ax=b\).

Note
BICGSTAB(l) is a method for solving non-symmetrical linear systems. BICGSTAB(l) is a modification of BICGSTAB that aims to improve convergence. See a paper here https://pdfs.semanticscholar.org/c185/7ceab3c9ab4dbcb6a52fb62916f5757c0b38.pdf

Member Typedef Documentation

◆ container_type

template<class ContainerType >
using dg::BICGSTABl< ContainerType >::container_type = ContainerType

◆ value_type

template<class ContainerType >
using dg::BICGSTABl< ContainerType >::value_type = dg::get_value_type<ContainerType>

value type of the ContainerType class

Constructor & Destructor Documentation

◆ BICGSTABl() [1/2]

template<class ContainerType >
dg::BICGSTABl< ContainerType >::BICGSTABl ( )
default

Allocate nothing, Call construct method before usage.

◆ BICGSTABl() [2/2]

template<class ContainerType >
dg::BICGSTABl< ContainerType >::BICGSTABl ( const ContainerType &  copyable,
unsigned  max_iterations,
unsigned  l_input 
)
inline

Allocate memory for the preconditioned BICGSTABl method.

Parameters
copyableA ContainerType must be copy-constructible from this
max_iterationsMaximum number of iterations (there is 2 matrix-vector products plus 2 Preconditioner-vector products per iteration)
l_inputSize of polynomial used for stabilisation. Usually 2 or 4 is a good number (makes l_input Bi-CG iterations before computing the minimal residual)
Note
l_input=1 computes exactly the same as Bi-CGstab does

Member Function Documentation

◆ construct()

template<class ContainerType >
template<class ... Params>
void dg::BICGSTABl< ContainerType >::construct ( Params &&...  ps)
inline

Perfect forward parameters to one of the constructors.

Template Parameters
Paramsdeduced by the compiler
Parameters
psparameters forwarded to constructors

◆ copyable()

template<class ContainerType >
const ContainerType & dg::BICGSTABl< ContainerType >::copyable ( ) const
inline

Return an object of same size as the object used for construction.

Returns
A copyable object; what it contains is undefined, its size is important

◆ get_max()

template<class ContainerType >
unsigned dg::BICGSTABl< ContainerType >::get_max ( ) const
inline

Get the current maximum number of iterations.

Returns
the current maximum

◆ set_max()

template<class ContainerType >
void dg::BICGSTABl< ContainerType >::set_max ( unsigned  new_max)
inline

Set the maximum number of iterations.

Parameters
new_maxNew maximum number

◆ set_throw_on_fail()

template<class ContainerType >
void dg::BICGSTABl< ContainerType >::set_throw_on_fail ( bool  throw_on_fail)
inline

Set or unset a throw on failure-to-converge.

Parameters
throw_on_failIf true, the solve method will thow a dg::Fail if it is unable to converge
Note
the default value is true

◆ set_verbose()

template<class ContainerType >
void dg::BICGSTABl< ContainerType >::set_verbose ( bool  verbose)
inline

Set or unset debugging output during iterations.

Parameters
verboseIf true, additional output will be written to std::cout during solution

◆ solve()

template<class ContainerType >
template<class MatrixType0 , class ContainerType0 , class ContainerType1 , class MatrixType1 , class ContainerType2 >
unsigned dg::BICGSTABl< ContainerType >::solve ( MatrixType0 &&  A,
ContainerType0 &  x,
const ContainerType1 &  b,
MatrixType1 &&  P,
const ContainerType2 &  W,
value_type  eps = 1e-12,
value_type  nrmb_correction = 1 
)

Solve \( Ax = b\) using a preconditioned BICGSTABl method.

The iteration stops if \( ||P(Ax-b)||_W < \epsilon( ||Pb||_S + C) \) where \(C\) is the absolute error in units of \( \epsilon\) and \( W \) defines a square norm

Attention
The stopping criterion differs from that of CG or LGMRES by the preconditioner. It is unfortunately cumbersome to obtain the real residual in this algorithm. If P is diagonal there is the opportunity to use W to offset its effect.
Parameters
AA matrix
xContains an initial value on input and the solution on output.
bThe right hand side vector. x and b may not be the same vector.
PThe preconditioner to be used
WWeights used to define the scalar product and the norm for the error condition
epsThe relative error to be respected
nrmb_correctionthe absolute error C in units of eps to be respected
Returns
Number of iterations used to achieve desired precision (in each iteration the matrix has to be applied twice)
Note
The method will throw dg::Fail if the desired accuracy is not reached within max_iterations You can unset this behaviour with the set_throw_on_fail member
Template Parameters
MatrixTypeAny class for which a specialization of TensorTraits exists and defines a tensor_category derived from AnyMatrixTag. Furthermore, any functor/lambda type with signature void operator()( const ContainerType0&, ContainerType1&) . For example In case of SelfMadeMatrixTag only those blas2 functions that have a corresponding member function in the Matrix class (e.g. symv( const ContainerType0&, ContainerType1&); ) can be called. If a Container has the RecursiveVectorTag, then the matrix is applied to each of the elements unless the type has the SelfMadeMatrixTag or is a Functor type.
ContainerTypeAny class for which a specialization of TensorTraits exists and which fulfills the requirements of the there defined data and execution policies derived from AnyVectorTag and AnyPolicyTag. Among others
  • dg::HVec (serial), dg::DVec (cuda / omp), dg::MHVec (mpi + serial) or dg::MDVec (mpi + cuda / omp)
  • std::vector<dg::DVec> (vector of shared device vectors), std::array<double, 4> (array of 4 doubles) or std::map < std::string, dg::DVec> ( a map of named vectors)
  • double (scalar) and other primitive types ...
If there are several ContainerTypes in the argument list, then TensorTraits must exist for all of them
See also
See The dg dispatch system for a detailed explanation of our type dispatch system

The documentation for this class was generated from the following file: