In this post I am going to write a (hopefully) simple code in matlab to solve the cavity flow problem using the vorticity stream function formulation. I will the compare the result to the result calculated by the OpenFOAM solver, icoFoam. Writing your own solvers is fun, rewarding, and is a practice that really cements some of the fundamental knowledge of CFD.
- Introduction to the Cavity Flow Problem
- Governing Equations
- Finite Differences and Solver Algorithm
- Understanding and setting the boundary conditions
- Semi-discretization of the governing equations
- Solving the vorticity equation in time
- Solving for the vorticity at the boundaries
- Solving for the stream function
- Putting it all together
- Results/Comparison to icoFoam
- Conclusion and some References
Introduction to the Cavity Flow Problem
The cavity flow problem is described in the following figure. Basically, there is a constant velocity across the top of the cavity which creates a circulating flow inside. To simulate this there is a constant velocity boundary condition applied to the lid, while the other three walls obey the no slip condition. Different Reynolds numbers give different results, so in this post I’ll simulate Re=10, and Re=800. At high Reynolds numbers we expect to see a more interesting result with secondary circulation zones forming in the corners of the cavity.