Skip to main content
`Ctrl`+`K`

# DMLocalToGlobalHookAdd

adds a callback to be run when a local to global is called

## Synopsis

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

Logically Collective

## Input Parameters

- dm - the `DM`

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

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

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

## Calling sequence of `beginhook`

- global - global `DM`

- l - local vector

- mode - mode

- g - global vector

- ctx - optional function context

## Calling sequence of `endhook`

- global - global `DM`

- l - local vector

- mode - mode

- g - global vector

- ctx - optional function context

## See Also

DM Basics, `DM`, `DMLocalToGlobal()`, `DMRefineHookAdd()`, `DMGlobalToLocalHookAdd()`, `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