Close

6th March 2013

OpenFOAM 2.2.0: Pre-processing

Dictionary Macro Expansion

OpenFOAM dictionary files include a macro syntax to allow convenient configuration of case files. The syntax has the following form where the value for a (10) is substituted for b in the subsequent line through the $ macro substitution.

a 10;
b $a;

In the latest version of OpenFOAM, this feature has been extended to allow variables to be accessed within different levels of sub-dictionaries, or scope. Scoping is performed using a ‘.’ (dot) syntax and is best illustrated by the following example, where b is set to the value of a, specified in a sub-dictionary called subdict.

subdict
{
    a 10;
}
b $subdict.a;

Additional syntax rules are:

  • To traverse up one level of sub-dictionary, use ‘..’ (double-dot) prefix, see below; to traverse up two levels use ‘...’ (triple-dot) prefix, etc.
  • To traverse to the top level dictionary use the ‘:’ (colon) prefix, see below.
  • For multiple levels of macro substitution, each specified with the ‘$’ dollar syntax, ‘{}’ brackets are required to protect the expansion, see below.
a 10;
b a;
c ${${b}}; // returns 10, since $b returns 'a', and $a returns 10

subdict
{
    b $..a;  // double-dot takes scope up 1 level, then 'a' is available

    subsubdict
    {
        c $:a; // colon takes scope to top level, then 'a' is available
    }
}

Patch Groups

In the latest version of OpenFOAM, we have introduced a new concept called patchGroups to allow users to group patches for pre- and post-processing. Patch groups can overlap, i.e. an individual patch can belong in multiple patch groups. Each patch can be added to one or more groups through the inGroups keyword. The information can be introduced at the meshing stage, e.g. in the boundary specification of the configuration of blockMesh, or in patchInfo in the configuration of snappyHexMesh, e.g.

refinementSurfaces
{
    motorBike
    {
        level (5 6);

        patchInfo
        {
            type     wall;
            inGroups (motorBike);
        }
    }
}

All constraint boundary types, e.g. empty, processor, etc. are automatically placed into a patch group of the same name.

Fields in OpenFOAM include boundary information in which users specify the type (boundary condition) and data for each individual patch. Users can now specify boundary conditions using individual patch names or patchGroup names, with patch names taking precedence over patch groups.

For the constraint boundary type described earlier, a standard file has been created in the installation etc/ directory that includes entries for all constraint patch groups, with the associated patch type, e.g.

cyclic  // patch group
{
    type  cyclic;  // patch type (i.e. boundary condition)
}

The user can include this file in field dictionaries, e.g. for U and p, to set all the possible constraint boundaries, as follows.

boundaryField
{
    //- Set patchGroups for constraint patches
    #include "$WM_PROJECT_DIR/etc/caseDicts/setConstraintTypes"
    ...
} 

While patch groups are useful for pre-processing, in particular in setting boundary conditions, they also offer post-processing capability. For example, Paraview will now display patch groups in the list of geometry objects, between internalMesh and individual patches, enabling convenient display of the patch groups. All post-processing tools, both utilities and function objects that allow patch selection using wild cards can also use patchGroups.

VTK Format Reading

The user can make use of Paraview as part of the meshing process, in conjunction with support for reading files in VTK legacy ASCII format, available in the latest release. Here are some examples of its use.

Feature edge meshes

Users can generate feature edge meshes in Paraview by using the Feature Edges filter. Data can be saved in VTK (ASCII) format and then be used by snappyHexMesh.

Surface meshes

Users can generate surface geometry in Paraview, e.g. using the Sphere Source filter. This geometry can then be saved in VTK (ASCII) format and used by surface mesh utilities, mesh generation with snappyHexMesh, etc.

Mesh generation

Paraview has some built-in utilities for mesh generation, e.g. Delaunay. Resulting meshes can be saved in VTK (ASCII) format and converted to OpenFOAM format with a new vtkUnstructuredToFoam mesh converter. Meshes include internal cells only, without boundaries.