Actual source code: partgather.c
1: #include <petsc/private/partitionerimpl.h>
3: typedef struct {
4: PetscInt unused;
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: PetscFunctionBegin;
17: PetscCall(ISCreateStride(PETSC_COMM_SELF, numVertices, 0, 1, partition));
18: PetscCall(PetscSectionSetDof(partSection, 0, numVertices));
19: for (PetscInt np = 1; np < nparts; ++np) PetscCall(PetscSectionSetDof(partSection, np, 0));
20: PetscFunctionReturn(PETSC_SUCCESS);
21: }
23: static PetscErrorCode PetscPartitionerInitialize_Gather(PetscPartitioner part)
24: {
25: PetscFunctionBegin;
26: part->noGraph = PETSC_TRUE;
27: part->ops->destroy = PetscPartitionerDestroy_Gather;
28: part->ops->partition = PetscPartitionerPartition_Gather;
29: PetscFunctionReturn(PETSC_SUCCESS);
30: }
32: /*MC
33: PETSCPARTITIONERGATHER = "gather" - A PetscPartitioner object
35: Level: intermediate
37: .seealso: `PetscPartitionerType`, `PetscPartitionerCreate()`, `PetscPartitionerSetType()`
38: M*/
40: PETSC_EXTERN PetscErrorCode PetscPartitionerCreate_Gather(PetscPartitioner part)
41: {
42: PetscPartitioner_Gather *p;
44: PetscFunctionBegin;
46: PetscCall(PetscNew(&p));
47: part->data = p;
49: PetscCall(PetscPartitionerInitialize_Gather(part));
50: PetscFunctionReturn(PETSC_SUCCESS);
51: }