Skip to content

Reporting tools

Andrew Heather requested to merge feature-reporting into develop

Adds new function objects

  • graphFunctionObject: Accumulates function object result values and renders into a graph in SVG format
  • foamReport: Replaces user-supplied keywords by run-time computed values in a text file

Examples - output added to simpleFoam/motorBike tutorial

Graph example:

Minimal example by using system/controlDict.functions to plot the residuals from the solverInfo function Object:

residualGraph1.svg

residualGraph
{
    type            graphFunctionObject;
    libs            (utilityFunctionObjects);
    writeControl    writeTime;

    logScaleX       no;
    logScaleY       yes;

    xlabel          "Iteration";
    ylabel          "log10(Initial residual)";

    functions
    {
        line1
        {
            object      solverInfo1;
            entry       Ux_initial;
        }
        line2
        {
            object      solverInfo1;
            entry       Uy_initial;
        }
        line3
        {
            object      solverInfo1;
            entry       Uz_initial;
        }
        line4
        {
            object      solverInfo1;
            entry       p_initial;
        }
    }
}

foamReport example

Markdown template rendered to PDF: foamReport1.pdf

foamReport1
{
    // Mandatory entries (unmodifiable)
    type            foamReport;
    libs            (utilityFunctionObjects);

    template        "<system>/myTemplate.md";

    substitutions
    {
        divSchemes1
        {
            type        dictionaryValue;
            object      fvSchemes;

            entries
            {
                divSchemes      "divSchemes";
            }
        }
        fvSolution1
        {
            type        dictionaryValue;
            path        "<system>/fvSolution";

            entries
            {
                solver_p        "solvers/p/solver";
                solver_p_tol    "solvers/p/tolerance";
                solver_p_reltol "solvers/p/relTol";
                solver_U        "solvers/U/solver";
                solver_U_tol    "solvers/U/tolerance";
                solver_U_reltol "solvers/U/relTol";
            }
        }
        controlDict1
        {
            type        dictionaryValue;
            path        "<system>/controlDict";

            entries
            {
                initial_deltaT       "deltaT";
            }
        }
        continuityErrors
        {
            type        functionObjectValue;
            functionObject continuityError1;

            entries
            {
                cont_error_local    local;
                cont_error_global   global;
                cont_error_cumulative cumulative;
            }
        }
    }

    // Optional entries (runtime modifiable)

    // Inherited entries
    ...
}

where the entries mean:

Property     | Description                          | Type | Reqd | Deflt
type         | Type name: foamReport                | word | yes  | -
libs         | Library name: utilityFunctionObjects | word | yes  | -
template     | Path to ser-supplied text template   | string | yes | -
substitutions | dictionary of substitution models   | dictionary | yes | -

The entries sections typically define a dictionary of keys (to use in your template) and method to set the key value, e.g. for a dictionaryValue model used to set values from the fvSolution file:

  type        dictionaryValue;
  path        "<system>/fvSolution";

  entries
  {
      solver_p        "solvers/p/solver";
      solver_p_tol    "solvers/p/tolerance";
  }

Merge request reports