Actual source code: partgather.c
petsc-3.14.6 2021-03-30
1: #include <petsc/private/partitionerimpl.h>
3: typedef struct {
4: PetscInt dummy;
5: } PetscPartitioner_Gather;
7: static PetscErrorCode PetscPartitionerDestroy_Gather(PetscPartitioner part)
8: {
12: PetscFree(part->data);
13: return(0);
14: }
16: static PetscErrorCode PetscPartitionerView_Gather_ASCII(PetscPartitioner part, PetscViewer viewer)
17: {
19: return(0);
20: }
22: static PetscErrorCode PetscPartitionerView_Gather(PetscPartitioner part, PetscViewer viewer)
23: {
24: PetscBool iascii;
30: PetscObjectTypeCompare((PetscObject) viewer, PETSCVIEWERASCII, &iascii);
31: if (iascii) {PetscPartitionerView_Gather_ASCII(part, viewer);}
32: return(0);
33: }
35: static PetscErrorCode PetscPartitionerPartition_Gather(PetscPartitioner part, PetscInt nparts, PetscInt numVertices, PetscInt start[], PetscInt adjacency[], PetscSection vertSection, PetscSection targetSection, PetscSection partSection, IS *partition)
36: {
37: PetscInt np;
41: ISCreateStride(PETSC_COMM_SELF, numVertices, 0, 1, partition);
42: PetscSectionSetDof(partSection,0,numVertices);
43: for (np = 1; np < nparts; ++np) {PetscSectionSetDof(partSection, np, 0);}
44: return(0);
45: }
47: static PetscErrorCode PetscPartitionerInitialize_Gather(PetscPartitioner part)
48: {
50: part->noGraph = PETSC_TRUE;
51: part->ops->view = PetscPartitionerView_Gather;
52: part->ops->destroy = PetscPartitionerDestroy_Gather;
53: part->ops->partition = PetscPartitionerPartition_Gather;
54: return(0);
55: }
57: /*MC
58: PETSCPARTITIONERGATHER = "gather" - A PetscPartitioner object
60: Level: intermediate
62: .seealso: PetscPartitionerType, PetscPartitionerCreate(), PetscPartitionerSetType()
63: M*/
65: PETSC_EXTERN PetscErrorCode PetscPartitionerCreate_Gather(PetscPartitioner part)
66: {
67: PetscPartitioner_Gather *p;
68: PetscErrorCode ierr;
72: PetscNewLog(part, &p);
73: part->data = p;
75: PetscPartitionerInitialize_Gather(part);
76: return(0);
77: }