# DMStagVecSplitToDMDA
create a DMDA and `Vec` from a DMStag and `Vec` 
## Synopsis
```
PetscErrorCode DMStagVecSplitToDMDA(DM dm, Vec vec, DMStagStencilLocation loc, PetscInt c, DM *pda, Vec *pdavec)
```
Logically Collective

High-level helper function which accepts a DMStag, a global vector, and location/dof,
and generates a corresponding DMDA and Vec.


## Input Parameters

- ***dm -*** the DMStag object
- ***vec-*** Vec object associated with `dm`
- ***loc -*** which subgrid to extract (see `DMStagStencilLocation`)
- ***c -*** which component to extract (see note below)



## Output Parameters

- ***pda -*** the new `DMDA`
- ***pdavec -*** the new `Vec`



## Notes
If a `c` value of `-k` is provided, the first `k` DOF for that position are extracted,
padding with zero values if needbe. If a non-negative value is provided, a single
DOF is extracted.

The caller is responsible for destroying the created `DMDA` and `Vec`.




## See Also
 `DMSTAG`, `DMDA`, `DMStagMigrateVec()`, `DMStagCreateCompatibleDMStag()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/stagda.c.html#DMStagVecSplitToDMDA">src/dm/impls/stag/stagda.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex4.c.html">src/dm/impls/stag/tutorials/ex4.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/stag/tutorials/ex6.c.html">src/dm/impls/stag/tutorials/ex6.c.html</A><BR>


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


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