# oundary conditions and forces

Hi Dear All,
I want to write the code using LBM. I not find the lift coefficient data for even Re=100 and convergence meet very quickly. I put here the boudary conditions and forces. Can any body suggest me that’s it’s right or wrong or i need to do some changes.
// symmetric bc: j=1 and NY-2 is the symmetry lines.
void bc_symmetry()
{
int i;
for(i=0;i<=NX-1;i++){
f[i] = f[i];
f[i] = f[i];
f[i] = f[i];
f[i][NY-1] = f[i][NY-3];
f[i][NY-1] = f[i][NY-3];
f[i][NY-1] = f[i][NY-3];
}
}

//periodic boundary condition
void bc_periodic()
{
int i;
for(i=0;i<=NX-1;i++){

``````	f[i] = f[i][NY-2];
f[i] = f[i][NY-2];
f[i] = f[i][NY-2];

f[i][NY-1] = f[i];
f[i][NY-1] = f[i];
f[i][NY-1] = f[i];
}
``````

}

//bounce-back boundary condition for wall(channel) between 0 and 1 or between NY-2 and NY-1
void bc_bounceback()
{
int i;
for(i=0;i<=NX-2;i++){
f[i] = f[i+1];
f[i][NY-1] = f[i+1][NY-2];
}
for(i=1;i<=NX-2;i++){
f[i] = f[i];
f[i][NY-1] = f[i][NY-2];
}
for(i=2;i<=NX-1;i++){
f[i] = f[i-1];
f[i][NY-1] = f[i-1][NY-2];
}
}

// calculate force on body
void get_force(int wall[NX][NY], int wb[NX][NY], double *fx, double *fy)
{
int i,j;
*fx = 0.0;
*fy = 0.0;
for(i=1;i<=NX-2;i++){
int ip = i+1;
int im = i-1;
for(j=1;j<=NY-2;j++){
int jp = j+1;
int jm = j-1;
if(wb[i][j]==1){ //need to check for if(wb[i][j]==0)

``````	        *fx = *fx - (f[im][j]+f[i][j])* (1-wall[im][j])
+ (f[ip][j]+f[i][j])* (1-wall[ip][j])
- (f[im][jm]+f[i][j])*(1-wall[im][jm])
+ (f[ip][jp]+f[i][j])*(1-wall[ip][jp])
+ (f[ip][jm]+f[i][j])*(1-wall[ip][jm])
- (f[im][jp]+f[i][j])*(1-wall[im][jp]);

*fy = *fy - (f[i][jm]+f[i][j])*(1-wall[i][jm])
+ (f[i][jp]+f[i][j])*(1-wall[i][jp])
- (f[im][jm]+f[i][j])*(1-wall[im][jm])
+ (f[ip][jp]+f[i][j])*(1-wall[ip][jp])
- (f[ip][jm]+f[i][j])*(1-wall[ip][jm])
+ (f[im][jp]+f[i][j])*(1-wall[im][jp]);

}
}
}
``````

}

Thanks in advance any suggestions will be highly appreticated.
Khan

i don’t understand your symmetry boundary condition. why do you copy information from two lattice sites ahead, as in

``````
f[i] = f[i];

``````

why not achieve symmetry by copying opposite variables on the same site, as in

``````
f[i] = f[i];

``````