OpenFOAM cheat sheet

Case directory structure

_myCaseName
+-- _0
|   +-- p
|   +-- U
|   +-- ...
+-- _constant
|   +-- _polyMesh
|   +-- xProperties
+-- _postProcessing
+-- _system
    +-- blockMeshDict
    +-- controlDict
    +-- fvSchemes
    +-- fvSolution

Stopping and resuming runs

If you are running an OpenFOAM solver in the foreground of a terminal, you can stop execution with Ctrl+C. If you are running it in the background, you can kill the corresponding process (OpenFOAM conveniently outputs its PID at the start of a run). Be aware that both of these approaches do not save the latest time-step/iteration.

If you want to interrupt execution and save the latest time-step/iteration, you can change the stopAt directive in your system/controlDict file to writeNow:

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          writeNow; // <-------

endTime         50;

Assuming you have runTimeModifiable set to yes, the OpenFOAM solver will stop running and write the data for the latest iteration.

You can resume a run that was previously interrupted by setting the startFrom directive to latestTime and re-executing the solver.

Cleaning up

To remove the mesh and the solution in the current case folder, run

$> foamCleanTutorials

This will also remove each of the processorN directories if running in parallel. There are also the commands:

$> foamCleanPolyMesh // Delete the mesh
$> foamListTimes -rm // Delete saved solutions
$> foamListTimes -rm -processor // For parallel runs

Example transportProperties file

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.x                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

nu              nu [ 0 2 -1 0 0 0 0 ] 0.01; //Re 100
//nu              nu [ 0 2 -1 0 0 0 0 ] 0.001;  //Re 1000

// ************************************************************************* //

The exponents for each of the SI units are specified in square brackets, and the order is [ kg m s K mol A cd ]. E.g. in the above example, the kinematic viscosity is $\nu = \frac{\mu}{\rho} = 0.01 \frac{m^2}{s}$ (for an incompressible solver, the kinematic viscosity is sufficient, as the density is constant).