Date: 2025-03-29T05:58:44+00:00

Actual source code: gcookie.c

      1: /*
      2:      Provides utility routines for manulating any type of PETSc object.
      3: */
      4: #include <petsc/private/petscimpl.h>

      6: /*@
      7:   PetscObjectGetClassId - Gets the classid for any `PetscObject`

      9:   Not Collective

     11:   Input Parameter:
     12: . obj - any PETSc object, for example a `Vec`, `Mat` or `KSP`. It must be cast with a (`PetscObject`), for example,
     13:         `PetscObjectGetClassId`((`PetscObject`)mat,&classid);

     15:   Output Parameter:
     16: . classid - the classid

     18:   Level: developer

     20: .seealso: `PetscObject`, `PetscClassId`, `PetscObjectGetClassName()`, `PetscObjectGetType()`
     21: @*/
     22: PetscErrorCode PetscObjectGetClassId(PetscObject obj, PetscClassId *classid)
     23: {
     24:   PetscFunctionBegin;
     26:   PetscAssertPointer(classid, 2);
     27:   *classid = obj->classid;
     28:   PetscFunctionReturn(PETSC_SUCCESS);
     29: }

     31: /*@
     32:   PetscObjectGetClassName - Gets the class name for any `PetscObject`

     34:   Not Collective

     36:   Input Parameter:
     37: . obj - any PETSc object, for example a `Vec`, `Mat` or `KSP`. It must be cast with a (`PetscObject`), for example,
     38:         `PetscObjectGetClassName`((`PetscObject`)mat,&classname);

     40:   Output Parameter:
     41: . classname - the class name, for example "Vec"

     43:   Level: developer

     45: .seealso: `PetscObject`, `PetscClassId`, `PetscObjectGetType()`, `PetscObjectGetClassId()`
     46: @*/
     47: PetscErrorCode PetscObjectGetClassName(PetscObject obj, const char *classname[])
     48: {
     49:   PetscFunctionBegin;
     51:   PetscAssertPointer(classname, 2);
     52:   *classname = obj->class_name;
     53:   PetscFunctionReturn(PETSC_SUCCESS);
     54: }