4.7 Case management tools

There are a set of applications and scripts that help with managing case files and help the user find and set keyword data entries in case files. The tools are described in the following sections.

4.7.1 File management scripts

The following tools help manage case files.

foamListTimes
lists the time directories for a case, omitting the 0 directory by default; the -rm option deletes the listed time directories, so that a case can be cleaned of time directories with results by the following command.

    foamListTimes -rm
foamCloneCase
creates a new case, by copying the 0, system and constant directories from an existing case; executed simply by the following command, where oldCase refers to an existing case directory.

    foamCloneCase oldCase newCase

4.7.2 foamDictionary and foamSearch

The foamDictionary utility offer several options for writing, editing and adding keyword entries in case files. The utility is executed with an OpenFOAM case dictionary file as an argument, e.g. from within a case directory on the fvSchemes file.


    foamDictionary system/fvSchemes
Without options, the utility lists all the keyword entries in the file, e.g. as follows for the fvSchemes file in the pitzDaily tutorial case for simpleFoam.
{
    FoamFile
    {
        version         2;
        format          ascii;
        class           dictionary;
        location        "system";
        object          fvSchemes;
    }
    ddtSchemes
    {
        default         steadyState;
    }
    gradSchemes
    {
        default         Gauss linear;
    }
    divSchemes
    {
        default         none;
        div(phi,U)      bounded Gauss linearUpwind grad(U);
        div(phi,k)      bounded Gauss limitedLinear 1;
        div(phi,epsilon) bounded Gauss limitedLinear 1;
        div(phi,omega)  bounded Gauss limitedLinear 1;
        div(phi,v2)     bounded Gauss limitedLinear 1;
        div((nuEff*dev2(T(grad(U))))) Gauss linear;
        div(nonlinearStress) Gauss linear;
    }
    laplacianSchemes
    {
        default         Gauss linear corrected;
    }
    interpolationSchemes
    {
        default         linear;
    }
    snGradSchemes
    {
        default         corrected;
    }
    wallDist
    {
        method          meshWave;
    }
}

The -entry option allows the user to print the entry for a particular keyword, e.g. divSchemes in the example below


    foamDictionary -entry divSchemes system/fvSchemes
The example clearly extracts the divSchemes dictionary.
divSchemes
{
    default         none;
    div(phi,U)      bounded Gauss linearUpwind grad(U);
    div(phi,k)      bounded Gauss limitedLinear 1;
    div(phi,epsilon) bounded Gauss limitedLinear 1;
    div(phi,omega)  bounded Gauss limitedLinear 1;
    div(phi,v2)     bounded Gauss limitedLinear 1;
    div((nuEff*dev2(T(grad(U))))) Gauss linear;
    div(nonlinearStress) Gauss linear;
}

The “/” syntax allows access to keywords with levels of sub-dictionary. For example, the div(phi,U) keyword can be accessed within the divSchemes sub-dictionary by the following command.


    foamDictionary -entry "divSchemes/div(phi,U)" system/fvSchemes
The example returns the single divSchemes/div(phi,U) entry.
div(phi,U)      bounded Gauss linearUpwind grad(U);

The -value option causes only the entry to be written.


    foamDictionary -entry "divSchemes/div(phi,U)" -value system/fvSchemes
The example removes the keyword and terminating semicolon, leaving just the data.
bounded Gauss linearUpwind grad(U)

The -keywords option causes only the keywords to be written.


    foamDictionary -entry divSchemes -keywords system/fvSchemes
The example produces a list of keywords inside the divSchemes dictionary.
default
div(phi,U)
div(phi,k)
div(phi,epsilon)
div(phi,omega)
div(phi,v2)
div((nuEff*dev2(T(grad(U)))))
div(nonlinearStress)

The example removes the keyword and terminating semicolon, leaving just the data.

bounded Gauss linearUpwind grad(U)

foamDictionary can set entries with the -set option. If the user wishes to change the div(phi,U) to the upwind scheme, they can enter the following.


    foamDictionary -entry "divSchemes.div(phi,U)" \
        -set "bounded Gauss upwind" system/fvSchemes
An alternative “=” syntax can be used with the -set option which is particularly useful when modifying multiple entries:


    foamDictionary -set "startFrom=startTime, startTime=0" system/controlDict

foamDictionary can add entries with the -add option. If the user wishes to add an entry named turbulence to divSchemes with the upwind scheme, they can enter the following.


    foamDictionary -entry "divSchemes.turbulence" \
       -add "bounded Gauss upwind" system/fvSchemes

The foamSearch script, demonstrated extensively in section 4.5 , uses foamDictionary functionality to extract and sort keyword entries from all files of a specified name in a specified dictionary. The -c option counts the number of entries of each type, e.g. the user could searche for the choice of solver for the p equation in all the fvSolution files in the tutorials.


    foamSearch -c $FOAM_TUTORIALS fvSolution solvers/p/solver
The search shows GAMG to be the most common choice in all the tutorials.


     59 solver          GAMG;
      3 solver          PBiCG;
     18 solver          PCG;
      5 solver          smoothSolver;

4.7.3 The foamGet script

The foamGet script copies configuration files into a case quickly and conveniently. The user must be inside a case directory to run the script or identify the case directory with the -case option. Its operation can be described using an example case, e.g. the pitzDaily case which can be obtained as follows:


    run
    cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
    cd pitzDaily
The mesh is generated for the case by going into the case directory and running blockMesh:


    cd pitzDaily
    blockMesh
The user might decide before running the simulation to configure some automatic post-processing as described in Section 6.2 . For example, the user can list the pre-configured function objects by the following command:


    postProcess -list
From the output, the user could select the patchFlowRate function to monitor the flow rate at the outlet patch. The patchFlowRate configuration file can be copied into the system directory using foamGet:


    foamGet patchFlowRate
In order to monitor the flow through the outlet patch, the patch entry in patchFlowRate file should be set as follows:


    patch    outlet;
The patchFlowRate configuration is then included in the case by adding to the functions sub-dictionary in the controlDict file:


    functions
    {
        ...
        #includeFunc writeObjects(kEpsilon:G) // existing entry
        #includeFunc patchFlowRate
    }

4.7.4 The foamInfo script

The foamInfo script provides quick information and examples relating to a subject that the user specifies. The subject can relate to models (including boundary conditions and packaged function objects), applications and scripts. For example, it prints information about the simpleFoam solver by typing the following:


    foamInfo simpleFoam
Information for the flowRateInletVelocity boundary condition can similarly be obtained by typing the following:


    foamInfo flowRateInletVelocity
The output includes: the location of the source code header file for this boundary condition; the description and usage details from the header file; and, a list of example cases that use the boundary condition.

The example usage for volumetric flow rate can be copied to replace the inlet boundary condition in the pitzDaily example from Section 4.7.3 . The volumetric flow rate, equivalent to a uniform flow speed of 10 m/s, is eqn so the modified inlet patch entry in the U file in the 0 directory should be:


    inlet
    {
        type                flowRateInletVelocity;
        volumetricFlowRate  2.54e-4;
        extrapolateProfile  yes;
        value               uniform (0 0 0);
    }
The simpleFoam solver can then be run. The solution at convergence (around 280 steps), visualised in ParaView, shows a nonuniform velocity profile at the inlet, due to the extrapolateProfile being switched on. The flow rate at the outlet, from the function object set up in Section 4.7.3 , is written to a surfaceFieldValue.dat file in the postProcessing/patchFlowRate/0 directory. The value converges towards the inlet flow rate.
OpenFOAM v10 User Guide - 4.7 Case management tools
CFD Direct