xref: /petsc/src/sys/objects/gtype.c (revision ace3abfce6818a63371c0ee8fdb525d96915299c)
1 #define PETSC_DLL
2 /*
3      Provides utility routines for manulating any type of PETSc object.
4 */
5 #include "petscsys.h"  /*I   "petscsys.h"    I*/
6 
7 #undef __FUNCT__
8 #define __FUNCT__ "PetscObjectGetType"
9 /*@C
10    PetscObjectGetType - Gets the object type of any PetscObject.
11 
12    Not Collective
13 
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);
18 
19    Output Parameter:
20 .  type - the object type
21 
22    Level: advanced
23 
24    Concepts: object type
25 @*/
26 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectGetType(PetscObject obj, const char *type[])
27 {
28   PetscFunctionBegin;
29   PetscValidHeader(obj,1);
30   PetscValidPointer(type,2);
31   *type = obj->type_name;
32   PetscFunctionReturn(0);
33 }
34 
35 #undef __FUNCT__
36 #define __FUNCT__ "PetscObjectSetType"
37 /*@C
38    PetscObjectSetType - Sets the object type of any PetscObject.
39 
40    Not Collective
41 
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
47 
48    Note: This does not currently work since we need to dispatch by type.
49 
50    Level: advanced
51 
52    Concepts: object type
53 @*/
54 PetscErrorCode PETSCSYS_DLLEXPORT PetscObjectSetType(PetscObject obj, const char type[])
55 {
56   PetscFunctionBegin;
57   PetscValidHeader(obj,1);
58   PetscValidCharPointer(type,2);
59   SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP, "Cannot set the type of a generic PetscObject");
60 }
61