PetscBagCreate#

Create a bag of values. A PetscBag is a representation of a C struct that can be saved to and read from files, can have values set from the options database

Synopsis#

#include "petscbag.h"   
PetscErrorCode PetscBagCreate(MPI_Comm comm, size_t bagsize, PetscBag *bag)

Collective

Input Parameters#

  • comm - communicator to share bag

  • bagsize - size of the C structure holding the values, for example sizeof(mystruct)

Output Parameter#

  • bag - the bag of values

Notes#

After creating the bag, for each entry in the C struct call the appropriate PetscBagRegisterInt() etc to define the C structs layout

The size of the struct must be small enough to fit in a PetscInt; by default PetscInt is 4 bytes; this means a bag cannot be larger than 2 gigabytes in length. The warning about casting to a shorter length can be ignored below unless your struct is too large

See Also#

PetscBag, PetscBagGetName(), PetscBagView(), PetscBagLoad(), PetscBagGetData() PetscBagRegisterReal(), PetscBagRegisterInt(), PetscBagRegisterBool(), PetscBagRegisterScalar() PetscBagSetFromOptions(), PetscBagDestroy(), PetscBagRegisterEnum()

Level#

intermediate

Location#

src/sys/classes/bag/bag.c

Examples#

src/ts/tutorials/ex77.c
src/ts/tutorials/ex53.c
src/snes/tutorials/ex27.c
src/snes/tutorials/ex69.c
src/snes/tutorials/ex17.c
src/snes/tutorials/ex36.c
src/sys/tutorials/ex5.c
src/ts/tutorials/ex76.c
src/dm/tutorials/ex7.c
src/sys/tutorials/ex5f90.F90


Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages