Main ContribExamples/ExampleSimple2DFlow

From OpenFOAMWiki

The case on this page is outdated and must be modified to work with newer OpenFOAM-versions. Improvements welcome

1 Internal Laminar Incompressible Viscous Flow

The title may sound complicated, but this is a good place to start if you are new to computational fluid dynamics (CFD). Let's break it down:

  • Internal: the flow is completely bounded by solid surfaces.
  • Laminar: no macroscopic mixing of adjacent fluid layers.
  • Incompressible: variations in fluid density are negligible.
  • Viscous: flow is friction-dominated rather than pressure-dominated

We will construct the simplest possible flow example, which is seen in every fluid mechanics textbook. The OpenFOAM case will be constructed in two dimensions. Effectively, this simulates the flow that will occur between infinitely wide parallel plates. Download the case here:


Untar the case in your run directory, for example /home/OpenFOAM/username/run.

2 Geometry and Mesh Creation

blockMesh is an OpenFOAM utility for creating simple geometries and meshes. blockMesh reads the file blockMeshDict which can be found in the constant/polyMesh directory. The example is set up according to the instructions in the OpenFOAM Users Manual. The flow will be parallel to the x axis. The thickness of the blocks (the z direction) does not matter because it's a 2D problem. We specify vertices, blocks, and patches. We don't need to specify edges because they're straight. The patches in the xz plane are defined as walls, the patches in the yz plane are defined as patches, and the patches in the xy plane are empty because the problem is 2D. To create the mesh, run blockMesh <path> 2D_flow. Files called cells, faces, points, and boundary will be created in the constant/polyMesh directory.

3 Boundary Conditions

Edit the file called boundary. Below the header is the number 5, indicating five dictionaries in the file. The dictionary names correspond to the boundaries defined in blockMeshDict. The file will already contain the correct nFaces and startFace for each boundary. All we have to do is define the type for each patch. The upper and lower faces are type wall, the inlet and outlet are type patch, and the "front" and "back" faces are "empty." The presence of the empty faces tells OpenFOAM that this is a 2D case.

We also have to edit the files in the directory 2D_flow/0 to define the fields for each boundary. The file called U defines velocity, and P defines pressure. To be continued...

4 Simulation Control

To be continued...

5 Run the Case

To be continued...

6 Post-Processing

Here is a color map of the velocity magnitude for fully developed laminar flow. Fully developed laminar flow between infinite parallel plates

6.1 Reference

Robert W. Fox, Alan T. McDonald, Philip J. Pritchard. Introduction to Fluid Mechanics. John Wiley and Sons, 2004.