6.4 Monitoring and managing jobs

This section is concerned primarily with successful running of OpenFOAM jobs and extends on the basic execution of solvers described in section 3.1. When a solver is executed, it reports the status of equation solution to standard output, i.e. the screen, if the level debug switch is set to 1 or 2 (default) in DebugSwitches in the $WM_PROJECT_DIR/etc/controlDict file. An example from the beginning of the solution of the cavity tutorial is shown below where it can be seen that, for each equation that is solved, a report line is written with the solver name, the variable that is solved, its initial and final residuals and number of iterations.


    Starting time loop

Time = 0.005

Max Courant Number = 0
BICCG:  Solving for Ux, Initial residual = 1, Final residual = 2.96338e-06, No Iterations 8
ICCG:  Solving for p, Initial residual = 1, Final residual = 4.9336e-07, No Iterations 35
time step continuity errors : sum local = 3.29376e-09, global = -6.41065e-20, cumulative = -6.41065e-20
ICCG:  Solving for p, Initial residual = 0.47484, Final residual = 5.41068e-07, No Iterations 34
time step continuity errors : sum local = 6.60947e-09, global = -6.22619e-19, cumulative = -6.86725e-19
ExecutionTime = 0.14 s


Time = 0.01

Max Courant Number = 0.585722
BICCG:  Solving for Ux, Initial residual = 0.148584, Final residual = 7.15711e-06, No Iterations 6
BICCG:  Solving for Uy, Initial residual = 0.256618, Final residual = 8.94127e-06, No Iterations 6
ICCG:  Solving for p, Initial residual = 0.37146, Final residual = 6.67464e-07, No Iterations 33
time step continuity errors : sum local = 6.34431e-09, global = 1.20603e-19, cumulative = -5.66122e-19
ICCG:  Solving for p, Initial residual = 0.271556, Final residual = 3.69316e-07, No Iterations 33
time step continuity errors : sum local = 3.96176e-09, global = 6.9814e-20, cumulative = -4.96308e-19
ExecutionTime = 0.16 s


Time = 0.015

Max Courant Number = 0.758267
BICCG:  Solving for Ux, Initial residual = 0.0448679, Final residual = 2.42301e-06, No Iterations 6
BICCG:  Solving for Uy, Initial residual = 0.0782042, Final residual = 1.47009e-06, No Iterations 7
ICCG:  Solving for p, Initial residual = 0.107474, Final residual = 4.8362e-07, No Iterations 32
time step continuity errors : sum local = 3.99028e-09, global = -5.69762e-19, cumulative = -1.06607e-18
ICCG:  Solving for p, Initial residual = 0.0806771, Final residual = 9.47171e-07, No Iterations 31
time step continuity errors : sum local = 7.92176e-09, global = 1.07533e-19, cumulative = -9.58537e-19
ExecutionTime = 0.19 s

6.4.1 The foamJob script for running jobs

The user may be happy to monitor the residuals, iterations, Courant number etc. as report data passes across the screen. Alternatively, the user can redirect the report to a log file which will improve the speed of the computation. The foamJob script provides useful options for this purpose with the following executing the specified <solver> as a background process and redirecting the output to a file named log:


    foamJob <solver>
For further options the user should execute foamJob -help. The user may monitor the log file whenever they wish, using the UNIXtail command, typically with the -f ‘follow’ option which appends the new data as the log file grows:


    tail -f log

6.4.2 The foamLog script for monitoring jobs

There are limitations to monitoring a job by reading the log file, in particular it is difficult to extract trends over a long period of time. The foamLog script is therefore provided to extract data of residuals, iterations, Courant number etc. from a log file and present it in a set of files that can be plotted graphically. The script is executed by:


    foamLog <logFile>

The files are stored in a subdirectory of the case directory named logs. Each file has the name <var>_<subIter> where <var> is the name of the variable specified in the log file and <subIter> is the iteration number within the time step. Those variables that are solved for, the initial residual takes the variable name <var> and final residual takes <var>FinalRes. By default, the files are presented in two-column format of time and the extracted values.

For example, in the cavity tutorial we may wish to observe the initial residual of the Ux equation to see whether the solution is converging to a steady-state. In that case, we would plot the data from the logs/Ux_0 file as shown in Figure 6.1. It can be seen here that the residual falls monotonically until it reaches the convergence tolerance of   −5
10   \relax \special {t4ht=.


PICT\relax \special {t4ht=

Figure 6.1: Initial residual of Ux in the cavity tutorial


foamLog generates files for everything it feasibly can from the log file. In the cavity tutorial example, this includes:

  • the Courant number, Courant_0;
  • Ux equation initial and final residuals, Ux_0 and UxFinalRes_0, and iterations, UxIters_0 (and equivalent Uy data);
  • cumulative, global and local continuity errors after each of the 2 p equations, contCumulative_0, contGlobal_0, contLocal_0 and contCumulative_1, contGlobal_1, contLocal_1;
  • residuals and iterations from the 2 p equations p_0, pFinalRes_0, pIters_0 and p_1, pFinalRes_1, pIters_1;
  • and execution time, executionTime.