[version 12][version 11][version 10][version 9][version 8][version 7][version 6]
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
- foamCleanPolyMesh
- deletes mesh files for a case; useful to execute before regenerating a mesh, particularly with snappyHexMesh which generates refinement history and other files that might need to be removed when re-meshing.
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
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
{
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 -value option causes only the entry to be written.
foamDictionary -entry "divSchemes.div(phi,U)" -value system/fvSchemes
The -keywords option causes only the keywords to be written.
foamDictionary -entry divSchemes -keywords system/fvSchemes
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.
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
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
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
cd pitzDaily
blockMesh
postProcess -list
foamGet flowRatePatch
name outlet;
functions
{
#includeFunc streamlines
#includeFunc flowRatePatch
}
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
foamInfo flowRateInletVelocity
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 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);
}