Actual source code: gcomm.c
2: /*
3: Provides utility routines for manulating any type of PETSc object.
4: */
5: #include <petscsys.h> /*I "petscsys.h" I*/
9: /*@C
10: PetscObjectGetComm - Gets the MPI communicator for any PetscObject,
11: regardless of the type.
13: Not Collective
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);
20: Output Parameter:
21: . comm - the MPI communicator
23: Level: advanced
25: Concepts: communicator^getting from object
26: Concepts: MPI communicator^getting from object
28: @*/
29: PetscErrorCode PetscObjectGetComm(PetscObject obj,MPI_Comm *comm)
30: {
36: if (obj->bops->getcomm) {
37: obj->bops->getcomm(obj,comm);
38: } else {
39: *comm = obj->comm;
40: }
41: return(0);
42: }
46: /*@
47: PetscObjectGetTabLevel - Gets the number of tabs that ASCII output for that object use
49: Not Collective
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);
56: Output Parameter:
57: . tab - the number of tabs
59: Level: developer
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.
65: .seealso: PetscObjectIncrementTabLevel()
67: @*/
68: PetscErrorCode PetscObjectGetTabLevel(PetscObject obj,PetscInt *tab)
69: {
72: *tab = obj->tablevel;
73: return(0);
74: }
78: /*@
79: PetscObjectIncrementTabLevel - Sets the number of tabs that ASCII output for that object use based on
80: the tablevel of another object. This should be called immediately after the object is created.
82: Not Collective
84: Input Parameter:
85: + obj - any PETSc object where we are changing the tab
86: . oldobj - the object providing the tab
87: - tab - the increment that is added to the old objects tab
90: Level: developer
92: Notes: this is used to manage the output from options that are imbedded in other objects. For example
93: the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects
94: is very clear.
96: .seealso: PetscObjectSetLabLevel(), PetscObjectGetTabLevel()
98: @*/
99: PetscErrorCode PetscObjectIncrementTabLevel(PetscObject obj,PetscObject oldobj,PetscInt tab)
100: {
104: if (oldobj) {
105: obj->tablevel = oldobj->tablevel + tab;
106: } else {
107: obj->tablevel = tab;
108: }
109: return(0);
110: }