# 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, Vec, InsertMode, Vec, void *), PetscErrorCode (*endhook)(DM, Vec, InsertMode, Vec, void *), void *ctx)
```
Logically Collective on dm


## 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 for beginhook
```none
beginhook(DM fine,VecScatter out,VecScatter in,DM coarse,void *ctx)
```


- ***dm -*** global DM
- ***g -*** global vector
- ***mode -*** mode
- ***l -*** local vector
- ***ctx -*** optional user-defined function context



## Calling sequence for endhook
```none
endhook(DM fine,VecScatter out,VecScatter in,DM coarse,void *ctx)
```


- ***global -*** global DM
- ***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`, `DMGlobalToLocal()`, `DMRefineHookAdd()`, `SNESFASGetInterpolation()`, `SNESFASGetInjection()`, `PetscObjectCompose()`, `PetscContainerCreate()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/interface/dm.c.html#DMGlobalToLocalHookAdd">src/dm/interface/dm.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/interface/dm.c)


[Index of all DM routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
