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:   PetscFree(part->data);
     10:   return 0;
     11: }

     13: static PetscErrorCode PetscPartitionerView_Gather_ASCII(PetscPartitioner part, PetscViewer viewer)
     14: {
     15:   return 0;
     16: }

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

     24:   PetscObjectTypeCompare((PetscObject) viewer, PETSCVIEWERASCII, &iascii);
     25:   if (iascii) PetscPartitionerView_Gather_ASCII(part, viewer);
     26:   return 0;
     27: }

     29: static PetscErrorCode PetscPartitionerPartition_Gather(PetscPartitioner part, PetscInt nparts, PetscInt numVertices, PetscInt start[], PetscInt adjacency[], PetscSection vertSection, PetscSection targetSection, PetscSection partSection, IS *partition)
     30: {
     31:   PetscInt       np;

     33:   ISCreateStride(PETSC_COMM_SELF, numVertices, 0, 1, partition);
     34:   PetscSectionSetDof(partSection,0,numVertices);
     35:   for (np = 1; np < nparts; ++np) PetscSectionSetDof(partSection, np, 0);
     36:   return 0;
     37: }

     39: static PetscErrorCode PetscPartitionerInitialize_Gather(PetscPartitioner part)
     40: {
     41:   part->noGraph        = PETSC_TRUE;
     42:   part->ops->view      = PetscPartitionerView_Gather;
     43:   part->ops->destroy   = PetscPartitionerDestroy_Gather;
     44:   part->ops->partition = PetscPartitionerPartition_Gather;
     45:   return 0;
     46: }

     48: /*MC
     49:   PETSCPARTITIONERGATHER = "gather" - A PetscPartitioner object

     51:   Level: intermediate

     53: .seealso: PetscPartitionerType, PetscPartitionerCreate(), PetscPartitionerSetType()
     54: M*/

     56: PETSC_EXTERN PetscErrorCode PetscPartitionerCreate_Gather(PetscPartitioner part)
     57: {
     58:   PetscPartitioner_Gather *p;

     61:   PetscNewLog(part, &p);
     62:   part->data = p;

     64:   PetscPartitionerInitialize_Gather(part);
     65:   return 0;
     66: }