# Periodic boundary conditions for solving Navier Stokes Equations on a Staggered Grid

 Register Blogs Members List Search Today's Posts Mark Forums Read

 February 21, 2016, 23:06 Periodic boundary conditions for solving Navier Stokes Equations on a Staggered Grid #1 New Member   Tanmay Agrawal Join Date: May 2015 Location: Taiwan Posts: 29 Rep Power: 10 Hello, I want to solve two dimensional Navier Stokes equations on a staggered grid for the case of Taylor-Green Vortex. As I am aware, we should use periodic boundary conditions on all the four boundaries. I am facing some trouble regarding implementation of this BC as I could not find enough literature about it. Suppose, if my index ranges from 0 to N. Then, is this the correct way to use periodic BC? u_vel(N) = u_vel(1) u_vel(0) = u_vel(N-1) and similarly for v_vel and pressure variables? Thanks!

 February 22, 2016, 04:26 #2 Member   Kaya Onur Dag Join Date: Apr 2013 Posts: 94 Rep Power: 13 Yes you should use periodic bc. I'd make it in a way that u_vel(N+1) = u_vel(0). So my derivative matrix will be say 3-diagonal and a point at the corners. Not that you can't do u_vel(N) = u_vel(1) but why wasting computation if you know the values

 February 22, 2016, 04:30 #3 Senior Member   Filippo Maria Denaro Join Date: Jul 2010 Posts: 6,763 Rep Power: 71 be carefull to the link between the periodic nodes if you use staggered grid!

February 22, 2016, 21:12
#4
New Member

Tanmay Agrawal
Join Date: May 2015
Location: Taiwan
Posts: 29
Rep Power: 10
Quote:
 Originally Posted by FMDenaro be carefull to the link between the periodic nodes if you use staggered grid!
I do not clearly get what you mean.
If I just write

u(0) = u(Nu-1), u(Nu) = u(2)
v(0) = v(Nv-1), v(Nv) = v(2)
p(0) = p(Np-1), p(Np) = p(2)

for their respective grids. Will it create some problem?

BTW, I am doing exactly this and my result diverges. I am using analytic solution as my initial conditions.

 February 23, 2016, 05:09 #5 Senior Member   Filippo Maria Denaro Join Date: Jul 2010 Posts: 6,763 Rep Power: 71 I depends on the grid topology you are using... For example, given L the periodicity lenght in the interval (0,L) and Nx the number of step sizes dx, the nodal grid can be written as x(i) =i*dx i=0:Nx or x(i)=(i-1)*dx i=1:Nx+1 now you have to define the staggering for the variables, for example in 2D u(i,j) at x(i),y(j)-dy/2 v(i,j) at x(i)-dx/2,y(j) p(i,j) at x(i)-dx/2, y(j)-dy/2

 February 23, 2016, 07:22 #6 Senior Member     Paolo Lampitella Join Date: Mar 2009 Location: Italy Posts: 2,152 Blog Entries: 29 Rep Power: 39 Usually, if you solve between 1 and N, periodicity is such that: 0 = N-1 N+1 = 2 so that: 1 = N

February 23, 2016, 22:52
#7
New Member

Tanmay Agrawal
Join Date: May 2015
Location: Taiwan
Posts: 29
Rep Power: 10
Quote:
 Originally Posted by sbaffini Usually, if you solve between 1 and N, periodicity is such that: 0 = N-1 N+1 = 2 so that: 1 = N

So, as in my case of a staggered grid, I have three separate grids for U, V and P. Their grid sizes being [N,N+1],[N+1,N],[N+1,N+1] respectively.

For the U velocity, I solve NS equations for the interior points i.e. upto N-1 points in x and N points in y-direction, and similarly for the other two primitive variables. I am using an explicit finite difference based method.

So, to apply the periodic BC, can I use your " 0 = N-1, N+1 = 2 " for all the three grids INDEPENDENTLY? Or, there has to be some correlation between applying periodicity for the three variables (may be because of staggered grid).

Since my results are still diverging, I can not understand where I am implementing BC wrong (my code works for Dirichlet BC where I specify a fix value on all the boundaries).

 February 26, 2016, 16:13 #8 Senior Member     Paolo Lampitella Join Date: Mar 2009 Location: Italy Posts: 2,152 Blog Entries: 29 Rep Power: 39 You should be able to use it independently for each grid. Maybe is something hardcoded in the implicit part?

February 26, 2016, 16:46
#9
Member

Kaya Onur Dag
Join Date: Apr 2013
Posts: 94
Rep Power: 13
Quote:
 Originally Posted by tanmayagrawal7 Thanks for your answer! So, as in my case of a staggered grid, I have three separate grids for U, V and P. Their grid sizes being [N,N+1],[N+1,N],[N+1,N+1] respectively. For the U velocity, I solve NS equations for the interior points i.e. upto N-1 points in x and N points in y-direction, and similarly for the other two primitive variables. I am using an explicit finite difference based method. So, to apply the periodic BC, can I use your " 0 = N-1, N+1 = 2 " for all the three grids INDEPENDENTLY? Or, there has to be some correlation between applying periodicity for the three variables (may be because of staggered grid). Since my results are still diverging, I can not understand where I am implementing BC wrong (my code works for Dirichlet BC where I specify a fix value on all the boundaries).
For the sake of simplicity lets say your indices start from 1 and N=5 i=1,2,3,4,5 j=1,2,3,4,5

P(N,j)=P(1,j) j=1...N
P(i,N)=P(i,1) i=1...N

u(N,j)=u(1,j)
v(i,N)=v(i,1)

 February 27, 2016, 05:32 #10 Senior Member     Paolo Lampitella Join Date: Mar 2009 Location: Italy Posts: 2,152 Blog Entries: 29 Rep Power: 39 I might have seriously overlooked at the matter (i only did staggered grid once, around 10 years ago, and without periodicity). Actually, what i suggested works properly for colocated finite difference schemes. Now i took my old program and put the variables down, and it is more clear to me. When you go to staggered you need to do different things for different variables/direction. In practice the grid has to be considered a la finite volume, which means you have: 1) Nx x Ny cell centers, where pressure is stored 2) (Nx+1) x Ny x-normal faces where Ux velocity is stored 3) Nx x (Ny+1) y-normal faces where Uy velocity is stored Thus, what to do? For the pressure, you strictly work a la finite volume: 0x = Nx 0y = Ny Nx+1 = 1x Ny+1 = 1y For the Ux velocity you work a la finite volume along y, but finite difference along x: 0x = Nx-1 Nx+1 = 2x 0y = Ny Ny+1 = 1y For the Uy velocity it is the converse, finite difference along y and finite volume along x: 0y = Ny-1 Ny+1 = 2y 0x = Nx Nx+1 = 1x This implies that your variables are decleared as: P(Nx,Ny), Ux(Nx+1,Ny), Uy (Nx,Ny+1) This should work but, as i said, i never tried. aero_head likes this.

 June 15, 2021, 08:04 #11 New Member   enes senyurt Join Date: Oct 2015 Posts: 4 Rep Power: 10 @sbaffini For an arbitrary problem and staggered scheme; lets say we have another variable (e.g shear stress component) grid Sxy (Nx+1) x (Ny+1) what has to be done?

June 15, 2021, 08:05
#12
New Member

enes senyurt
Join Date: Oct 2015
Posts: 4
Rep Power: 10
For an arbitrary problem and staggered scheme; lets say we have another variable (e.g shear stress component) grid Sxy (Nx+1) x (Ny+1) what has to be done?

Quote:
 Originally Posted by sbaffini I might have seriously overlooked at the matter (i only did staggered grid once, around 10 years ago, and without periodicity). Actually, what i suggested works properly for colocated finite difference schemes. Now i took my old program and put the variables down, and it is more clear to me. When you go to staggered you need to do different things for different variables/direction. In practice the grid has to be considered a la finite volume, which means you have: 1) Nx x Ny cell centers, where pressure is stored 2) (Nx+1) x Ny x-normal faces where Ux velocity is stored 3) Nx x (Ny+1) y-normal faces where Uy velocity is stored Thus, what to do? For the pressure, you strictly work a la finite volume: 0x = Nx 0y = Ny Nx+1 = 1x Ny+1 = 1y For the Ux velocity you work a la finite volume along y, but finite difference along x: 0x = Nx-1 Nx+1 = 2x 0y = Ny Ny+1 = 1y For the Uy velocity it is the converse, finite difference along y and finite volume along x: 0y = Ny-1 Ny+1 = 2y 0x = Nx Nx+1 = 1x This implies that your variables are decleared as: P(Nx,Ny), Ux(Nx+1,Ny), Uy (Nx,Ny+1) This should work but, as i said, i never tried.

June 15, 2021, 09:45
#13
Senior Member

Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,763
Rep Power: 71
Quote:
 Originally Posted by ened89 For an arbitrary problem and staggered scheme; lets say we have another variable (e.g shear stress component) grid Sxy (Nx+1) x (Ny+1) what has to be done?

This is not a new variable, you compute it from the velocity.

June 15, 2021, 09:48
#14
Senior Member

Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,152
Blog Entries: 29
Rep Power: 39
Quote:
 Originally Posted by ened89 For an arbitrary problem and staggered scheme; lets say we have another variable (e.g shear stress component) grid Sxy (Nx+1) x (Ny+1) what has to be done?
What is exactly your question? What has to be done for what?

June 15, 2021, 10:00
#15
New Member

enes senyurt
Join Date: Oct 2015
Posts: 4
Rep Power: 10
I have a scheme as in the picture for an FDTD simulation. I want to use periodic BC in left and right, for velocity components I do the same procedure but I dont know what to do for Sxy to make periodicity. Without periodicity I am making stress mirroring and the become zero in boundary.

Quote:
 Originally Posted by sbaffini What is exactly your question? What has to be done for what?
Attached Images
 scheme.PNG (5.6 KB, 6 views)

June 15, 2021, 10:03
#16
New Member

enes senyurt
Join Date: Oct 2015
Posts: 4
Rep Power: 10
So should I compute again Sxy from the copied velocity values ?

Quote:
 Originally Posted by FMDenaro This is not a new variable, you compute it from the velocity.

 June 15, 2021, 10:04 #17 Senior Member     Paolo Lampitella Join Date: Mar 2009 Location: Italy Posts: 2,152 Blog Entries: 29 Rep Power: 39 Very generally speaking, for periodicity (but applies to the distributed parallel case as well) one should only exchange the independent variables (say, velocity) and compute everything in place. So, as mentioned by Filippo, the stress should be recomputed once you have the correct velocity in the periodic nodes. EDIT: ok, this doesn't sound really correct in general, but for staggered grids might be your best option aero_head likes this.

June 15, 2021, 10:05
#18
Senior Member

Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,152
Blog Entries: 29
Rep Power: 39
Quote:
 Originally Posted by ened89 So should I compute again Sxy from the copied velocity values ?
yes indeed

 Tags boundary, boundary condition, navier stoke solver, periodic bc, solver