OpenFOAM BCs

1 Boundary condition types

Boundary conditions can be of two principal types:

  • Value boundary conditions, where the value of the property at the boundary is set to a specified value. These are called Dirichlet boundary conditions. One example for the Dirichlet boundary conditions is the no-slip wall boundary condition, which sets the velocity to zero.
  • Gradient boundary conditions, where the gradient of a value is set to a specific value. These are called Neumann boundary conditions. An example is the velocity condition at an outlet, which is commonly given as a zero gradient in velocity.
  • There are combinations of these two types in the Cauchy and Mixed boundary condition.

All of the special boundary conditions are derived from these fundamental types.

In CFD the solution vector consists of pressure p and velocity U. So we have to give boundary conditions for these two properties.

In this document I will only describe the BCs we use, a full list of all available boundary conditions (most of which will not be of interest in our context) can be found here. The anatomy of an OpenFOAM boundary condition file is described here: OpenFOAM Boundary Condition Files.

1.1 Pressure Boundary Conditions

Most common pressure boundary conditions used in our simulations are:

  • fixedValue: set boundary condition to a fixed value (very often zero relative pressure at an outlet 1)
  • zeroGradient: this is the typical pressure BC that goes with a velocity BC that prescribes a fixed value for the velocity.
  • Windkessel boundaries are a special case, so see the Windkessel boundary documentation: Windkessel BCs

    /*--------------------------------*- C++ -*----------------------------------*\
    | =========                 |                                                 |
    | \\      /  F ield         | foam-extend: Open Source CFD                    |
    |  \\    /   O peration     | Version:     4.0                                |
    |   \\  /    A nd           | Web:         http://www.foam-extend.org         |
    |    \\/     M anipulation  |                                                 |
    \*---------------------------------------------------------------------------*/
    FoamFile
    {
        version     2.0;
        format      ascii;
        class       volScalarField;
        location    "0";
        object      p;
    }
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    dimensions      [0 2 -2 0 0 0 0];
    
    internalField   uniform 0;
    
    boundaryField
    {
        ICA
        {
            type            fixedValue;
            value           uniform 0;
        }
        ECA
        {
            type            fixedValue;
            value           uniform 0;
        }
        wall
        {
            type            zeroGradient;
        }
        APEX
        {
            type            zeroGradient;
        }
        SINUS
        {
            type            zeroGradient;
        }
        CCA
        {
            type            zeroGradient;
        }
    }
    // ************************************************************************* //
    

Important: OpenFOAM uses kinematic pressures, not static pressures. Note that the dimensions [0 2 -2 0 0 0 0]; are in \({m^{2} s^{-2}}\), not in \({Pa}\).

Kinematic pressure is related to static pressure as kinematic viscosity to dynamic viscosity:

\[p_{k} = \frac{p_{s}}{\rho}\]

See also: OpenFOAM User Guide: Kinematic Pressure

1.2 TODO Velocity Boundary Conditions

Velocity boundary conditions also have the two basic modes of setting a value and setting a gradient. But there are many more special use boundary conditions derived from these.

  • fixedValue boundary conditions need to set the components of the velocity vector.
  • fixedGradient boundary conditions are mostly used in the special form of a zeroGradient which does not need any parameters to be set.

The following shows these basic boundary condition in their native habitat:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | foam-extend: Open Source CFD                    |
|  \\    /   O peration     | Version:     4.0                                |
|   \\  /    A nd           | Web:         http://www.foam-extend.org         |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    location    "0";
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0 0 0);

boundaryField
{
    ICA
    {
        type            zeroGradient;
    }
    ECA
    {
        type            zeroGradient;
    }
    WALL
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }
    APEX
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }
    SINUS
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }
    CCA
    {
        type            fixedValue;
        value           uniform (0 0 1);
    }
}


// ************************************************************************* //

As you can see, the outlets have zeroGradient conditions, while both walls and inlet have fixedValue conditions. For the walls, the value is (0 0 0), while for the inlet the components are given in vector form (0 0 1), since the inlet in this case is in normal-z direction. Take care that you get the direction right! One of the most common mistakes is to set the flow direction to point out of the volume - which essentially sucks … the fluid out of the inlet, which rarely is what you want.

1.3 Special and complex boundary conditions

1.3.1 groovyBC

We will need to describe more complex inlet conditions, however. And while there are quite a few specialised boundary conditions available in OpenFOAM, I prefer to use an additional framework for that: “Swiss Army Knife for FOAM (swak4Foam). This comes with some very useful tools, but the one we are going to use most is the awesome (and awesomely named) groovyBC.

groovyBC allows to define almost any BC using a C code like syntax and has a lot of maths built in. It can be a bit daunting at first, but once you get it, you can do almost anything with it. See this document for more info: groovyBC

1.3.2 Windkessel Boundary Conditions

Windkessel Modelling describes the response of the circulation to the flow.

Windkessel BCs are implemented in haemoFOAM.

Footnotes:

1

In incompressible flow, the actual pressure is not needed. It is, therefore, common to use only relative pressures in simulations.

Author: Torsten Schenkel

Created: 2021-01-07 Thu 18:44