The advection term

In the previous sessions, we have explored in details how openFoam solves the diffusion equation. In this session, we will explore how openFoam solves the advection equation.

Do you remember the governing equations of hydrothermal convection?

(79)\[\varepsilon \rho_f \left( \beta_f \frac{\partial p}{\partial t} - \alpha_f \frac{\partial T}{\partial t} \right) = \nabla \cdot \left( \rho_f \frac{k}{\mu_f} (\nabla p - \rho_f \vec{g}) \right)\]
(80)\[(\varepsilon \rho_f C_{pf} + (1-\varepsilon)\rho_r C_{pr})\textcolor{green}{\frac{\partial T}{\partial t}} = \textcolor{orange}{\nabla \cdot (\lambda_r \nabla T)} \textcolor{purple}{- \rho_f C_{pf} \vec{U}\cdot \nabla T} + \frac{\mu_f}{k} \parallel \vec{U} \parallel ^2 - \left( \frac{\partial ln \rho_f}{\partial ln T} \right)_p \frac{Dp}{Dt}\]

We have already looked into the numerical FVM implementation of the time derivative (green term)and the diffusion term (orange term). The purple term is the transport, so-called advection term. It handles the transport of variable by the flowing fluid. In the hydrothermal convection case, we have transported the temperature, \(T\), with the fluid.

In a more general form, a transient advection diffusion equation can be written as:

\[\frac{\partial T}{\partial t} = \nabla \cdot \left( D \nabla T \right) - \nabla \cdot \left( \vec{U} T \right)\]

where \(T\) is the transported scalar, \(D\) is the diffusion coefficient and \(\vec{U}\) is the velocity field.

Forms of the advection term

Did you notice the difference between the temperature equation for hydrothermal convection and the general advection equation? In the form given for hydrothermal convection, the specific heat \(c_p\), the density \(\rho\), and the velocity \(\vec{u}\) are outside the divergence, while in the general form they are inside (due to the conservative form of the equation). The advection term is also called the convective term.

The reason is not that these variables are constant but lies in the way the energy conservation equation is derived. If it is written in terms of energy (e.g. enthalpy or internal energy), we would have the respective terms included in the divergence. If we use the temperature form, using the specific heat, those terms end up outside the divergence. You can check [Guo et al., 2020] for details.

Resolving advection

The core of the advection or transport term solving process involves the discretization of the convective fluxes across the control volume faces. This discretization is crucial as it directly influences the stability and accuracy of the simulation. OpenFOAM provides a range of discretization schemes, such as the upwind, linear, and higher-order schemes like QUICK and cubic, which are discussed and presented in [Moukalled et al., 2016]. The choice of scheme can significantly affect the numerical diffusion and the overall solution’s fidelity.

For instance, the upwind scheme, while robust and simple, can introduce considerable numerical diffusion, leading to a less accurate representation of sharp gradients. On the other hand, higher-order schemes offer improved accuracy but can lead to numerical instabilities if not handled properly. You can find an introduction to different advection scheme in the companian lecture on finite elements and general numerical methods (Link)

Moreover, OpenFOAM incorporates the concept of boundedness through the use of Total Variation Diminishing (TVD) schemes to ensure that the physical and numerical bounds are respected, especially in cases involving steep gradients or when dealing with scalar quantities like concentration or temperature.

In essence, the numerics of solving the advection/transport term in OpenFOAM involve a careful balance between accuracy, stability, and computational efficiency, with the choice of discretization schemes and iterative solvers playing pivotal roles in the outcome of the CFD simulations.

Implementation in OpenFoam

The way the advection term is solved is again handled in the file system/fvSchemes.

 1/*--------------------------------*- C++ -*----------------------------------*\
 2=========                 |
 3\\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
 4\\    /   O peration     | Website:  https://openfoam.org
 5 \\  /    A nd           | Version:  7
 6  \\/     M anipulation  |
 7\*---------------------------------------------------------------------------*/
 8FoamFile
 9{
10  version     2.0;
11  format      ascii;
12  class       dictionary;
13  location    "system";
14  object      fvSchemes;
15}
16// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
17
18ddtSchemes
19{
20  default         Euler;
21}
22
23gradSchemes
24{
25  default         Gauss linear;
26}
27
28divSchemes
29{
30   default         none;
31   div(phi,T)      Gauss MUSCL grad(T);
32}
33
34laplacianSchemes
35{
36  default         none;
37  laplacian(DT,T) Gauss linear corrected;
38}
39
40 interpolationSchemes
41{
42  default         linear;
43}
44
45snGradSchemes
46{
47  default         corrected;
48}
49
50
51// ************************************************************************* //

Tip

There are many different advection schemes implemented in OpenFoam. You can get a list of all available schemes by changing the advection scheme to something invalid like abc. Openfoam will throw an error and list all available schemes.