Actual source code: gtype.c

petsc-3.9.4 2018-09-11
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:    PetscObjectGetType - Gets the object type of any PetscObject.

 10:    Not Collective

 12:    Input Parameter:
 13: .  obj - any PETSc object, for example a Vec, Mat or KSP.
 14:          Thus must be cast with a (PetscObject), for example,
 15:          PetscObjectGetType((PetscObject)mat,&type);

 17:    Output Parameter:
 18: .  type - the object type

 20:    Level: advanced

 22:    Concepts: object type
 23: @*/
 24: PetscErrorCode  PetscObjectGetType(PetscObject obj, const char *type[])
 25: {
 29:   *type = obj->type_name;
 30:   return(0);
 31: }

 33: /*@C
 34:    PetscObjectSetType - Sets the object type of any PetscObject.

 36:    Not Collective

 38:    Input Parameters:
 39: +  obj - any PETSc object, for example a Vec, Mat or KSP.
 40:          Thus must be cast with a (PetscObject), for example,
 41:          PetscObjectGetType((PetscObject)mat,&type);
 42: -  type - the object type

 44:    Note: This does not currently work since we need to dispatch by type.

 46:    Level: advanced

 48:    Concepts: object type
 49: @*/
 50: PetscErrorCode  PetscObjectSetType(PetscObject obj, const char type[])
 51: {
 55:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP, "Cannot set the type of a generic PetscObject");
 56: }