:orphan: # DMGetNeighbors Gets an array containing the MPI ranks of all the processes neighbors ## Synopsis ``` #include "petscdm.h" #include "petscdmlabel.h" #include "petscds.h" PetscErrorCode DMGetNeighbors(DM dm, PetscInt *nranks, const PetscMPIInt *ranks[]) ``` Not Collective ## Input Parameter - ***dm -*** The `DM` ## Output Parameters - ***nranks -*** the number of neighbours - ***ranks -*** the neighbors ranks ## Note Do not free the array, it is freed when the `DM` is destroyed. ## See Also [](ch_dmbase), `DM`, `DMDAGetNeighbors()`, `PetscSFGetRootRanks()` ## Level beginner ## Location src/dm/interface/dm.c ## Examples src/dm/tutorials/swarm_ex3.c
## Implementations DMGetNeighbors_DA in src/dm/impls/da/dacreate.c
DMGetNeighbors_Plex in src/dm/impls/plex/plexcreate.c
DMGetNeighbors_Stag in src/dm/impls/stag/stag.c
--- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/dm/interface/dm.c) [Index of all DM routines](index.md) [Table of Contents for all manual pages](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)