Opm::detail::MatrixCoefficients< Matrix > Class Template Reference

The coefficients of solveReordered(), from a sparse block matrix. More...

#include <UpwindTransportSolver.hpp>

Public Types

using Scalar = typename Block::field_type
 

Public Member Functions

 MatrixCoefficients (const Matrix &matrix)
 Collect the diagonal blocks and the nonzero couplings of a matrix. More...
 
std::size_t numCells () const
 The number of cells, i.e. block rows of the matrix. More...
 
const SparseTable< int > & graph () const
 The dependency graph, as input to Opm::tarjan(). More...
 
const Block & diagonal (std::size_t c) const
 The diagonal block of a cell. More...
 
template<class Function >
void forEachCoupling (std::size_t c, Function &&f) const
 Call a function for each cell that a cell depends on. More...
 

Static Public Attributes

static constexpr std::size_t blockSize = Block::rows
 

Detailed Description

template<class Matrix>
class Opm::detail::MatrixCoefficients< Matrix >

The coefficients of solveReordered(), from a sparse block matrix.

Only the nonzero off-diagonal blocks couple cells. The matrix must outlive this object.

The interface that ReorderedSystem uses:

  • Scalar and blockSize, the size N of the blocks.
  • numCells(), and graph() with the cells each cell depends on.
  • diagonal(c), a reference to the N x N diagonal block.
  • forEachCoupling(c, f), which calls f(u, block) for each cell u in row c of graph() with the off-diagonal block of the equation.
Template Parameters
MatrixSquare sparse block matrix such as Dune::BCRSMatrix with square blocks.

Member Typedef Documentation

◆ Scalar

template<class Matrix >
using Opm::detail::MatrixCoefficients< Matrix >::Scalar = typename Block::field_type

Constructor & Destructor Documentation

◆ MatrixCoefficients()

template<class Matrix >
Opm::detail::MatrixCoefficients< Matrix >::MatrixCoefficients ( const Matrix &  matrix)
inlineexplicit

Collect the diagonal blocks and the nonzero couplings of a matrix.

Parameters
matrixThe matrix. Every row must have a diagonal block.
Exceptions
std::invalid_argumentif the matrix is not square or a row has no diagonal block.
std::runtime_errorif a diagonal or coupling block contains NaN or infinite values.

References Opm::detail::forEachNonzeroCoupling(), Opm::detail::isFiniteBlock(), and Opm::to_string().

Member Function Documentation

◆ diagonal()

template<class Matrix >
const Block & Opm::detail::MatrixCoefficients< Matrix >::diagonal ( std::size_t  c) const
inline

The diagonal block of a cell.

Parameters
cThe cell.
Returns
A reference to the block A[c][c] in the matrix.

◆ forEachCoupling()

template<class Matrix >
template<class Function >
void Opm::detail::MatrixCoefficients< Matrix >::forEachCoupling ( std::size_t  c,
Function &&  f 
) const
inline

Call a function for each cell that a cell depends on.

Template Parameters
FunctionCallable as f(std::size_t u, const Block& block).
Parameters
cThe cell.
fCalled for each cell u in row c of graph(), with the block A[c][u].

◆ graph()

template<class Matrix >
const SparseTable< int > & Opm::detail::MatrixCoefficients< Matrix >::graph ( ) const
inline

The dependency graph, as input to Opm::tarjan().

Returns
One row per cell r, listing the columns c != r with a nonzero block A[r][c], in the order of the matrix row. Blocks that are stored but zero give no edge.

◆ numCells()

template<class Matrix >
std::size_t Opm::detail::MatrixCoefficients< Matrix >::numCells ( ) const
inline

The number of cells, i.e. block rows of the matrix.

Returns
The number of cells.

Member Data Documentation

◆ blockSize

template<class Matrix >
constexpr std::size_t Opm::detail::MatrixCoefficients< Matrix >::blockSize = Block::rows
staticconstexpr

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