Finite element applications distribute meshes across MPI processes as collections of elements, not vertices. ParMETIS provides two functions for this case:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/KarypisLab/ParMETIS/llms.txt
Use this file to discover all available pages before exploring further.
ParMETIS_V3_PartMeshKway partitions the elements directly, while ParMETIS_V3_Mesh2Dual converts a distributed element mesh to a dual graph so that ParMETIS_V3_PartKway can be used. Both approaches require describing the mesh with elmdist, eptr, and eind arrays, which are the element-level analogues of vtxdist, xadj, and adjncy.
Describing the distributed mesh
elmdist
elmdist is a replicated array of length npes + 1. elmdist[i] is the global index of the first element owned by process i. All processes must hold an identical copy.
eptr and eind
eptr and eind describe the node lists of local elements in CSR format. eptr[i+1] - eptr[i] is the number of nodes in local element i, and eind[eptr[i]..eptr[i+1]-1] holds their global node indices.
ncommonnodes
Two elements are considered adjacent when they share at leastncommonnodes nodes.
| Element type | Recommended value | Adjacency kind |
|---|---|---|
| Triangles, quads | 2 | Edge adjacency |
| Tetrahedra | 3 | Face adjacency |
| Hexahedra | 4 | Face adjacency |
Two approaches: PartMeshKway vs Mesh2Dual + PartKway
PartMeshKway is the simpler path. Call it directly when you only need a partition array for the elements. Mesh2Dual + PartKway gives more control.Mesh2Dual constructs the dual graph (one graph node per mesh element, edges between adjacent elements) and returns xadj/adjncy pointers that you then pass to PartKway. Use this when you need the dual graph for other purposes, or when you want to apply multi-constraint partitioning that PartMeshKway does not expose.
The
xadj and adjncy arrays returned by Mesh2Dual are allocated by ParMETIS. You are responsible for freeing them with free() after use.