#include "petscsys.h" MPI_Comm PetscObjectComm(PetscObject obj)Not Collective
| obj | - any PETSc object, for example a Vec, Mat or KSP. Thus must be cast with a (PetscObject), for example, SETERRQ(PetscObjectComm((PetscObject)mat,...); | 
| comm | - the MPI communicator or MPI_COMM_NULL if object is not valid | 
      comm = PetscObjectComm((PetscObject)obj);
instead use PetscObjectGetComm()