1 #include <petsc/private/partitionerimpl.h> /*I "petscpartitioner.h" I*/ 2 3 typedef struct { 4 PetscInt dummy; 5 } PetscPartitioner_Gather; 6 7 static PetscErrorCode PetscPartitionerDestroy_Gather(PetscPartitioner part) { 8 PetscFunctionBegin; 9 PetscCall(PetscFree(part->data)); 10 PetscFunctionReturn(0); 11 } 12 13 static PetscErrorCode PetscPartitionerView_Gather_ASCII(PetscPartitioner part, PetscViewer viewer) { 14 PetscFunctionBegin; 15 PetscFunctionReturn(0); 16 } 17 18 static PetscErrorCode PetscPartitionerView_Gather(PetscPartitioner part, PetscViewer viewer) { 19 PetscBool iascii; 20 21 PetscFunctionBegin; 22 PetscValidHeaderSpecific(part, PETSCPARTITIONER_CLASSID, 1); 23 PetscValidHeaderSpecific(viewer, PETSC_VIEWER_CLASSID, 2); 24 PetscCall(PetscObjectTypeCompare((PetscObject)viewer, PETSCVIEWERASCII, &iascii)); 25 if (iascii) PetscCall(PetscPartitionerView_Gather_ASCII(part, viewer)); 26 PetscFunctionReturn(0); 27 } 28 29 static PetscErrorCode PetscPartitionerPartition_Gather(PetscPartitioner part, PetscInt nparts, PetscInt numVertices, PetscInt start[], PetscInt adjacency[], PetscSection vertSection, PetscSection targetSection, PetscSection partSection, IS *partition) { 30 PetscInt np; 31 32 PetscFunctionBegin; 33 PetscCall(ISCreateStride(PETSC_COMM_SELF, numVertices, 0, 1, partition)); 34 PetscCall(PetscSectionSetDof(partSection, 0, numVertices)); 35 for (np = 1; np < nparts; ++np) PetscCall(PetscSectionSetDof(partSection, np, 0)); 36 PetscFunctionReturn(0); 37 } 38 39 static PetscErrorCode PetscPartitionerInitialize_Gather(PetscPartitioner part) { 40 PetscFunctionBegin; 41 part->noGraph = PETSC_TRUE; 42 part->ops->view = PetscPartitionerView_Gather; 43 part->ops->destroy = PetscPartitionerDestroy_Gather; 44 part->ops->partition = PetscPartitionerPartition_Gather; 45 PetscFunctionReturn(0); 46 } 47 48 /*MC 49 PETSCPARTITIONERGATHER = "gather" - A PetscPartitioner object 50 51 Level: intermediate 52 53 .seealso: `PetscPartitionerType`, `PetscPartitionerCreate()`, `PetscPartitionerSetType()` 54 M*/ 55 56 PETSC_EXTERN PetscErrorCode PetscPartitionerCreate_Gather(PetscPartitioner part) { 57 PetscPartitioner_Gather *p; 58 59 PetscFunctionBegin; 60 PetscValidHeaderSpecific(part, PETSCPARTITIONER_CLASSID, 1); 61 PetscCall(PetscNewLog(part, &p)); 62 part->data = p; 63 64 PetscCall(PetscPartitionerInitialize_Gather(part)); 65 PetscFunctionReturn(0); 66 } 67