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