Skip to main content

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_PartGeom partitions a distributed set of vertices using space-filling curve techniques applied to their spatial coordinates. Because it does not analyze graph topology, it runs significantly faster than multilevel methods but typically produces higher edge cuts. This function is most useful as a rapid initial partition before further refinement, or in situations where adjacency information is unavailable. No xadj or adjncy arrays are required.
int ParMETIS_V3_PartGeom(
    idx_t *vtxdist, idx_t *ndims, real_t *xyz, idx_t *part, MPI_Comm *comm);

Parameters

vtxdist
idx_t*
Distribution of vertices across processes. vtxdist[i] is the global index of the first vertex on process i, and vtxdist[i+1] - vtxdist[i] is the number of local vertices on process i. Size npes + 1; must be identical on all processes.
ndims
idx_t*
Number of coordinate dimensions. Must be 2 (2D) or 3 (3D).
xyz
real_t*
Vertex coordinates for all local vertices, stored interleaved by vertex: [x0, y0, z0, x1, y1, z1, ...]. Size local_nvtxs * ndims.
part
idx_t*
Output. Partition assignment for each local vertex. part[i] is the partition ID of local vertex i. The caller must allocate this array with at least local_nvtxs elements. The number of partitions produced equals the number of MPI processes.
comm
MPI_Comm*
Pointer to the MPI communicator covering all participating processes.

Return value

Returns METIS_OK (1) on success. Any other value indicates an error.
This function does not use graph topology. For better partition quality when adjacency data is available, use ParMETIS_V3_PartGeomKway or ParMETIS_V3_PartKway instead.

Usage example

#include <parmetis.h>

int main(int argc, char *argv[]) {
    MPI_Init(&argc, &argv);
    MPI_Comm comm = MPI_COMM_WORLD;

    int npes, rank;
    MPI_Comm_size(comm, &npes);
    MPI_Comm_rank(comm, &rank);

    idx_t local_nvtxs = 10;
    idx_t vtxdist[npes + 1];
    for (int i = 0; i <= npes; i++) vtxdist[i] = i * local_nvtxs;

    /* 3D coordinates for each local vertex */
    idx_t ndims = 3;
    real_t xyz[local_nvtxs * 3]; /* [x0,y0,z0, x1,y1,z1, ...] */

    idx_t part[local_nvtxs];

    int ret = ParMETIS_V3_PartGeom(vtxdist, &ndims, xyz, part, &comm);

    if (ret != METIS_OK) { /* handle error */ }

    MPI_Finalize();
    return 0;
}

Build docs developers (and LLMs) love