OFELI's Logo

An Object Oriented Finite Element Library

LinearSolver< T_ > Class Template Reference

Class to solve systems of linear equations by iterative methods. More...

#include <LinearSolver.h>

Public Member Functions

 LinearSolver ()
 Default Constructor. More...
 
 LinearSolver (int max_it, real_t tolerance)
 Constructor with iteration parameters. More...
 
 LinearSolver (SpMatrix< T_ > &A, const Vect< T_ > &b, Vect< T_ > &x)
 Constructor using matrix, right-hand side and solution vector. More...
 
 LinearSolver (SkMatrix< T_ > &A, const Vect< T_ > &b, Vect< T_ > &x)
 Constructor using skyline-stored matrix, right-hand side and solution vector. More...
 
 LinearSolver (TrMatrix< T_ > &A, const Vect< T_ > &b, Vect< T_ > &x)
 Constructor using a tridiagonal matrix, right-hand side and solution vector. More...
 
 LinearSolver (BMatrix< T_ > &A, const Vect< T_ > &b, Vect< T_ > &x)
 Constructor using a banded matrix, right-hand side and solution vector. More...
 
 LinearSolver (DMatrix< T_ > &A, const Vect< T_ > &b, Vect< T_ > &x)
 Constructor using a dense matrix, right-hand side and solution vector. More...
 
 LinearSolver (DSMatrix< T_ > &A, const Vect< T_ > &b, Vect< T_ > &x)
 Constructor using a dense symmetric matrix, right-hand side and solution vector. More...
 
 LinearSolver (SkSMatrix< T_ > &A, const Vect< T_ > &b, Vect< T_ > &x)
 Constructor using skyline-stored symmetric matrix, right-hand side and solution vector. More...
 
 LinearSolver (SkMatrix< T_ > &A, Vect< T_ > &b, Vect< T_ > &x)
 Constructor using matrix, right-hand side. More...
 
virtual ~LinearSolver ()
 Destructor.
 
void setMaxIter (int m)
 Set Maximum number of iterations. More...
 
void setTolerance (real_t tol)
 Set tolerance value.
 
void setSolution (Vect< T_ > &x)
 Set solution vector.
 
void setRHS (Vect< T_ > &b)
 Set right-hand side vector.
 
void setMatrix (OFELI::Matrix< T_ > *A)
 Set matrix in the case of a pointer to Matrix. More...
 
void setMatrix (SpMatrix< T_ > &A)
 Set matrix in the case of a pointer to matrix. More...
 
void setMatrix (SkMatrix< T_ > &A)
 Set matrix in the case of a skyline matrix. More...
 
void set (SpMatrix< T_ > &A, const Vect< T_ > &b, Vect< T_ > &x)
 Set matrix, right-hand side and initial guess. More...
 
void setSolver (Iteration s, Preconditioner p=DIAG_PREC)
 Set solver and preconditioner. More...
 
Iteration getSolver () const
 Return solver code.
 
Preconditioner getPreconditioner () const
 Return solver preconditioner.
 
int solve (SpMatrix< T_ > &A, const Vect< T_ > &b, Vect< T_ > &x, Iteration s, Preconditioner p=DIAG_PREC)
 Solve equations using system data, prescribed solver and preconditioner. More...
 
int solve (Iteration s, Preconditioner p=DIAG_PREC)
 Solve equations using prescribed solver and preconditioner. More...
 
int solve ()
 Solve equations all arguments must have been given by other member functions. More...
 
void setFact ()
 Factorize matrix.
 
void setNoFact ()
 Do not factorize matrix.
 
int getNbIter () const
 Get number of performed iterations.
 

Detailed Description

template<class T_>
class OFELI::LinearSolver< T_ >

Class to solve systems of linear equations by iterative methods.

Constructor & Destructor Documentation

◆ LinearSolver() [1/10]

Default Constructor.

Initializes default parameters and pointers to 0.

◆ LinearSolver() [2/10]

LinearSolver ( int  max_it,
real_t  tolerance 
)

Constructor with iteration parameters.

Parameters
[in]max_itMaximal number of iterations
[in]toleranceTolerance for convergence (measured in relative weighted 2-Norm) in input, effective discrepancy in output.
Author
Rachid Touzani

◆ LinearSolver() [3/10]

LinearSolver ( SpMatrix< T_ > &  A,
const Vect< T_ > &  b,
Vect< T_ > &  x 
)

Constructor using matrix, right-hand side and solution vector.

Parameters
[in]AReference to instance of class SpMatrix
[in]bVect instance that contains the right-hand side
[in,out]xVect instance that contains initial guess on input and solution on output

◆ LinearSolver() [4/10]

LinearSolver ( SkMatrix< T_ > &  A,
const Vect< T_ > &  b,
Vect< T_ > &  x 
)

Constructor using skyline-stored matrix, right-hand side and solution vector.

Parameters
[in]ASkMatrix instance that contains matrix
[in]bVect instance that contains the right-hand side
[in,out]xVect instance that contains initial guess on input and solution on output

◆ LinearSolver() [5/10]

LinearSolver ( TrMatrix< T_ > &  A,
const Vect< T_ > &  b,
Vect< T_ > &  x 
)

Constructor using a tridiagonal matrix, right-hand side and solution vector.

Parameters
[in]ATrMatrix instance that contains matrix
[in]bVect instance that contains the right-hand side
[in,out]xVect instance that contains initial guess on input and solution on output

◆ LinearSolver() [6/10]

LinearSolver ( BMatrix< T_ > &  A,
const Vect< T_ > &  b,
Vect< T_ > &  x 
)

Constructor using a banded matrix, right-hand side and solution vector.

Parameters
[in]ABMatrix instance that contains matrix
[in]bVect instance that contains the right-hand side
[in,out]xVect instance that contains initial guess on input and solution on output

◆ LinearSolver() [7/10]

LinearSolver ( DMatrix< T_ > &  A,
const Vect< T_ > &  b,
Vect< T_ > &  x 
)

Constructor using a dense matrix, right-hand side and solution vector.

Parameters
[in]ADMatrix instance that contains matrix
[in]bVect instance that contains the right-hand side
[in,out]xVect instance that contains initial guess on input and solution on output

◆ LinearSolver() [8/10]

LinearSolver ( DSMatrix< T_ > &  A,
const Vect< T_ > &  b,
Vect< T_ > &  x 
)

Constructor using a dense symmetric matrix, right-hand side and solution vector.

Parameters
[in]ADSMatrix instance that contains matrix
[in]bVect instance that contains the right-hand side
[in,out]xVect instance that contains initial guess on input and solution on output

◆ LinearSolver() [9/10]

LinearSolver ( SkSMatrix< T_ > &  A,
const Vect< T_ > &  b,
Vect< T_ > &  x 
)

Constructor using skyline-stored symmetric matrix, right-hand side and solution vector.

Parameters
[in]ASkMatrix instance that contains matrix
[in]bVect instance that contains the right-hand side
[in,out]xVect instance that contains initial guess on input and solution on output

◆ LinearSolver() [10/10]

LinearSolver ( SkMatrix< T_ > &  A,
Vect< T_ > &  b,
Vect< T_ > &  x 
)

Constructor using matrix, right-hand side.

Parameters
[in]ASkMatrix instance that contains matrix
[in]bVect instance that contains the right-hand side
[in,out]xVect instance that contains the initial guess on input and solution on output

Member Function Documentation

◆ set()

void set ( SpMatrix< T_ > &  A,
const Vect< T_ > &  b,
Vect< T_ > &  x 
)

Set matrix, right-hand side and initial guess.

Parameters
[in]AReference to matrix as a SpMatrix instance
[in]bVector containing right-hand side
[in,out]xVector containing initial guess on input and solution on output

◆ setMatrix() [1/3]

void setMatrix ( OFELI::Matrix< T_ > *  A)

Set matrix in the case of a pointer to Matrix.

Parameters
[in]APointer to abstract Matrix class

◆ setMatrix() [2/3]

void setMatrix ( SkMatrix< T_ > &  A)

Set matrix in the case of a skyline matrix.

Parameters
[in]AMatrix as instance of class SkMatrix

◆ setMatrix() [3/3]

void setMatrix ( SpMatrix< T_ > &  A)

Set matrix in the case of a pointer to matrix.

Parameters
[in]APointer to abstract Matrix class

◆ setMaxIter()

void setMaxIter ( int  m)

Set Maximum number of iterations.

Default value is 1000

◆ setSolver()

void setSolver ( Iteration  s,
Preconditioner  p = DIAG_PREC 
)

Set solver and preconditioner.

Parameters
[in]sSolver identification parameter. To be chosen in the enumeration variable Iteration:
DIRECT_SOLVER, CG_SOLVER, CGS_SOLVER, BICG_SOLVER, BICG_STAB_SOLVER, GMRES_SOLVER, QMR_SOLVER
[in]pPreconditioner identification parameter. By default, the diagonal preconditioner is used. To be chosen in the enumeration variable Preconditioner:
IDENT_PREC, DIAG_PREC, SSOR_PREC, ILU_PREC [Default: ILU_PREC]
Note
The argument p has no effect if the solver is DIRECT_SOLVER

◆ solve() [1/3]

int solve ( )

Solve equations all arguments must have been given by other member functions.

Solver and preconditioner parameters must have been set by function setSolver. Otherwise, default values are set.

◆ solve() [2/3]

int solve ( Iteration  s,
Preconditioner  p = DIAG_PREC 
)

Solve equations using prescribed solver and preconditioner.

Parameters
[in]sSolver identification parameter To be chosen in the enumeration variable Iteration:
DIRECT_SOLVER, CG_SOLVER, CGS_SOLVER, BICG_SOLVER, BICG_STAB_SOLVER, GMRES_SOLVER, QMR_SOLVER [Default: CGS_SOLVER]
[in]pPreconditioner identification parameter. To be chosen in the enumeration variable Preconditioner:
IDENT_PREC, DIAG_PREC, SSOR_PREC, DILU_PREC, ILU_PREC [Default: DIAG_PREC]
Note
The argument p has no effect if the solver is DIRECT_SOLVER

◆ solve() [3/3]

int solve ( SpMatrix< T_ > &  A,
const Vect< T_ > &  b,
Vect< T_ > &  x,
Iteration  s,
Preconditioner  p = DIAG_PREC 
)

Solve equations using system data, prescribed solver and preconditioner.

Parameters
[in]AReference to matrix as a SpMatrix instance
[in]bVector containing right-hand side
[in,out]xVector containing initial guess on input and solution on output
[in]sSolver identification parameter To be chosen in the enumeration variable Iteration:
DIRECT_SOLVER, CG_SOLVER, CGS_SOLVER, BICG_SOLVER, BICG_STAB_SOLVER, GMRES_SOLVER, QMR_SOLVER [Default: CGS_SOLVER]
[in]pPreconditioner identification parameter. To be chosen in the enumeration variable Preconditioner:
IDENT_PREC, DIAG_PREC, SSOR_PREC, ILU_PREC, DILU_PREC [Default: DIAG_PREC]
Remarks
The argument p has no effect if the solver is DIRECT_SOLVER
Warning
If the library eigen is used, only the preconditioners IDENT_PREC, DIAG_PREC and ILU_PREC are available.





Copyright © 1998-2022 Rachid Touzani