Actual source code: gcomm.c

petsc-3.11.4 2019-09-28
Report Typos and Errors

  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:
 23:     Never use this in the form
 24: $       comm = PetscObjectComm((PetscObject)obj); 
 25:         instead use PetscObjectGetComm()

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

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

 38: /*@C
 39:    PetscObjectGetComm - Gets the MPI communicator for any PetscObject,
 40:    regardless of the type.

 42:    Not Collective

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

 49:    Output Parameter:
 50: .  comm - the MPI communicator

 52:    Level: advanced

 54:    Concepts: communicator^getting from object
 55:    Concepts: MPI communicator^getting from object

 57: .seealso: PetscObjectComm()
 58: @*/
 59: PetscErrorCode  PetscObjectGetComm(PetscObject obj,MPI_Comm *comm)
 60: {

 66:   if (obj->bops->getcomm) {
 67:     obj->bops->getcomm(obj,comm);
 68:   } else *comm = obj->comm;
 69:   return(0);
 70: }

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

 75:    Not Collective

 77:    Input Parameter:
 78: .  obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be
 79:          cast with a (PetscObject), for example,
 80:          PetscObjectGetComm((PetscObject)mat,&comm);

 82:    Output Parameter:
 83: .   tab - the number of tabs

 85:    Level: developer

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

 92: .seealso:  PetscObjectIncrementTabLevel()

 94: @*/
 95: PetscErrorCode  PetscObjectGetTabLevel(PetscObject obj,PetscInt *tab)
 96: {
 99:   *tab = obj->tablevel;
100:   return(0);
101: }

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

106:    Not Collective

108:    Input Parameters:
109: +  obj - any PETSc object, for example a Vec, Mat or KSP. Thus must be
110:          cast with a (PetscObject), for example,
111:          PetscObjectGetComm((PetscObject)mat,&comm);
112: -   tab - the number of tabs

114:    Level: developer

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

121: .seealso:  PetscObjectIncrementTabLevel()
122: @*/
123: PetscErrorCode  PetscObjectSetTabLevel(PetscObject obj,PetscInt tab)
124: {
127:   obj->tablevel = tab;
128:   return(0);
129: }

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

135:    Not Collective

137:    Input Parameter:
138: +  obj - any PETSc object where we are changing the tab
139: .  oldobj - the object providing the tab
140: -  tab - the increment that is added to the old objects tab


143:    Level: developer

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

150: .seealso:   PetscObjectSetTabLevel(),  PetscObjectGetTabLevel()

152: @*/
153: PetscErrorCode  PetscObjectIncrementTabLevel(PetscObject obj,PetscObject oldobj,PetscInt tab)
154: {

158:   if (oldobj) obj->tablevel = oldobj->tablevel + tab;
159:   else obj->tablevel = tab;
160:   return(0);
161: }