Actual source code: petscbag.h
2: #ifndef PETSCBAG_H
3: #define PETSCBAG_H
5: #include <petscsys.h>
7: /* SUBMANSEC = Sys */
9: /*S
10: PetscBag - PETSc object that manages a collection of user data including parameters.
11: A bag is essentially a C struct with serialization (you can save it and load it from files).
13: Level: beginner
15: Sample Usage:
16: .vb
17: typedef struct {
18: PetscInt height;
19: PetscScalar root;
20: PetscReal byebye;
21: } MyParameters;
23: PetscBag bag;
24: MyParameters *params;
26: PetscBagCreate(PETSC_COMM_WORLD,sizeof(MyParameters),&bag);
27: PetscBagGetData(bag,(void **)¶ms);
28: PetscBagSetName(bag,"MyParameters");
29: PetscBagRegisterInt(bag,¶ms.height,22,"height","Height of the water tower");
30: .ve
32: .seealso: `PetscBagSetName()`, `PetscBagGetName()`, `PetscBagView()`, `PetscBagLoad()`, `PetscBagGetData()`
33: `PetscBagRegisterReal()`, `PetscBagRegisterInt()`, `PetscBagRegisterBool()`, `PetscBagRegisterScalar()`
34: `PetscBagSetFromOptions()`, `PetscBagRegisterVec()`, `PetscBagCreate()`, `PetscBagDestroy()`, `PetscBagRegisterEnum()`
35: S*/
36: typedef struct _n_PetscBag *PetscBag;
37: typedef struct _n_PetscBagItem *PetscBagItem;
39: PETSC_EXTERN PetscErrorCode PetscBagCreate(MPI_Comm, size_t, PetscBag *);
40: PETSC_EXTERN PetscErrorCode PetscBagDestroy(PetscBag *);
41: PETSC_EXTERN PetscErrorCode PetscBagGetData(PetscBag, void **);
42: PETSC_EXTERN PetscErrorCode PetscBagRegisterReal(PetscBag, void *, PetscReal, const char *, const char *);
43: PETSC_EXTERN PetscErrorCode PetscBagRegisterRealArray(PetscBag, void *, PetscInt, const char *, const char *);
44: PETSC_EXTERN PetscErrorCode PetscBagRegisterString(PetscBag, void *, PetscInt, const char *, const char *, const char *);
45: PETSC_EXTERN PetscErrorCode PetscBagRegisterScalar(PetscBag, void *, PetscScalar, const char *, const char *);
46: PETSC_EXTERN PetscErrorCode PetscBagRegisterInt(PetscBag, void *, PetscInt, const char *, const char *);
47: PETSC_EXTERN PetscErrorCode PetscBagRegisterInt64(PetscBag, void *, PetscInt64, const char *, const char *);
48: PETSC_EXTERN PetscErrorCode PetscBagRegisterIntArray(PetscBag, void *, PetscInt, const char *, const char *);
49: PETSC_EXTERN PetscErrorCode PetscBagRegisterEnum(PetscBag, void *, const char *const *, PetscEnum, const char *, const char *);
50: PETSC_EXTERN PetscErrorCode PetscBagRegisterBool(PetscBag, void *, PetscBool, const char *, const char *);
51: PETSC_EXTERN PetscErrorCode PetscBagRegisterBoolArray(PetscBag, void *, PetscInt, const char *, const char *);
52: PETSC_EXTERN PetscErrorCode PetscBagGetNames(PetscBag, const char *[]);
54: PETSC_EXTERN PetscErrorCode PetscBagSetFromOptions(PetscBag);
55: PETSC_EXTERN PetscErrorCode PetscBagGetName(PetscBag, char **);
56: PETSC_EXTERN PetscErrorCode PetscBagSetName(PetscBag, const char *, const char *);
57: PETSC_EXTERN PetscErrorCode PetscBagSetOptionsPrefix(PetscBag, const char *);
59: PETSC_EXTERN PetscErrorCode PetscBagView(PetscBag, PetscViewer);
60: PETSC_EXTERN PetscErrorCode PetscBagLoad(PetscViewer, PetscBag);
61: PETSC_EXTERN PetscErrorCode PetscBagViewFromOptions(PetscBag, PetscObject, const char[]);
63: PETSC_EXTERN PetscErrorCode PetscBagSetViewer(PetscBag, PetscErrorCode (*)(PetscBag, PetscViewer));
64: PETSC_EXTERN PetscErrorCode PetscBagSetLoader(PetscBag, PetscErrorCode (*)(PetscBag, PetscViewer));
65: PETSC_EXTERN PetscErrorCode PetscBagSetDestroy(PetscBag, PetscErrorCode (*)(PetscBag));
67: #define PETSC_BAG_FILE_CLASSID 1211219
69: #endif