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 if (!obj) SETERRQ(PETSC_ERR_ARG_CORRUPT,"Null object"); 35 if (obj->bops->getcomm) { 36 ierr = obj->bops->getcomm(obj,comm);CHKERRQ(ierr); 37 } else { 38 *comm = obj->comm; 39 } 40 PetscFunctionReturn(0); 41 } 42 43 44