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  FuncApprox
 To set function approximation methods. More...
 
class  GeoModel
 To set geometry modelling. More...
 
class  Integration
 Class for numerical integration methods. More...
 
class  Iter< T_ >
 Class to drive an iterative process. More...
 
class  LeastSquare
 To compute a least square approximation. More...
 
class  LinearSolver
 Class to solve systems of linear equations by direct or 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.
 
#define MAX_NB_MESHES   10
 Maximum number of meshes.
 
#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.
 
#define IterationLoop    while (++theIteration<MaxNbIterations && Converged==false)
 A macro to loop on iterations for an iterative procedure.
 

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)
 Biconjugate gradient solver function.
 
template<class T_ >
int BiCG (const SpMatrix< T_ > &A, int prec, const Vect< T_ > &b, Vect< T_ > &x, int max_it, real_t toler)
 Biconjugate gradient solver function.
 
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)
 Conjugate gradient solver function.
 
template<class T_ >
int CG (const SpMatrix< T_ > &A, int prec, const Vect< T_ > &b, Vect< T_ > &x, int max_it, real_t toler)
 Conjugate gradient solver function.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
ostream & operator<< (ostream &s, const ODESolver &de)
 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.
 
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.
 
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.
 
ostream & operator<< (ostream &s, TimeStepping &ts)
 Output differential system information.
 

Detailed Description

Solver functions and classes.

Macro Definition Documentation

◆ IterationLoop

#define IterationLoop    while (++theIteration<MaxNbIterations && Converged==false)

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

Function Documentation

◆ BiCG() [1/2]

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 
)

Biconjugate gradient solver function.

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]AProblem matrix (Instance of class SpMatrix).
[in]PPreconditioner (Instance of class Prec).
[in]bRight-hand side vector (class Vect)
[in,out]xVect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded).
[in]max_itMaximum number of iterations.
toler[in] Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
<T_>Data type (double, float, complex<double>, ...)
Author
Rachid Touzani

◆ BiCG() [2/2]

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

Biconjugate gradient solver function.

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]AProblem matrix (Instance of class SpMatrix).
[in]precEnum variable selecting a preconditioner, among the values IDENT_PREC, DIAG_PREC, ILU_PREC or SSOR_PREC
[in]bRight-hand side vector (class Vect)
[in,out]xVect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded).
[in]max_itMaximum number of iterations.
toler[in] Tolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
<T_>Data type (double, float, complex<double>, ...)
Author
Rachid Touzani

◆ CG() [1/2]

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 
)

Conjugate gradient solver function.

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]AProblem matrix (Instance of class SpMatrix).
[in]PPreconditioner (Instance of class Prec).
[in]bRight-hand side vector (class Vect)
[in,out]xVect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded).
[in]max_itMaximum number of iterations.
[in]tolerTolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
<T_>Data type (double, float, complex<double>, ...)
Author
Rachid Touzani

◆ CG() [2/2]

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

Conjugate gradient solver function.

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]AProblem matrix (Instance of abstract class SpMatrix).
[in]precEnum variable selecting a preconditioner, among the values IDENT_PREC, DIAG_PREC, ILU_PREC or SSOR_PREC
[in]bRight-hand side vector (class Vect)
[in,out]xVect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded).
[in]max_itMaximum number of iterations.
[in]tolerTolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
<T_>Data type (double, float, complex<double>, ...)
Author
Rachid Touzani

◆ CGS() [1/2]

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.

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]AProblem matrix (Instance of class SpMatrix).
[in]PPreconditioner (Instance of class Prec).
[in]bRight-hand side vector (class Vect)
[in,out]xVect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded).
[in]max_itMaximum number of iterations.
[in]tolerTolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations
Template Parameters
<T_>Data type (real_t, float, complex<real_t>, ...)
Author
Rachid Touzani

◆ CGS() [2/2]

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.

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]AProblem matrix (Instance of class SpMatrix).
[in]precEnum variable selecting a preconditioner, among the values IDENT_PREC, DIAG_PREC, ILU_PREC or SSOR_PREC
[in]bRight-hand side vector (class Vect)
[in,out]xVect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded).
[in]max_itMaximum number of iterations.
[in]tolerTolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations
Template Parameters
<T_>Data type (real_t, float, complex<real_t>, ...)
Author
Rachid Touzani

◆ GMRes() [1/2]

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.

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]AProblem matrix (Instance of class SpMatrix).
[in]PPreconditioner (Instance of class Prec).
[in]bRight-hand side vector (class Vect)
[in,out]xVect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded).
[in]mNumber of subspaces to generate for iterations.
[in]max_itMaximum number of iterations.
[in]tolerTolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
<T_>Data type (double, float, complex<double>, ...)
Author
Rachid Touzani

◆ GMRes() [2/2]

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.

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]AProblem matrix (Instance of class SpMatrix).
[in]precEnum variable selecting a preconditioner, among the values IDENT_PREC, DIAG_PREC, ILU_PREC or SSOR_PREC
[in]bRight-hand side vector (class Vect)
[in,out]xVect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded).
[in]mNumber of subspaces to generate for iterations.
[in]max_itMaximum number of iterations.
[in]tolerTolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
<T_>Data type (double, float, complex<double>, ...)
Author
Rachid Touzani

◆ GS()

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.

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]AProblem matrix (Instance of class SpMatrix).
[in]bRight-hand side vector (class Vect)
[in,out]xVect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded).
[in]omegaRelaxation parameter.
[in]max_itMaximum number of iterations.
[in]tolerTolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations
Template Parameters
<T_>Data type (real_t, float, complex<real_t>, ...)
Author
Rachid Touzani

◆ Jacobi()

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.

Parameters
[in]AProblem matrix (Instance of class SpMatrix).
[in]bRight-hand side vector (class Vect)
[in,out]xVect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded).
[in]omegaRelaxation parameter.
[in]max_itMaximum number of iterations.
[in,out]tolerTolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,
Template Parameters
<T_>Data type (real_t, float, complex<real_t>, ...)
<M_>Matrix storage class
Author
Rachid Touzani

◆ operator<<()

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

Output differential system information.

Author
Rachid Touzani

◆ Richardson()

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.

Parameters
[in]AProblem matrix problem (Instance of abstract class M_).
[in]bRight-hand side vector (class Vect)
xVect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded).
[in]omegaRelaxation parameter.
[in]max_itMaximum number of iterations.
[in]tolerTolerance for convergence (measured in relative weighted 2-Norm).
[in]verboseInformation 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
<T_>Data type (real_t, float, complex<real_t>, ...)
<M_>Matrix storage class
Author
Rachid Touzani

◆ Schur()

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.

The linear system is of the form

     | A  U | |x|   |b|
     |      | | | = | |
     | L  D | |y|   |c|
Parameters
[in]AInstance 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]UInstance of class SpMatrix for the upper triangle block. The matrix can be rectangular
[in]LInstance of class SpMatrix for the lower triangle block. The matrix can be rectangular
[in]DInstance of class SpMatrix for the second diagonal block. The matrix must be factorizable (Do not use SpMatrix class)
[in,out]bVector (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]cVect 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
<T_>data type (real_t, float, ...)
Author
Rachid Touzani

◆ SSOR()

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.

Parameters
[in]AProblem matrix (Instance of abstract class M_).
[in]bRight-hand side vector (class Vect)
[in,out]xVect instance containing initial solution guess in input and solution of the linear system in output (If iterations have succeeded).
[in]max_itMaximum number of iterations.
[in]tolerTolerance for convergence (measured in relative weighted 2-Norm).
Returns
Number of performed iterations,

Template Arguments:

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