[Table of Contents][Index]

5.2 Boundaries

In this section we discuss the way in which boundaries are treated in OpenFOAM. The subject of boundaries is a little involved because their role in modelling is not simply that of a geometric entity but an integral part of the solution and numerics through boundary conditions or inter-boundary ‘connections’. A discussion of boundaries sits uncomfortably between a discussion on meshes, fields, discretisation, computational processing etc. Its placement in this Chapter on meshes is a choice of convenience.

We first need to consider that, for the purpose of applying boundary conditions, a boundary is generally broken up into a set of patches. One patch may include one or more enclosed areas of the boundary surface which do not necessarily need to be physically connected.

Figure 5.3: Patch attributes

There are three attributes associated with a patch that are described below in their natural hierarchy and Figure 5.3 shows the names of different patch types introduced at each level of the hierarchy. The hierarchy described below is very similar, but not identical, to the class hierarchy used in the OpenFOAM library.

Base type
The type of patch described purely in terms of geometry or a data ‘communication link’.
Primitive type
The base numerical patch condition assigned to a field variable on the patch.
Derived type
A complex patch condition, derived from the primitive type, assigned to a field variable on the patch.

5.2.1 Specification of patch types in OpenFOAM

The patch types are specified in the mesh and field files of a OpenFOAM case. More precisely:

  • the base type is specified under the type keyword for each patch in the boundary file, located in the constant/polyMesh directory;
  • the numerical patch type, be it a primitive or derived type, is specified under the type keyword for each patch in a field file.

An example boundary file is shown below for a sonicFoam case, followed by a pressure field file, p, for the same case:

18  6
19  (
20      inlet
21      {
22          type            patch;
23          nFaces          50;
24          startFace       10325;
25      }
26      outlet
27      {
28          type            patch;
29          nFaces          40;
30          startFace       10375;
31      }
32      bottom
33      {
34          type            symmetryPlane;
35          inGroups        1(symmetryPlane);
36          nFaces          25;
37          startFace       10415;
38      }
39      top
40      {
41          type            symmetryPlane;
42          inGroups        1(symmetryPlane);
43          nFaces          125;
44          startFace       10440;
45      }
46      obstacle
47      {
48          type            patch;
49          nFaces          110;
50          startFace       10565;
51      }
52      defaultFaces
53      {
54          type            empty;
55          inGroups        1(empty);
56          nFaces          10500;
57          startFace       10675;
58      }
59  )
61  // ************************************************************************* //

17  dimensions      [1 -1 -2 0 0 0 0];
19  internalField   uniform 1;
21  boundaryField
22  {
23      inlet
24      {
25          type            fixedValue;
26          value           uniform 1;
27      }
29      outlet
30      {
31          type            waveTransmissive;
32          field           p;
33          phi             phi;
34          rho             rho;
35          psi             thermo:psi;
36          gamma           1.4;
37          fieldInf        1;
38          lInf            3;
39          value           uniform 1;
40      }
42      bottom
43      {
44          type            symmetryPlane;
45      }
47      top
48      {
49          type            symmetryPlane;
50      }
52      obstacle
53      {
54          type            zeroGradient;
55      }
57      defaultFaces
58      {
59          type            empty;
60      }
61  }
63  // ************************************************************************* //

The type in the boundary file is patch for all patches except those that have some geometrical constraint applied to them, i.e. the symmetryPlane and empty patches. The p file includes primitive types applied to the inlet and bottom faces, and a more complex derived type applied to the outlet. Comparison of the two files shows that the base and numerical types are consistent where the base type is not a simple patch, i.e. for the symmetryPlane and empty patches.

5.2.2 Base types

The base and geometric types are described below; the keywords used for specifying these types in OpenFOAM are summarised in Table 5.1.

Figure 5.4: Axi-symmetric geometry using the wedge patch type. 

Selection Key Description

patch generic patch
symmetryPlane plane of symmetry
empty front and back planes of a 2D geometry
wedge wedge front and back for an axi-symmetric geometry
cyclic cyclic plane
wall wall — used for wall functions in turbulent flows
processor inter-processor boundary

Table 5.1: Basic patch types. 

The basic patch type for a patch condition that contains no geometric or topological information about the mesh (with the exception of wall), e.g. an inlet or an outlet.
There are instances where a patch that coincides with a wall needs to be identifiable as such, particularly where specialist modelling is applied at wall boundaries. A good example is wall turbulence modelling where a wall must be specified with a wall patch type, so that the distance from the wall to the cell centres next to the wall are stored as part of the patch.
For a symmetry plane.
While OpenFOAM always generates geometries in 3 dimensions, it can be instructed to solve in 2 (or 1) dimensions by specifying a special empty condition on each patch whose plane is normal to the 3rd (and 2nd) dimension for which no solution is required.
For 2 dimensional axi-symmetric cases, e.g. a cylinder, the geometry is specified as a wedge of small angle (e.g.  < 5∘) and 1 cell thick running along the plane of symmetry, straddling one of the coordinate planes, as shown in Figure 5.4. The axi-symmetric wedge planes must be specified as separate patches of wedge type. The details of generating wedge-shaped geometries using blockMesh are described in section 5.3.3.
Enables two patches to be treated as if they are physically connected; used for repeated geometries, e.g. heat exchanger tube bundles. One cyclic patch is linked to another through a neighbourPatch keyword in the boundary file. Each pair of connecting faces must have similar area to within a tolerance given by the matchTolerance keyword in the boundary file. Faces do not need to be of the same orientation.
If a code is being run in parallel, on a number of processors, then the mesh must be divided up so that each processor computes on roughly the same number of cells. The boundaries between the different parts of the mesh are called processor boundaries.

5.2.3 Primitive types

The primitive types are listed in Table 5.2.


Description of condition for patch field ϕ

Data to specify


Value of ϕ is specified


Normal gradient of ϕ is specified


Normal gradient of ϕ is zero


Boundary field ϕ derived from other fields


Mixed fixedValue/ fixedGradient condition depending on the value in valueFraction

refValue, refGradient, valueFraction, value

A mixed condition with tensorial valueFraction, e.g.  for different levels of mixing in normal and tangential directions

refValue, refGradient, valueFraction, value

Table 5.2: Primitive patch field types. 

5.2.4 Derived types

There are numerous derived types of boundary conditions in OpenFOAM, too many to list here. Instead a small selection is listed in Table 5.3. If the user wishes to obtain a list of all available models, they should consult the OpenFOAM source code. Derived boundary condition source code can be found at the following locations:

  • in $FOAM_SRC/finiteVolume/fields/fvPatchFields/derived
  • within certain model libraries, that can be located by typing the following command in a terminal window
            find $FOAM_SRC -name ”*derivedFvPatch*”

  • within certain solvers, that can be located by typing the following command in a terminal window
            find $FOAM_SOLVERS -name ”*fvPatch*”

Types derived from fixedValue

Data to specify


Replaces the normal of the patch value so the flux across the patch is zero


When p is known at inlet, U is evaluated from the flux, normal to the patch


When p is known at inlet, U is calculated from the flux in the inletDirection

value, inletDirection

Specifies a vector boundary condition, normal to the patch, by its magnitude; +ve for vectors pointing out of the domain


Total pressure p0 = p +  1ρ|U |2 2 is fixed; when U changes, p is adjusted accordingly


Calculates a fluctuating variable based on a scale of a mean value

referenceField, fluctuationScale
Types derived from fixedGradient/zeroGradient


Calculates normal component of U at inlet from flux


Sets fixedGradient pressure based on the atmospheric pressure gradient

Types derived from mixed


Switches U and p between fixedValue and zeroGradient depending on direction of U

inletValue, value

Switches U and p between fixedValue and zeroGradient depending on direction of U

outletValue, value

Combination of pressureInletVelocity and inletOutlet


Combination of pressureDirectedInletVelocity and inletOutlet

value, inletDirection

Transmits supersonic pressure waves to surrounding pressure p∞


Transmits oblique shocks to surroundings at p∞, T∞, U ∞

pInf, TInf, UInf
Other types

slip zeroGradient if ϕ is a scalar; if ϕ is a vector, normal component is fixedValue zero, tangential components are zeroGradient


Mixed zeroGradient/ slip condition depending on the valueFraction; = 0 for slip


Note: p is pressure, U is velocity
Table 5.3: Derived patch field types. 

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

Training for OpenFOAM Meshing

See our Essential CFD and Applied CFD courses for details

Essential CFD

  • Introduction to meshes: meshing strategy, blockMesh quick start, boundary types, patch groups
  • snappyHexMesh introduction: surface patching, castellated mesh, surface snapping
  • snappyHexMesh enhancements: assessing mesh quality, layer insertion, cell refinement introduction
  • snappyHexMesh refinement: tri-surface manipulation, surface refinement, region refinement, more on layers

Applied CFD

  • Mesh conversion: conversion tools, extracting surface, re-meshing a poor quality mesh, anisotropic refinement
  • snappyHexMesh feature capturing: extracting feature, explicit feature capturing, adjusting features
  • snappyHexMesh meshing baffles: baffle geometry, face zones, creating baffles
  • Multi-region meshing: geometry for multi-regions, specifying regions, capturing region boundaries