Extending Libraries
The OpenFOAM software includes over 80 shared libraries containing a range of functionality for numerics, linear solvers, modelling, meshing, post-processing, etc. Libraries are designed to be conveniently extended with the following features helping to make the task easier.
- Hierarchical design
- Libraries often begin with a generic base class from which classes of models, methods, etc are derived. Extending a library then involves adding one or more derived classes, using existing classes as examples to work from.
- Dynamic linking of libraries
- When a new library is created, it does not need to be linked directly into applications wishing to use its functionality. Instead, the user can dynamically link the library at run-time, through a setting in the case controlDict file.
- Run-time selection
- At run-time, OpenFOAM automatically creates lists of names of models and methods defined in libraries, from which the user can make a selection. For example, when a turbulence model library is used, a list of turbulence models is constructed at run-time, from which the user choose a model within one of the case input files. When a library is extended or a new one added, the new models/methods are automatically picked up by the run-time selection mechanism, so are available to the user.