[Table of Contents][Index][Version 5 | Version 4 | Version 3]

4.6 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.6.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 need removing when re-meshing.

4.6.2 The foamDictionary tool

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

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.4, 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;

© 2011-2017 OpenFOAM Foundation
CC-NC-ND 3.0