Opm::Linear::TpsaMatrix< Scalar > Class Template Reference

TPSA matrix for linear elasticity. More...

#include <TpsaMatrix.hpp>

Public Types

using IstlMatrix = TpsaMatrixView< Scalar >
 What the linear solver operates on. More...
 
using MatrixBlock = Opm::MatrixBlock< Scalar, numTpsaEq, numTpsaEq >
 Dense local block the linearizer accumulates into. More...
 
using BlockAddress = TpsaBlockRef< Scalar >
 What blockAddress() returns. More...
 
using field_type = Scalar
 Field type of the matrix entries. More...
 

Public Member Functions

 TpsaMatrix (std::size_t rows, std::size_t columns)
 Construct a matrix of the given block dimensions. More...
 
template<class Simulator >
 TpsaMatrix (const Simulator &simulator)
 Construct a square matrix sized from a simulator's degrees of freedom. More...
 
 TpsaMatrix (const TpsaMatrix &)=delete
 
 TpsaMatrix (TpsaMatrix &&)=delete
 
TpsaMatrixoperator= (const TpsaMatrix &)=delete
 
TpsaMatrixoperator= (TpsaMatrix &&)=delete
 
template<class Set >
void reserve (const std::vector< Set > &sparsityPattern)
 Allocate all sub-matrices from a common sparsity pattern. More...
 
BlockAddress blockAddress (const std::size_t rowIdx, const std::size_t colIdx) const
 Handle on the block at (rowIdx, colIdx). More...
 
void clear ()
 Set all matrix entries to zero. More...
 
void clearRow (const std::size_t row, const Scalar diag=1.0)
 Set the given row to zero, except for the main diagonal. More...
 
void makeOverlapRowsInvalid (const std::vector< int > &overlapRows)
 Zero out the overlap rows and put the identity on their diagonal. More...
 
void scaleFields (const std::array< Scalar, numTpsaFields > &rowFac, const std::array< Scalar, numTpsaFields > &colFac)
 Scale the system by one factor per field: A <- D_row * A * D_col. More...
 
void block (const std::size_t rowIdx, const std::size_t colIdx, MatrixBlock &value) const
 Fill value with the stored entries of the given block. More...
 
void setBlock (const std::size_t rowIdx, const std::size_t colIdx, const MatrixBlock &value)
 Overwrite the given block with a dense 7x7 block. More...
 
void addToBlock (const std::size_t rowIdx, const std::size_t colIdx, const MatrixBlock &value)
 Add a dense 7x7 block to the given block. More...
 
void commit ()
 No local caching, so nothing to commit. More...
 
void finalize ()
 The structure is already solver-ready after reserve(). More...
 
IstlMatrixistlMatrix ()
 The sub-matrix view the linear solver operates on. More...
 
const IstlMatrixistlMatrix () const
 The sub-matrix view the linear solver operates on. More...
 
std::size_t rows () const
 Number of block rows. More...
 
std::size_t cols () const
 Number of block columns. More...
 
std::size_t N () const
 Number of block rows. More...
 
std::size_t M () const
 Number of block columns. More...
 
std::size_t nonzeroes () const
 Number of nonzero blocks in the shared sparsity pattern. More...
 
DispDispMatrix00T< Scalar > & dd00 ()
 Access the u_x-u_x sub-matrix. More...
 
DispDispMatrix11T< Scalar > & dd11 ()
 Access the u_y-u_y sub-matrix. More...
 
DispDispMatrix22T< Scalar > & dd22 ()
 Access the u_z-u_z sub-matrix. More...
 
RotRotMatrixT< Scalar > & rr ()
 Access the rotation-rotation sub-matrix. More...
 
SPresSPresMatrixT< Scalar > & spsp ()
 Access the solid pressure-solid pressure sub-matrix. More...
 
const DispDispMatrix00T< Scalar > & dd00 () const
 Access the u_x-u_x sub-matrix. More...
 
const DispDispMatrix11T< Scalar > & dd11 () const
 Access the u_y-u_y sub-matrix. More...
 
const DispDispMatrix22T< Scalar > & dd22 () const
 Access the u_z-u_z sub-matrix. More...
 
const RotRotMatrixT< Scalar > & rr () const
 Access the rotation-rotation sub-matrix. More...
 
const SPresSPresMatrixT< Scalar > & spsp () const
 Access the solid pressure-solid pressure sub-matrix. More...
 

Friends

class TpsaBlockRef< Scalar >
 

Detailed Description

template<class Scalar>
class Opm::Linear::TpsaMatrix< Scalar >

TPSA matrix for linear elasticity.

This is the equivalent as IstlSparseMatrixAdapter class is for flow linearizations. The TPSA linearizer still provides dense 7x7 blocks, but internally in the class the entries go into 19 sub-matrices. Displacement-displacement sub-matrix have been divided up in 1x1 fields for the Hypre BoomerAMG preconditioner. Overview of sub-matrix fields:

field 0: u_x            (1 dof)
field 1: u_y            (1 dof)
field 2: u_z            (1 dof)
field 3: rot_x/y/z      (3 dofs)
field 4: p_solid        (1 dof)

Note that, displacement-displacement off-diagonals are zero in linear elasticity

Template Parameters
ScalarField type of the matrix entries.

Member Typedef Documentation

◆ BlockAddress

template<class Scalar >
using Opm::Linear::TpsaMatrix< Scalar >::BlockAddress = TpsaBlockRef<Scalar>

What blockAddress() returns.

◆ field_type

template<class Scalar >
using Opm::Linear::TpsaMatrix< Scalar >::field_type = Scalar

Field type of the matrix entries.

◆ IstlMatrix

template<class Scalar >
using Opm::Linear::TpsaMatrix< Scalar >::IstlMatrix = TpsaMatrixView<Scalar>

What the linear solver operates on.

◆ MatrixBlock

template<class Scalar >
using Opm::Linear::TpsaMatrix< Scalar >::MatrixBlock = Opm::MatrixBlock<Scalar, numTpsaEq, numTpsaEq>

Dense local block the linearizer accumulates into.

Constructor & Destructor Documentation

◆ TpsaMatrix() [1/4]

template<class Scalar >
Opm::Linear::TpsaMatrix< Scalar >::TpsaMatrix ( std::size_t  rows,
std::size_t  columns 
)
inline

Construct a matrix of the given block dimensions.

No storage is allocated here; call reserve() with the sparsity pattern first.

Parameters
[in]rowsNumber of block rows, i.e. degrees of freedom.
[in]columnsNumber of block columns, i.e. degrees of freedom.

◆ TpsaMatrix() [2/4]

template<class Scalar >
template<class Simulator >
Opm::Linear::TpsaMatrix< Scalar >::TpsaMatrix ( const Simulator simulator)
inlineexplicit

Construct a square matrix sized from a simulator's degrees of freedom.

Template Parameters
SimulatorSimulator type exposing model().numTotalDof().
Parameters
[in]simulatorSimulator the number of degrees of freedom is taken from. Only read during construction.

◆ TpsaMatrix() [3/4]

template<class Scalar >
Opm::Linear::TpsaMatrix< Scalar >::TpsaMatrix ( const TpsaMatrix< Scalar > &  )
delete

◆ TpsaMatrix() [4/4]

template<class Scalar >
Opm::Linear::TpsaMatrix< Scalar >::TpsaMatrix ( TpsaMatrix< Scalar > &&  )
delete

Member Function Documentation

◆ addToBlock()

template<class Scalar >
void Opm::Linear::TpsaMatrix< Scalar >::addToBlock ( const std::size_t  rowIdx,
const std::size_t  colIdx,
const MatrixBlock value 
)
inline

Add a dense 7x7 block to the given block.

Parameters
[in]rowIdxBlock row index.
[in]colIdxBlock column index.
[in]valueDense block added to the stored entries. Its displacement-displacement off-diagonals are ignored.

References Opm::Linear::TpsaMatrix< Scalar >::blockAddress().

◆ block()

template<class Scalar >
void Opm::Linear::TpsaMatrix< Scalar >::block ( const std::size_t  rowIdx,
const std::size_t  colIdx,
MatrixBlock value 
) const
inline

Fill value with the stored entries of the given block.

The displacement-displacement off-diagonals are not stored and come back as zero.

Parameters
[in]rowIdxBlock row index.
[in]colIdxBlock column index.
[out]valueDense block the entries are written to. Fully overwritten.

References Opm::Linear::TpsaMatrix< Scalar >::blockAddress(), and Opm::Linear::TpsaBlockRef< Scalar >::gather().

◆ blockAddress()

template<class Scalar >
BlockAddress Opm::Linear::TpsaMatrix< Scalar >::blockAddress ( const std::size_t  rowIdx,
const std::size_t  colIdx 
) const
inline

Handle on the block at (rowIdx, colIdx).

Only called while the sparsity pattern is set up, so the linear scan over the row is not on any hot path.

Parameters
[in]rowIdxBlock row index.
[in]colIdxBlock column index.
Returns
Handle on the requested block.
Exceptions
std::logic_errorIf the block is not part of the sparsity pattern.

Referenced by Opm::Linear::TpsaMatrix< Scalar >::addToBlock(), Opm::Linear::TpsaMatrix< Scalar >::block(), and Opm::Linear::TpsaMatrix< Scalar >::setBlock().

◆ clear()

template<class Scalar >
void Opm::Linear::TpsaMatrix< Scalar >::clear ( )

Set all matrix entries to zero.

Does nothing when called before reserve().

◆ clearRow()

template<class Scalar >
void Opm::Linear::TpsaMatrix< Scalar >::clearRow ( const std::size_t  row,
const Scalar  diag = 1.0 
)

Set the given row to zero, except for the main diagonal.

The main diagonal of the block on the diagonal is set to diag. Written as dense blocks so that the field split is applied by TpsaBlockRef, i.e. by the same index map assembly goes through, rather than by a second description of which slots are field-diagonal.

Parameters
[in]rowBlock row to clear.
[in]diagValue put on the main diagonal of the diagonal block.

◆ cols()

template<class Scalar >
std::size_t Opm::Linear::TpsaMatrix< Scalar >::cols ( ) const
inline

Number of block columns.

Returns
Number of block columns of the matrix.

◆ commit()

template<class Scalar >
void Opm::Linear::TpsaMatrix< Scalar >::commit ( )
inline

No local caching, so nothing to commit.

◆ dd00() [1/2]

template<class Scalar >
DispDispMatrix00T< Scalar > & Opm::Linear::TpsaMatrix< Scalar >::dd00 ( )
inline

Access the u_x-u_x sub-matrix.

Returns
Reference to the sub-matrix. Only meaningful after reserve().

◆ dd00() [2/2]

template<class Scalar >
const DispDispMatrix00T< Scalar > & Opm::Linear::TpsaMatrix< Scalar >::dd00 ( ) const
inline

Access the u_x-u_x sub-matrix.

Returns
Reference to the sub-matrix. Only meaningful after reserve().

◆ dd11() [1/2]

template<class Scalar >
DispDispMatrix11T< Scalar > & Opm::Linear::TpsaMatrix< Scalar >::dd11 ( )
inline

Access the u_y-u_y sub-matrix.

Returns
Reference to the sub-matrix. Only meaningful after reserve().

◆ dd11() [2/2]

template<class Scalar >
const DispDispMatrix11T< Scalar > & Opm::Linear::TpsaMatrix< Scalar >::dd11 ( ) const
inline

Access the u_y-u_y sub-matrix.

Returns
Reference to the sub-matrix. Only meaningful after reserve().

◆ dd22() [1/2]

template<class Scalar >
DispDispMatrix22T< Scalar > & Opm::Linear::TpsaMatrix< Scalar >::dd22 ( )
inline

Access the u_z-u_z sub-matrix.

Returns
Reference to the sub-matrix. Only meaningful after reserve().

◆ dd22() [2/2]

template<class Scalar >
const DispDispMatrix22T< Scalar > & Opm::Linear::TpsaMatrix< Scalar >::dd22 ( ) const
inline

Access the u_z-u_z sub-matrix.

Returns
Reference to the sub-matrix. Only meaningful after reserve().

◆ finalize()

template<class Scalar >
void Opm::Linear::TpsaMatrix< Scalar >::finalize ( )
inline

The structure is already solver-ready after reserve().

◆ istlMatrix() [1/2]

template<class Scalar >
IstlMatrix & Opm::Linear::TpsaMatrix< Scalar >::istlMatrix ( )
inline

The sub-matrix view the linear solver operates on.

Only valid after reserve(); the view points into this object.

Returns
Reference to the 5x5 view over the sub-matrices.

◆ istlMatrix() [2/2]

template<class Scalar >
const IstlMatrix & Opm::Linear::TpsaMatrix< Scalar >::istlMatrix ( ) const
inline

The sub-matrix view the linear solver operates on.

Only valid after reserve(); the view points into this object.

Returns
Reference to the 5x5 view over the sub-matrices.

◆ M()

template<class Scalar >
std::size_t Opm::Linear::TpsaMatrix< Scalar >::M ( ) const
inline

Number of block columns.

Returns
Number of block columns of the matrix.

◆ makeOverlapRowsInvalid()

template<class Scalar >
void Opm::Linear::TpsaMatrix< Scalar >::makeOverlapRowsInvalid ( const std::vector< int > &  overlapRows)

Zero out the overlap rows and put the identity on their diagonal.

Parameters
[in]overlapRowsBlock rows that are not owned by this process.

◆ N()

template<class Scalar >
std::size_t Opm::Linear::TpsaMatrix< Scalar >::N ( ) const
inline

Number of block rows.

Returns
Number of block rows of the matrix.

◆ nonzeroes()

template<class Scalar >
std::size_t Opm::Linear::TpsaMatrix< Scalar >::nonzeroes ( ) const
inline

Number of nonzero blocks in the shared sparsity pattern.

Returns
Number of nonzero blocks, or zero before reserve() has been called.

◆ operator=() [1/2]

template<class Scalar >
TpsaMatrix & Opm::Linear::TpsaMatrix< Scalar >::operator= ( const TpsaMatrix< Scalar > &  )
delete

◆ operator=() [2/2]

template<class Scalar >
TpsaMatrix & Opm::Linear::TpsaMatrix< Scalar >::operator= ( TpsaMatrix< Scalar > &&  )
delete

◆ reserve()

template<class Scalar >
template<class Set >
void Opm::Linear::TpsaMatrix< Scalar >::reserve ( const std::vector< Set > &  sparsityPattern)
inline

Allocate all sub-matrices from a common sparsity pattern.

Also flattens the pattern, caches the value-array base pointer of every sub-matrix and sets up the solver view. Must be called before any block is accessed.

Template Parameters
SetOrdered container of column indices, e.g. std::set<unsigned>.
Parameters
[in]sparsityPatternOne entry per block row, holding that row's column indices in ascending order.

◆ rows()

template<class Scalar >
std::size_t Opm::Linear::TpsaMatrix< Scalar >::rows ( ) const
inline

Number of block rows.

Returns
Number of block rows of the matrix.

◆ rr() [1/2]

template<class Scalar >
RotRotMatrixT< Scalar > & Opm::Linear::TpsaMatrix< Scalar >::rr ( )
inline

Access the rotation-rotation sub-matrix.

Returns
Reference to the sub-matrix. Only meaningful after reserve().

◆ rr() [2/2]

template<class Scalar >
const RotRotMatrixT< Scalar > & Opm::Linear::TpsaMatrix< Scalar >::rr ( ) const
inline

Access the rotation-rotation sub-matrix.

Returns
Reference to the sub-matrix. Only meaningful after reserve().

◆ scaleFields()

template<class Scalar >
void Opm::Linear::TpsaMatrix< Scalar >::scaleFields ( const std::array< Scalar, numTpsaFields > &  rowFac,
const std::array< Scalar, numTpsaFields > &  colFac 
)

Scale the system by one factor per field: A <- D_row * A * D_col.

Every sub-matrix couples exactly one field row to one field column, so a field scaling is a single factor per sub-matrix and can be applied to the flat value arrays without walking the sparsity pattern.

Parameters
[in]rowFacRow (equation) factor of each field.
[in]colFacColumn (unknown) factor of each field.
Note
Scales in place, so it must be called once per assembly. Does nothing when called before reserve().

◆ setBlock()

template<class Scalar >
void Opm::Linear::TpsaMatrix< Scalar >::setBlock ( const std::size_t  rowIdx,
const std::size_t  colIdx,
const MatrixBlock value 
)
inline

Overwrite the given block with a dense 7x7 block.

Parameters
[in]rowIdxBlock row index.
[in]colIdxBlock column index.
[in]valueDense block the stored entries are copied from. Its displacement-displacement off-diagonals are ignored.

References Opm::Linear::TpsaMatrix< Scalar >::blockAddress().

◆ spsp() [1/2]

template<class Scalar >
SPresSPresMatrixT< Scalar > & Opm::Linear::TpsaMatrix< Scalar >::spsp ( )
inline

Access the solid pressure-solid pressure sub-matrix.

Returns
Reference to the sub-matrix. Only meaningful after reserve().

◆ spsp() [2/2]

template<class Scalar >
const SPresSPresMatrixT< Scalar > & Opm::Linear::TpsaMatrix< Scalar >::spsp ( ) const
inline

Access the solid pressure-solid pressure sub-matrix.

Returns
Reference to the sub-matrix. Only meaningful after reserve().

Friends And Related Function Documentation

◆ TpsaBlockRef< Scalar >

template<class Scalar >
friend class TpsaBlockRef< Scalar >
friend

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