CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   help!on simple method code (http://www.cfd-online.com/Forums/main/90416-help-simple-method-code.html)

 houkensjtu July 9, 2011 10:45

help!on simple method code

I post a thread yesterday on SIMPLE method and Now I'm reading sample code from:
http://www.students.ncl.ac.uk/f.j.he...webs/codes.php

Maybe you are very familiar with this code.However I can't understand a paragrah in the main function in[simple.cpp]:

...
}/*}}}*/

void Boundary_velocities(Matrix& Vel_u, Matrix& Vel_v) { /*{{{*/
//The values of the final row are the same as the previous one
unsigned FinalRow_u = Vel_u.numberOfRows() - 1;
for (unsigned col = 0; col < Vel_u.numberOfCols(); col++)
Vel_u(FinalRow_u, col) = Vel_u(FinalRow_u - 1, col);

//The values of the final column are the same as the previous one
unsigned FinalCol_v = Vel_v.numberOfCols() - 1;
for (unsigned row = 0; row < Vel_v.numberOfRows(); row++)
Vel_v(row, FinalCol_v) = Vel_v(row, FinalCol_v - 1);

//------------Mass balance
unsigned FinalCol_u = Vel_u.numberOfCols() - 1;
for (unsigned row = 1; row < Vel_u.numberOfRows() - 2; row++)
Vel_u(row, FinalCol_u) = 0;
//Vel_u(row, FinalCol_u) = Vel_u(row, FinalCol_u - 1) + Vel_v(row-1, FinalCol_u) - Vel_v(row,FinalCol_u);

//Vel_u(FinalRow_u-1, FinalCol_u) = Vel_u(FinalRow_u-1, FinalCol_u-1);
Vel_u(FinalRow_u-1, FinalCol_u) = 0;

unsigned FinalRow_v = Vel_v.numberOfRows() - 1;
for (unsigned col = 1; col < Vel_v.numberOfCols() - 1; col++)
Vel_v(FinalRow_v, col) = Vel_v(FinalRow_v - 1, col) + Vel_u(FinalRow_v,col-1) - Vel_u(FinalRow_v,col);

}
/*}}}*/

What does red part means?Is it trying to make sure the mass balance on the exit?or what?
I have also read other books like from patankar,but I am not quite clear that if SIMPLE method will automatically fufill the mass balance over all calculation region?

 All times are GMT -4. The time now is 21:06.