[petsc-users] Suggestions for code with dof >> 1 ?

Jed Brown jedbrown at mcs.anl.gov
Mon Oct 7 16:47:58 CDT 2013


Christophe Ortiz <christophe.ortiz at ciemat.es> writes:
> I am not sure to understand what you mean. What do you mean by modules able
> to register additional variables ?

It depends on the scope of your code.  If you are solving only one
problem, then you're probably happy to define a struct somewhere that
your entire code can see it and place your fields in there.  In that
case, you can use the offsetof() macro to do stable indexing within the
struct (so that you can add or reorder fields later without needing to
change code like matrix assembly).

Other projects are more like frameworks where users want to write
libraries of material models, process parametrizations, and the like.
If you had a single global struct, then everyone would be changing
things and you give up the ability to change the fields at run-time,
meaning that you'll have a soup of #ifdefs and in general, the struct
becomes a constant source of problems.  So you wouldn't want that.  A
better approach is to have a dynamic registration system where you
declare dependencies and access fields through an interface.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131007/d4271f03/attachment.pgp>


More information about the petsc-users mailing list