xref: /petsc/src/sys/objects/gcomm.c (revision 2423ceccb24e7c4e920586461c18d276a9f3c5ae)
1 #define PETSC_DLL
2 /*
3      Provides utility routines for manulating any type of PETSc object.
4 */
5 #include "petsc.h"  /*I   "petsc.h"    I*/
6 
7 #undef __FUNCT__
8 #define __FUNCT__ "PetscObjectGetComm"
9 /*@C
10    PetscObjectGetComm - Gets the MPI communicator for any PetscObject,
11    regardless of the type.
12 
13    Not Collective
14 
15    Input Parameter:
16 .  obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be
17          cast with a (PetscObject), for example,
18          PetscObjectGetComm((PetscObject)mat,&comm);
19 
20    Output Parameter:
21 .  comm - the MPI communicator
22 
23    Level: advanced
24 
25    Concepts: communicator^getting from object
26    Concepts: MPI communicator^getting from object
27 
28 @*/
29 PetscErrorCode PETSC_DLLEXPORT PetscObjectGetComm(PetscObject obj,MPI_Comm *comm)
30 {
31   PetscErrorCode ierr;
32 
33   PetscFunctionBegin;
34   PetscValidHeader(obj,1);
35   PetscValidPointer(comm,2);
36   if (obj->bops->getcomm) {
37     ierr = obj->bops->getcomm(obj,comm);CHKERRQ(ierr);
38   } else {
39     *comm = obj->comm;
40   }
41   PetscFunctionReturn(0);
42 }
43 
44 
45