# DMDACreate2d
Creates an object that will manage the communication of  two-dimensional regular array data that is distributed across some processors. 
## Synopsis
```
#include "petscdmda.h"   
PetscErrorCode DMDACreate2d(MPI_Comm comm, DMBoundaryType bx, DMBoundaryType by, DMDAStencilType stencil_type, PetscInt M, PetscInt N, PetscInt m, PetscInt n, PetscInt dof, PetscInt s, const PetscInt lx[], const PetscInt ly[], DM *da)
```
Collective


## Input Parameters

- ***comm -*** MPI communicator
- ***bx,by -*** type of ghost nodes the array have.
Use one of `DM_BOUNDARY_NONE`, `DM_BOUNDARY_GHOSTED`, `DM_BOUNDARY_PERIODIC`.
- ***stencil_type -*** stencil type.  Use either `DMDA_STENCIL_BOX` or `DMDA_STENCIL_STAR`.
- ***M,N -*** global dimension in each direction of the array
- ***m,n -*** corresponding number of processors in each dimension
(or `PETSC_DECIDE` to have calculated)
- ***dof -*** number of degrees of freedom per node
- ***s -*** stencil width
- ***lx, ly -*** arrays containing the number of nodes in each cell along
the x and y coordinates, or NULL. If non-null, these
must be of length as m and n, and the corresponding
m and n cannot be PETSC_DECIDE. The sum of the lx[] entries
must be M, and the sum of the ly[] entries must be N.



## Output Parameter

- ***da -*** the resulting distributed array object



## Options Database Keys

- ***-dm_view -*** Calls `DMView()` at the conclusion of `DMDACreate2d()`
- ***-da_grid_x <nx> -*** number of grid points in x direction
- ***-da_grid_y <ny> -*** number of grid points in y direction
- ***-da_processors_x <nx> -*** number of processors in x direction
- ***-da_processors_y <ny> -*** number of processors in y direction
- ***-da_refine_x <rx> -*** refinement ratio in x direction
- ***-da_refine_y <ry> -*** refinement ratio in y direction
- ***-da_refine <n> -*** refine the DMDA n times before creating





## Notes
The stencil type `DMDA_STENCIL_STAR` with width 1 corresponds to the
standard 5-pt stencil, while `DMDA_STENCIL_BOX` with width 1 denotes
the standard 9-pt stencil.

The array data itself is NOT stored in the `DMDA`, it is stored in `Vec` objects;
The appropriate vector objects can be obtained with calls to `DMCreateGlobalVector()`
and DMCreateLocalVector() and calls to `VecDuplicate()` if more are needed.

You must call `DMSetUp()` after this call before using this `DM`.

If you wish to use the options database to change values in the `DMDA` call `DMSetFromOptions()` after this call
but before `DMSetUp()`.


## See Also
 `DM`, `DMDA`, `DMDestroy()`, `DMView()`, `DMDACreate1d()`, `DMDACreate3d()`, `DMGlobalToLocalBegin()`, `DMDAGetRefinementFactor()`,
`DMGlobalToLocalEnd()`, `DMLocalToGlobalBegin()`, `DMLocalToLocalBegin()`, `DMLocalToLocalEnd()`, `DMDASetRefinementFactor()`,
`DMDAGetInfo()`, `DMCreateGlobalVector()`, `DMCreateLocalVector()`, `DMDACreateNaturalVector()`, `DMLoad()`, `DMDAGetOwnershipRanges()`,
`DMStagCreate2d()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/da/da2.c.html#DMDACreate2d">src/dm/impls/da/da2.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex1.c.html">src/dm/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex10.c.html">src/dm/tutorials/ex10.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex11f90.F90.html">src/dm/tutorials/ex11f90.F90.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex12.c.html">src/dm/tutorials/ex12.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex14.c.html">src/dm/tutorials/ex14.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex2.c.html">src/dm/tutorials/ex2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex20.c.html">src/dm/tutorials/ex20.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex21.c.html">src/dm/tutorials/ex21.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex22.c.html">src/dm/tutorials/ex22.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex25.c.html">src/dm/tutorials/ex25.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/tutorials/ex3.c.html">src/dm/tutorials/ex3.c.html</A><BR>


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


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