I've been trying to use a PetscBag to read in a number of options I want to pass to a program I'm writing. Before I came across the documentation for PetscBag, I was planning on using a struct and a function that would take the struct and use PetscOptionsGetSometype()
to set all the values in the struct.
I figured that PetscBag would save some code, but seeing as each variable in the PetscBag has to use PetscOptionsRegisterSometype()
, it looks to be just as much code to use the PetscBag as not to use it.
On the other hand, I don't know that much about how the struct I was going to use would work when run with MPI.
What should a PetscBag be used for? What advantages do they have over vanilla structs?