The Functor system: a new on-the-fly take on Material Properties based on C++ functions
In the context of solving multiphysics problems, the discretization of the partial differential equations (PDE) at hand often takes the spotlight. However, for most engineering users and even application developers, the discretization of the equations has already been performed. Instead, they are tasked with implementing specific closure relations and material properties. MOOSE has long enabled this using the Materials system. This system relied on the pre-computation of all properties before they are used in the PDE or in postprocessing. In this talk we will introduce the Functor system, which was deployed in MOOSE in 2021, then present a few applications of functors in flow modeling simulations by the NEAMS program. Functors first offer great flexibility in their evaluation. Rather than storing various arrays for material properties, they are evaluated on the fly at the location and state, e.g. current or old value, requested. Unlike regular material properties, several operations such as the time derivative, the divergence and the curl can be requested from a functor. Similar to material properties, functors can be made to depend on arbitrary combinations of variables, functions, postprocessors and other properties. However, unlike material properties, any of these can be substituted for a functor material property. Thanks to this, objects no longer need to be duplicated based on the types of their parameters.