Setup Guide

OpenFOAM Inlet Boundary Conditions: velocity, pressure, turbulence

Inlet boundary conditions are among the most common sources of divergence and poor results in OpenFOAM. Getting velocity, pressure, and turbulence quantities right at the inlet is fundamental to any simulation.

By CFDpilot · Updated April 2026

Velocity inlet (fixedValue)

The standard velocity inlet specifies a uniform velocity normal to the patch:

// 0/U
inlet
{
    type        fixedValue;
    value       uniform (10 0 0);   // 10 m/s in x-direction
}

For an inlet normal to a surface where the direction isn't purely axial, specify the exact vector. The magnitude must match your Reynolds number target.

Pressure at the inlet

When velocity is fixed at the inlet, pressure must be free to float — use zeroGradient:

// 0/p
inlet
{
    type        zeroGradient;
}

Never fix both velocity and pressure at the same patch — this over-constrains the problem and causes divergence.

Pressure-driven flow (no fixed velocity)

If you drive the flow by a pressure difference rather than a fixed velocity:

// 0/p — fixed pressure at inlet
inlet
{
    type        fixedValue;
    value       uniform 101325;   // Pa (absolute)
}

// 0/U — velocity is computed, must allow backflow
inlet
{
    type        pressureInletOutletVelocity;
    value       uniform (0 0 0);
}

Turbulence quantities at the inlet: k and epsilon

For k-ε and k-ω SST, you need to specify turbulence intensity I and a length scale L at the inlet. Typical values: I = 5% (0.05) for internal flows, L = 0.07 × hydraulic diameter.

// k = 1.5 * (U * I)^2
// Example: U=10 m/s, I=0.05 → k = 1.5 * (10*0.05)^2 = 0.375 m²/s²

// epsilon = C_mu^0.75 * k^1.5 / L
// C_mu = 0.09, L = 0.07 * D_h
// Example: L=0.07m → epsilon = 0.09^0.75 * 0.375^1.5 / 0.07 ≈ 0.14 m²/s³
// 0/k
inlet
{
    type        fixedValue;
    value       uniform 0.375;
}

// 0/epsilon
inlet
{
    type        fixedValue;
    value       uniform 0.14;
}

Turbulence at the inlet: omega (k-omega SST)

// omega = k^0.5 / (C_mu^0.25 * L)
// Example: k=0.375, L=0.07 → omega ≈ 14.9 s⁻¹

// 0/omega
inlet
{
    type        fixedValue;
    value       uniform 14.9;
}

turbulentIntensityKineticEnergyInlet

OpenFOAM provides a convenience BC that computes k automatically from intensity and a reference velocity. This avoids manual calculation:

// 0/k
inlet
{
    type            turbulentIntensityKineticEnergyInlet;
    intensity       0.05;
    value           uniform 0.375;
}

turbulentMixingLengthDissipationRateInlet

The companion BC to compute epsilon automatically from a mixing length:

// 0/epsilon
inlet
{
    type            turbulentMixingLengthDissipationRateInlet;
    mixingLength    0.07;   // L = 0.07 * D_h in metres
    value           uniform 0.14;
}

// 0/omega — equivalent for k-omega SST
inlet
{
    type            turbulentMixingLengthFrequencyInlet;
    mixingLength    0.07;
    value           uniform 14.9;
}

These BCs recompute the turbulence quantities from k each time step, ensuring consistency with any updated k field at the inlet.

nut at the inlet

// 0/nut — computed from k and epsilon/omega at inlet
inlet
{
    type        calculated;
    value       uniform 0;
}

Non-uniform velocity profiles at the inlet

For fully developed pipe or channel flow, the inlet velocity should reflect the real profile rather than a uniform plug flow. Two approaches:

1. Power-law profile via codedFixedValue:

// 0/U — turbulent power-law profile (1/7 power law)
inlet
{
    type            codedFixedValue;
    value           uniform (0 0 0);
    name            powerLawInlet;
    code
    #{
        const fvPatch& p = this->patch();
        const vectorField& Cf = p.Cf();
        vectorField& U = *this;
        scalar R = 0.05;      // pipe radius [m]
        scalar Umax = 12.0;   // centreline velocity [m/s]
        forAll(Cf, i)
        {
            scalar r = mag(Cf[i] - vector(0,0,0));  // radial distance
            U[i] = vector(Umax * pow(1.0 - r/R, 1.0/7.0), 0, 0);
        }
    #};
}

2. Mapped inlet from a precursor simulation:

// 0/U — mapped from a periodic precursor channel
inlet
{
    type        mapped;
    offset      (0 0 0);
    interpolationScheme cellPoint;
    setAverage  false;
    value       uniform (10 0 0);
}

The mapped approach requires matching the inlet patch geometry to an internal region of a precursor periodic simulation. This is the most physically accurate method for turbulent inflow generation in LES.

Inlet boundary conditions for compressible solvers

For rhoSimpleFoam and rhoPimpleFoam, pressure is now a thermodynamic quantity with units Pa. Total pressure inlets are often more physical than fixed static pressure:

// 0/p — total pressure inlet for compressible flow
inlet
{
    type        totalPressure;
    p0          uniform 101325;   // total (stagnation) pressure [Pa]
    value       uniform 101325;
}

// 0/U — must allow the solver to set direction
inlet
{
    type        pressureInletOutletVelocity;
    value       uniform (0 0 0);
}

// 0/T — temperature at inlet
inlet
{
    type        fixedValue;
    value       uniform 300;   // 300 K
}

Turbulence intensity guidelines by application

Selecting the right turbulence intensity requires understanding the physical context of the inlet:

Common mistakes

Get your inlet conditions checked instantly — free

Upload your case and CFDpilot flags wrong inlet types, missing turbulence fields, and physically inconsistent values.

Check my inlet BCs →
Official documentation

Frequently Asked Questions

What turbulence intensity should I use at the inlet?

Use I = 5% for most standard internal flows (pipe, duct, channel). For wind tunnel inflows, I = 0.1–1%. For flows downstream of fans, bends, or grilles, use I = 10–20%. When data is unavailable, 5% is the standard engineering default for internal flows.

How do I calculate k and epsilon at the inlet?

k = 1.5 × (U × I)² where I is fractional turbulence intensity. epsilon = C_mu^0.75 × k^1.5 / L where C_mu = 0.09 and L = 0.07 × hydraulic diameter. For omega: omega = k^0.5 / (C_mu^0.25 × L). These formulas assume fully developed turbulence at the inlet.

Can I fix both velocity and pressure at the inlet?

No. Fixing both velocity (fixedValue) and pressure (fixedValue) at the same patch over-constrains the Navier-Stokes equations and leads to immediate divergence. Use fixedValue for velocity with zeroGradient for pressure, or fixedValue for pressure with pressureInletOutletVelocity for velocity.

What is pressureInletOutletVelocity and when should I use it?

pressureInletOutletVelocity computes velocity from the pressure gradient at the boundary for inflow, and applies zeroGradient for outflow. Use it when pressure is prescribed at the inlet (pressure-driven flow). It is also useful at outlets where backflow is expected, since it handles reversed flow without crashing the solver.

How do I specify a fully developed turbulent pipe profile at the inlet?

The most accurate approach is a mapped inlet from a precursor periodic pipe simulation. For simpler cases, use codedFixedValue with the 1/7 power law: U = U_max × (1 - r/R)^(1/7). This gives a reasonable approximation to the turbulent velocity profile without running a precursor simulation.

Why does the solver diverge in the first few iterations with my inlet setup?

Most early-iteration divergence from inlet BCs comes from: (1) k or epsilon set to zero causing division by zero, (2) both velocity and pressure fixed simultaneously, or (3) a very large initial velocity creating high CFL numbers. Check that k > 1e-6, that your pressure-velocity coupling is correct, and run potentialFoam to get a smooth initial velocity field before starting the turbulent solver.