Date: 2025-03-29T05:58:24+00:00

Actual source code: partgather.c

      1: #include <petsc/private/partitionerimpl.h>

      3: typedef struct {
      4:   PetscInt dummy;
      5: } PetscPartitioner_Gather;

      7: static PetscErrorCode PetscPartitionerDestroy_Gather(PetscPartitioner part)
      8: {
      9:   PetscFunctionBegin;
     10:   PetscCall(PetscFree(part->data));
     11:   PetscFunctionReturn(PETSC_SUCCESS);
     12: }

     14: static PetscErrorCode PetscPartitionerPartition_Gather(PetscPartitioner part, PetscInt nparts, PetscInt numVertices, PetscInt start[], PetscInt adjacency[], PetscSection vertSection, PetscSection edgeSection, PetscSection targetSection, PetscSection partSection, IS *partition)
     15: {
     16:   PetscInt np;

     18:   PetscFunctionBegin;
     19:   PetscCall(ISCreateStride(PETSC_COMM_SELF, numVertices, 0, 1, partition));
     20:   PetscCall(PetscSectionSetDof(partSection, 0, numVertices));
     21:   for (np = 1; np < nparts; ++np) PetscCall(PetscSectionSetDof(partSection, np, 0));
     22:   PetscFunctionReturn(PETSC_SUCCESS);
     23: }

     25: static PetscErrorCode PetscPartitionerInitialize_Gather(PetscPartitioner part)
     26: {
     27:   PetscFunctionBegin;
     28:   part->noGraph        = PETSC_TRUE;
     29:   part->ops->destroy   = PetscPartitionerDestroy_Gather;
     30:   part->ops->partition = PetscPartitionerPartition_Gather;
     31:   PetscFunctionReturn(PETSC_SUCCESS);
     32: }

     34: /*MC
     35:   PETSCPARTITIONERGATHER = "gather" - A PetscPartitioner object

     37:   Level: intermediate

     39: .seealso: `PetscPartitionerType`, `PetscPartitionerCreate()`, `PetscPartitionerSetType()`
     40: M*/

     42: PETSC_EXTERN PetscErrorCode PetscPartitionerCreate_Gather(PetscPartitioner part)
     43: {
     44:   PetscPartitioner_Gather *p;

     46:   PetscFunctionBegin;
     48:   PetscCall(PetscNew(&p));
     49:   part->data = p;

     51:   PetscCall(PetscPartitionerInitialize_Gather(part));
     52:   PetscFunctionReturn(PETSC_SUCCESS);
     53: }