Actual source code: gtype.c

      1: #define PETSC_DLL
      2: /*
      3:      Provides utility routines for manulating any type of PETSc object.
      4: */
     5:  #include petsc.h

      9: /*@C
     10:    PetscObjectGetType - Gets the object type of any PetscObject.

     12:    Not Collective

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

     19:    Output Parameter:
     20: .  type - the object type

     22:    Level: advanced

     24:    Concepts: object type
     25: @*/
     26: PetscErrorCode PETSC_DLLEXPORT PetscObjectGetType(PetscObject obj, const char *type[])
     27: {
     29:   if (!obj) SETERRQ(PETSC_ERR_ARG_CORRUPT, "Null object");
     31:   *type = obj->type_name;
     32:   return(0);
     33: }

     37: /*@C
     38:    PetscObjectSetType - Sets the object type of any PetscObject.

     40:    Not Collective

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

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

     50:    Level: advanced

     52:    Concepts: object type
     53: @*/
     54: PetscErrorCode PETSC_DLLEXPORT PetscObjectSetType(PetscObject obj, const char type[])
     55: {
     57:   if (!obj) SETERRQ(PETSC_ERR_ARG_CORRUPT, "Null object");
     59:   SETERRQ(PETSC_ERR_SUP, "Cannot set the type of a generic PetscObject")
     60: }