Actual source code: gcomm.c

petsc-3.5.4 2015-05-23
Report Typos and Errors
  2: /*
  3:      Provides utility routines for manulating any type of PETSc object.
  4: */
  5: #include <petsc-private/petscimpl.h>  /*I   "petscsys.h"    I*/

  9: /*@C
 10:    PetscObjectComm - Gets the MPI communicator for any PetscObject   regardless of the type.

 12:    Not Collective

 14:    Input Parameter:
 15: .  obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be
 16:          cast with a (PetscObject), for example,
 17:          SETERRQ(PetscObjectComm((PetscObject)mat,...);

 19:    Output Parameter:
 20: .  comm - the MPI communicator or MPI_COMM_NULL if object is not valid

 22:    Level: advanced

 24:    Notes: Never use this in the form
 25: $       comm = PetscObjectComm((PetscObject)obj); 
 26:         instead use PetscObjectGetComm()

 28:    Concepts: communicator^getting from object
 29:    Concepts: MPI communicator^getting from object

 31: .seealso: PetscObjectGetComm()
 32: @*/
 33: MPI_Comm  PetscObjectComm(PetscObject obj)
 34: {
 35:   if (!obj) return MPI_COMM_NULL;
 36:   return obj->comm;
 37: }

 41: /*@C
 42:    PetscObjectGetComm - Gets the MPI communicator for any PetscObject,
 43:    regardless of the type.

 45:    Not Collective

 47:    Input Parameter:
 48: .  obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be
 49:          cast with a (PetscObject), for example,
 50:          PetscObjectGetComm((PetscObject)mat,&comm);

 52:    Output Parameter:
 53: .  comm - the MPI communicator

 55:    Level: advanced

 57:    Concepts: communicator^getting from object
 58:    Concepts: MPI communicator^getting from object

 60: .seealso: PetscObjectComm()
 61: @*/
 62: PetscErrorCode  PetscObjectGetComm(PetscObject obj,MPI_Comm *comm)
 63: {

 69:   if (obj->bops->getcomm) {
 70:     obj->bops->getcomm(obj,comm);
 71:   } else *comm = obj->comm;
 72:   return(0);
 73: }

 77: /*@
 78:    PetscObjectGetTabLevel - Gets the number of tabs that ASCII output for that object use

 80:    Not Collective

 82:    Input Parameter:
 83: .  obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be
 84:          cast with a (PetscObject), for example,
 85:          PetscObjectGetComm((PetscObject)mat,&comm);

 87:    Output Parameter:
 88: .   tab - the number of tabs

 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:  PetscObjectIncrementTabLevel()

 98: @*/
 99: PetscErrorCode  PetscObjectGetTabLevel(PetscObject obj,PetscInt *tab)
100: {
103:   *tab = obj->tablevel;
104:   return(0);
105: }

109: /*@
110:    PetscObjectSetTabLevel - Sets the number of tabs that ASCII output for that object use

112:    Not Collective

114:    Input Parameters:
115: +  obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be
116:          cast with a (PetscObject), for example,
117:          PetscObjectGetComm((PetscObject)mat,&comm);
118: -   tab - the number of tabs

120:    Level: developer

122:     Notes: this is used to manage the output from options that are imbedded in other objects. For example
123:       the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects
124:       is very clear.

126: .seealso:  PetscObjectIncrementTabLevel()
127: @*/
128: PetscErrorCode  PetscObjectSetTabLevel(PetscObject obj,PetscInt tab)
129: {
132:   obj->tablevel = tab;
133:   return(0);
134: }

138: /*@
139:    PetscObjectIncrementTabLevel - Sets the number of tabs that ASCII output for that object use based on
140:          the tablevel of another object. This should be called immediately after the object is created.

142:    Not Collective

144:    Input Parameter:
145: +  obj - any PETSc object where we are changing the tab
146: .  oldobj - the object providing the tab
147: -  tab - the increment that is added to the old objects tab


150:    Level: developer

152:     Notes: this is used to manage the output from options that are imbedded in other objects. For example
153:       the KSP object inside a SNES object. By indenting each lower level further the heirarchy of objects
154:       is very clear.

156: .seealso:   PetscObjectSetLabLevel(),  PetscObjectGetTabLevel()

158: @*/
159: PetscErrorCode  PetscObjectIncrementTabLevel(PetscObject obj,PetscObject oldobj,PetscInt tab)
160: {

164:   if (oldobj) obj->tablevel = oldobj->tablevel + tab;
165:   else obj->tablevel = tab;
166:   return(0);
167: }