:orphan: # 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 ## 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` ```none PetscErrorCode 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 of `endhook` ```none PetscErrorCode 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 [](ch_dmbase), `DM`, `DMGlobalToLocal()`, `DMRefineHookAdd()`, `SNESFASGetInterpolation()`, `SNESFASGetInjection()`, `PetscObjectCompose()`, `PetscContainerCreate()` ## Level advanced ## Location src/dm/interface/dm.c --- [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](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)