1 2 /* 3 Provides utility routines for manulating any type of PETSc object. 4 */ 5 #include <petscsys.h> /*I "petscsys.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 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 #undef __FUNCT__ 45 #define __FUNCT__ "PetscObjectGetTabLevel" 46 /*@ 47 PetscObjectGetTabLevel - Gets the number of tabs that ASCII output for that object use 48 49 Not Collective 50 51 Input Parameter: 52 . obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be 53 cast with a (PetscObject), for example, 54 PetscObjectGetComm((PetscObject)mat,&comm); 55 56 Output Parameter: 57 . tab - the number of tabs 58 59 Level: developer 60 61 Notes: this is used to manage the output from options that are imbedded in other objects. For example 62 the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects 63 is very clear. 64 65 .seealso: PetscObjectIncrementTabLevel() 66 67 @*/ 68 PetscErrorCode PetscObjectGetTabLevel(PetscObject obj,PetscInt *tab) 69 { 70 PetscFunctionBegin; 71 PetscValidHeader(obj,1); 72 *tab = obj->tablevel; 73 PetscFunctionReturn(0); 74 } 75 76 #undef __FUNCT__ 77 #define __FUNCT__ "PetscObjectSetTabLevel" 78 /*@ 79 PetscObjectSetTabLevel - Sets the number of tabs that ASCII output for that object use 80 81 Not Collective 82 83 Input Parameters: 84 + obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be 85 cast with a (PetscObject), for example, 86 PetscObjectGetComm((PetscObject)mat,&comm); 87 - tab - the number of tabs 88 89 Level: developer 90 91 Notes: this is used to manage the output from options that are imbedded in other objects. For example 92 the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects 93 is very clear. 94 95 .seealso: PetscObjectIncrementTabLevel() 96 @*/ 97 PetscErrorCode PetscObjectSetTabLevel(PetscObject obj,PetscInt tab) 98 { 99 PetscFunctionBegin; 100 PetscValidHeader(obj,1); 101 obj->tablevel = tab; 102 PetscFunctionReturn(0); 103 } 104 105 #undef __FUNCT__ 106 #define __FUNCT__ "PetscObjectIncrementTabLevel" 107 /*@ 108 PetscObjectIncrementTabLevel - Sets the number of tabs that ASCII output for that object use based on 109 the tablevel of another object. This should be called immediately after the object is created. 110 111 Not Collective 112 113 Input Parameter: 114 + obj - any PETSc object where we are changing the tab 115 . oldobj - the object providing the tab 116 - tab - the increment that is added to the old objects tab 117 118 119 Level: developer 120 121 Notes: this is used to manage the output from options that are imbedded in other objects. For example 122 the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects 123 is very clear. 124 125 .seealso: PetscObjectSetLabLevel(), PetscObjectGetTabLevel() 126 127 @*/ 128 PetscErrorCode PetscObjectIncrementTabLevel(PetscObject obj,PetscObject oldobj,PetscInt tab) 129 { 130 131 PetscFunctionBegin; 132 PetscValidHeader(obj,1); 133 if (oldobj) { 134 obj->tablevel = oldobj->tablevel + tab; 135 } else { 136 obj->tablevel = tab; 137 } 138 PetscFunctionReturn(0); 139 } 140