opm-simulators
Loading...
Searching...
No Matches
Opm::ISTLSolverTPSA< TypeTag > Class Template Reference

Class for setting up ISTL linear solvers for TPSA. More...

#include <ISTLSolverTPSA.hpp>

Inheritance diagram for Opm::ISTLSolverTPSA< TypeTag >:
Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapterTPSA >, GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > >

Public Member Functions

 ISTLSolverTPSA (const Simulator &simulator)
 Constructor.
void initialize ()
 Setup linear solver object based on runtime/default parameters.
void initPrepare (const Matrix &M, Vector &b)
 Prepare matix and rhs vector for linear solve.
void prepare (const Matrix &M, Vector &b) override
 Prepare the solver with the given matrix and right-hand side vector.
void prepare (const SparseMatrixAdapter &M, Vector &b) override
 Prepare the solver with the given matrix and right-hand side vector.
void prepareFlexibleSolver ()
 Prepare linear solver.
bool solve (Vector &x) override
 Solve the system of equations Ax = b.
void resetSolveCount ()
 Reset number of solver calls to zero.
void eraseMatrix () override
 Signals that the memory for the matrix internally in the solver could be erased.
void setActiveSolver (int) override
 Set the active solver by its index.
int numAvailableSolvers () const override
 Get the number of available solvers.
void setResidual (Vector &) override
 Set the residual vector.
void setMatrix (const SparseMatrixAdapter &) override
 Set the matrix for the solver.
void getResidual (Vector &b) const override
 Get the residual vector.
int getSolveCount () const override
 Get the count of how many times the solver has been called.
int iterations () const override
 Get the number of iterations used in the last solve.
const CommunicationType * comm () const override
 Get the communication object used by the solver.
Public Member Functions inherited from Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapterTPSA >, GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > >
virtual void prepare (const Matrix &M, GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > &b)=0
 Prepare the solver with the given matrix and right-hand side vector.
virtual void setResidual (GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > &b)=0
 Set the residual vector.
virtual void getResidual (GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > &b) const=0
 Get the residual vector.
virtual void setMatrix (const GetPropType< TypeTag, Properties::SparseMatrixAdapterTPSA > &M)=0
 Set the matrix for the solver.
virtual bool solve (GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > &x)=0
 Solve the system of equations Ax = b.

Static Public Member Functions

static void registerParameters ()
 Register runtime/default parameters for linear solver.

Protected Member Functions

bool isParallel () const
 Check for parallel session.
bool checkConvergence (const Dune::InverseOperatorResult &result) const
 Check for linear solver convergence.
Matrix & getMatrix ()
 Get reference to system matrix object.
const Matrix & getMatrix () const
 Get reference to system matrix object.

Protected Attributes

const Simulator & simulator_
std::any parallelInformation_
int solveCount_
int iterations_
detail::FlexibleSolverInfo< Matrix, Vector, CommunicationType > flexibleSolver_
TpsaLinearSolverParameters parameters_
PropertyTree prm_
Matrix * matrix_
Vector * rhs_
std::shared_ptr< CommunicationType > comm_
std::vector< int > overlapRows_

Additional Inherited Members

Public Types inherited from Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapterTPSA >, GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > >
using CommunicationType
using Matrix
Static Protected Member Functions inherited from Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapterTPSA >, GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > >
static bool checkConvergence (const Dune::InverseOperatorResult &result, const FlowLinearSolverParameters &parameters)
 Check the convergence of the linear solver.

Detailed Description

template<class TypeTag>
class Opm::ISTLSolverTPSA< TypeTag >

Class for setting up ISTL linear solvers for TPSA.

Implements AbstractISTLSolver interface for TPSA linear solvers.

Constructor & Destructor Documentation

◆ ISTLSolverTPSA()

template<class TypeTag>
Opm::ISTLSolverTPSA< TypeTag >::ISTLSolverTPSA ( const Simulator & simulator)
inline

Constructor.

Parameters
simulatorSimulator object

Member Function Documentation

◆ checkConvergence()

template<class TypeTag>
bool Opm::ISTLSolverTPSA< TypeTag >::checkConvergence ( const Dune::InverseOperatorResult & result) const
inlineprotected

Check for linear solver convergence.

Parameters
resultLinear solver result container
Returns
Bool indicating convergence

◆ comm()

template<class TypeTag>
const CommunicationType * Opm::ISTLSolverTPSA< TypeTag >::comm ( ) const
inlineoverridevirtual

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.

Implements Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapterTPSA >, GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > >.

◆ eraseMatrix()

template<class TypeTag>
void Opm::ISTLSolverTPSA< TypeTag >::eraseMatrix ( )
inlineoverridevirtual

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.

Implements Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapterTPSA >, GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > >.

◆ getMatrix() [1/2]

template<class TypeTag>
Matrix & Opm::ISTLSolverTPSA< TypeTag >::getMatrix ( )
inlineprotected

Get reference to system matrix object.

Returns
Reference to matrix

◆ getMatrix() [2/2]

template<class TypeTag>
const Matrix & Opm::ISTLSolverTPSA< TypeTag >::getMatrix ( ) const
inlineprotected

Get reference to system matrix object.

Returns
Reference to matrix

◆ getResidual()

template<class TypeTag>
void Opm::ISTLSolverTPSA< TypeTag >::getResidual ( Vector & b) const
inlineoverride

Get the residual vector.

This method retrieves the current residual vector from the solver.

Parameters
bThe vector to store the residual.

◆ getSolveCount()

template<class TypeTag>
int Opm::ISTLSolverTPSA< TypeTag >::getSolveCount ( ) const
inlineoverridevirtual

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.

Implements Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapterTPSA >, GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > >.

◆ initPrepare()

template<class TypeTag>
void Opm::ISTLSolverTPSA< TypeTag >::initPrepare ( const Matrix & M,
Vector & b )
inline

Prepare matix and rhs vector for linear solve.

Parameters
MSystem matrix
bRight-hand side vector

◆ isParallel()

template<class TypeTag>
bool Opm::ISTLSolverTPSA< TypeTag >::isParallel ( ) const
inlineprotected

Check for parallel session.

Returns
Bool indicating if this is a parallel session
Warning
comm_ must be set before using this function

◆ iterations()

template<class TypeTag>
int Opm::ISTLSolverTPSA< TypeTag >::iterations ( ) const
inlineoverridevirtual

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().

Implements Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapterTPSA >, GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > >.

◆ numAvailableSolvers()

template<class TypeTag>
int Opm::ISTLSolverTPSA< TypeTag >::numAvailableSolvers ( ) const
inlineoverridevirtual

Get the number of available solvers.

Returns
The number of solvers that can be used.

Implements Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapterTPSA >, GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > >.

◆ prepare() [1/2]

template<class TypeTag>
void Opm::ISTLSolverTPSA< TypeTag >::prepare ( const Matrix & M,
Vector & b )
inlineoverride

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.

◆ prepare() [2/2]

template<class TypeTag>
void Opm::ISTLSolverTPSA< TypeTag >::prepare ( const SparseMatrixAdapter & M,
Vector & b )
inlineoverride

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.

◆ prepareFlexibleSolver()

template<class TypeTag>
void Opm::ISTLSolverTPSA< TypeTag >::prepareFlexibleSolver ( )
inline

Prepare linear solver.

Create linear solver using FlexibleSolverInfo struct from ISTLSolver.hpp, or update preconditioner if solver has been created

◆ setActiveSolver()

template<class TypeTag>
void Opm::ISTLSolverTPSA< TypeTag >::setActiveSolver ( int )
inlineoverridevirtual

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.

Implements Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapterTPSA >, GetPropType< TypeTag, Properties::GlobalEqVectorTPSA > >.

◆ setMatrix()

template<class TypeTag>
void Opm::ISTLSolverTPSA< TypeTag >::setMatrix ( const SparseMatrixAdapter & )
inlineoverride

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().

◆ setResidual()

template<class TypeTag>
void Opm::ISTLSolverTPSA< TypeTag >::setResidual ( Vector & )
inlineoverride

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().

◆ solve()

template<class TypeTag>
bool Opm::ISTLSolverTPSA< TypeTag >::solve ( Vector & x)
inlineoverride

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:


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