The open source CFD toolbox
Function objects

Function objects are run-time selectable options that generate additional output both during and after the calculation. These vary from providing additional logging to the screen, to generating text, image and field files.

Many workflows can be configured to generate the desired post-processing data during the run. 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.

# Usage

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

functions
{
<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 output at every output time:

functions
{
Co1
{
type                CourantNo;
libs                ("libfieldFunctionObjects.so");
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.

\$FOAM_CASE/postProcessing/<functionObjectName>/<time>/<data>


## Post-process utility

postProcess -func 'Co'


## Application post-processing

<application> -postProcess


For example, having completed a simpleFoam calculation:

simpleFoam -postProcess


# Options

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

Source code: