pressure boundary conditions for collocated grid for Navier-Stokes
Assumptions:
1. Uniform equally spaced grid 2. 2D When using the Chorin Projection method to solve the incompressible NS on a collocated grid we end up having to solve the following elliptic PDE where we have the face velocities Our boundary conditions on all four sides are When solving the pressure Poisson equation on the 4 boundaries is the procedure the same as if we were using the staggered grid? I've read some literature on it and I still don't quite understand if the pressure boundary conditions are treated differently. In my code I have Code:
P(1,:) = P(2,:) the pressure boundaries are treated differently. I was curious if my understanding of how to implement the pressure BCs on a collocated is correct. In my code I am using standard central differencing with extra treatment for the handling the ghost points. |
Actually, fixing the homogeneous Neumann BC, you have to correct the source term with the correct normal velocity components. Otherwise, the compatibility condition is not fulfilled.
I can suggest to have a look to the procedure I used here, you will find the answer to what you are asking for https://www.researchgate.net/publica...y-driven_flows https://www.researchgate.net/publica...taggered_grids |
Pressure BC
Hi Dr. Denaro,
Thank you for the two papers! In terms of the homogenous Neumann BC in Dr. Tryggva's code, is that what the u and v velocity terms are acting as? Upon first read I was quite confused. |
Quote:
|
Pressure BC
1 Attachment(s)
Hi,
Upon reading your paper, I am curious if you could provide some insight on the differences between your pressure BC and the ones from the slides. The one in your paper has velocity components v_(n+1) and v* however the one of in Tryggva's only has the v* component. Conceptually yours makes more sense, but I'm not quite grasping the idea of it enough to have a full understanding. Sorry for the stupid question. |
Quote:
You can also see the BC in this way: once the homogeneous Neumann condition is set (d phy/dy=0) then you have v*=v_n+1 that you insert in the source term. Therefore, in the slides you have to consider the physical velocity component. |
Pressure BC
Hi Dr. Denaro,
Thank you for the excellent explanation, I will try both procedures. In terms of the corner boundary conditions, the pressure BC would be handled as follows (following the method from the slides) Code:
P(1,ny) = P(2,ny-1) + (1/dt)*(dx*us(1,ny) + dy*vs(1,ny)); |
Quote:
You do not have to discretize the Neumann BC.s... just substitute the normal derivative into the equation for the nodes close to the frontiers, simplify the entries of the matrix and modify the source term. |
I give you an example for a 1D simple case:
d/dx(dp/dx) =(1/dt) du*/dx with the Neumann BC (U is the known physical velocity on the boundary) dp/dx = (1/dt) (u*- U) Now consider that i=1 is a boundary and i=2 is the first node where you write the pressure equation. X......X.....|.....X.....|..... FV grid 1......2............3......... i ordering Discretize at i=2 the equation first in this way (dp/dx|i=2+1/2 -dp/dx|i=1)/dx = (1/dt) (u*|i=2+1/2 - u*|i=1 )/dx Now use the Neumann BC dp/dx|i=1 =(1/dt)*(u*|i=1-U) and substitute in the equation (dp/dx|i=2+1/2)/dx = (1/dt) (u*|i=2+1/2-U )/dx discretize (p(3)-p(2))/dx^2 = (1/dt) ((u*(3)+u*(2))/2 -U)/dx This is the equation for the node i=2 after inserting the non-homogeneous Neumann BC. As you can see, no u* on the boundary is required, only the physical velocity U. You have no need to write the equation at i=1 where the BC is prescribed. |
Pressure BC
1 Attachment(s)
Hi Dr. Denaro,
That clears up a lot. Using SOR my implementation is Code:
for j=2:ny-1 Splitting up gives Using We get Now I use SOR which gives I am under the impression I still have the solve the PPE at i=2, ny, j=2,ny but with the non-homogeneous Neumann BC and apply the correction to the RHS of the PPE. Thank you for the help Dr. Denaro! EDIT: Looking at the pressure contour I notice the top left is different than that of the top right in the sense of the contours. Is that correct? With a staggered grid I don't believe I get that. |
1) For the lid driven cavity is correct that you have at corners a non-symmetric pattern, you have pressure increaing when the flow impact with the wall.
2) Depending on you formulation, you can end up with an approximate projection, that is the discrete divergence-free constraint is not driven to zero up to machine precision but only up to the local truncation error. 3) If you see the expression for the BC.s, it will be that same if you prescribe dp/dx=0 and u*=U (=0 for a wall) in the source term. 4) If the BC.s are correct, you do not need to prescribe any fixed value for the pressure, you can let SOR to set the constant. That will increas the rate of convergence. |
Pressure BC
Hi Dr Denaro,
1. Thats good to know that is supposed to happen in the corners. 2. Interesting 3. I will test it out 4. I am setting the pressure BC's manually as I am merely test the code on well known test problems. Eventually I will expand it to 3D and study more complexed problems. In terms of the corners points P(nx,1), P(1,ny), P(nx,ny) I applied as follows Code:
R(2,ny) = (rho/dt)*((1/dx)*(ufs(2,ny) - u(1,ny)) + (1/dy)*(v(1,ny) - vfs(2,ny))); |
Quote:
If you want to compute the pressure along the walls, you need to compute it explicitly from the Neumann BC after the SOR has reached convergence. |
Pressure BC
Hi,
Is it necessary to compute the pressure along the walls after P has reached convergence given I've already computed the pressure at the walls within the iteration process?. |
That's the point! In your SOR you have to compute only the equations for the internal unknowns and all these equations (once you substitute correctly the BC.s) have no nodes for the pressure at the walls! For this reason, only after you get the solution the pressure at the walls can be computed.
|
Pressure BC
Hi Dr. Denaro,
I believe I have made a mistake in my code (correct me if i'm wrong.) If I care about the pressure at i=2 and j=2, then at the end points should it not be i=nx-1 and j=ny-1 instead of i=nx and j=ny. Upon imposing the non-homogenous Neumann BC at ny-1 and ny-1 I get 0s on all four sides and after my SOR iteration (outside the loop) I set P(1,: ) = P(2,: ), P(nx,: ) = P(nx-1,: ), P(:,1) = P(:,2), P(:,ny) = P(:,ny-1). I'm using backward/forward differencing for the Neumann BCs after I have iterated my pressure Poisson for the interior. I assume this is what you meant? Code:
while (IterCntr == 0 && Iter <= IterMax) |
I strongly suggest to use a different approach... Assume i=2,nx-1 and j=2,ny-1 are the internal pressure unknowns. You have to split the cycle for nodes where the unchanged Laplace (no BC.s) matrix entries and the unchanged source term are in effect: i=3,nx-2 and j=3,ny-2.
This way, you treat explicitly the nodes involving BC.s and write the modified SOR instructions both changing the matrix entries and the source term. And the instructions P(1,: ) = P(2,: ), P(nx,: ) = P(nx-1,: ), P(:,1) = P(:,2), P(:,ny) = P(:,ny-1) correspond to homogeneous Neumann conditions. Actually, you are using non homegeneous ones....Note that dp/dn=0 is a boundary layer approximation. My question is now: how do you compute the intermediate velocity v* on the boundaries? |
Pressure BC
If I understand you correctly, I need to change my indexing for the interior notes from 2:nx-1, 2:ny-1 TO 3:nx-2, 3:ny-2 so I can handle i=2,j=2,i=nx-1,j=ny-1.
The way I am calculating u* and v* is by explicitly setting it to the boundary, in this case 0 (except for us(:,ny).) Code:
for j=3:ny-2 Similar to that of the slides in my earlier posted? By my understanding, by having my loops, 3:nx-2 and 3:ny-2, I am able to correctly solve the PPE at the boundarys i=2,i=nx-1,j=2,j=ny-1 and then finally (after I have iterated P) i=1,j=1,i=nx,j=ny. Thank you for the patience, I don't know why this is so hard for me to grasp :confused: |
I give an example of pseudo-code
i=2;j=2 (2 BC.s) p(i,j)=.. j=2 (1 BC) for i=3,nx-2 p(i,j)=... end i=nx-1;j=2 (2 BC.s) p(i,j)=.. for j=3,ny-2 i=2 (1 BC) p(i,j)=.. i=nx-1 p(i,j)=-- end and so on.. The setting of u* and v* is somehow complex and depends on the accuracy you want to treat the time integration. Setting u*=v*=0 on the walls is equivalent to set dp/dn=0 ... Have you read some literature about this issue? |
All times are GMT -4. The time now is 00:30. |