Macros and Tensor classes; Solid Material Models
I’ve had a look at the implementation of materials (in our nomenclature that’s ‚M‘ processes, i.e. stress-strain relationships) in FEBio. There are some very interesting features worth considering for OGS6. We’re not that far, yet. But some of the concepts I describe below are relevant for ALL physical processes (automated input file handling, tensor classes, …). So have a look if you get a chance:
- All materials are derived from a base class which contains features shared by many materials with common characteristics (elasticity, viscoelasticity, incompressibility, plasticity,…). These base classes contain virtual functions that need to be overwritten/specified in a particular material class. This ensures common interfaces in my understanding.
- Macros are used to “register” the materials in the framework of FEBio. The same goes for material parameters that are defined. You simply declare them (.h) and register them in the framework (.h and *.cpp). The entire programme is then aware of their existence.
- The result of the previous two points is very useful: All one needs to do to implement a new material is create a class (derived from a base class) and implement the functions for stresses and the tangent modulus (necessary for the Newton-Raphson scheme). The software is automatically aware of the material class, its parameters etc. No additional coding has to be done in terms of calling the function at the right place, or reading the parameters (and material definition) from the input file. All of this functionality is automatically created by the macros and the base class design. One place in the code only - the logical one (actual model).
- Tensor (first, second and fourth order; various symmetries) classes and operators are defined. As calculations with tensors require (always the same) loops, this creates for very compact coding. One can multiply a second with a fourth order tensor simply by writing a*c instead of writing out the loops. The advantage is readability of the code just like you had the formula in front of you.
- Certain basic kinematic quantities are computed and stored at the integration point level. The stress and tangent functions then do not have to compute them again and again but simply use the value (they get the integration point as an argument). What data is transferred depends on the material class again to avoid unnecessary communication (no history necessary for elastic materials).
- There’s a tangent diagnostic tool that allows automatic checking whether the implemented analytical tangent is correct. Testing occurs via a specific input file and command line argument. It compares the analytical tangent to one obtained by a residual finite difference. Very useful, as both mathematical and coding errors are common for more complex models (fourth order tensors are tricky).
All in all – this is extremely efficient from a coding perspective later on because only the necessary information (the actual constitutive model) needs to be coded and nothing else. Plus coding is just like writing an equation. Everything I outlined is explained in more detail here (it’s a short enough read):
Th