Opm::AbstractISTLSolver< TypeTag > Class Template Referenceabstract

Abstract interface for ISTL solvers. More...

#include <AbstractISTLSolver.hpp>

Inheritance diagram for Opm::AbstractISTLSolver< TypeTag >:
Inheritance graph

Public Types

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

Public Member Functions

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

Static Protected Member Functions

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

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.

Member Typedef Documentation

◆ CommunicationType

template<class TypeTag >
using Opm::AbstractISTLSolver< TypeTag >::CommunicationType = Dune::OwnerOverlapCopyCommunication<int, int>

◆ Matrix

template<class TypeTag >
using Opm::AbstractISTLSolver< TypeTag >::Matrix = typename SparseMatrixAdapter::IstlMatrix

◆ SparseMatrixAdapter

template<class TypeTag >
using Opm::AbstractISTLSolver< TypeTag >::SparseMatrixAdapter = GetPropType<TypeTag, Properties::SparseMatrixAdapter>

◆ Vector

template<class TypeTag >
using Opm::AbstractISTLSolver< TypeTag >::Vector = GetPropType<TypeTag, Properties::GlobalEqVector>

Constructor & Destructor Documentation

◆ ~AbstractISTLSolver()

template<class TypeTag >
virtual Opm::AbstractISTLSolver< TypeTag >::~AbstractISTLSolver ( )
virtualdefault

Member Function Documentation

◆ checkConvergence()

template<class TypeTag >
static bool Opm::AbstractISTLSolver< TypeTag >::checkConvergence ( const Dune::InverseOperatorResult &  result,
const FlowLinearSolverParameters parameters 
)
inlinestaticprotected

Check the convergence of the linear solver.

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

Parameters
resultThe result of the linear solver.
parametersThe parameters used for the linear solver.
Returns
true if the solver has converged, false otherwise.

References Opm::FlowLinearSolverParameters::ignoreConvergenceFailure_, and Opm::FlowLinearSolverParameters::relaxed_linear_solver_reduction_.

Referenced by Opm::ISTLSolver< TypeTag >::checkConvergence().

◆ 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
bThe vector to store the residual.

Implemented in Opm::ISTLSolverGpuBridge< TypeTag >, Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< 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
MThe matrix representing the system of equations.
bThe right-hand side vector.

Implemented in Opm::ISTLSolverGpuBridge< TypeTag >, Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< 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
MThe sparse matrix representing the system of equations.
bThe 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
numThe index of the solver to set as active.
Note
The index corresponds to the order in which solvers are registered.

Implemented in Opm::ISTLSolver< TypeTag >, Opm::gpuistl::ISTLSolverGPUISTL< 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
MThe 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::ISTLSolverGpuBridge< TypeTag >, Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< 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
bThe residual vector to set.
Note
This method should be called in addition to prepare() and setMatrix() before calling solve().

Implemented in Opm::ISTLSolverGpuBridge< TypeTag >, Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >, Opm::ISTLSolver< 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
xThe 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:

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


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