Sample code for SIMPLEalgorithm and solving LidDriven Cavity flow test is uploaded
Dear colleagues!
I uploaded sample code for SIMPLEalgorithm and solving liddriven cavity flow test (Re=1000). It has a lot of shortcomings, but I think that it will be useful for all newcomers. I intend to develop it further, but now it very slowly converges. All notes will be useful, and hope it can be discussed. The code can be found here: http://www.cfdonline.com/Wiki/Sampl...9__Fortran_90 It predecessor  the code for solving SmithHutton test can be found here: http://www.cfdonline.com/Wiki/Appro...s_and_examples http://www.cfdonline.com/Wiki/Sampl...t__Fortran_90 I'll be glad and grateful to get your opinion about it 
SimpleAlgorithm
HI, I started programming a SIMPLEalgorithm myself based on Malalaskera's book on a staggered grid for a 1d constant density permanent flow. It's not working properly, velocities converge in 2 or 3 iterations but pressures don't, I think I have a problem with BC's treatment (constant known velocity on one side and constant known pressure on the other). Do you know any book that shows a clear example on boundary conditions treatment?, I mean, all books, from Patankar, Anderson, Versteg, etc talk about it, but no one has a clear example.
The code you wrote is on a colocated grid, do you think it has advantages over a staggered grid for the 1d problem I'm trying to solve? Thanks in advance 
Hi! Look here, may be this will be useful http://www.cfdonline.com/Forums/mai...flowpipe.html

SIMPLE Algortihm in Matlab
Hi all..I have been trying to code for viscous incompressible flows using SIMPLE algorithm in Matlab using a staggered grid approach. The code worked really well for Couette flow. However for lid driven cavity, it is not showing required results. I have tried using different Reynolds number like 10, 100, 1000. Initially the code seems as if it will give the required result, however after a few iterations, oscillations begin and the solution fails. Is there any stability criteria for this flow problem? The time step I had used was 0.001 secs. Any kind of help in this regards will be highly appreciated. Thanks a lot.

hi,
1 in boundary conditions, the velocity in the wall is Up or Uface? 2 or we need to define the boundary conditions for both velocities? and how? 
Hi Hamza
We specify both velocity components on the wall u and v (0,0 for solid walls, 1,0 for moving wall) Just fixed them (they are not corrected during solution). U_face calculated inside program. check the code,it's quite simple. 
Hi, thank you Michail for your answers they are very useful, i realized the code for Newtonian and NonNewtionian fluids.
Now i am trayin the viscoelastic case, but i have a problem of numerical stability when increasing WE (WE is a parameter in the equations), i want to know if you have an idea about this. you can find the problem and equations in the article "Finite volume simulation of viscoelastic laminar flow in a liddriven cavity" (Kerim Yapici, Bulent Karasozen, Yusuf Uludag) (2009) 
hallo Hamza
I took a glance through the paper You referred. First of all I would like to ask  how many equations do You solve? If 3 You are wrong. There are 3 additional equations for stresses. They are solving the same way as momentum equations. so if You want to apply my code for this problem You should: 1) Add to solver 3 equations for stresses, likewise for scalar here https://www.cfdonline.com/Wiki/Samp...t__Fortran_90 (the same scheme i used here for momentum equations U,V) 2) Modify source term in momentum equations 3) Modify boundary conditions (eq. 7 in that paper) so there is some work here. But not too complicated :)) 
Hi michail,
yes i see, we have three unknowns added so automatically we need 3 others equations which are given in the constitutive equations. i have applied all your remarks, and when i take WE=0 (newtonian case) the results are good, but for WE#0 here the convergence problem occurs, I think i need a special treatment of source term !! 
Hallo
the source term in equations of motion (for U and V) summarized from pressure gradient and stresses.] I guess, You should implement underrelaxation for stresses' equations: (look in S. Patankar) ! underrelaxation  Alfa = 0.8 Urf = 1. / Alfa Ap(1:NXmaxC,1:NYmaxC,1) = Ap(1:NXmaxC,1:NYmaxC,1) * Urf Sp(1:NXmaxC,1:NYmaxC,1) = Sp(1:NXmaxC,1:NYmaxC,1) + (1.  Alfa )* & Ap(1:NXmaxC,1:NYmaxC,1)*F(1:NXmaxC,1:NYmaxC,1) ! / Alfa Ap(1:NXmaxC,1:NYmaxC,2) = Ap(1:NXmaxC,1:NYmaxC,2) * Urf Sp(1:NXmaxC,1:NYmaxC,2) = Sp(1:NXmaxC,1:NYmaxC,2) + (1.  Alfa )* & Ap(1:NXmaxC,1:NYmaxC,2)*F(1:NXmaxC,1:NYmaxC,2) ! / Alfa ! I would make relaxation koeffitient alfa=0.2..0.3 in stress equations. and... Check for bugs. Check for bugs. sleep a night and again: Check for bugs Good luck! 
Hi Michail, I hope you had a good day,
Yes i am used the underrelaxation for stresses equations. and now i am trying again... thank you for your encouragement :) 
Okay, then let's take it more seriously:
1) First of all, check all math in Your code. For this: a) go through all possible referencesissues  at least 20, better 30. a0) the solution of the problem is already found, search it in publications b) make yourself sure, that you have complete understanding of mathematical formulation of governing equations and solution algorithm c) check all signs and coefficients in your code, write out all math with pencil and paper, compare them. 2) Debug Your code. a) make UDS scheme for momentum ans stresses equations b) make the lowest possible underrelaxation coefficients  0.50.7 for velocities, 0.1 for pressure. c) search for suitable relaxation coefficients for stresses  vary them from 0.01 till 0.99 d) get convergence. then you can go for improvement 
Boundary Condition Treatment
Hello Mijail,
I am solving the lid driven cavity using SIMPLE algorithm in C++. I am facing same problem as yours, the treatment of boundary condition as no clear example is available in Patankar and Malalaskera's Book. Please recommend me some solution to your problem Quote:

All times are GMT 4. The time now is 03:37. 