# DMGenerateRegister
Adds a grid generator to DM 
## Synopsis
```
#include "petscdm.h"          
PetscErrorCode DMGenerateRegister(const char sname[], PetscErrorCode (*fnc)(DM, PetscBool, DM *), PetscErrorCode (*rfnc)(DM, PetscReal *, DM *), PetscErrorCode (*alfnc)(DM, Vec, DMLabel, DMLabel, DM *), PetscInt dim)
```
Not Collective


## Input Parameters

- ***name_solver -*** name of a new user-defined grid generator
- ***fnc -*** generator function
- ***rfnc -*** refinement function
- ***alfnc -*** adapt by label function
- ***dim -*** dimension of boundary of domain



## Notes
DMGenerateRegister() may be called multiple times to add several user-defined solvers.


## Sample usage
```none
   DMGenerateRegister("my_generator",MyGeneratorCreate,MyGeneratorRefiner,MyGeneratorAdaptor,dim);
```


Then, your generator can be chosen with the procedural interface via
```none
DMGenerate(dm,"my_generator",...)
```
or at runtime via the option
```none
-dm_generator my_generator
```




## See Also
 `DMGenerateRegisterAll()`, `DMPlexGenerate()`, `DMGenerateRegisterDestroy()`


## Level
advanced

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


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/interface/dmgenerate.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)  
