Skip to main content
`Ctrl`+`K`

# DMDASetGetMatrix

Sets the routine used by the `DMDA` to allocate a matrix.

## Synopsis

    #include "petscdmda.h"
    PetscErrorCode DMDASetGetMatrix(DM da, PetscErrorCode (*f)(DM da, Mat *A))

Logically Collective; No Fortran Support

## Input Parameters

- da - the `DMDA` object

- f - the function that allocates the matrix for that specific `DMDA`

## Calling sequence of `f`

- da - the `DMDA` object

- A - the created matrix

## Notes

If the function is not provided a default function is used that uses the `DMDAStencilType`, `DMBoundaryType`, and value of `DMDASetStencilWidth()` to construct the matrix.

See `DMDASetBlockFills()` that provides a simple way to provide the nonzero structure for the diagonal and off-diagonal blocks of the matrix without providing a custom function

## Developer Note

This should be called `DMDASetCreateMatrix()`

## See Also

DMDA - Creating vectors for structured grids, `DM`, `DMDA`, `DMCreateMatrix()`, `DMDASetBlockFills()`

## Level

developer

## Location

src/dm/impls/da/da.c

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