Skip to main content
`Ctrl`+`K`

# DMGlobalToLocalHookAdd

adds a callback to be run when `DMGlobalToLocal()` is called

## Synopsis

    #include "petscdm.h"
    #include "petscdmlabel.h"
    #include "petscds.h"
    PetscErrorCode DMGlobalToLocalHookAdd(DM dm, PetscErrorCode (*beginhook)(DM dm, Vec g, InsertMode mode, Vec l, void *ctx), PetscErrorCode (*endhook)(DM dm, Vec g, InsertMode mode, Vec l, void *ctx), void *ctx)

Logically Collective

## Input Parameters

- dm - the `DM`

- beginhook - function to run at the beginning of `DMGlobalToLocalBegin()`

- endhook - function to run after `DMGlobalToLocalEnd()` has completed

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

## Calling sequence of `beginhook`

- dm - global `DM`

- g - global vector

- mode - mode

- l - local vector

- ctx - optional user-defined function context

## Calling sequence of `endhook`

- dm - global `DM`

- g - global vector

- mode - mode

- l - local vector

- ctx - optional user-defined function context

## Note

The hook may be used to provide, for example, values that represent boundary conditions in the local vectors that do not exist on the global vector.

## See Also

DM Basics, `DM`, `DMGlobalToLocal()`, `DMRefineHookAdd()`, `SNESFASGetInterpolation()`, `SNESFASGetInjection()`, `PetscObjectCompose()`, `PetscContainerCreate()`

## Level

advanced

## Location

src/dm/interface/dm.c

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