DOLFINx
0.1.0
DOLFINx C++ interface
|
It is a simple wrapper for a PETSc matrix pointer (Mat). Its main purpose is to assist memory management of PETSc Mat objects. More...
#include <PETScMatrix.h>
Public Types | |
enum | AssemblyType : std::int32_t { FINAL, FLUSH } |
Assembly type FINAL - corresponds to PETSc MAT_FINAL_ASSEMBLY FLUSH - corresponds to PETSc MAT_FLUSH_ASSEMBLY. | |
Public Member Functions | |
PETScMatrix (MPI_Comm comm, const SparsityPattern &sparsity_pattern, const std::string &type=std::string()) | |
Create holder for a PETSc Mat object from a sparsity pattern. | |
PETScMatrix (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 the PETScMatrix. | |
PETScMatrix (const PETScMatrix &A)=delete | |
PETScMatrix (PETScMatrix &&A)=default | |
Move constructor (falls through to base class move constructor) | |
~PETScMatrix ()=default | |
Destructor. | |
PETScMatrix & | operator= (const PETScMatrix &A)=delete |
Assignment operator (deleted) | |
PETScMatrix & | operator= (PETScMatrix &&A)=default |
Move assignment operator. | |
void | apply (AssemblyType type) |
Finalize assembly of tensor. The following values are recognized for the mode parameter: More... | |
double | norm (la::Norm norm_type) const |
Return norm of matrix. | |
void | set_options_prefix (std::string options_prefix) |
Sets the prefix used by PETSc when searching the options database. | |
std::string | get_options_prefix () const |
Returns the prefix used by PETSc when searching the options database. | |
void | set_from_options () |
Call PETSc function MatSetFromOptions on the PETSc Mat object. | |
void | set_nullspace (const la::VectorSpaceBasis &nullspace) |
Attach nullspace to matrix (typically used by Krylov solvers when solving singular systems) | |
void | set_near_nullspace (const la::VectorSpaceBasis &nullspace) |
Attach 'near' nullspace to matrix (used by preconditioners, such as smoothed aggregation algerbraic multigrid) | |
![]() | |
PETScOperator (Mat A, bool inc_ref_count) | |
Constructor. | |
PETScOperator (const PETScOperator &A)=delete | |
PETScOperator (PETScOperator &&A) | |
Move constructor. | |
virtual | ~PETScOperator () |
Destructor. | |
PETScOperator & | operator= (const PETScOperator &A)=delete |
Assignment operator (deleted) | |
PETScOperator & | operator= (PETScOperator &&A) |
Move assignment operator. | |
std::array< std::int64_t, 2 > | size () const |
Return number of rows and columns (num_rows, num_cols). PETSc returns -1 if size has not been set. | |
PETScVector | create_vector (std::size_t dim) const |
Initialize vector to be compatible with the matrix-vector product y = Ax. In the parallel case, size and layout are both important. More... | |
Mat | mat () const |
Return PETSc Mat pointer. | |
Static Public Member Functions | |
static std::function< int(std::int32_t, const std::int32_t *, std::int32_t, const std::int32_t *, const PetscScalar *)> | set_fn (Mat A, InsertMode mode) |
Return a function with an interface for adding or inserting values into the matrix A (calls MatSetValuesLocal) More... | |
static std::function< int(std::int32_t, const std::int32_t *, std::int32_t, const std::int32_t *, const PetscScalar *)> | set_block_fn (Mat A, InsertMode mode) |
Return a function with an interface for adding or inserting values into the matrix A using blocked indices (calls MatSetValuesBlockedLocal) More... | |
static std::function< int(std::int32_t, const std::int32_t *, std::int32_t, const std::int32_t *, const PetscScalar *)> | set_block_expand_fn (Mat A, int bs0, int bs1, InsertMode mode) |
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. More... | |
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.
void PETScMatrix::apply | ( | AssemblyType | type | ) |
Finalize assembly of tensor. The following values are recognized for the mode parameter:
type | FINAL - corresponds to PETSc MatAssemblyBegin+End(MAT_FINAL_ASSEMBLY) FLUSH - corresponds to PETSc MatAssemblyBegin+End(MAT_FLUSH_ASSEMBLY) |
|
static |
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.
[in] | A | The matrix to set values in |
[in] | bs0 | Block size for the matrix rows |
[in] | bs1 | Block size for the matrix columns |
[in] | mode | The PETSc insert mode (ADD_VALUES, INSERT_VALUES, ...) |
|
static |
Return a function with an interface for adding or inserting values into the matrix A using blocked indices (calls MatSetValuesBlockedLocal)
[in] | A | The matrix to set values in |
[in] | mode | The PETSc insert mode (ADD_VALUES, INSERT_VALUES, ...) |
|
static |
Return a function with an interface for adding or inserting values into the matrix A (calls MatSetValuesLocal)
[in] | A | The matrix to set values in |
[in] | mode | The PETSc insert mode (ADD_VALUES, INSERT_VALUES, ...) |