Actual source code: petscbag.h

     4:  #include petsc.h

      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: $      typedef struct {
     15: $         PetscInt     height;
     16: $         PetscScalar  root;
     17: $         PetscReal    byebye;
     18: $      } MyParameters;
     19: $
     20: $      PetscBag     bag;
     21: $      MyParameters *params;
     22: $
     23: $      PetscBagCreate(PETSC_COMM_WORLD,sizeof(MyParameters),&bag);
     24: $      PetscBagGetData(bag,(void **)&params);
     25: $      PetscBagSetName(bag,"MyParameters");
     26: $      PetscBagRegisterInt(bag,&params.height,22,"height","Height of the water tower");
     27: $

     29: .seealso:  PetscBagSetName(), PetscBagGetName(), PetscBagView(), PetscBagLoad(), PetscBagGetData()
     30:            PetscBagRegisterReal(), PetscBagRegisterInt(), PetscBagRegisterTruth(), PetscBagRegisterScalar()
     31:            PetscBagSetFromOptions(), PetscBagRegisterVec(), PetscBagCreate(), PetscBagDestroy(), PetscBagRegisterEnum()
     32: S*/
     33: typedef struct _n_PetscBag*     PetscBag;
     34: typedef struct _n_PetscBagItem* PetscBagItem;

     36: EXTERN PetscErrorCode  PetscBagCreate(MPI_Comm,size_t,PetscBag*);
     37: EXTERN PetscErrorCode  PetscBagDestroy(PetscBag);
     38: EXTERN PetscErrorCode  PetscBagGetData(PetscBag,void **);
     39: EXTERN PetscErrorCode  PetscBagRegisterReal(PetscBag,void*,PetscReal, const char*, const char*);
     40: EXTERN PetscErrorCode  PetscBagRegisterString(PetscBag,void*,PetscInt,const char*, const char*, const char*);
     41: EXTERN PetscErrorCode  PetscBagRegisterScalar(PetscBag,void*,PetscScalar,const  char*,const  char*);
     42: EXTERN PetscErrorCode  PetscBagRegisterInt(PetscBag,void*,PetscInt,const  char*,const  char*);
     43: EXTERN PetscErrorCode  PetscBagRegisterEnum(PetscBag,void*,const  char*[],PetscEnum,const char*,const  char*);
     44: EXTERN PetscErrorCode  PetscBagRegisterTruth(PetscBag,void*,PetscTruth,const  char*,const  char*);

     46: EXTERN PetscErrorCode  PetscBagSetFromOptions(PetscBag);
     47: EXTERN PetscErrorCode  PetscBagGetName(PetscBag, char **name);
     48: EXTERN PetscErrorCode  PetscBagSetName(PetscBag, const char *, const char *);

     50: EXTERN PetscErrorCode  PetscBagView(PetscBag,PetscViewer);
     51: EXTERN PetscErrorCode  PetscBagLoad(PetscViewer,PetscBag*);

     53: EXTERN PetscErrorCode  PetscBagSetViewer(PetscBag,PetscErrorCode (*)(PetscBag,PetscViewer));
     54: EXTERN PetscErrorCode  PetscBagSetLoader(PetscBag,PetscErrorCode (*)(PetscBag,PetscViewer));
     55: EXTERN PetscErrorCode  PetscBagSetDestroy(PetscBag,PetscErrorCode (*)(PetscBag));

     58: #endif