27#ifndef EWOMS_ISTL_SPARSE_MATRIX_ADAPTER_HH
28#define EWOMS_ISTL_SPARSE_MATRIX_ADAPTER_HH
30#include <dune/istl/bcrsmatrix.hh>
31#include <dune/common/fmatrix.hh>
32#include <dune/common/version.hh>
41template <
class MatrixBlockType,
class AllocatorType=std::allocator<MatrixBlockType> >
46 using IstlMatrix = Dune::BCRSMatrix<MatrixBlockType, AllocatorType>;
50 static_assert(std::is_same<MatrixBlock, MatrixBlockType>::value,
51 "IstlMatrix::block_type and MatrixBlockType must be identical");
54 using Scalar =
typename MatrixBlock::field_type;
68 template <
class Simulator>
80 istlMatrix_.reset(
new IstlMatrix(rows_, columns_, IstlMatrix::random));
86 for (
size_t dofIdx = 0; dofIdx < rows_; ++ dofIdx)
89 istlMatrix_->endrowsizes();
94 for (
size_t dofIdx = 0; dofIdx < rows_; ++ dofIdx) {
98 istlMatrix_->addindex(dofIdx, *
nIt);
100 istlMatrix_->endindices();
107 {
return *istlMatrix_; }
109 {
return *istlMatrix_; }
127 { (*istlMatrix_) =
Scalar(0.0); }
158 MatrixBlockType* blockAddress(
const size_t rowIdx,
const size_t colIdx)
const
196 std::unique_ptr<IstlMatrix> istlMatrix_;
A sparse matrix interface backend for BCRSMatrix from dune-istl.
Definition istlsparsematrixadapter.hh:43
void setBlock(const size_t rowIdx, const size_t colIdx, const MatrixBlock &value)
Set matrix block to given block.
Definition istlsparsematrixadapter.hh:165
void clear()
Set all matrix entries to zero.
Definition istlsparsematrixadapter.hh:126
Dune::BCRSMatrix< MatrixBlockType, AllocatorType > IstlMatrix
Implementation of matrix.
Definition istlsparsematrixadapter.hh:46
void finalize()
Finish modifying the matrix, i.e., convert the data structure from one tailored for linearization to ...
Definition istlsparsematrixadapter.hh:189
IstlSparseMatrixAdapter(const size_t rows, const size_t columns)
Constructor creating an empty matrix.
Definition istlsparsematrixadapter.hh:59
void reserve(const std::vector< Set > &sparsityPattern)
Allocate matrix structure give a sparsity pattern.
Definition istlsparsematrixadapter.hh:77
size_t cols() const
Return number of columns of the matrix.
Definition istlsparsematrixadapter.hh:120
size_t rows() const
Return number of rows of the matrix.
Definition istlsparsematrixadapter.hh:114
typename IstlMatrix::block_type MatrixBlock
block type forming the matrix entries
Definition istlsparsematrixadapter.hh:49
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).
Definition istlsparsematrixadapter.hh:135
void commit()
Commit matrix from local caches into matrix native structure.
Definition istlsparsematrixadapter.hh:179
void addToBlock(const size_t rowIdx, const size_t colIdx, const MatrixBlock &value)
Add block to matrix block.
Definition istlsparsematrixadapter.hh:171
IstlMatrix & istlMatrix()
Return constant reference to matrix implementation.
Definition istlsparsematrixadapter.hh:106
void block(const size_t rowIdx, const size_t colIdx, MatrixBlock &value) const
Fill given block with entries stored in the matrix.
Definition istlsparsematrixadapter.hh:155
typename MatrixBlock::field_type Scalar
type of scalar
Definition istlsparsematrixadapter.hh:54
IstlSparseMatrixAdapter(const Simulator &simulator)
Constructor taking simulator and creating an empty matrix .
Definition istlsparsematrixadapter.hh:69
Manages the initializing and running of time dependent problems.
Definition simulator.hh:92
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242