Actual source code: gcomm.c

  1: /*
  2:      Provides utility routines for manulating any type of PETSc object.
  3: */
 4:  #include petsc.h

  8: /*@C
  9:    PetscObjectGetComm - Gets the MPI communicator for any PetscObject, 
 10:    regardless of the type.

 12:    Not Collective

 14:    Input Parameter:
 15: .  obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be
 16:          cast with a (PetscObject), for example, 
 17:          PetscObjectGetComm((PetscObject)mat,&comm);

 19:    Output Parameter:
 20: .  comm - the MPI communicator

 22:    Level: advanced

 24:    Concepts: communicator^getting from object
 25:    Concepts: MPI communicator^getting from object

 27: @*/
 28: PetscErrorCode PetscObjectGetComm(PetscObject obj,MPI_Comm *comm)
 29: {

 33:   if (!obj) SETERRQ(PETSC_ERR_ARG_CORRUPT,"Null object");
 34:   if (obj->bops->getcomm) {
 35:     obj->bops->getcomm(obj,comm);
 36:   } else {
 37:     *comm = obj->comm;
 38:   }
 39:   return(0);
 40: }