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 PetscPartitionerView_Gather_ASCII(PetscPartitioner part, PetscViewer viewer)
 15: {
 16:   PetscFunctionBegin;
 17:   PetscFunctionReturn(PETSC_SUCCESS);
 18: }

 20: static PetscErrorCode PetscPartitionerView_Gather(PetscPartitioner part, PetscViewer viewer)
 21: {
 22:   PetscBool iascii;

 24:   PetscFunctionBegin;
 27:   PetscCall(PetscObjectTypeCompare((PetscObject)viewer, PETSCVIEWERASCII, &iascii));
 28:   if (iascii) PetscCall(PetscPartitionerView_Gather_ASCII(part, viewer));
 29:   PetscFunctionReturn(PETSC_SUCCESS);
 30: }

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

 36:   PetscFunctionBegin;
 37:   PetscCall(ISCreateStride(PETSC_COMM_SELF, numVertices, 0, 1, partition));
 38:   PetscCall(PetscSectionSetDof(partSection, 0, numVertices));
 39:   for (np = 1; np < nparts; ++np) PetscCall(PetscSectionSetDof(partSection, np, 0));
 40:   PetscFunctionReturn(PETSC_SUCCESS);
 41: }

 43: static PetscErrorCode PetscPartitionerInitialize_Gather(PetscPartitioner part)
 44: {
 45:   PetscFunctionBegin;
 46:   part->noGraph        = PETSC_TRUE;
 47:   part->ops->view      = PetscPartitionerView_Gather;
 48:   part->ops->destroy   = PetscPartitionerDestroy_Gather;
 49:   part->ops->partition = PetscPartitionerPartition_Gather;
 50:   PetscFunctionReturn(PETSC_SUCCESS);
 51: }

 53: /*MC
 54:   PETSCPARTITIONERGATHER = "gather" - A PetscPartitioner object

 56:   Level: intermediate

 58: .seealso: `PetscPartitionerType`, `PetscPartitionerCreate()`, `PetscPartitionerSetType()`
 59: M*/

 61: PETSC_EXTERN PetscErrorCode PetscPartitionerCreate_Gather(PetscPartitioner part)
 62: {
 63:   PetscPartitioner_Gather *p;

 65:   PetscFunctionBegin;
 67:   PetscCall(PetscNew(&p));
 68:   part->data = p;

 70:   PetscCall(PetscPartitionerInitialize_Gather(part));
 71:   PetscFunctionReturn(PETSC_SUCCESS);
 72: }