# Fully Periodic boundary conditions

Hello,
Can any body provide me the fortran code for fully periodic boundary conditions? Mine is not working. have some ambiguities regarding it. Best regards and Thanks in advance…

you can use the following streaming function. It is already include periodic boundary

[code=“cpp”]

for (int q=0; q<9 ; q++)
{
for (int i=0; i<nx ; i++)
{
int ii=(i+cx[q]+nx)%nx;
for (int j=0; j<ny ; j++)
{
int jj=(j+cy[q]+ny)%ny;
fnew[ii][jj][q]=fold[i][j][q];
}
}
}

``````
you can convert this streaming function to fortran by taking care of the indecies and using the mod function instead of %. the mod function is used to to the get the rest of the division.

regards``````

Thanks
But how to define c?
And should i redistribute the flow both in x and y direction when it reenters?
Regards

Hi

for d2q9
cx[]={0,1,0,-1,0,1,-1,-1,1};
cy[]={0,0,1,0,-1,1,1,-1,-1};

I am not sure what you mean by “should i redistribute the flow both in x and y direction when it reenters?”

but if you mean distribute each distribution function in its direction even in the the end of the domain to reenter fron the other side then the previous streaming function will do that.
assume q=7 which has cx=-1, cy=-1 at i=0, j=0;

fnew[nx-1][ny-1][7]=fold[0][0][7];

this value will leave form the buttom left corner and reenter at the upper right corner

regards

If you are using C or Fortran you can use the cshift function.

Exactly, it will reenter by streaming step, but some initial acceleration is provided in the flow direction when it reenters to give some initial push to the fluid . Because it is not gravity driven flow.
Regards

Will see cshift function
Regards

@pinky
I think may be you can try to add some froce term on the node you want to accelerat. maybe this will work.

@pleb01
could you give me a general Idea how you did this in c in 2d array. Actually I tried to do it once but I did not succeed

regards

Hello SaS,

I want to ask two questions regarding LBM (I am using a D2Q9 model).

1. In the absence of any obstacle, distribution functions leaving the domain re-enter (from enterance) the boundaries as a result of streaming process. So, in addition to streaming, whether we should define periodic boundary conditions separately or streaming itself is enough?

2. If in addition to streaming process, we have to apply fully periodic boundary conditions separately, then what to do with the distribution functions present at the corner nodes. the distribution function # 5 at the bottom left corner node will be coming from the distribution function # 5 at the top left corner and the distribution function # 5 at the bottom right corner node.
Same will happen with some other the distribution functions present at the edges of domain.