Loading...
Searching...
No Matches
Opm::AbstractISTLSolver< TypeTag > Class Template Referenceabstract

Abstract interface for ISTL solvers. More...

`#include <AbstractISTLSolver.hpp>`

Inheritance diagram for Opm::AbstractISTLSolver< TypeTag >:

## Public Types

using | CommunicationType = Dune::Communication<int>
using | SparseMatrixAdapter = GetPropType<TypeTag, Properties::SparseMatrixAdapter>
using | Vector = GetPropType<TypeTag, Properties::GlobalEqVector>
using | Matrix = typename SparseMatrixAdapter::IstlMatrix

## Public Member Functions

virtual void | eraseMatrix ()=0
| Signals that the memory for the matrix internally in the solver could be erased.
virtual void | setActiveSolver (int num)=0
| Set the active solver by its index.
virtual int | numAvailableSolvers () const =0
| Get the number of available solvers.
virtual void | prepare (const Matrix &M, Vector &b)=0
| Prepare the solver with the given matrix and right-hand side vector.
virtual void | prepare (const SparseMatrixAdapter &M, Vector &b)=0
| Prepare the solver with the given sparse matrix and right-hand side vector.
virtual void | setResidual (Vector &b)=0
| Set the residual vector.
virtual void | getResidual (Vector &b) const =0
| Get the residual vector.
virtual void | setMatrix (const SparseMatrixAdapter &M)=0
| Set the matrix for the solver.
virtual bool | solve (Vector &x)=0
| Solve the system of equations Ax = b.
virtual int | iterations () const =0
| Get the number of iterations used in the last solve.
virtual const CommunicationType * | comm () const =0
| Get the communication object used by the solver.
virtual int | getSolveCount () const =0
| Get the count of how many times the solver has been called.

## Static Protected Member Functions

static bool | checkConvergence (const Dune::InverseOperatorResult &result, const FlowLinearSolverParameters &parameters)
| Check the convergence of the linear solver.

## Detailed Description

template<class TypeTag>
class Opm::AbstractISTLSolver< TypeTag >

Abstract interface for ISTL solvers.

This class defines the interface for ISTL solvers used in OPM. It provides methods for preparing the solver, setting and getting residuals, solving the system, and managing communication.

Note
  This class is used in the ISTLSolverRuntimeOptionProxy which we where we can set the solver type at runtime, and this proxy holds a pointer to an instance of this class.

Todo
  We should remove the use of setResidual() and setMatrix() methods and instead use prepare() with the SparseMatrixAdapter and Vector directly. This would simplify the interface and reduce the number of required method calls before solving the system.

## Member Function Documentation

## checkConvergence()

template<class TypeTag>

bool Opm::AbstractISTLSolver< TypeTag >::checkConvergence | ( | const Dune::InverseOperatorResult & | result,
|  | const FlowLinearSolverParameters & | parameters )

inline static protected

Check the convergence of the linear solver.

This method checks if the linear solver has converged based on the result and parameters.

Parameters

  result | The result of the linear solver.
  parameters | The parameters used for the linear solver.

Returns
  true if the solver has converged, false otherwise.

## comm()

template<class TypeTag>

virtual const CommunicationType * Opm::AbstractISTLSolver< TypeTag >::comm | ( |  | ) | const

pure virtual

Get the communication object used by the solver.

This method returns a pointer to the communication object used by the solver.

Returns
  A pointer to the communication object.

Implemented in Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< TypeTag >, and Opm::ISTLSolverRuntimeOptionProxy< TypeTag >.

## eraseMatrix()

template<class TypeTag>

virtual void Opm::AbstractISTLSolver< TypeTag >::eraseMatrix | ( |  | ) |

pure virtual

Signals that the memory for the matrix internally in the solver could be erased.

Note
  This call could be ignored by the solver, but it is a hint that the solver does not need the matrix anymore.

Implemented in Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< TypeTag >, and Opm::ISTLSolverRuntimeOptionProxy< TypeTag >.

## getResidual()

template<class TypeTag>

virtual void Opm::AbstractISTLSolver< TypeTag >::getResidual | ( | Vector & | b | ) | const

pure virtual

Get the residual vector.

This method retrieves the current residual vector from the solver.

Parameters

  b | The vector to store the residual.

Implemented in Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< TypeTag >, Opm::ISTLSolverGpuBridge< TypeTag >, and Opm::ISTLSolverRuntimeOptionProxy< TypeTag >.

## getSolveCount()

template<class TypeTag>

virtual int Opm::AbstractISTLSolver< TypeTag >::getSolveCount | ( |  | ) | const

pure virtual

Get the count of how many times the solver has been called.

This method returns the number of times the solve() method has been called.

Returns
  The count of solve calls.

Implemented in Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< TypeTag >, and Opm::ISTLSolverRuntimeOptionProxy< TypeTag >.

## iterations()

template<class TypeTag>

virtual int Opm::AbstractISTLSolver< TypeTag >::iterations | ( |  | ) | const

pure virtual

Get the number of iterations used in the last solve.

This method returns the number of iterations that the solver performed during the last call to solve().

Returns
  The number of iterations.

Note
  This value is only valid after a call to solve().

Implemented in Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< TypeTag >, and Opm::ISTLSolverRuntimeOptionProxy< TypeTag >.

## numAvailableSolvers()

template<class TypeTag>

virtual int Opm::AbstractISTLSolver< TypeTag >::numAvailableSolvers | ( |  | ) | const

pure virtual

Get the number of available solvers.

Returns
  The number of solvers that can be used.

Implemented in Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< TypeTag >, and Opm::ISTLSolverRuntimeOptionProxy< TypeTag >.

## prepare() [1/2]

template<class TypeTag>

virtual void Opm::AbstractISTLSolver< TypeTag >::prepare | ( | const Matrix & | M,
|  | Vector & | b )

pure virtual

Prepare the solver with the given matrix and right-hand side vector.

This method initializes the solver with the provided matrix and vector, preparing it for solving the system of equations.

Parameters

  M | The matrix representing the system of equations.
  b | The right-hand side vector.

Implemented in Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< TypeTag >, Opm::ISTLSolverGpuBridge< TypeTag >, and Opm::ISTLSolverRuntimeOptionProxy< TypeTag >.

## prepare() [2/2]

template<class TypeTag>

virtual void Opm::AbstractISTLSolver< TypeTag >::prepare | ( | const SparseMatrixAdapter & | M,
|  | Vector & | b )

pure virtual

Prepare the solver with the given sparse matrix and right-hand side vector.

This method initializes the solver with the provided sparse matrix and vector, preparing it for solving the system of equations.

Parameters

  M | The sparse matrix representing the system of equations.
  b | The right-hand side vector.

Note
  This method should be called in addition to setResidual() and setMatrix() before calling solve().

Implemented in Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< TypeTag >, and Opm::ISTLSolverRuntimeOptionProxy< TypeTag >.

## setActiveSolver()

template<class TypeTag>

virtual void Opm::AbstractISTLSolver< TypeTag >::setActiveSolver | ( | int | num | ) |

pure virtual

Set the active solver by its index.

Parameters

  num | The index of the solver to set as active.

Note
  The index corresponds to the order in which solvers are registered.

Implemented in Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< TypeTag >, and Opm::ISTLSolverRuntimeOptionProxy< TypeTag >.

## setMatrix()

template<class TypeTag>

virtual void Opm::AbstractISTLSolver< TypeTag >::setMatrix | ( | const SparseMatrixAdapter & | M | ) |

pure virtual

Set the matrix for the solver.

This method sets the matrix that the solver will use to solve the system of equations.

Parameters

  M | The sparse matrix adapter containing the matrix data.

Note
  This method should be called in addition to prepare() and setResidual() before calling solve().

Implemented in Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< TypeTag >, Opm::ISTLSolverGpuBridge< TypeTag >, and Opm::ISTLSolverRuntimeOptionProxy< TypeTag >.

## setResidual()

template<class TypeTag>

virtual void Opm::AbstractISTLSolver< TypeTag >::setResidual | ( | Vector & | b | ) |

pure virtual

Set the residual vector.

This method sets the residual vector for the solver.

Parameters

  b | The residual vector to set.

Note
  This method should be called in addition to prepare() and setMatrix() before calling solve().

Implemented in Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< TypeTag >, Opm::ISTLSolverGpuBridge< TypeTag >, and Opm::ISTLSolverRuntimeOptionProxy< TypeTag >.

## solve()

template<class TypeTag>

virtual bool Opm::AbstractISTLSolver< TypeTag >::solve | ( | Vector & | x | ) |

pure virtual

Solve the system of equations Ax = b.

This method solves the linear system represented by the matrix A and the right-hand side vector b, storing the solution in vector x.

Parameters

  x | The vector to store the solution.

Returns
  true if the solver converged, false otherwise.

Before this function is called, the following function calls should have been made:

- prepare(const Matrix& M, Vector& b) or prepare(const SparseMatrixAdapter& M, Vector& b)
- setResidual(Vector& b) or setResidual(const Vector& b)
- setMatrix(const SparseMatrixAdapter& M)

Implemented in Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< TypeTag >, Opm::ISTLSolverGpuBridge< TypeTag >, and Opm::ISTLSolverRuntimeOptionProxy< TypeTag >.

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

- opm/simulators/linalg/AbstractISTLSolver.hpp