Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/de/d18/classdolfinx_1_1la_1_1petsc_1_1Matrix.html
DOLFINx 0.8.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Matrix Class Reference

#include <petsc.h>

Inheritance diagram for Matrix:
Inheritance graph
[legend]
Collaboration diagram for Matrix:
Collaboration graph
[legend]

Public Types

enum class  AssemblyType : std::int32_t { FINAL , FLUSH }
 

Public Member Functions

 Matrix (MPI_Comm comm, const SparsityPattern &sp, std::string type=std::string())
 Create holder for a PETSc Mat object from a sparsity pattern.
 
 Matrix (Mat A, bool inc_ref_count)
 
 Matrix (const Matrix &A)=delete
 
 Matrix (Matrix &&A)=default
 Move constructor (falls through to base class move constructor)
 
 ~Matrix ()=default
 Destructor.
 
Matrixoperator= (const Matrix &A)=delete
 Assignment operator (deleted)
 
Matrixoperator= (Matrix &&A)=default
 Move assignment operator.
 
void apply (AssemblyType type)
 
double norm (Norm norm_type) const
 Return norm of matrix.
 
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.
 
- Public Member Functions inherited from Operator
 Operator (Mat A, bool inc_ref_count)
 Constructor.
 
 Operator (const Operator &A)=delete
 
 Operator (Operator &&A)
 Move constructor.
 
virtual ~Operator ()
 Destructor.
 
Operatoroperator= (const Operator &A)=delete
 Assignment operator (deleted)
 
Operatoroperator= (Operator &&A)
 Move assignment operator.
 
std::array< std::int64_t, 2 > size () const
 
Vec create_vector (std::size_t dim) const
 
Mat mat () const
 Return PETSc Mat pointer.
 

Static Public Member Functions

static auto set_fn (Mat A, InsertMode mode)
 
static auto set_block_fn (Mat A, InsertMode mode)
 
static auto set_block_expand_fn (Mat A, int bs0, int bs1, InsertMode mode)
 

Detailed Description

It is a simple wrapper for a PETSc matrix pointer (Mat). Its main purpose is to assist memory management of PETSc Mat objects.

For advanced usage, access the PETSc Mat pointer using the function mat() and use the standard PETSc interface.

Member Enumeration Documentation

◆ AssemblyType

enum class AssemblyType : std::int32_t
strong

Assembly type FINAL - corresponds to PETSc MAT_FINAL_ASSEMBLY FLUSH - corresponds to PETSc MAT_FLUSH_ASSEMBLY

Constructor & Destructor Documentation

◆ Matrix()

Matrix ( Mat A,
bool inc_ref_count )

Create holder of a PETSc Mat object/pointer. The Mat A object should already be created. If inc_ref_count is true, the reference counter of the Mat will be increased. The Mat reference count will always be decreased upon destruction of the petsc::Matrix.

Member Function Documentation

◆ apply()

void apply ( AssemblyType type)

Finalize assembly of tensor. The following values are recognized for the mode parameter:

Parameters
typeFINAL - corresponds to PETSc MatAssemblyBegin+End(MAT_FINAL_ASSEMBLY) FLUSH - corresponds to PETSc MatAssemblyBegin+End(MAT_FLUSH_ASSEMBLY)

◆ get_options_prefix()

std::string get_options_prefix ( ) const

Returns the prefix used by PETSc when searching the options database

◆ set_block_expand_fn()

static auto set_block_expand_fn ( Mat A,
int bs0,
int bs1,
InsertMode mode )
inlinestatic

Return a function with an interface for adding or inserting blocked values to the matrix A using non-blocked insertion (calls MatSetValuesLocal). Internally it expands the blocked indices into non-blocked arrays.

Parameters
[in]AThe matrix to set values in
[in]bs0Block size for the matrix rows
[in]bs1Block size for the matrix columns
[in]modeThe PETSc insert mode (ADD_VALUES, INSERT_VALUES, ...)

◆ set_block_fn()

static auto set_block_fn ( Mat A,
InsertMode mode )
inlinestatic

Return a function with an interface for adding or inserting values into the matrix A using blocked indices (calls MatSetValuesBlockedLocal)

Parameters
[in]AThe matrix to set values in
[in]modeThe PETSc insert mode (ADD_VALUES, INSERT_VALUES, ...)

◆ set_fn()

static auto set_fn ( Mat A,
InsertMode mode )
inlinestatic

Return a function with an interface for adding or inserting values into the matrix A (calls MatSetValuesLocal)

Parameters
[in]AThe matrix to set values in
[in]modeThe PETSc insert mode (ADD_VALUES, INSERT_VALUES, ...)

◆ set_options_prefix()

void set_options_prefix ( std::string options_prefix)

Sets the prefix used by PETSc when searching the options database


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