# MatMeshToCellGraph
Uses the ParMETIS package to convert a `Mat` that represents coupling of vertices of a mesh to a `Mat` the represents the graph of the coupling between cells (the "dual" graph) and is suitable for partitioning with the `MatPartitioning object`. Use this to partition cells of a mesh. 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatMeshToCellGraph(Mat mesh, PetscInt ncommonnodes, Mat *dual)
```
Collective


## Input Parameters

- ***mesh -*** the graph that represents the coupling of the vertices of the mesh
- ***ncommonnodes -*** mesh elements that share this number of common nodes are considered neighbors, use 2 for triangles and
quadrilaterials, 3 for tetrahedrals and 4 for hexahedrals



## Output Parameter

- ***dual -*** the dual graph



## Notes
Currently requires ParMetis to be installed and uses ParMETIS_V3_Mesh2Dual()

```none
Each row of the mesh object represents a single cell in the mesh. For triangles it has 3 entries, quadrilaterials 4 entries,
```
```none
tetrahedrals 4 entries and hexahedrals 8 entries. You can mix triangles and quadrilaterals in the same mesh, but cannot
```
```none
mix  tetrahedrals and hexahedrals
```
```none
The columns of each row of the Mat mesh are the global vertex numbers of the vertices of that row's cell.
```
```none
The number of rows in mesh is number of cells, the number of columns is the number of vertices.
```




## See Also
 `MatCreateMPIAdj()`, `MatPartitioningCreate()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/partition/impls/pmetis/pmetis.c.html#MatMeshToCellGraph">src/mat/partition/impls/pmetis/pmetis.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex11.c.html">src/mat/tutorials/ex11.c.html</A><BR>


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


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