Actual source code: gcomm.c
petsc-3.8.4 2018-03-24
2: /*
3: Provides utility routines for manulating any type of PETSc object.
4: */
5: #include <petsc/private/petscimpl.h>
7: /*@C
8: PetscObjectComm - Gets the MPI communicator for any PetscObject regardless of the type.
10: Not Collective
12: Input Parameter:
13: . obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be
14: cast with a (PetscObject), for example,
15: SETERRQ(PetscObjectComm((PetscObject)mat,...);
17: Output Parameter:
18: . comm - the MPI communicator or MPI_COMM_NULL if object is not valid
20: Level: advanced
22: Notes: Never use this in the form
23: $ comm = PetscObjectComm((PetscObject)obj);
24: instead use PetscObjectGetComm()
26: Concepts: communicator^getting from object
27: Concepts: MPI communicator^getting from object
29: .seealso: PetscObjectGetComm()
30: @*/
31: MPI_Comm PetscObjectComm(PetscObject obj)
32: {
33: if (!obj) return MPI_COMM_NULL;
34: return obj->comm;
35: }
37: /*@C
38: PetscObjectGetComm - Gets the MPI communicator for any PetscObject,
39: regardless of the type.
41: Not Collective
43: Input Parameter:
44: . obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be
45: cast with a (PetscObject), for example,
46: PetscObjectGetComm((PetscObject)mat,&comm);
48: Output Parameter:
49: . comm - the MPI communicator
51: Level: advanced
53: Concepts: communicator^getting from object
54: Concepts: MPI communicator^getting from object
56: .seealso: PetscObjectComm()
57: @*/
58: PetscErrorCode PetscObjectGetComm(PetscObject obj,MPI_Comm *comm)
59: {
65: if (obj->bops->getcomm) {
66: obj->bops->getcomm(obj,comm);
67: } else *comm = obj->comm;
68: return(0);
69: }
71: /*@
72: PetscObjectGetTabLevel - Gets the number of tabs that ASCII output for that object use
74: Not Collective
76: Input Parameter:
77: . obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be
78: cast with a (PetscObject), for example,
79: PetscObjectGetComm((PetscObject)mat,&comm);
81: Output Parameter:
82: . tab - the number of tabs
84: Level: developer
86: Notes: this is used to manage the output from options that are imbedded in other objects. For example
87: the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects
88: is very clear.
90: .seealso: PetscObjectIncrementTabLevel()
92: @*/
93: PetscErrorCode PetscObjectGetTabLevel(PetscObject obj,PetscInt *tab)
94: {
97: *tab = obj->tablevel;
98: return(0);
99: }
101: /*@
102: PetscObjectSetTabLevel - Sets the number of tabs that ASCII output for that object use
104: Not Collective
106: Input Parameters:
107: + obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be
108: cast with a (PetscObject), for example,
109: PetscObjectGetComm((PetscObject)mat,&comm);
110: - tab - the number of tabs
112: Level: developer
114: Notes: this is used to manage the output from options that are imbedded in other objects. For example
115: the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects
116: is very clear.
118: .seealso: PetscObjectIncrementTabLevel()
119: @*/
120: PetscErrorCode PetscObjectSetTabLevel(PetscObject obj,PetscInt tab)
121: {
124: obj->tablevel = tab;
125: return(0);
126: }
128: /*@
129: PetscObjectIncrementTabLevel - Sets the number of tabs that ASCII output for that object use based on
130: the tablevel of another object. This should be called immediately after the object is created.
132: Not Collective
134: Input Parameter:
135: + obj - any PETSc object where we are changing the tab
136: . oldobj - the object providing the tab
137: - tab - the increment that is added to the old objects tab
140: Level: developer
142: Notes: this is used to manage the output from options that are imbedded in other objects. For example
143: the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects
144: is very clear.
146: .seealso: PetscObjectSetLabLevel(), PetscObjectGetTabLevel()
148: @*/
149: PetscErrorCode PetscObjectIncrementTabLevel(PetscObject obj,PetscObject oldobj,PetscInt tab)
150: {
154: if (oldobj) obj->tablevel = oldobj->tablevel + tab;
155: else obj->tablevel = tab;
156: return(0);
157: }