In this article, we will demonstrate how to carry out verification of simple problems in OpenFOAM.
Steady state laminar flow over a flat plate is one of the most taught classic fluid mechanics problems. One of the reasons for its popularity is we can learn the concept of boundary layers very deeply while very simply. And we can calculate the boundary layer thickness by using Blasius’s method for laminar boundary layer as :
In this formula, delta_99 is the distance from the wall at which the fluid velocity is 99% of the free stream velocity.
Blasius laminar boundary layer approach is also useful in learning CFD and verification. In this hands on tutorial, we are going to guide you through your OpenFOAM case setup to calculate this very interesting problem.
We will use OpenFOAM’s classic “Cavity” tutorial as a base for our case. Although the solver used is icoFoam which is a transient laminar solver, we will run the simulation long enough to reach at the steady state solution, first.
So, we copy the cavity tutorial to our desired location. You can do this easily in your Ubuntu terminal as follows:
cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity/cavity $your_desired_location
Then we need to change the name of the case directory to flat_plate
mv cavity flat_plate && cd flat_plate
After that, we need to change boundary conditions to create the flow over a flat plate. So, we will need to change the patch names and patch types for the inlet and outlet boundaries. The imagination of the boundary conditions are as follows:
Here, we use inlet velocity U=1m/s, plate length L=1m and kinematic viscosity of fluid nu=1e-3 for simplicity. This will yield Reynolds number of 1000 for our flow.
First, we will create the mesh using cavity’s default settings. Run the command
blockMesh
paraFoam -touch
Then, we can look at the mesh inside Paraview. Open the flat_plate.OpenFOAM in Paraview and choose OpenFOAM Reader. Then, inside Paraview, in the drop-down menu, choose Surface with Wdges. You can see the mesh, now.
Since the length is 0.1 in x-direction, we will change it to 1m. Lets go to system/blockMeshDict to correct it! As the vertices coordinates are (x: 0~1, y:0~1, z:0~0.1) while the scale is 0.1, we will change the scale to 1.0.
Also, inside the Mesh Regions, we do not have our desired inlet, outlet, top and bottom walls. So, we need to edit blockMeshDict file to create these patches. Inside the blockMeshDict, we can see that there are only movingWall and fixedWalls boundaries. We will change the name and types of these walls.
Now we have divided the patches into our desired patches. We blockMesh again and we get our desired patches at proper length.
After that, we change the 0/U and 0/p boundary conditions for inlet and outlet conditions. Since we assume inlet velocity as 1 m/s in the positive x-direction, we define uniform (1 0 0) for 0/U while we assign zeroGradient for 0/p. For the outlet, the pressure is uniform 0 while velocity is calculated from solver, thus assigning zeroGradient.
Then we will change the fluid properties such that the kinematic viscosity nu=0.001. We need to edit constant/transportProperties file and change nu to 0.001 as below.
Finally, we can run our solver since we do not need to care much about other things like fvSchemes and fvSolution files. We run the solver by typing
icoFoam > log | tail -f log. The simulation will run very fast.
In Paraview, we can see our velocity field and the boundary layer.
We can see the velocity profile is not fully developed yet. So, the results may not be as reliable as we want. Now, we can improve the mesh by increasing length in x direction and refining the mesh in y direction. So, we will go to system/blockMeshDict file and increase x coordinates to 5 and we will use stretching layers in y direction near the wall. The new blockMeshDict would look like this:
Now we will validate the result against that by Blasius. The above is measured at x=2m. Since U=1 and nu=1e-3, Re = 2000. The new result would look like below.
Then from Blasius formula, delta_99 = 0.223m. From the above result, we can see that the velocity is around 0.99m/s at y=0.22m. Our simulation results have very good agreement with the theoretical solution by Blasius!
Summary
We carried out CFD simulations for laminar flow over a flat plate using OpenFOAM’s icoFoam solver. We used “Cavity” tutorial and modified it to create our desired proper boundary conditions. The results show good agreements with Blasius boundary layer formula. Increasing domain length in flow direction and using stretching mesh lead to much better results than original results.
We need to always remember that CFD is not just Colorful Fluid Dynamics. Understanding the flow phenomena and carrying out proper verification and validation steps make your result reliable and useful.
You can download the case files here.
Other useful and interesting blog posts here
Our newsletter here
2 comments
This is one of the best explanations I’ve come across. Thanks!
Thank you. Please stay tuned for more information.