Loading...
Searching...
No Matches
Opm::gpuistl::ISTLSolverGPUISTL< TypeTag > Class Template Reference

ISTL solver for GPU using the GPU ISTL backend. More...

`#include <ISTLSolverGPUISTL.hpp>`

Inheritance diagram for Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >:

## Public Types

using | SparseMatrixAdapter = GetPropType<TypeTag, Properties::SparseMatrixAdapter>
using | Vector = GetPropType<TypeTag, Properties::GlobalEqVector>
using | Simulator = GetPropType<TypeTag, Properties::Simulator>
using | ElementMapper = GetPropType<TypeTag, Properties::ElementMapper>
using | Matrix = typename SparseMatrixAdapter::IstlMatrix
using | ThreadManager = GetPropType<TypeTag, Properties::ThreadManager>
using | GridView = GetPropType<TypeTag, Properties::GridView>
using | ElementContext = GetPropType<TypeTag, Properties::ElementContext>
using | ElementChunksType = Opm::ElementChunks<GridView, Dune::Partitions::All>
using | real_type = typename Vector::field_type
using | GPUMatrix = Opm::gpuistl::GpuSparseMatrixWrapper<real_type>
using | GPUVector = Opm::gpuistl::GpuVector<real_type>
using | GPUVectorInt = Opm::gpuistl::GpuVector<int>
using | CommunicationType = Dune::Communication<int>
using | SolverType = Opm::gpuistl::detail::FlexibleSolverWrapper<GPUMatrix, GPUVector, CommunicationType>
Public Types inherited from Opm::AbstractISTLSolver< TypeTag >
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

| ISTLSolverGPUISTL (const Simulator &simulator, const FlowLinearSolverParameters &parameters, bool forceSerial=false)
| Construct a system solver.
| ISTLSolverGPUISTL (const Simulator &simulator)
| Construct a system solver.
void | eraseMatrix () override
| Signals that the memory for the matrix internally in the solver could be erased.
void | setActiveSolver (int num) override
| Set the active solver by its index.
int | numAvailableSolvers () const override
| Get the number of available solvers.
void | prepare (const SparseMatrixAdapter &M, Vector &b) override
| Prepare the solver with the given matrix and right-hand side vector.
void | prepare (const Matrix &M, Vector &b) override
| Prepare the solver with the given matrix and right-hand side vector.
void | setResidual (Vector &) override
| Set the residual vector.
void | getResidual (Vector &b) const override
| Get the residual vector.
void | setMatrix (const SparseMatrixAdapter &) override
| Set the matrix for the solver.
bool | solve (Vector &x) override
| Solve the system of linear equations Ax = b.
int | iterations () const override
const CommunicationType * | comm () const override
| Get the communication object used by the solver.
bool | isParallel () const
| Check if we are running in parallel mode.
int | getSolveCount () const override
| Get the count of how many times the solver has been called.

## Static Public Attributes

static constexpr std::size_t | pressureIndex = GetPropType<TypeTag, Properties::Indices>::pressureSwitchIdx

## Additional Inherited Members

Static Protected Member Functions inherited from Opm::AbstractISTLSolver< TypeTag >
static bool | checkConvergence (const Dune::InverseOperatorResult &result, const FlowLinearSolverParameters &parameters)
| Check the convergence of the linear solver.

## Detailed Description

template<class TypeTag>
class Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >

ISTL solver for GPU using the GPU ISTL backend.

This class implements the AbstractISTLSolver interface and provides methods to prepare the solver, set and get residuals, solve the system, and manage communication.

Template Parameters

  TypeTag | The type tag for the properties used in this solver.

Note
  This solver takes CPU matrices and vectors, but uses GPU matrices and vectors internally for computations.

## Constructor & Destructor Documentation

## ISTLSolverGPUISTL() [1/2]

template<class TypeTag>

Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::ISTLSolverGPUISTL | ( | const Simulator & | simulator,
|  | const FlowLinearSolverParameters & | parameters,
|  | bool | forceSerial = false )

inline

Construct a system solver.

Parameters

  [in] | simulator | The opm-models simulator object
  [in] | parameters | Explicit parameters for solver setup, do not read them from command line parameters.
  [in] | forceSerial | If true, will set up a serial linear solver only, local to the current rank, instead of creating a parallel (MPI distributed) linear solver.

## ISTLSolverGPUISTL() [2/2]

template<class TypeTag>

Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::ISTLSolverGPUISTL | ( | const Simulator & | simulator | ) |

inline explicit

Construct a system solver.

Parameters

  [in] | simulator | The opm-models simulator object

## Member Function Documentation

## comm()

template<class TypeTag>

const CommunicationType * Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::comm | ( |  | ) | const

inline override 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.

Implements Opm::AbstractISTLSolver< TypeTag >.

## eraseMatrix()

template<class TypeTag>

void Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::eraseMatrix | ( |  | ) |

inline override 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.
  This method will not do anything.

Implements Opm::AbstractISTLSolver< TypeTag >.

## getResidual()

template<class TypeTag>

void Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::getResidual | ( | Vector & | b | ) | const

inline override virtual

Get the residual vector.

This method retrieves the current residual vector from the solver. It copies the data from the internal GPU vector to the provided vector.

Parameters

  b | The vector to store the residual.

Implements Opm::AbstractISTLSolver< TypeTag >.

## getSolveCount()

template<class TypeTag>

int Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::getSolveCount | ( |  | ) | const

inline override 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.

Implements Opm::AbstractISTLSolver< TypeTag >.

## isParallel()

template<class TypeTag>

bool Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::isParallel | ( |  | ) | const

inline

Check if we are running in parallel mode.

Returns
  true if running with multiple MPI processes and not forced to serial, false otherwise.

## iterations()

template<class TypeTag>

int Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::iterations | ( |  | ) | const

inline override virtual

Returns the actual number of iterations used in the last solve.

Implements Opm::AbstractISTLSolver< TypeTag >.

## numAvailableSolvers()

template<class TypeTag>

int Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::numAvailableSolvers | ( |  | ) | const

inline override virtual

Get the number of available solvers.

Returns
  The number of solvers that can be used.

Note
  This method always returns 1, as only one solver is available for the GPU backend.

Implements Opm::AbstractISTLSolver< TypeTag >.

## prepare() [1/2]

template<class TypeTag>

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

inline override virtual

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

This method initializes the solver with the provided matrix and right-hand side vector. It updates the internal GPU matrix and right-hand side vector.

Parameters

  M | The matrix to be used in the solver.
  b | The right-hand side vector.

Implements Opm::AbstractISTLSolver< TypeTag >.

## prepare() [2/2]

template<class TypeTag>

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

inline override virtual

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

This method initializes the solver with the provided matrix and right-hand side vector. It updates the internal GPU matrix and right-hand side vector.

Parameters

  M | The matrix to be used in the solver.
  b | The right-hand side vector.

Implements Opm::AbstractISTLSolver< TypeTag >.

## setActiveSolver()

template<class TypeTag>

void Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::setActiveSolver | ( | int | num | ) |

inline override 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.
  This method will throw an exception if the solver number is not 0, as only one solver is available for the GPU backend.

Implements Opm::AbstractISTLSolver< TypeTag >.

## setMatrix()

template<class TypeTag>

void Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::setMatrix | ( | const SparseMatrixAdapter & |  | ) |

inline override 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().
  This method does not set the matrix directly, as it should be handled in prepare().

Implements Opm::AbstractISTLSolver< TypeTag >.

## setResidual()

template<class TypeTag>

void Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::setResidual | ( | Vector & |  | ) |

inline override 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().
  Unused in this implementation.

Implements Opm::AbstractISTLSolver< TypeTag >.

## solve()

template<class TypeTag>

bool Opm::gpuistl::ISTLSolverGPUISTL< TypeTag >::solve | ( | Vector & | x | ) |

inline override virtual

Solve the system of linear 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, prepare() should have been called with a valid matrix and right-hand side vector.

Implements Opm::AbstractISTLSolver< TypeTag >.

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

- opm/simulators/linalg/gpuistl/ISTLSolverGPUISTL.hpp