Date: 2022-03-31T04:46:07+00:00

Actual source code: gtype.c

      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: @*/
     23: PetscErrorCode  PetscObjectGetType(PetscObject obj, const char *type[])
     24: {
     27:   *type = obj->type_name;
     28:   return 0;
     29: }

     31: /*@C
     32:    PetscObjectSetType - Sets the object type of any PetscObject.

     34:    Not Collective

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

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

     44:    Level: advanced

     46: @*/
     47: PetscErrorCode  PetscObjectSetType(PetscObject obj, const char type[])
     48: {
     51:   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP, "Cannot set the type of a generic PetscObject");
     52:   return 0;
     53: }