Skip to main content
`Ctrl`+`K`

# 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

DM Basics, `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

Index of all DM routines
Table of Contents for all manual pages
Index of all manual pages