MatMPIAIJGetLocalMat — PETSc 3.22.5 documentation

Skip to main content
`Ctrl`+`K`

# MatMPIAIJGetLocalMat

Creates a `MATSEQAIJ` from a `MATMPIAIJ` matrix.

## Synopsis

    #include "petscmat.h"
    PetscErrorCode MatMPIAIJGetLocalMat(Mat A, MatReuse scall, Mat *A_loc)

Not Collective

## Input Parameters

- A - the matrix

- scall - either `MAT_INITIAL_MATRIX` or `MAT_REUSE_MATRIX`

## Output Parameter

- A_loc - the local sequential matrix generated

## Notes

The matrix is created by taking all `A`’s local rows and putting them into a sequential matrix with `mlocal` rows and `n` columns.`mlocal` is the row count obtained with `MatGetLocalSize()` and `n` is the global column count obtained with `MatGetSize()`.

In other words combines the two parts of a parallel `MATMPIAIJ` matrix on each process to a single matrix.

When `A` is sequential and `MAT_INITIAL_MATRIX` is requested, the matrix returned is the diagonal part of `A` (which contains the entire matrix), with its reference count increased by one. Hence changing values of `A_loc` changes `A`. If `MAT_REUSE_MATRIX` is requested on a sequential matrix then `MatCopy`(Adiag,*`A_loc`,`SAME_NONZERO_PATTERN`) is called to fill `A_loc`. Thus one can preallocate the appropriate sequential matrix `A_loc` and then call this routine with `MAT_REUSE_MATRIX`. In this case, one can modify the values of `A_loc` without affecting the original sequential matrix.

## See Also

Matrices, `Mat`, `MATMPIAIJ`, `MatGetOwnershipRange()`, `MatMPIAIJGetLocalMatCondensed()`, `MatMPIAIJGetLocalMatMerge()`

## Level

developer

## Location

src/mat/impls/aij/mpi/mpiaij.c

Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages