# PetscSubcomm
A decomposition of an MPI communicator into subcommunicators 
## Synopsis
```
typedef struct _n_PetscSubcomm *PetscSubcomm;
```

## Notes
After a call to `PetscSubcommSetType()`, `PetscSubcommSetTypeGeneral()`, or `PetscSubcommSetFromOptions()` one may call
```none
`PetscSubcommChild()` returns the associated subcommunicator on this process
```
```none
`PetscSubcommContiguousParent()` returns a parent communitor but with all child of the same subcommunicator having contiguous rank
```


## Sample Usage
```none
       `PetscSubcommCreate()`
       `PetscSubcommSetNumber()`
       `PetscSubcommSetType`(`PETSC_SUBCOMM_INTERLACED`);
       ccomm = `PetscSubcommChild()`
       `PetscSubcommDestroy()`
```





## Notes
```none
`PETSC_SUBCOMM_GENERAL` - similar to `MPI_Comm_split()` each process sets the new communicator (color) they will belong to and the order within that communicator
```
```none
`PETSC_SUBCOMM_CONTIGUOUS` - each new communicator contains a set of process with contiguous ranks in the original MPI communicator
```
```none
`PETSC_SUBCOMM_INTERLACED` - each new communictor contains a set of processes equally far apart in rank from the others in that new communicator
```

Example: Consider a communicator with six processes split into 3 subcommunicators.
```none
`PETSC_SUBCOMM_CONTIGUOUS` - the first communicator contains rank 0,1  the second rank 2,3 and the third rank 4,5 in the original ordering of the original communicator
```
```none
`PETSC_SUBCOMM_INTERLACED` - the first communicator contains rank 0,3, the second 1,4 and the third 2,5
```


## Developer Note
This is used in objects such as `PCREDUNDANT` to manage the subcommunicators on which the redundant computations
are performed.


## See Also
 `PetscSubcommCreate()`, `PetscSubcommSetNumber()`, `PetscSubcommSetType()`, `PetscSubcommView()`, `PetscSubcommSetFromOptions()`


## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscsystypes.h.html#PetscSubcomm">include/petscsystypes.h</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscsystypes.h)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
