# PetscBag
PETSc object that manages a collection of user data including parameters. A bag is essentially a C struct with serialization (you can save it and load it from files). 
## Synopsis
```
typedef struct _n_PetscBag     *PetscBag;
```



## Sample Usage
```none
      typedef struct {
         PetscInt     height;
         PetscScalar  root;
         PetscReal    byebye;
      } MyParameters;

      PetscBag     bag;
      MyParameters *params;

      PetscCall(PetscBagCreate(PETSC_COMM_WORLD,sizeof(MyParameters),&bag));
      PetscCall(PetscBagGetData(bag,(void **)&params));
      PetscCall(PetscBagSetName(bag,"MyParameters"));
      PetscCall(PetscBagRegisterInt(bag,&params.height,22,"height","Height of the water tower"));
```



## See Also
 `PetscBagSetName()`, `PetscBagGetName()`, `PetscBagView()`, `PetscBagLoad()`, `PetscBagGetData()`
`PetscBagRegisterReal()`, `PetscBagRegisterInt()`, `PetscBagRegisterBool()`, `PetscBagRegisterScalar()`
`PetscBagSetFromOptions()`, `PetscBagRegisterVec()`, `PetscBagCreate()`, `PetscBagDestroy()`, `PetscBagRegisterEnum()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscbag.h.html#PetscBag">include/petscbag.h</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscbag.h)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
