Function objects

Many workflows can be configured using function objects to derive additional data both during and after calculations, typically in the form of additional logging to the screen, or generating text, image and field files.

This eliminates the need to store all run-time generated data, hence saving considerable resources. Furthermore, function objects are readily applied to batch-driven processes, improving reliability by standardising the sequence of operations and reducing the amount of manual interaction.


Function objects are specified in the main controlDict file in an optional functions dictionary:

    <user-defined name>
        type        <object type>;
        libs        (<list of library file names>);

Each object is defined in its own sub-dictionary, under a user-defined name, and evaluated either:

  • at run-time,
  • via the postProcess utility, or
  • the -postProcess option, available to solver applications.

Run-time control

When applied at run-time, the objects are controlled according to the optional two options:

  • executeControl: when the object is updated, and
  • writeControl: when the object output is written.

These take the same type of values as the writeControl entry in the controlDict, with some additions:

  • timeStep: time step intervals, e.g. every x time steps
  • writeTime: calculation write times, i.e. alongside standard field output
  • runTime/adjustableRunTime: run time intervals, e.g. every x seconds of calculation time
  • clockTime: (wall) clock time intervals
  • cpuTime: CPU time intervals
  • onEnd: on completion of the case.

For example, to set a Courant Number function object to evaluate every 2 time steps and write at every output time:

        type                CourantNo;
        libs                ("");
        executeControl      timeStep;
        executeInterval     2;
        writeControl        writeTime;

Data derived from function objects are written to the case postProcessing directory, typically in a subdirectory with the same name as the object, e.g.


Post-process utility

When specified without additional arguments, the postProcess utility executes all objects defined in the controlDict:


Some functions can be invoked directly without the need to specify the input dictionary using the -func option, e.g. to execute the Courant number function object:

postProcess -func 'CourantNo'

Application post-processing

The -postProcess option is available to all solvers, and operates similarly to the stand-alone postProcess utility. For example, having completed a simpleFoam calculation:

simpleFoam -postProcess

will execute all function objects defined in the controlDict.


Function objects are grouped into libraries that perform similar operations or operate on similar object types:

Further information

Source code:

Copyright ©  OpenCFD Ltd. 2017
Creative Commons License