Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType > Class Template Reference

A sparse matrix interface backend for BCRSMatrix from dune-istl. More...

#include <istlsparsematrixadapter.hh>

Public Types

using IstlMatrix = Dune::BCRSMatrix< MatrixBlockType, AllocatorType >
 Implementation of matrix. More...
 
using MatrixBlock = typename IstlMatrix::block_type
 block type forming the matrix entries More...
 
using Scalar = typename MatrixBlock::field_type
 type of scalar More...
 

Public Member Functions

 IstlSparseMatrixAdapter (const size_t rows, const size_t columns)
 Constructor creating an empty matrix. More...
 
template<class Simulator >
 IstlSparseMatrixAdapter (const Simulator &simulator)
 Constructor taking simulator and creating an empty matrix . More...
 
template<class Set >
void reserve (const std::vector< Set > &sparsityPattern)
 Allocate matrix structure give a sparsity pattern. More...
 
IstlMatrixistlMatrix ()
 Return constant reference to matrix implementation. More...
 
const IstlMatrixistlMatrix () const
 
size_t rows () const
 Return number of rows of the matrix. More...
 
size_t cols () const
 Return number of columns of the matrix. More...
 
void clear ()
 Set all matrix entries to zero. More...
 
void clearRow (const size_t row, const Scalar diag=1.0)
 Set given row to zero except for the main-diagonal entry (if it exists). More...
 
void block (const size_t rowIdx, const size_t colIdx, MatrixBlock &value) const
 Fill given block with entries stored in the matrix. More...
 
MatrixBlockType * blockAddress (const size_t rowIdx, const size_t colIdx) const
 
void setBlock (const size_t rowIdx, const size_t colIdx, const MatrixBlock &value)
 Set matrix block to given block. More...
 
void addToBlock (const size_t rowIdx, const size_t colIdx, const MatrixBlock &value)
 Add block to matrix block. More...
 
void commit ()
 Commit matrix from local caches into matrix native structure. More...
 
void finalize ()
 Finish modifying the matrix, i.e., convert the data structure from one tailored for linearization to one aimed at the linear solver. More...
 

Protected Attributes

size_t rows_
 
size_t columns_
 
std::unique_ptr< IstlMatrixistlMatrix_
 

Detailed Description

template<class MatrixBlockType, class AllocatorType = std::allocator<MatrixBlockType>>
class Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >

A sparse matrix interface backend for BCRSMatrix from dune-istl.

Member Typedef Documentation

◆ IstlMatrix

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
using Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::IstlMatrix = Dune::BCRSMatrix<MatrixBlockType, AllocatorType>

Implementation of matrix.

◆ MatrixBlock

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
using Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::MatrixBlock = typename IstlMatrix::block_type

block type forming the matrix entries

◆ Scalar

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
using Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::Scalar = typename MatrixBlock::field_type

type of scalar

Constructor & Destructor Documentation

◆ IstlSparseMatrixAdapter() [1/2]

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::IstlSparseMatrixAdapter ( const size_t  rows,
const size_t  columns 
)
inline

Constructor creating an empty matrix.

◆ IstlSparseMatrixAdapter() [2/2]

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
template<class Simulator >
Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::IstlSparseMatrixAdapter ( const Simulator simulator)
inline

Constructor taking simulator and creating an empty matrix .

Member Function Documentation

◆ addToBlock()

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
void Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::addToBlock ( const size_t  rowIdx,
const size_t  colIdx,
const MatrixBlock value 
)
inline

Add block to matrix block.

◆ block()

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
void Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::block ( const size_t  rowIdx,
const size_t  colIdx,
MatrixBlock value 
) const
inline

Fill given block with entries stored in the matrix.

◆ blockAddress()

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
MatrixBlockType * Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::blockAddress ( const size_t  rowIdx,
const size_t  colIdx 
) const
inline

◆ clear()

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
void Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::clear ( )
inline

Set all matrix entries to zero.

◆ clearRow()

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
void Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::clearRow ( const size_t  row,
const Scalar  diag = 1.0 
)
inline

Set given row to zero except for the main-diagonal entry (if it exists).

If the sparsity pattern of the matrix features an explicit block on the main diagonal, the diagonal on that block is set to the second agument of the function.

◆ cols()

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
size_t Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::cols ( ) const
inline

Return number of columns of the matrix.

References Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::columns_.

◆ commit()

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
void Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::commit ( )
inline

Commit matrix from local caches into matrix native structure.

For the ISTL adapter this is unnecessary because there is no caching mechanism.

◆ finalize()

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
void Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::finalize ( )
inline

Finish modifying the matrix, i.e., convert the data structure from one tailored for linearization to one aimed at the linear solver.

This may compress the matrix if the build mode is implicit. For the ISTL adapter this is not required.

◆ istlMatrix() [1/2]

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
IstlMatrix & Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::istlMatrix ( )
inline

Return constant reference to matrix implementation.

References Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::istlMatrix_.

◆ istlMatrix() [2/2]

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
const IstlMatrix & Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::istlMatrix ( ) const
inline

◆ reserve()

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
template<class Set >
void Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::reserve ( const std::vector< Set > &  sparsityPattern)
inline

◆ rows()

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
size_t Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::rows ( ) const
inline

◆ setBlock()

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
void Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::setBlock ( const size_t  rowIdx,
const size_t  colIdx,
const MatrixBlock value 
)
inline

Set matrix block to given block.

Member Data Documentation

◆ columns_

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
size_t Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::columns_
protected

◆ istlMatrix_

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
std::unique_ptr<IstlMatrix> Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::istlMatrix_
protected

◆ rows_

template<class MatrixBlockType , class AllocatorType = std::allocator<MatrixBlockType>>
size_t Opm::Linear::IstlSparseMatrixAdapter< MatrixBlockType, AllocatorType >::rows_
protected

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