Loading...
Searching...
No Matches
dolfin::TpetraMatrix Class Reference

`#include <TpetraMatrix.h>`

Inheritance diagram for dolfin::TpetraMatrix:
[legend]
Collaboration diagram for dolfin::TpetraMatrix:
[legend]

## Public Types

typedef Tpetra::CrsMatrix< double, int, dolfin::la_index > | matrix_type
| Matrix type (scalar, local index, global index).
typedef Tpetra::CrsGraph< int, dolfin::la_index > | graph_type
| Graph type (local index, global index).
typedef Tpetra::Map< int, dolfin::la_index > | map_type
| Map type (local index, global index).

## Public Member Functions

| TpetraMatrix ()
| Create empty matrix.
| TpetraMatrix (Teuchos::RCP< matrix_type > A)
| Create a wrapper around a Teuchos::RCP<matrix_type> pointer.
| TpetraMatrix (const TpetraMatrix &A)
| Copy constructor.
virtual | ~TpetraMatrix ()
| Destructor.
void | init (const TensorLayout &tensor_layout)
| Initialize zero tensor using tensor layout.
bool | empty () const
| Return true if empty.
std::size_t | size (std::size_t dim) const
| Return size of given dimension.
std::pair< std::int64_t, std::int64_t > | local_range (std::size_t dim) const
| Return local ownership range.
std::size_t | nnz () const
| Return number of non-zero entries in matrix (collective).
virtual void | zero ()
| Set all entries to zero and keep any sparse structure.
virtual void | apply (std::string mode)
| Finalize assembly of tensor. The mode parameter is ignored.
MPI_Comm | mpi_comm () const
| Return MPI communicator.
virtual std::string | str (bool verbose) const
| Return informal string representation (pretty-print).
virtual std::shared_ptr< GenericMatrix > | copy () const
| Return copy of matrix.
virtual void | init_vector (GenericVector &z, std::size_t dim) const
virtual void | get (double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols) const
| Get block of values.
virtual void | set (const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)
| Set block of values using global indices.
virtual void | set_local (const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)
| Set block of values using local indices.
virtual void | add (const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)
| Add block of values using global indices.
virtual void | add_local (const double *block, std::size_t m, const dolfin::la_index *rows, std::size_t n, const dolfin::la_index *cols)
| Add block of values using local indices.
virtual void | axpy (double a, const GenericMatrix &A, bool same_nonzero_pattern)
| Add multiple of given matrix (AXPY operation).
virtual void | getrow (std::size_t row, std::vector< std::size_t > &columns, std::vector< double > &values) const
| Get non-zero values of given row.
virtual void | setrow (std::size_t row, const std::vector< std::size_t > &columns, const std::vector< double > &values)
| Set values for given row.
virtual void | zero (std::size_t m, const dolfin::la_index *rows)
| Set given rows (global row indices) to zero.
virtual void | zero_local (std::size_t m, const dolfin::la_index *rows)
| Set given rows (local row indices) to zero.
virtual void | ident (std::size_t m, const dolfin::la_index *rows)
| Set given rows (global row indices) to identity matrix.
virtual void | ident_local (std::size_t m, const dolfin::la_index *rows)
| Set given rows (local row indices) to identity matrix.
virtual void | mult (const GenericVector &x, GenericVector &y) const
| Compute matrix-vector product y = Ax.
virtual void | transpmult (const GenericVector &x, GenericVector &y) const
virtual void | get_diagonal (GenericVector &x) const
| Get diagonal of a matrix.
virtual void | set_diagonal (const GenericVector &x)
| Set diagonal of a matrix.
virtual const TpetraMatrix & | operator*= (double a)
| Multiply matrix by given number.
virtual const TpetraMatrix & | operator/= (double a)
| Divide matrix by given number.
virtual const GenericMatrix & | operator= (const GenericMatrix &A)
| Assignment operator.
virtual bool | is_symmetric (double tol) const
| Test if matrix is symmetric.
virtual GenericLinearAlgebraFactory & | factory () const
| Return linear algebra backend factory.
double | norm (std::string norm_type) const
| Return norm of matrix.
const TpetraMatrix & | operator= (const TpetraMatrix &A)
| Assignment operator.
Teuchos::RCP< matrix_type > | mat ()
| Return Teuchos reference counted pointer to raw matrix.
Teuchos::RCP< const matrix_type > | mat () const
| Return Teuchos reference counted pointer to raw matrix (const).
Public Member Functions inherited from dolfin::GenericMatrix
virtual | ~GenericMatrix ()
| Destructor.
virtual std::size_t | rank () const
| Return tensor rank (number of dimensions).
virtual void | get (double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows) const
| Get block of values.
virtual void | set (const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)
| Set block of values using global indices.
virtual void | set_local (const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)
| Set block of values using local indices.
virtual void | add (const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)
| Add block of values using global indices.
virtual void | add_local (const double *block, const dolfin::la_index *num_rows, const dolfin::la_index *const *rows)
| Add block of values using local indices.
virtual void | add (const double *block, const std::vector< ArrayView< const dolfin::la_index > > &rows)
| Add block of values using global indices.
virtual void | add_local (const double *block, const std::vector< ArrayView< const dolfin::la_index > > &rows)
| Add block of values using local indices.
const GenericMatrix & | operator+= (const GenericMatrix &A)
| Add given matrix.
const GenericMatrix & | operator-= (const GenericMatrix &A)
| Subtract given matrix.
virtual double | operator() (dolfin::la_index i, dolfin::la_index j) const
| Get value of given entry.
virtual double | getitem (std::pair< dolfin::la_index, dolfin::la_index > ij) const
| Get value of given entry.
virtual void | setitem (std::pair< dolfin::la_index, dolfin::la_index > ij, double value)
virtual void | ident_zeros (double tol=DOLFIN_EPS)
| Insert one on the diagonal for all zero rows.
Public Member Functions inherited from dolfin::GenericTensor
virtual | ~GenericTensor ()
| Destructor.
Public Member Functions inherited from dolfin::LinearAlgebraObject
virtual const LinearAlgebraObject * | instance () const
| Return concrete instance / unwrap (const version).
virtual LinearAlgebraObject * | instance ()
| Return concrete instance / unwrap (non-const version).
virtual std::shared_ptr< const LinearAlgebraObject > | shared_instance () const
| Return concrete shared ptr instance / unwrap (const version).
virtual std::shared_ptr< LinearAlgebraObject > | shared_instance ()
| Return concrete shared ptr instance / unwrap (non-const version).
Public Member Functions inherited from dolfin::Variable
| Variable ()
| Create unnamed variable.
| Variable (const std::string name, const std::string label)
| Create variable with given name and label.
| Variable (const Variable &variable)
| Copy constructor.
virtual | ~Variable ()
| Destructor.
const Variable & | operator= (const Variable &variable)
| Assignment operator.
void | rename (const std::string name, const std::string label)
| Rename variable.
std::string | name () const
| Return name.
std::string | label () const
| Return label (description).
std::size_t | id () const

## Static Public Member Functions

static void | graphdump (const Teuchos::RCP< const graph_type > graph)
| Print out a graph, for debugging.

## Additional Inherited Members

Public Attributes inherited from dolfin::Variable
Parameters | parameters
| Parameters.
Protected Member Functions inherited from dolfin::GenericLinearOperator
virtual void | init_layout (const GenericVector &x, const GenericVector &y, GenericLinearOperator *wrapper)

## Detailed Description

This class provides a simple matrix class based on Tpetra. It is a wrapper for a Tpetra matrix pointer (Teuchos::RCP<matrix_type>) implementing the GenericMatrix interface.

The interface is intentionally simple. For advanced usage, access the Tpetra::RCP<matrix_type> pointer using the function mat() and use the standard Tpetra interface.

## Member Function Documentation

## add()

void TpetraMatrix::add | ( | const double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows,
|  | std::size_t | n,
|  | const dolfin::la_index * | cols )

virtual

Add block of values using global indices.

Implements dolfin::GenericMatrix.

## add_local()

void TpetraMatrix::add_local | ( | const double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows,
|  | std::size_t | n,
|  | const dolfin::la_index * | cols )

virtual

Add block of values using local indices.

Implements dolfin::GenericMatrix.

## apply()

void TpetraMatrix::apply | ( | std::string | mode | ) |

virtual

Finalize assembly of tensor. The mode parameter is ignored.

Implements dolfin::GenericMatrix.

## axpy()

void TpetraMatrix::axpy | ( | double | a,
|  | const GenericMatrix & | A,
|  | bool | same_nonzero_pattern )

virtual

Add multiple of given matrix (AXPY operation).

Implements dolfin::GenericMatrix.

## copy()

std::shared_ptr< GenericMatrix > TpetraMatrix::copy | ( |  | ) | const

virtual

Return copy of matrix.

Implements dolfin::GenericMatrix.

## empty()

bool TpetraMatrix::empty | ( |  | ) | const

virtual

Return true if empty.

Implements dolfin::GenericTensor.

## factory()

GenericLinearAlgebraFactory & TpetraMatrix::factory | ( |  | ) | const

virtual

Return linear algebra backend factory.

Implements dolfin::GenericTensor.

## get()

void TpetraMatrix::get | ( | double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows,
|  | std::size_t | n,
|  | const dolfin::la_index * | cols ) const

virtual

Get block of values.

Implements dolfin::GenericMatrix.

## get_diagonal()

void TpetraMatrix::get_diagonal | ( | GenericVector & | x | ) | const

virtual

Get diagonal of a matrix.

Implements dolfin::GenericMatrix.

## getrow()

void TpetraMatrix::getrow | ( | std::size_t | row,
|  | std::vector< std::size_t > & | columns,
|  | std::vector< double > & | values ) const

virtual

Get non-zero values of given row.

Implements dolfin::GenericMatrix.

## ident()

void TpetraMatrix::ident | ( | std::size_t | m,
|  | const dolfin::la_index * | rows )

virtual

Set given rows (global row indices) to identity matrix.

Implements dolfin::GenericMatrix.

## ident_local()

void TpetraMatrix::ident_local | ( | std::size_t | m,
|  | const dolfin::la_index * | rows )

virtual

Set given rows (local row indices) to identity matrix.

Implements dolfin::GenericMatrix.

## init()

void TpetraMatrix::init | ( | const TensorLayout & | tensor_layout | ) |

virtual

Initialize zero tensor using tensor layout.

Implements dolfin::GenericTensor.

## init_vector()

void TpetraMatrix::init_vector | ( | GenericVector & | z,
|  | std::size_t | dim ) const

virtual

Initialize vector z to be compatible with the matrix-vector product y = Ax. In the parallel case, both size and layout are important.

Parameters

  z | (GenericVector&) Vector to initialise
  dim | (std::size_t) The dimension (axis): dim = 0 --> z = y, dim = 1 --> z = x

Implements dolfin::GenericMatrix.

## is_symmetric()

bool TpetraMatrix::is_symmetric | ( | double | tol | ) | const

virtual

Test if matrix is symmetric.

Reimplemented from dolfin::GenericMatrix.

## local_range()

std::pair< std::int64_t, std::int64_t > TpetraMatrix::local_range | ( | std::size_t | dim | ) | const

virtual

Return local ownership range.

Implements dolfin::GenericMatrix.

## mpi_comm()

MPI_Comm TpetraMatrix::mpi_comm | ( |  | ) | const

virtual

Return MPI communicator.

Implements dolfin::LinearAlgebraObject.

## mult()

void TpetraMatrix::mult | ( | const GenericVector & | x,
|  | GenericVector & | y ) const

virtual

Compute matrix-vector product y = Ax.

Implements dolfin::GenericLinearOperator.

## nnz()

std::size_t TpetraMatrix::nnz | ( |  | ) | const

virtual

Return number of non-zero entries in matrix (collective).

Implements dolfin::GenericMatrix.

## norm()

double TpetraMatrix::norm | ( | std::string | norm_type | ) | const

virtual

Return norm of matrix.

Implements dolfin::GenericMatrix.

## operator*=()

const TpetraMatrix & TpetraMatrix::operator*= | ( | double | a | ) |

virtual

Multiply matrix by given number.

Implements dolfin::GenericMatrix.

## operator/=()

const TpetraMatrix & TpetraMatrix::operator/= | ( | double | a | ) |

virtual

Divide matrix by given number.

Implements dolfin::GenericMatrix.

## operator=()

const GenericMatrix & TpetraMatrix::operator= | ( | const GenericMatrix & | A | ) |

virtual

Assignment operator.

Implements dolfin::GenericMatrix.

## set()

void TpetraMatrix::set | ( | const double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows,
|  | std::size_t | n,
|  | const dolfin::la_index * | cols )

virtual

Set block of values using global indices.

Implements dolfin::GenericMatrix.

## set_diagonal()

void TpetraMatrix::set_diagonal | ( | const GenericVector & | x | ) |

virtual

Set diagonal of a matrix.

Implements dolfin::GenericMatrix.

## set_local()

void TpetraMatrix::set_local | ( | const double * | block,
|  | std::size_t | m,
|  | const dolfin::la_index * | rows,
|  | std::size_t | n,
|  | const dolfin::la_index * | cols )

virtual

Set block of values using local indices.

Implements dolfin::GenericMatrix.

## setrow()

void TpetraMatrix::setrow | ( | std::size_t | row,
|  | const std::vector< std::size_t > & | columns,
|  | const std::vector< double > & | values )

virtual

Set values for given row.

Implements dolfin::GenericMatrix.

## size()

std::size_t TpetraMatrix::size | ( | std::size_t | dim | ) | const

virtual

Return size of given dimension.

Implements dolfin::GenericMatrix.

## str()

std::string TpetraMatrix::str | ( | bool | verbose | ) | const

virtual

Return informal string representation (pretty-print).

Implements dolfin::GenericMatrix.

## transpmult()

void TpetraMatrix::transpmult | ( | const GenericVector & | x,
|  | GenericVector & | y ) const

virtual

Matrix-vector product, y = A^T x. The y vector must either be zero-sized or have correct size and parallel layout.

Implements dolfin::GenericMatrix.

## zero() [1/2]

void TpetraMatrix::zero | ( |  | ) |

virtual

Set all entries to zero and keep any sparse structure.

Implements dolfin::GenericMatrix.

## zero() [2/2]

void TpetraMatrix::zero | ( | std::size_t | m,
|  | const dolfin::la_index * | rows )

virtual

Set given rows (global row indices) to zero.

Implements dolfin::GenericMatrix.

## zero_local()

void TpetraMatrix::zero_local | ( | std::size_t | m,
|  | const dolfin::la_index * | rows )

virtual

Set given rows (local row indices) to zero.

Implements dolfin::GenericMatrix.

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

- /build/dolfin-wwk1CC/dolfin-2019.2.0~legacy20240219.1c52e83/dolfin/la/TpetraMatrix.h
- /build/dolfin-wwk1CC/dolfin-2019.2.0~legacy20240219.1c52e83/dolfin/la/TpetraMatrix.cpp