# DMPlexCreateBoxMesh
Creates a mesh on the tensor product of unit intervals (box) using simplices or tensor cells (hexahedra). 
## Synopsis
```
#include "petscdmplex.h"   
#include "petscdmplex.h"   
PetscErrorCode DMPlexCreateBoxMesh(MPI_Comm comm, PetscInt dim, PetscBool simplex, const PetscInt faces[], const PetscReal lower[], const PetscReal upper[], const DMBoundaryType periodicity[], PetscBool interpolate, DM *dm)
```
Collective


## Input Parameters

- ***comm        -*** The communicator for the DM object
- ***dim         -*** The spatial dimension
- ***simplex     -*** PETSC_TRUE for simplices, PETSC_FALSE for tensor cells
- ***faces       -*** Number of faces per dimension, or NULL for (1,) in 1D and (2, 2) in 2D and (1, 1, 1) in 3D
- ***lower       -*** The lower left corner, or NULL for (0, 0, 0)
- ***upper       -*** The upper right corner, or NULL for (1, 1, 1)
- ***periodicity -*** The boundary type for the X,Y,Z direction, or NULL for DM_BOUNDARY_NONE
- ***interpolate -*** Flag to create intermediate mesh pieces (edges, faces)



## Output Parameter

- ***dm  -*** The DM object


Note: If you want to customize this mesh using options, you just need to
```none
DMCreate(comm, &dm);
```
```none
DMSetType(dm, DMPLEX);
```
```none
DMSetFromOptions(dm);
```
and use the options on the DMSetFromOptions() page.


## Here is the numbering returned for 2 faces in each direction for tensor cells
```none
10---17---11---18----12
```
```none
|         |         |
```
```none
|         |         |
```
```none
20    2   22    3    24
```
```none
|         |         |
```
```none
|         |         |
```
```none
7---15----8---16----9
```
```none
|         |         |
```
```none
|         |         |
```
```none
19    0   21    1   23
```
```none
|         |         |
```
```none
|         |         |
```
```none
4---13----5---14----6
```

and for simplicial cells

```none
14----8---15----9----16
```
```none
|\     5  |\      7 |
```
```none
| \       | \       |
```
```none
13   2    14    3    15
```
```none
| 4   \   | 6   \   |
```
```none
|       \ |       \ |
```
```none
11----6---12----7----13
```
```none
|\        |\        |
```
```none
| \    1  | \     3 |
```
```none
10   0    11    1    12
```
```none
| 0   \   | 2   \   |
```
```none
|       \ |       \ |
```
```none
8----4----9----5----10
```




## See Also
 `DMSetFromOptions()`, `DMPlexCreateFromFile()`, `DMPlexCreateHexCylinderMesh()`, `DMSetType()`, `DMCreate()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/plex/plexcreate.c.html#DMPlexCreateBoxMesh">src/dm/impls/plex/plexcreate.c</A>

## Examples
<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/dt/dualspace/impls/lagrange/tutorials/ex2.c.html">src/dm/dt/dualspace/impls/lagrange/tutorials/ex2.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/field/tutorials/ex1.c.html">src/dm/field/tutorials/ex1.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex56.c.html">src/snes/tutorials/ex56.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex75.c.html">src/snes/tutorials/ex75.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/snes/tutorials/ex77.c.html">src/snes/tutorials/ex77.c.html</A><BR>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/dm/impls/plex/plexcreate.c.html#DMPlexCreateBoxMesh_Internal">DMPlexCreateBoxMesh_Internal in src/dm/impls/plex/plexcreate.c</A><BR>


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


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