MatCreateKAIJ#
Creates a matrix of type MATKAIJ.
Synopsis#
#include "petscmat.h"
PetscErrorCode MatCreateKAIJ(Mat A, PetscInt p, PetscInt q, const PetscScalar S[], const PetscScalar T[], Mat *kaij)
Collective
Input Parameters#
A - the
MATAIJmatrixp - number of rows in
SandTq - number of columns in
SandTS - the
Smatrix (can beNULL), stored as aPetscScalararray (column-major)T - the
Tmatrix (can beNULL), stored as aPetscScalararray (column-major)
Output Parameter#
kaij - the new
MATKAIJmatrix
Notes#
The created matrix is of the following form:
[I \otimes S + A \otimes T]
where
S is a dense (p \times q) matrix
T is a dense (p \times q) matrix
A is a `MATAIJ` (n \times n) matrix
I is the identity matrix
The resulting matrix is (np \times nq)
S and T are always stored independently on all processes as PetscScalar arrays in
column-major format.
This function increases the reference count on the MATAIJ matrix, so the user is free to destroy the matrix if it is not needed.
Changes to the entries of the MATAIJ matrix will immediately affect the MATKAIJ matrix, so MatMult() and the other operations
always use the current entries. Reassembling an operand does not, however, raise the object state of the MATKAIJ matrix itself, and
a PC decides whether to rebuild from that state, so follow the reassembly with MatAssemblyBegin()/MatAssemblyEnd() on the
MATKAIJ matrix, exactly as for any other matrix handed to a KSP; otherwise the preconditioner is reused unchanged. Assembling the
MATKAIJ matrix forwards the operands’ nonzero states to it, so a PC sees a changed nonzero pattern only when an operand’s pattern
actually changed. Changing S or T with MatKAIJSetS(), MatKAIJSetT(), or MatKAIJRestoreS()/MatKAIJRestoreT() raises the
state on its own.
Developer Notes#
In the MATMPIKAIJ case, the internal ‘AIJ’ and ‘OAIJ’ sequential KAIJ matrices are kept up to date by tracking the object state
of the A matrix that describes the blockwise action of the MATMPIKAIJ matrix and, if the object state has changed, lazily
rebuilding ‘AIJ’ and ‘OAIJ’ just before executing operations with the MATMPIKAIJ matrix. If new types of operations are added,
routines implementing those must also ensure these are rebuilt when needed (by calling the internal MatKAIJ_build_AIJ_OAIJ() routine).
That rebuild is local. It only marks the ghost scatter stale, and the next MatMult() checks, and possibly rebuilds, the
scatter collectively.
See Also#
Matrices, Mat, MatCreateKAIJAB(), MatKAIJSetA(), MatKAIJSetS(), MatKAIJSetT(), MatKAIJGetA(), MatKAIJGetS(), MatKAIJGetT(), MATKAIJ
Level#
advanced
Location#
Examples#
src/mat/tests/ex177.c
src/mat/tests/ex248.c
src/mat/tests/ex277.c
src/ksp/ksp/tutorials/ex74.c
src/ksp/ksp/tutorials/ex77.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages