Date: 2026-07-30T21:13:58+00:00

Actual source code: petscpartitioner.h

      1: #pragma once

      3: #include <petscsection.h>

      5: /* MANSEC = Mat */
      6: /* SUBMANSEC = MatGraphOperations */

      8: /*S
      9:   PetscPartitioner - PETSc object that manages a graph partitioner

     11:   Level: intermediate

     13:   Note:
     14:   Also consider `MatPartitioning` which provides an alternative API for partitioning.

     16: .seealso: `PetscPartitionerCreate()`, `PetscPartitionerSetType()`, `PetscPartitionerType`, `MatPartitioning`, `MatPartitioningCreate()`
     17: S*/
     18: typedef struct _p_PetscPartitioner *PetscPartitioner;

     20: PETSC_EXTERN PetscClassId   PETSCPARTITIONER_CLASSID;
     21: PETSC_EXTERN PetscErrorCode PetscPartitionerInitializePackage(void);
     22: PETSC_EXTERN PetscErrorCode PetscPartitionerFinalizePackage(void);

     24: /*J
     25:   PetscPartitionerType - String with the name of a PETSc graph partitioner

     27:   Level: beginner

     29: .seealso: `PetscPartitionerSetType()`, `PetscPartitioner`
     30: J*/
     31: typedef const char *PetscPartitionerType;
     32: #define PETSCPARTITIONERPARMETIS   "parmetis"
     33: #define PETSCPARTITIONERPTSCOTCH   "ptscotch"
     34: #define PETSCPARTITIONERCHACO      "chaco"
     35: #define PETSCPARTITIONERSIMPLE     "simple"
     36: #define PETSCPARTITIONERSHELL      "shell"
     37: #define PETSCPARTITIONERGATHER     "gather"
     38: #define PETSCPARTITIONERMULTISTAGE "multistage"

     40: PETSC_EXTERN PetscFunctionList PetscPartitionerList;
     41: PETSC_EXTERN PetscErrorCode    PetscPartitionerRegister(const char[], PetscErrorCode (*)(PetscPartitioner));

     43: PETSC_EXTERN PetscErrorCode PetscPartitionerCreate(MPI_Comm, PetscPartitioner *);
     44: PETSC_EXTERN PetscErrorCode PetscPartitionerDestroy(PetscPartitioner *);
     45: PETSC_EXTERN PetscErrorCode PetscPartitionerSetType(PetscPartitioner, PetscPartitionerType);
     46: PETSC_EXTERN PetscErrorCode PetscPartitionerGetType(PetscPartitioner, PetscPartitionerType *);
     47: PETSC_EXTERN PetscErrorCode PetscPartitionerSetUp(PetscPartitioner);
     48: PETSC_EXTERN PetscErrorCode PetscPartitionerReset(PetscPartitioner);
     49: PETSC_EXTERN PetscErrorCode PetscPartitionerSetFromOptions(PetscPartitioner);
     50: PETSC_EXTERN PetscErrorCode PetscPartitionerViewFromOptions(PetscPartitioner, PetscObject, const char[]);
     51: PETSC_EXTERN PetscErrorCode PetscPartitionerView(PetscPartitioner, PetscViewer);
     52: PETSC_EXTERN PetscErrorCode PetscPartitionerPartition(PetscPartitioner, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscSection, PetscSection, PetscSection, PetscSection, IS *);

     54: PETSC_EXTERN PetscErrorCode PetscPartitionerShellSetPartition(PetscPartitioner, PetscInt, const PetscInt[], const PetscInt[]);
     55: PETSC_EXTERN PetscErrorCode PetscPartitionerShellSetRandom(PetscPartitioner, PetscBool);
     56: PETSC_EXTERN PetscErrorCode PetscPartitionerShellGetRandom(PetscPartitioner, PetscBool *);

     58: /*E
     59:     PetscPartitionerMultistageStrategy - indicates what type of strategy to use

     61:     Values:
     62: +  `PETSCPARTITIONER_MS_STRATEGY_NODE` - Use node-aware stages
     63: -  `PETSCPARTITIONER_MS_STRATEGY_MSECTION` - Use recursive m-sections

     65:     Level: intermediate

     67: .seealso: `PetscPartitionerSetType()`, `PetscPartitioner`, `PETSCPARTITIONERMULTISTAGE`
     68: E*/
     69: typedef enum {
     70:   PETSCPARTITIONER_MS_STRATEGY_NODE,
     71:   PETSCPARTITIONER_MS_STRATEGY_MSECTION
     72: } PetscPartitionerMultistageStrategy;
     73: PETSC_EXTERN const char *const PetscPartitionerMultistageStrategyList[];

     75: PetscErrorCode PetscPartitionerMultistageSetStages(PetscPartitioner, PetscInt, MPI_Group[]);

     77: /* We should implement PetscPartitioner with MatPartitioning */
     78: #include <petscmat.h>
     79: #define PETSCPARTITIONERMATPARTITIONING "matpartitioning"
     80: PETSC_EXTERN PetscErrorCode PetscPartitionerMatPartitioningGetMatPartitioning(PetscPartitioner, MatPartitioning *);