Skip to main content
`Ctrl`+`K`

# DMDASNESSetFunctionLocal

set a local residual evaluation function for use with `DMDA`

## Synopsis

    #include "petscdmda.h"
    #include "petscsnes.h"
    PetscErrorCode DMDASNESSetFunctionLocal(DM dm, InsertMode imode, PetscErrorCode (*func)(DMDALocalInfo *info, void *x, void *f, void *ctx), void *ctx)

Logically Collective

## Input Parameters

- dm - `DM` to associate callback with

- imode - `INSERT_VALUES` if local function computes owned part, `ADD_VALUES` if it contributes to ghosted part

- func - local residual evaluation

- ctx - optional context for local residual evaluation

## Calling sequence of `func`

- info - `DMDALocalInfo` defining the subdomain to evaluate the residual on

- x - dimensional pointer to state at which to evaluate residual (e.g. PetscScalar *x or **x or ***x)

- f - dimensional pointer to residual, write the residual here (e.g. PetscScalar *f or **f or ***f)

- ctx - optional context passed above

## See Also

SNES: Nonlinear Solvers, `DMDA`, `DMDASNESSetJacobianLocal()`, `DMSNESSetFunction()`, `DMDACreate1d()`, `DMDACreate2d()`, `DMDACreate3d()`

## Level

beginner

## Location

src/snes/utils/dmdasnes.c

## Examples

src/snes/tutorials/ex25.c
src/snes/tutorials/ex46.c
src/snes/tutorials/ex48.c
src/snes/tutorials/ex15.c
src/snes/tutorials/ex33.c
src/snes/tutorials/ex4.c
src/snes/tutorials/ex19.c
src/snes/tutorials/ex40f90.F90
src/snes/tutorials/ex16.c
src/snes/tutorials/ex30.c

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