:orphan: # PetscObjectComm Gets the MPI communicator for any `PetscObject` regardless of the type. ## Synopsis ``` #include "petscsys.h" MPI_Comm PetscObjectComm(PetscObject obj) ``` Not Collective ## Input Parameter - ***obj -*** any PETSc object, for example a `Vec`, `Mat` or `KSP`. Thus must be cast with a (`PetscObject`), for example, `PetscObjectComm`((`PetscObject`)mat,...); ## Output Parameter - ***comm -*** the MPI communicator or `MPI_COMM_NULL` if `obj` is not valid ## Note This is one of the rare PETSc routines that does not return an error code. Use `PetscObjectGetComm()` when appropriate for error handling. ## See Also `PetscObject`, `PetscObjectGetComm()` ## Level advanced ## Location src/sys/objects/gcomm.c ## Examples src/dm/field/tutorials/ex1.c
src/dm/impls/plex/tutorials/ex10.c
src/dm/impls/plex/tutorials/ex11.c
src/dm/impls/plex/tutorials/ex6.c
src/dm/impls/plex/tutorials/ex7.c
src/dm/impls/stag/tutorials/ex2.c
src/dm/impls/stag/tutorials/ex3.c
src/dm/impls/stag/tutorials/ex4.c
src/dm/impls/stag/tutorials/ex6.c
src/dm/impls/stag/tutorials/ex8.c
src/dm/label/tutorials/ex1.c
--- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/objects/gcomm.c) [Index of all Sys routines](index.md) [Table of Contents for all manual pages](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)