METIS partitions finite element meshes by first converting them to a graph, partitioning the graph, and then deriving the other side’s partition. Two strategies are available: the dual approach treats elements as graph vertices (two elements are adjacent if they share at leastDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/KarypisLab/METIS/llms.txt
Use this file to discover all available pages before exploring further.
ncommon nodes), and the nodal approach treats mesh nodes as graph vertices (two nodes are adjacent if they belong to the same element). The conversion functions METIS_MeshToDual and METIS_MeshToNodal can also be called directly when you need the graph representation itself.
Element-Node CSR Format
All mesh functions represent meshes using two arrays in a format analogous to graph CSR:eptr— integer array of sizene + 1. Elementiuses nodeseind[eptr[i] .. eptr[i+1]-1].eind— flat array of node indices for all elements. Total length equalseptr[ne], which is the sum of the number of nodes over all elements.
eptr correctly marks each element’s slice of eind.
METIS_PartMeshDual
Partitions a mesh by constructing the dual graph (elements as vertices, shared faces as edges), partitioning it usingMETIS_PartGraphKway or METIS_PartGraphRecursive, and then inducing a node partition from the element partition.
Number of elements in the mesh.
Number of nodes in the mesh.
Element-node CSR row-pointer array of size
ne + 1.Element-node CSR column-index array. Contains the node indices of every element.
Element weights array of size
ne. Pass NULL for unit element weights.Element sizes for communication-volume minimization, array of size
ne. Pass NULL for unit sizes.Minimum number of nodes that two elements must share to be connected in the dual graph. For triangular/tetrahedral meshes with shared edges/faces, typical values are
2 (shared edge) or 3 (shared triangular face). Setting ncommon = 1 connects all elements that share any node.Number of desired partitions.
Target partition weights. Array of size
nparts. tpwgts[i] is the desired fraction of the total element weight in partition i. Values must sum to 1.0. Pass NULL for equal partitioning.Options array of size
METIS_NOPTIONS initialized with METIS_SetDefaultOptions. The METIS_OPTION_PTYPE option selects between k-way (METIS_PTYPE_KWAY, default) and recursive bisection (METIS_PTYPE_RB).Output: objective value of the computed partition (edge cut or communication volume of the dual graph).
Output: element partition array of size
ne. epart[i] is the partition number assigned to element i. Must be pre-allocated by the caller.Output: node partition array of size
nn. npart[i] is the partition number assigned to node i. Derived from the element partition by assigning each node to the partition that dominates its element neighborhood. Must be pre-allocated by the caller.METIS_PartMeshNodal
Partitions a mesh by constructing the nodal graph (nodes as vertices, edges between nodes sharing an element), partitioning it, and inducing an element partition from the node partition.Number of elements in the mesh.
Number of nodes in the mesh.
Element-node CSR row-pointer array of size
ne + 1.Element-node CSR column-index array.
Node weights array of size
nn. Pass NULL for unit node weights.Node sizes for communication-volume minimization, array of size
nn. Pass NULL for unit sizes.Number of desired partitions.
Target partition weights. Array of size
nparts. Pass NULL for equal partitioning.Options array initialized with
METIS_SetDefaultOptions.Output: objective value of the computed partition.
Output: element partition array of size
ne. Derived from the node partition. Must be pre-allocated.Output: node partition array of size
nn. Primary partitioning output. Must be pre-allocated.METIS_MeshToDual
Converts a mesh to its dual graph. Returns the graph’s CSR arrays via output pointer-to-pointer parameters. The caller is responsible for freeing the returned arrays usingMETIS_Free.
Number of elements.
Number of nodes.
Element-node CSR row-pointer array.
Element-node CSR column-index array.
Minimum number of shared nodes required for an edge in the dual graph.
Numbering flag. Pass
0 for 0-based numbering, 1 for 1-based (Fortran-style). The returned graph uses the same numbering.Output: pointer to the allocated
xadj array for the dual graph. METIS allocates this array. Free with METIS_Free(*r_xadj).Output: pointer to the allocated
adjncy array for the dual graph. METIS allocates this array. Free with METIS_Free(*r_adjncy).METIS_MeshToNodal
Converts a mesh to its nodal graph. LikeMETIS_MeshToDual, the returned arrays are allocated by METIS and must be freed by the caller with METIS_Free.
Number of elements.
Number of nodes.
Element-node CSR row-pointer array.
Element-node CSR column-index array.
Numbering flag:
0 for 0-based, 1 for 1-based.Output: pointer to the allocated
xadj array for the nodal graph. Free with METIS_Free(*r_xadj).Output: pointer to the allocated
adjncy array for the nodal graph. Free with METIS_Free(*r_adjncy).Complete Example: Partitioning a Triangular Mesh
Using MeshToDual Directly
When you need the graph itself (for example, to inspect connectivity or to pass it toMETIS_PartGraphKway with custom options):
Dual vs Nodal: When to Use Each
| Dual (PartMeshDual) | Nodal (PartMeshNodal) | |
|---|---|---|
| Primary partition | Elements | Nodes |
| Graph built from | Elements sharing ncommon nodes | Nodes sharing an element |
| Typical use | FEM solvers that work element-by-element | FEM solvers that assemble by node |
ncommon parameter | Required (controls connectivity) | Not applicable |
| Induced partition | Nodes derived from elements | Elements derived from nodes |