2D Lid Driven Cavity Flow using SIMPLE algorithm

版本 1.1.0 (7.6 KB) 作者: MJ Sarfi
The classical lid-driven cavity flow is solved for stead state using SIMPLE algorithm.
3.1K 次下载
更新时间 2018/8/8

查看许可证

Boundary conditions:

v=0 on all sides. u=0 on right,left and bottom and u=lid velocity at top BC

Numerical method:

SIMPLE algorithm used for resolving velocity-pressure coupling. Staggered grid for u and v. To see how indexing works in staggered grid, Please check out "Versteeg, Malalasekera: an introduction to computational fluid dynamics" text book. Discretization of the governing equations is based on this text book. u and v are updated by Jacobi method in every iteration. Pressure correction equation is directly solved using a penta-diagonal matrix algorithm in every iteration. Proper choice of under-relaxation factors needed for convergence. Jacobi method is the least efficient way for this type of problems but it's simple and easy to prallelize. You are encouraged to apply other iterative methods such as line by line TDMA, Guess-seidel, multigrid or SOR for faster convergence.

Pressure correction:

I often see people struggling with solving the pressure correction equation in SIMPLE algorithm because the BCs for P' are unclear. here is how to tackle it:
1) pressure is a relative concept. So, clamp the pressure of one node in the domain to zero as a boundary condition and the pressure at other nodes will be measured relative to that point. It's a common practice to set P(1,1)=0 and because P(1,1) is known P'(1,1)=0, but you'll need to compute P' at other nodes. It's obvious that aS = 0 for a P' point that is located on the bottom wall because there is no P' node under it but it has aW,aE,aN. Other boundary P' values will be set this way. you'll end up with a penta-diagonal matrix of coefficients.

I have written this code in Parallel using PETSc (C language). I am going to upload it on GitHub pretty soon. It's much faster than this version because:
1) It is parallel and not serial so you can you can use multiple processors.
2) The C version solves the Momentum equations by iterating a couple of times unlike the MATLAB version which does only one Jacobi sweep.
3) Most importantly, PETSc uses Krylov subspace iterative method (type:GMRES) and it also uses preconditioners (I found Additive Shwartz PC the best) to solve momentum and pressure correction, which is way more efficient than Jacobi method in terms of convergence rate.

引用格式

MJ Sarfi (2024). 2D Lid Driven Cavity Flow using SIMPLE algorithm (https://www.mathworks.com/matlabcentral/fileexchange/68348-2d-lid-driven-cavity-flow-using-simple-algorithm), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2018a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Partial Differential Equation Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.1.0

Fixed a mistake in assembling the matrix of coefficients for the pressure correction equation
Fixed another mistake about the defining the Peclet number in power-law upwinding scheme

1.0.0