Skip to main content
`Ctrl`+`K`

# DMSubDomainHookAdd

adds a callback to be run when restricting a problem to subdomain `DM`s with `DMCreateDomainDecomposition()`

## Synopsis

    #include "petscdm.h"
    #include "petscdmlabel.h"
    #include "petscds.h"
    PetscErrorCode DMSubDomainHookAdd(DM global, PetscErrorCode (*ddhook)(DM global, DM block, void *ctx), PetscErrorCode (*restricthook)(DM global, VecScatter out, VecScatter in, DM block, void *ctx), void *ctx)

Logically Collective; No Fortran Support

## Input Parameters

- global - global `DM`

- ddhook - function to run to pass data to the decomposition `DM` upon its creation

- restricthook - function to run to update data on block solve (at the beginning of the block solve)

- ctx - [optional] user-defined context for provide data for the hooks (may be `NULL`)

## Calling sequence of `ddhook`

- global - global `DM`

- block - subdomain `DM`

- ctx - optional user-defined function context

## Calling sequence of `restricthook`

- global - global `DM`

- out - scatter to the outer (with ghost and overlap points) sub vector

- in - scatter to sub vector values only owned locally

- block - subdomain `DM`

- ctx - optional user-defined function context

## Notes

This function can be used if auxiliary data needs to be set up on subdomain `DM`s.

If this function is called multiple times, the hooks will be run in the order they are added.

In order to compose with nonlinear preconditioning without duplicating storage, the hook should be implemented to extract the global information from its context (instead of from the `SNES`).

## Developer Note

It is unclear what “block solve” means within the definition of `restricthook`

## See Also

DM Basics, `DM`, `DMSubDomainHookRemove()`, `DMRefineHookAdd()`, `SNESFASGetInterpolation()`, `SNESFASGetInjection()`, `PetscObjectCompose()`, `PetscContainerCreate()`, `DMCreateDomainDecomposition()`

## Level

advanced

## Location

src/dm/interface/dm.c

## Examples

src/ts/tutorials/ex29.c

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