TPZMatrixSolver

The TPZMatrixSolver represents a solver for algebraic equation systems in which the matrix has entries with the type TVar, where TVar = STATE, for real problems, and TVar = CSTATE, for complex problems.

The available solvers are

enum TPZMatrixSolver::MSolver

Defines the solvers available in NeoPZ

Values:

enumerator ENoSolver

No solver selected

enumerator EJacobi

Jacobi solver

enumerator ESOR

Successive Over Relaxation solver

enumerator ESSOR

Symmetric Successive Over Relaxation solver

enumerator ECG

Conjugate Gradient solver

enumerator EGMRES

Generalised Minimal Residual method

enumerator EBICGSTAB

Biconjugate Gradient Stabilized Method

enumerator EDirect

LU, LDLt or Cholesky

enumerator EMultiply

Further documentation on TPZMatrixSolver

template<class TVar>
class TPZMatrixSolver : public TPZSolver

Defines the interface for matrix solvers.

Solver These are used for solving linear or non-linear systems of equations.

Subclassed by TPZMGSolver< TVar >, TPZPardisoSolver< TVar >, TPZSequenceSolver< TVar >, TPZStepSolver< TVar >

Public Types

enum MSolver

Defines the solvers available in NeoPZ

Values:

enumerator ENoSolver

No solver selected

enumerator EJacobi

Jacobi solver

enumerator ESOR

Successive Over Relaxation solver

enumerator ESSOR

Symmetric Successive Over Relaxation solver

enumerator ECG

Conjugate Gradient solver

enumerator EGMRES

Generalised Minimal Residual method

enumerator EBICGSTAB

Biconjugate Gradient Stabilized Method

enumerator EDirect

LU, LDLt or Cholesky

enumerator EMultiply

Public Functions

TPZMatrixSolver(TPZAutoPointer<TPZMatrix<TVar>> Refmat)

Constructor with initialization parameter.

Parameters

Refmat – Sets reference matrix to nullptr

TPZMatrixSolver(const TPZMatrixSolver<TVar> &Source)

Copy constructor.

Parameters

Source – Model object to be copied from

virtual ~TPZMatrixSolver()

Destructor.

virtual void Solve(const TPZFMatrix<TVar> &F, TPZFMatrix<TVar> &result, TPZFMatrix<TVar> *residual = 0) = 0

Solves the system of linear equations.

Parameters
  • F – contains Force vector

  • result – contains the solution

  • residual – contains the residual for that linear system

inline virtual void Decompose()

Decompose the system of equations if a direct solver is used.

inline virtual void SetMatrix(TPZAutoPointer<TPZBaseMatrix> Refmat)

Sets a matrix to the current object.

Parameters

Refmat – Sets reference matrix to RefMat

inline virtual void UpdateFrom(TPZAutoPointer<TPZBaseMatrix> mat_base)

Updates the values of the current matrix based on the values of the matrix.

virtual void ResetMatrix() override

Resets current object.

inline virtual void SetReferenceMatrix(TPZAutoPointer<TPZBaseMatrix> matrix)

This method gives a preconditioner to share a matrix with the referring solver object.

inline TPZAutoPointer<TPZMatrix<TVar>> Matrix() const

Returns a pointer to TPZMatrix<>

void ShareMatrix(TPZMatrixSolver<TVar> &other)

Shares the current matrix with another object of same type.

Parameters

other – Object that will share current matrix

virtual int ClassId() const override

Saveable specific methods.

virtual void Write(TPZStream &buf, int withclassid) const override

Writes this object to the TPZStream buffer.

Include the classid if withclassid = true

virtual void Read(TPZStream &buf, void *context) override

Reads an objects from the TPZStream buffer.

TPZStepSolver

template<class TVar>
class TPZStepSolver : public TPZMatrixSolver<TVar>

Defines step solvers class.

Solver

Public Functions

inline virtual TPZSolver *Clone() const override

Clones the current object returning a pointer of type TPZSolver.

inline REAL GetTolerance() const

return the value of tolerance from the solver

void ResetSolver()

reset the data structure of the solver object

inline std::list<int64_t> &Singular()

returns the equations for which the equations had zero pivot

virtual void ResetMatrix() override

This method will reset the matrix associated with the solver.

This is useful when the matrix needs to be recomputed in a non linear problem

inline virtual void UpdateFrom(TPZAutoPointer<TPZBaseMatrix> matrix) override

Updates the values of the current matrix based on the values of the matrix.

virtual void Solve(const TPZFMatrix<TVar> &F, TPZFMatrix<TVar> &result, TPZFMatrix<TVar> *residual = 0) override

Solves the system of linear equations.

Parameters
  • F – contains Force vector

  • result – contains the solution

  • residual – contains the residual for that linear system

virtual void Decompose() override

Decompose the system of equations if a direct solver is used.

void SetPreconditioner(TPZMatrixSolver<TVar> &solve)

Define the preconditioner as a solver object.

inline int NumIterations()

Number of iterations of last solve.

inline TPZMatrixSolver<TVar> *PreConditioner()

access method to the preconditioner

virtual int ClassId() const override

Serialization methods.

virtual void Write(TPZStream &buf, int withclassid) const override

Writes this object to the TPZStream buffer.

Include the classid if withclassid = true

virtual void Read(TPZStream &buf, void *context) override

Reads an objects from the TPZStream buffer.

TPZPardisoSolver

The TPZPardisoSolver class acts as an wrapper for controlling the Intel MKL PARDISO Solver. Therefore, for one to use it, NeoPZ should have been configured using USING_MKL=ON. While the PARDISO solver can still be used through TPZStepSolver, using an instance of TPZPardisoSolver directly provides a finer control of the PARDISO parameters.

Note

The PARDISO solver is a solver for both symmetric and non-symmetric sparse matrices, so it should be used with either TPZSSpStructMatrix or TPZSpStructMatrix.

Note

There is still plenty of tuning options to be implemented in this class. Please contact us or submit a Pull Request if you think this class could be improved.

template<class TVar>
class TPZPardisoSolver : public TPZMatrixSolver<TVar>

This class acts as a wrapper for calls to the PARDISO solver.

It is both used internally by the sparse matrix classes or it can be used by the user instead of TPZStepSolver to have a finer control over PARDISO parameters. Inspired by PardisoSolver by Armando Duarte.

Note

It is only compatible with sparse matrices. Use it with TPZFYsmpMatrix or TPZSYsmpMatrix

Note

This class is meaningless unless the library is linked against MKL library.

Public Types

enum MSystemType

Symmetry of the algebraic system

Values:

enumerator ENonInitialized
enumerator ESymmetric
enumerator ENonSymmetric
enum MStructure

Storage format

Values:

enumerator ENonInitialized
enumerator ESymmetric
enumerator ENonSymmetric
enum MProperty

Whether the algebraic system is positive definite

Values:

enumerator ENonInitialized
enumerator EPositiveDefinite
enumerator EIndefinite

Public Functions

TPZPardisoSolver()

Default constructor.

TPZPardisoSolver(MSystemType systemtype, MStructure structure, MProperty prop)

Constructor with info on the algebraic system

TPZPardisoSolver(const TPZPardisoSolver &copy) = default

Copy constructor

TPZPardisoSolver(TPZPardisoSolver &&copy) = default

Move constructor

TPZPardisoSolver &operator=(const TPZPardisoSolver &copy) = default

Copy-assignment operator

TPZPardisoSolver &operator=(TPZPardisoSolver &&copy) = default

Move-assignment operator

virtual ~TPZPardisoSolver()

Destructor

virtual void SetMatrix(TPZAutoPointer<TPZBaseMatrix> Refmat) override

Sets the associated matrix of the solver.

If SetMatrixType has not been called, the following defaults are assumed: Symmetric matrices: MSystemType::ESymmetric, MProperty::EIndefinite Non-symmetric matrices: MSystemType::ENonSymmetric, MProperty::EIndefinite

Note

Only sparse matrices are compatible with this solver.

virtual void Decompose() override

Decompose the matrix.

virtual void Solve(const TPZFMatrix<TVar> &rhs, TPZFMatrix<TVar> &sol, TPZFMatrix<TVar> *residual = nullptr) override

Use the decomposed matrix to invert the system of equations This method also decomposed the matrix if needed.

void SetMatrixType(MSystemType systemtype, MProperty prop)

Change the matrix type.

Note

This method should only be called by the userbefore a matrix has been set.

void SetMessageLevel(int lvl)

Sets the message level of the pardiso solver.

Anything different than zero results in statistical information being printed.

virtual TPZPardisoSolver<TVar> *Clone() const override

Clones the current object returning a pointer of type TPZSolver.

inline void SetStructure(MStructure str)

Sets matrix structure.

inline TPZVec<long long> &GetParam()

Gets reference to pardiso fParam array.