Tutorial 2 – Lid Driven Cavity

Lid-driven Cavity

For the pdf version of this tutorial, see the userguide.

This tutorial describes how to set up and run the first non-trivial flow problem. The lid-driven cavity flow is a standard test case for numerical schemes, and a number of results have been published in literature, see e.g. [1][2]. This tutorial assumes that you have completed the previous tutorial, know how to edit files and postprocess the solution with your favorite visualization tool, e.g. ParaView. Also, the later parts of the tutorial assume that you have access to a computer with an MPI-based parallelization with at least 4 computing cores – otherwise, it will just take a lot longer :).

The tutorial is split into two parts: The basic part will teach you about setting up the code and running the simulations. The advanced part will build on this and give you a glimpse on how to make modification to code to accommodate more complex simulation and add features you might need. If you are just interested in running the code as is, you may skip the advanced part, or just complete parts of it.

Flow description

The flow under consideration is essentially incompressible and two-dimensional, but we will use the three-dimensional code for the compressible Navier-Stokes equations to solve it here. This is not the most efficient way to compute this flow, but it works well to show you how to set up and run a simulation in this tutorial. The computation will be conducted in a three-dimensional, square domain with periodic boundary conditions in the “third” direction. The wall of the cavity are modeled as isothermal walls, and a fixed flow is prescribed at the upper boundary, i.e. the lid of the domain. For the Reynolds numbers investigated here, this generates a steady, vortical flow field in the cavity.

The following picture shows the resulting velocity field and streamlines for $Re=400$.
Contours of velocity magnitude for the $Re=400$ lid-driven cavity case.

Compiler options

Make sure that FLEXI is compiled with the cmake options listed in the following table.

Option Value Comment
FLEXI_MPI ON optional

Table: Cmake options for the cavity simulation. \label{tab:cavity_cmakeoptions}

The standard settings are sufficient for this example. To check whether they are set, change to your build folder and open the cmake GUI

ccmake [flexi root directory]

If necessary, set the above options and then compile the code by issuing


These settings are identical for both parts of the tutorial. Now continue with the basic or advanced tutorial!

  • Basic Tutorial

    Basic Tutorial

  • Advanced Tutorial

    Advanced Tutorial

[1] S. K. N. ;. . C. T. Ghia U.; Ghia, “High-re solutions for incompressible flow using the navier-stokes equations and a multigrid method,” Journal of computational physics, vol. 48, p. 387–411, 1982.
title = {High-Re Solutions for Incompressible Flow Using the Navier-Stokes Equations and a Multigrid Method},
volume = {48},
journal = {Journal of Computational Physics},
author = {Ghia, U.; Ghia, K. N.; Shin, C. T.},
year = {1982},
pages = {387--411}
[2] W. J. S. ;. . T. Gao Z.; Hesthaven, “Efficient absorbing layers for weakly compressible flows,” Submitted to journal of scientific computing, 2016.
title = {Efficient Absorbing Layers for Weakly Compressible Flows},
journal = {submitted to Journal of Scientific Computing},
author = {Gao, Z.; Hesthaven, J. S.; Warburton, T.},
year = {2016},