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

`#include <PETScNestMatrix.h>`

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

## Public Member Functions

| PETScNestMatrix ()
| Create empty matrix.
| PETScNestMatrix (std::vector< std::shared_ptr< GenericMatrix > > mats)
virtual | ~PETScNestMatrix ()
| Destructor.
virtual void | mult (const GenericVector &x, GenericVector &y) const
void | init_vectors (GenericVector &z_out, std::vector< std::shared_ptr< GenericVector > > z_in) const
void | get_block_dofs (std::vector< dolfin::la_index > &dofs, std::size_t idx) const
std::size_t | size (std::size_t dim) const
virtual std::string | str (bool verbose) const
Public Member Functions inherited from dolfin::PETScMatrix
| PETScMatrix ()
| Create empty matrix (on MPI_COMM_WORLD).
| PETScMatrix (MPI_Comm comm)
| Create empty matrix.
| PETScMatrix (Mat A)
| PETScMatrix (const PETScMatrix &A)
| Copy constructor.
virtual | ~PETScMatrix ()
| Destructor.
void | init (const TensorLayout &tensor_layout)
| Initialize zero tensor using tensor layout.
bool | is_nest ()
| Check is the matrix as nest type.
void | set_nest (std::vector< Mat > mats)
| Initialize or update a nested matrix from the list of its blocks.
bool | empty () const
| Return true if empty.
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)
MPI_Comm | mpi_comm () const
| Return MPI communicator.
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).
double | norm (std::string norm_type) const
| Return norm of matrix.
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 | 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 PETScMatrix & | operator*= (double a)
| Multiply matrix by given number.
virtual const PETScMatrix & | 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.
void | set_options_prefix (std::string options_prefix)
std::string | get_options_prefix () const
void | set_from_options ()
| Call PETSc function MatSetFromOptions on the PETSc Mat object.
const PETScMatrix & | operator= (const PETScMatrix &A)
| Assignment operator.
void | set_nullspace (const VectorSpaceBasis &nullspace)
void | set_near_nullspace (const VectorSpaceBasis &nullspace)
void | binary_dump (std::string file_name) const
| Dump matrix to PETSc binary format.
void | convert_to_aij ()
| Convert matrix to AIJ format.
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
Public Member Functions inherited from dolfin::PETScBaseMatrix
| PETScBaseMatrix ()
| Constructor.
| PETScBaseMatrix (Mat A)
| Constructor.
| PETScBaseMatrix (const PETScBaseMatrix &A)
| Copy constructor.
| ~PETScBaseMatrix ()
| Destructor.
std::size_t | size (std::size_t dim) const
| Return number of rows (dim = 0) or columns (dim = 1).
std::pair< std::int64_t, std::int64_t > | size () const
std::pair< std::int64_t, std::int64_t > | local_range (std::size_t dim) const
| Return local range along dimension dim.
void | init_vector (GenericVector &z, std::size_t dim) const
Mat | mat () const
| Return PETSc Mat pointer.
MPI_Comm | mpi_comm () const
| Return the MPI communicator.
Public Member Functions inherited from dolfin::PETScObject
| PETScObject ()
| Constructor. Ensures that PETSc has been initialised.
virtual | ~PETScObject ()
| Destructor.

## Additional Inherited Members

Static Public Member Functions inherited from dolfin::PETScObject
static void | petsc_error (int error_code, std::string filename, std::string petsc_function)
| Print error message for PETSc calls that return an error.
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)
Protected Attributes inherited from dolfin::PETScBaseMatrix
Mat | _matA

## Detailed Description

PETScNestMatrix creates an NxN nested matrix from a list of 'sub-matrices' in order from top left down to bottom right. Therefore the number of matrices supplied must be a perfect square. If any matrices are empty, a NULL pointer can be supplied.

## Constructor & Destructor Documentation

## PETScNestMatrix()

PETScNestMatrix::PETScNestMatrix | ( | std::vector< std::shared_ptr< GenericMatrix > > | mats | ) |

explicit

Create a nested Matrix from a list of matrices

Parameters

  mats | - list of matrices

## Member Function Documentation

## get_block_dofs()

void PETScNestMatrix::get_block_dofs | ( | std::vector< dolfin::la_index > & | dofs,
|  | std::size_t | idx ) const

Get dofs for each block

Parameters

  dofs | - return list of dof indices for a given block
  idx | - index of block

## init_vectors()

void PETScNestMatrix::init_vectors | ( | GenericVector & | z_out,
|  | std::vector< std::shared_ptr< GenericVector > > | z_in ) const

Initialise a nest vector for use with matrix

Parameters

  z_out | - Vector to initialise
  z_in | - list of Vectors to nest into z_out

## mult()

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

virtual

Mat-Vec multiply

Parameters

  x | - input vector
  y | - output vector y = A*x

Reimplemented from dolfin::PETScMatrix.

## size()

std::size_t dolfin::PETScNestMatrix::size | ( | std::size_t | dim | ) | const

inline virtual

Return size of given dimension

Parameters

  dim | - dimension (0 or 1)

Reimplemented from dolfin::PETScMatrix.

## str()

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

virtual

Text description

Parameters

  verbose |

Reimplemented from dolfin::PETScMatrix.

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

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