 An Object Oriented Finite Element Library

Solver

Solver functions and classes. More...

## Classes

class  Reconstruction
To perform various reconstruction operations. More...

class  EigenProblemSolver
Class to find eigenvalues and corresponding eigenvectors of a given matrix in a generalized eigenproblem, i.e. Find scalars l and non-null vectors v such that [K]{v} = l[M]{v} where [K] and [M] are symmetric matrices. The eigenproblem can be originated from a PDE. For this, we will refer to the matrices K and M as Stiffness and Mass matrices respectively. More...

class  Integration
Class for numerical integration methods. More...

class  Iter< T_ >
Class to drive an iterative process. More...

class  LinearSolver< T_ >
Class to solve systems of linear equations by iterative methods. More...

class  LPSolver
To solve a linear programming problem. More...

class  MyNLAS
Abstract class to define by user specified function. More...

class  MyOpt
Abstract class to define by user specified optimization function. More...

class  NLASSolver
To solve a system of nonlinear algebraic equations of the form f(u) = 0. More...

class  ODESolver
To solve a system of ordinary differential equations. More...

class  OptSolver
To solve an optimization problem with bound constraints. More...

class  Prec< T_ >
To set a preconditioner. More...

class  TimeStepping
To solve time stepping problems, i.e. systems of linear ordinary differential equations of the form [A2]{y"} + [A1]{y'} + [A0]{y} = {b}. More...

## Macros

#define MAX_NB_INPUT_FIELDS   3
Maximum number of fields for an equation. More...

#define MAX_NB_MESHES   10
Maximum number of meshes. More...

#define TIME_LOOP(ts, t, ft, n)
A macro to loop on time steps to integrate on time ts : Time step t : Initial time value updated at each time step ft : Final time value n : Time step index.

#define TimeLoop
A macro to loop on time steps to integrate on time. More...

#define IterationLoop    while (++theIteration<MaxNbIterations && Converged==false)
A macro to loop on iterations for an iterative procedure. More...

## Functions

ostream & operator<< (ostream &s, const Muscl3DT &m)
Output mesh data as calculated in class Muscl3DT.

template<class T_ >
int BiCG (const SpMatrix< T_ > &A, const Prec< T_ > &P, const Vect< T_ > &b, Vect< T_ > &x, int max_it, real_t &toler)

template<class T_ >
int BiCG (const SpMatrix< T_ > &A, int prec, const Vect< T_ > &b, Vect< T_ > &x, int max_it, real_t toler)

template<class T_ >
int BiCGStab (const SpMatrix< T_ > &A, const Prec< T_ > &P, const Vect< T_ > &b, Vect< T_ > &x, int max_it, real_t toler)
Biconjugate gradient stabilized solver function. More...

template<class T_ >
int BiCGStab (const SpMatrix< T_ > &A, int prec, const Vect< T_ > &b, Vect< T_ > &x, int max_it, real_t toler)
Biconjugate gradient stabilized solver function. More...

template<class T_ >
int CG (const SpMatrix< T_ > &A, const Prec< T_ > &P, const Vect< T_ > &b, Vect< T_ > &x, int max_it, real_t toler)

template<class T_ >
int CG (const SpMatrix< T_ > &A, int prec, const Vect< T_ > &b, Vect< T_ > &x, int max_it, real_t toler)

template<class T_ >
int CGS (const SpMatrix< T_ > &A, const Prec< T_ > &P, const Vect< T_ > &b, Vect< T_ > &x, int max_it, real_t toler)
Conjugate Gradient Squared solver function. More...

template<class T_ >
int CGS (const SpMatrix< T_ > &A, int prec, const Vect< T_ > &b, Vect< T_ > &x, int max_it, real_t toler)
Conjugate Gradient Squared solver function. More...

ostream & operator<< (ostream &s, const EigenProblemSolver &es)
Output eigenproblem information.

template<class T_ >
int GMRes (const SpMatrix< T_ > &A, const Prec< T_ > &P, const Vect< T_ > &b, Vect< T_ > &x, size_t m, int max_it, real_t toler)
GMRes solver function. More...

template<class T_ >
int GMRes (const SpMatrix< T_ > &A, int prec, const Vect< T_ > &b, Vect< T_ > &x, size_t m, int max_it, real_t toler)
GMRes solver function. More...

template<class T_ >
int GS (const SpMatrix< T_ > &A, const Vect< T_ > &b, Vect< T_ > &x, real_t omega, int max_it, real_t toler)
Gauss-Seidel solver function. More...

template<class T_ >
int Jacobi (const SpMatrix< T_ > &A, const Vect< T_ > &b, Vect< T_ > &x, real_t omega, int max_it, real_t toler)
Jacobi solver function. More...

ostream & operator<< (ostream &s, const LPSolver &os)
Output solver information.

ostream & operator<< (ostream &s, const NLASSolver &nl)
Output nonlinear system information.

ostream & operator<< (ostream &s, const ODESolver &de)
Output differential system information.

ostream & operator<< (ostream &s, const OptSolver &os)
Output differential system information.

template<class T_ , class M_ >
int Richardson (const M_ &A, const Vect< T_ > &b, Vect< T_ > &x, real_t omega, int max_it, real_t toler, int verbose)
Richardson solver function. More...

template<class T_ >
void Schur (SkMatrix< T_ > &A, SpMatrix< T_ > &U, SpMatrix< T_ > &L, SpMatrix< T_ > &D, Vect< T_ > &b, Vect< T_ > &c)
Solve a linear system of equations with a 2x2-block matrix. More...

template<class T_ , class M_ >
int SSOR (const M_ &A, const Vect< T_ > &b, Vect< T_ > &x, int max_it, real_t toler)
SSOR solver function. More...

ostream & operator<< (ostream &s, TimeStepping &ts)
Output differential system information. More...

## Detailed Description

Solver functions and classes.

## ◆ IterationLoop

 #define IterationLoop    while (++theIteration

A macro to loop on iterations for an iterative procedure.

It uses the following global variables defined in OFELI: `theIteration, MaxNbIterations, Converged`

Warning
The variable `theIteration` must be zeroed before using this macro

## ◆ MAX_NB_INPUT_FIELDS

 #define MAX_NB_INPUT_FIELDS   3

Maximum number of fields for an equation.

Useful for coupled problems

## ◆ MAX_NB_MESHES

 #define MAX_NB_MESHES   10

Maximum number of meshes.

Useful for coupled problems

## ◆ TimeLoop

 #define TimeLoop
Value:
int theStep
Time step counter.
real_t theFinalTime
Final time value.
int NbTimeSteps
Number of time steps.
real_t theTime
Time value.
real_t theTimeStep
Time step label.

A macro to loop on time steps to integrate on time.

It uses the following global variables defined in OFELI: `theStep, theTime, theTimeStep, theFinalTime`

## ◆ BiCG() [1/2]

 int BiCG ( const SpMatrix< T_ > & A, const Prec< T_ > & P, const Vect< T_ > & b, Vect< T_ > & x, int max_it, real_t & toler )

This function uses the preconditioned Biconjugate Conjugate Gradient algorithm to solve a linear system with a sparse matrix.
The global variable Verbosity enables choosing output message level

• Verbosity < 2 : No output message
• Verbosity > 1 : Notify executing the function BiCG
• Verbosity > 2 : Notify convergence with number of performed iterations or divergence
• Verbosity > 3 : Output each iteration number and residual
• Verbosity > 6 : Print final solution if convergence
• Verbosity > 10 : Print obtained solution at each iteration
Parameters
 [in] A Problem matrix (Instance of class SpMatrix). [in] P Preconditioner (Instance of class Prec). [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] max_it Maximum number of iterations. toler [in] Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
 Data type (double, float, complex, ...)

## ◆ BiCG() [2/2]

 int BiCG ( const SpMatrix< T_ > & A, int prec, const Vect< T_ > & b, Vect< T_ > & x, int max_it, real_t toler )

This function uses the preconditioned Biconjugate Conjugate Gradient algorithm to solve a linear system with a sparse matrix.
The global variable Verbosity enables choosing output message level

• Verbosity < 2 : No output message
• Verbosity > 1 : Notify executing the function CG
• Verbosity > 2 : Notify convergence with number of performed iterations or divergence
• Verbosity > 3 : Output each iteration number and residual
• Verbosity > 6 : Print final solution if convergence
• Verbosity > 10 : Print obtained solution at each iteration
Parameters
 [in] A Problem matrix (Instance of class SpMatrix). [in] prec Enum variable selecting a preconditioner, among the values `IDENT_PREC`, `DIAG_PREC`, `ILU_PREC` or `SSOR_PREC` [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] max_it Maximum number of iterations. toler [in] Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
 Data type (double, float, complex, ...)

## ◆ BiCGStab() [1/2]

 int BiCGStab ( const SpMatrix< T_ > & A, const Prec< T_ > & P, const Vect< T_ > & b, Vect< T_ > & x, int max_it, real_t toler )

This function uses the preconditioned Conjugate Gradient Stabilized algorithm to solve a linear system with a sparse matrix.
The global variable Verbosity enables choosing output message level

• Verbosity < 2 : No output message
• Verbosity > 1 : Notify executing the function BiCGStab
• Verbosity > 2 : Notify convergence with number of performed iterations or divergence
• Verbosity > 3 : Output each iteration number and residual
• Verbosity > 6 : Print final solution if convergence
• Verbosity > 10 : Print obtained solution at each iteration
Parameters
 [in] A Problem matrix (Instance of class SpMatrix). [in] P Preconditioner (Instance of class Prec). [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess on input and solution of the linear system on output (If iterations have succeeded). [in] max_it Maximum number of iterations. [in] toler Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
 Data type (double, float, complex, ...)

## ◆ BiCGStab() [2/2]

 int BiCGStab ( const SpMatrix< T_ > & A, int prec, const Vect< T_ > & b, Vect< T_ > & x, int max_it, real_t toler )

This function uses the preconditioned Conjugate Gradient Stabilized algorithm to solve a linear system with a sparse matrix.
The global variable Verbosity enables choosing output message level

• Verbosity < 2 : No output message
• Verbosity > 1 : Notify executing the function CG
• Verbosity > 2 : Notify convergence with number of performed iterations or divergence
• Verbosity > 3 : Output each iteration number and residual
• Verbosity > 6 : Print final solution if convergence
• Verbosity > 10 : Print obtained solution at each iteration
Parameters
 [in] A Problem matrix (Instance of class SpMatrix). [in] prec Enum variable selecting a preconditioner, among the values `IDENT_PREC`, `DIAG_PREC`, `ILU_PREC` or `SSOR_PREC` [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] max_it Maximum number of iterations. [in] toler Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
 Data type (double, float, complex, ...)

## ◆ CG() [1/2]

 int CG ( const SpMatrix< T_ > & A, const Prec< T_ > & P, const Vect< T_ > & b, Vect< T_ > & x, int max_it, real_t toler )

This function uses the preconditioned Conjugate Gradient algorithm to solve a linear system with a sparse matrix.
The global variable Verbosity enables choosing output message level

• Verbosity < 2 : No output message
• Verbosity > 1 : Notify executing the function CG
• Verbosity > 2 : Notify convergence with number of performed iterations or divergence
• Verbosity > 3 : Output each iteration number and residual
• Verbosity > 6 : Print final solution if convergence
• Verbosity > 10 : Print obtained solution at each iteration
Parameters
 [in] A Problem matrix (Instance of class SpMatrix). [in] P Preconditioner (Instance of class Prec). [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] max_it Maximum number of iterations. [in] toler Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
 Data type (double, float, complex, ...)

## ◆ CG() [2/2]

 int CG ( const SpMatrix< T_ > & A, int prec, const Vect< T_ > & b, Vect< T_ > & x, int max_it, real_t toler )

This function uses the preconditioned Conjugate Gradient algorithm to solve a linear system with a sparse matrix.
The global variable Verbosity enables choosing output message level

• Verbosity < 2 : No output message
• Verbosity > 1 : Notify executing the function CG
• Verbosity > 2 : Notify convergence with number of performed iterations or divergence
• Verbosity > 3 : Output each iteration number and residual
• Verbosity > 6 : Print final solution if convergence
• Verbosity > 10 : Print obtained solution at each iteration
Parameters
 [in] A Problem matrix (Instance of abstract class SpMatrix). [in] prec Enum variable selecting a preconditioner, among the values `IDENT_PREC`, `DIAG_PREC`, `ILU_PREC` or `SSOR_PREC` [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] max_it Maximum number of iterations. [in] toler Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
 Data type (double, float, complex, ...)

## ◆ CGS() [1/2]

 int CGS ( const SpMatrix< T_ > & A, const Prec< T_ > & P, const Vect< T_ > & b, Vect< T_ > & x, int max_it, real_t toler )

This function uses the preconditioned Conjugate Gradient Squared algorithm to solve a linear system with a sparse matrix.
The global variable Verbosity enables choosing output message level

• Verbosity < 2 : No output message
• Verbosity > 1 : Notify executing the function CGS
• Verbosity > 2 : Notify convergence with number of performed iterations or divergence
• Verbosity > 3 : Output each iteration number and residual
• Verbosity > 6 : Print final solution if convergence
• Verbosity > 10 : Print obtained solution at each iteration
Parameters
 [in] A Problem matrix (Instance of class SpMatrix). [in] P Preconditioner (Instance of class Prec). [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] max_it Maximum number of iterations. [in] toler Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations
Template Parameters
 Data type (real_t, float, complex, ...)

## ◆ CGS() [2/2]

 int CGS ( const SpMatrix< T_ > & A, int prec, const Vect< T_ > & b, Vect< T_ > & x, int max_it, real_t toler )

This function uses the preconditioned Conjugate Gradient Squared algorithm to solve a linear system with a sparse matrix.
The global variable Verbosity enables choosing output message level

• Verbosity < 2 : No output message
• Verbosity > 1 : Notify executing the function CG
• Verbosity > 2 : Notify convergence with number of performed iterations or divergence
• Verbosity > 3 : Output each iteration number and residual
• Verbosity > 6 : Print final solution if convergence
• Verbosity > 10 : Print obtained solution at each iteration
Parameters
 [in] A Problem matrix (Instance of class SpMatrix). [in] prec Enum variable selecting a preconditioner, among the values `IDENT_PREC`, `DIAG_PREC`, `ILU_PREC` or `SSOR_PREC` [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] max_it Maximum number of iterations. [in] toler Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations
Template Parameters
 Data type (real_t, float, complex, ...)

## ◆ GMRes() [1/2]

 int GMRes ( const SpMatrix< T_ > & A, const Prec< T_ > & P, const Vect< T_ > & b, Vect< T_ > & x, size_t m, int max_it, real_t toler )

GMRes solver function.

This function uses the preconditioned GMRES algorithm to solve a linear system with a sparse matrix.
The global variable Verbosity enables choosing output message level

• Verbosity < 2 : No output message
• Verbosity > 1 : Notify executing the function CMRes
• Verbosity > 2 : Notify convergence with number of performed iterations or divergence
• Verbosity > 3 : Output each iteration number and residual
• Verbosity > 6 : Print final solution if convergence
• Verbosity > 10 : Print obtained solution at each iteration
Parameters
 [in] A Problem matrix (Instance of class SpMatrix). [in] P Preconditioner (Instance of class Prec). [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] m Number of subspaces to generate for iterations. [in] max_it Maximum number of iterations. [in] toler Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
 Data type (double, float, complex, ...)

## ◆ GMRes() [2/2]

 int GMRes ( const SpMatrix< T_ > & A, int prec, const Vect< T_ > & b, Vect< T_ > & x, size_t m, int max_it, real_t toler )

GMRes solver function.

This function uses the preconditioned GMRES algorithm to solve a linear system with a sparse matrix.
The global variable Verbosity enables choosing output message level

• Verbosity < 2 : No output message
• Verbosity > 1 : Notify executing the function CG
• Verbosity > 2 : Notify convergence with number of performed iterations or divergence
• Verbosity > 3 : Output each iteration number and residual
• Verbosity > 6 : Print final solution if convergence
• Verbosity > 10 : Print obtained solution at each iteration
Parameters
 [in] A Problem matrix (Instance of class SpMatrix). [in] prec Enum variable selecting a preconditioner, among the values `IDENT_PREC`, `DIAG_PREC`, `ILU_PREC` or `SSOR_PREC` [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] m Number of subspaces to generate for iterations. [in] max_it Maximum number of iterations. [in] toler Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
 Data type (double, float, complex, ...)

## ◆ GS()

 int GS ( const SpMatrix< T_ > & A, const Vect< T_ > & b, Vect< T_ > & x, real_t omega, int max_it, real_t toler )

Gauss-Seidel solver function.

This function uses the relaxed Gauss-Seidel algorithm to solve a linear system with a sparse matrix.
The global variable Verbosity enables choosing output message level

• Verbosity < 2 : No output message
• Verbosity > 1 : Notify executing the function GS
• Verbosity > 2 : Notify convergence with number of performed iterations or divergence
• Verbosity > 3 : Output each iteration number and residual
• Verbosity > 6 : Print final solution if convergence
• Verbosity > 10 : Print obtained solution at each iteration
Parameters
 [in] A Problem matrix (Instance of class SpMatrix). [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] omega Relaxation parameter. [in] max_it Maximum number of iterations. [in] toler Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations
Template Parameters
 Data type (real_t, float, complex, ...)

## ◆ Jacobi()

 int Jacobi ( const SpMatrix< T_ > & A, const Vect< T_ > & b, Vect< T_ > & x, real_t omega, int max_it, real_t toler )

Jacobi solver function.

Parameters
 [in] A Problem matrix (Instance of class SpMatrix). [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] omega Relaxation parameter. [in] max_it Maximum number of iterations. [in,out] toler Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
 Data type (real_t, float, complex, ...) Matrix storage class

## ◆ operator<<()

 ostream & operator<< ( ostream & s, TimeStepping & ts )

Output differential system information.

## ◆ Richardson()

 int Richardson ( const M_ & A, const Vect< T_ > & b, Vect< T_ > & x, real_t omega, int max_it, real_t toler, int verbose )

Richardson solver function.

Parameters
 [in] A Problem matrix problem (Instance of abstract class M_). [in] b Right-hand side vector (class Vect) x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] omega Relaxation parameter. [in] max_it Maximum number of iterations. [in] toler Tolerance for convergence (measured in relative weighted 2-Norm). [in] verbose Information output parameter (`0`: No output, `1`: Output iteration information, `2` and greater: Output iteration information and solution at each iteration.
Returns
nb_it Number of performed iterations,
Template Parameters
 Data type (real_t, float, complex, ...) Matrix storage class

## ◆ Schur()

 void Schur ( SkMatrix< T_ > & A, SpMatrix< T_ > & U, SpMatrix< T_ > & L, SpMatrix< T_ > & D, Vect< T_ > & b, Vect< T_ > & c )

Solve a linear system of equations with a 2x2-block matrix.

The linear system is of the form

```     | A  U | |x|   |b|
|      | | | = | |
| L  D | |y|   |c|```
Parameters
 [in] A Instance of class SkMatrix class for the first diagonal block. The matrix must be invertible and factorizable (Do not use SpMatrix class) where `A`, `U`, `L`, `D` are instances of matrix classes, [in] U Instance of class SpMatrix for the upper triangle block. The matrix can be rectangular [in] L Instance of class SpMatrix for the lower triangle block. The matrix can be rectangular [in] D Instance of class SpMatrix for the second diagonal block. The matrix must be factorizable (Do not use SpMatrix class) [in,out] b Vector (Instance of class Vect) that contains the first block of right-hand side on input and the first block of the solution on output. `b` must have the same size as the dimension of `A`. [in,out] c Vect instance that contains the second block of right-hand side on output and the first block of the solution on output. `c` must have the same size as the dimension of `D`.

Template Argument:

Template Parameters
 data type (real_t, float, ...)

## ◆ SSOR()

 int SSOR ( const M_ & A, const Vect< T_ > & b, Vect< T_ > & x, int max_it, real_t toler )

SSOR solver function.

Parameters
 [in] A Problem matrix (Instance of abstract class M_). [in] b Right-hand side vector (class Vect) [in,out] x Vect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded). [in] max_it Maximum number of iterations. [in] toler Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,

Template Arguments:

• T_ data type (double, float, ...)
• M_ Matrix storage class