# DMForestSetAdaptivityPurpose
During the pre-setup phase, set whether the current DM is being adapted from its source (set with DMForestSetAdaptivityForest()) for the purpose of refinement (DM_ADAPT_REFINE), coarsening (DM_ADAPT_COARSEN), or undefined (DM_ADAPT_DETERMINE).  This only matters for the purposes of reference counting: during DMDestroy(), cyclic references can be found between DMs only if the cyclic reference is due to a fine/coarse relationship (see DMSetFineDM()/DMSetCoarseDM()).  If the purpose is not refinement or coarsening, and the user does not maintain a reference to the post-adaptation forest (i.e., the one created by DMForestTemplate()), then this can cause a memory leak.  This method is used by subtypes of DMForest when automatically constructing mesh hierarchies. 
## Synopsis
```
#include "petscdmforest.h" 
#include "petscdm.h" 
#include "petscdmlabel.h" 
PetscErrorCode DMForestSetAdaptivityPurpose(DM dm, DMAdaptFlag purpose)
```
Logically collective on dm


## Input Parameters

- ***dm -*** the forest
- ***purpose -*** the adaptivity purpose





## See Also
 `DMForestTemplate()`, `DMForestSetAdaptivityForest()`, `DMForestGetAdaptivityForest()`, `DMAdaptFlag`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/forest/forest.c.html#DMForestSetAdaptivityPurpose">src/dm/impls/forest/forest.c</A>


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


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