CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Periodic boundary conditions for solving Navier Stokes Equations on a Staggered Grid (https://www.cfd-online.com/Forums/main/167013-periodic-boundary-conditions-solving-navier-stokes-equations-staggered-grid.html)

 tanmayagrawal7 February 22, 2016 00:06

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

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!

 kaya February 22, 2016 05:26

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

 FMDenaro February 22, 2016 05:30

be carefull to the link between the periodic nodes if you use staggered grid!

 tanmayagrawal7 February 22, 2016 22:12

Quote:
 Originally Posted by FMDenaro (Post 586239) 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.

 FMDenaro February 23, 2016 06:09

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

 sbaffini February 23, 2016 08:22

Usually, if you solve between 1 and N, periodicity is such that:

0 = N-1
N+1 = 2

so that:

1 = N

 tanmayagrawal7 February 23, 2016 23:52

Quote:
 Originally Posted by sbaffini (Post 586453) 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).

 sbaffini February 26, 2016 17:13

You should be able to use it independently for each grid. Maybe is something hardcoded in the implicit part?

 kaya February 26, 2016 17:46

Quote:
 Originally Posted by tanmayagrawal7 (Post 586575) 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

http://oi68.tinypic.com/118eyh2.jpg

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)

 sbaffini February 27, 2016 06:32

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.

 ened89 June 15, 2021 09:04

@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?

 ened89 June 15, 2021 09:05

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 (Post 587114) 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.

 FMDenaro June 15, 2021 10:45

Quote:
 Originally Posted by ened89 (Post 806101) 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.

 sbaffini June 15, 2021 10:48

Quote:
 Originally Posted by ened89 (Post 806101) 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?

 ened89 June 15, 2021 11:00

1 Attachment(s)
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 (Post 806113) What is exactly your question? What has to be done for what?

 ened89 June 15, 2021 11:03

So should I compute again Sxy from the copied velocity values ?

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

 sbaffini June 15, 2021 11:04

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

 sbaffini June 15, 2021 11:05

Quote:
 Originally Posted by ened89 (Post 806118) So should I compute again Sxy from the copied velocity values ?
yes indeed

 All times are GMT -4. The time now is 02:51.