Creation of buffer

Dear all,

I have a question about a creation of buffer. It’s the usual way to do things, especially for me it’s useful in Shan-Chen model. For example I’d like to impose my physical domain to be (1,nx,1,ny) and buffers are substraction physical domain from all domain (0,nx+1, 0,ny+1).

As I can understand all the operations collide and streaming are done either through boundary conditions or it is assumed that there are periodic boundary conditions. But if I’d like to create buffer, what should I do in that case?

Thank you,

Hi Alex,

I’m not sure to understand what you want to do. Maybe if you explain m a bit better, I’ll be able to give an “intelligent” answer… (But that’s not sure.)


Hi, intelligent Orestis! :slight_smile:

Thank you for responding. The situation is that for Shan-Chen force you need to take the summation over nearest neighbours of psi function. Just take a look at the boundary. If your boundary is periodic you need to take density for psi function from corresponding periodic point. That adds a coding and if conditions, but what I used in my previous codes - is the creation of buffer - that means your physical domain is (1,nx,1,ny) and buffer is substraction of physical domain from (0,nx+1, 0,ny+1). In that case you can populate buffers with anything you’d like to: Densities for Shan-Chen force, populations from periodic corresponding points. What does it mean? That means you apply streaming step, Shan-Chen force without worrying about your domain boundaries at all. Buffers take care of it.

And the question is how to do those buffers elegantly in OpenLB? Or probably you have some templates for it.

I really hope that I explain it’s a little better, if not - I will try again :slight_smile:


Hi Alex,
there is no “buffer” by default in OpenLB, but you can create it if you want. Before explaining more details about how you could do it note that for periodic boundaries you can just access the sites by looking at the points in the following way (let’s make it in 1D to be easier). Suppose you are at the position iX,iY and you want to access iX+c[i] which could possibly be “outside” the numerical domain and therefore you would like your border to be periodic (and you would like to compute the density on this node for example).

int nx = lattice.getNx();

for (i=0; i<9; ++i)
int nextX = (iX+c[i]+nx) % nx;
T rho = lattice.get(nextX,iY).computeRho();
… do what you want with it

Of course this is not very efficient since you have to compute a modulo, but it is completely generic and it works.

Now for the creation of a buffer. You can just create a lattice which is bigger than the “physical” lattice (two cells in each direction in your case) and define a “BufferDynamics” on it. For this BufferDynamics you can inspire yourself of the NoDynamics class (which is in the src/core/dynamics.h directory) and modify computeRho and defineRho (or any other of these classes) to store the desired values. This will allow you to impose and to get the desired values of rho on your border.

I hope I understood what you wnmated to do and that my answer is more or less clear to you…


Hi Orestis,

It’s exactly what I am doing now for Shan-Chen model. But my droplet goes into X direction after falling down to the wall - I think it’s something with boundaries in that case. But it will be good to listen to your opinion. Did you try to do the same simulation (droplet impringement on the bounceback wall)?

Also, could you tell me how do you make your bounceback wall, especially populate it. Do you go through all bounceback and initialize it with future coming populations or do it in another way?

For creation of buffer - it’s what I need exactly! Thank you!

Ciao Alex …

to deal with bubbles using ShanChen model … brr … what a nasty topic. I’m wasting hours trying to understand how to make work the ShanChen model for fluid-solid interaction. Once I had your problem more or less … and it was of course due to wrong boundary conditions as you said… for instance my periodic boundary condition were wrong… they were not really periodic… actually I wasn’t implementing any inter-particle forces on it. The result was a bubble moving in the direction of this periodic edge of my lattice.

For what concern bounce back… well … the normal bounce back should work fine. Now, I’m not sure, but what I would do is to have the normal bounce back on what you call “buffer-zone” … and then maybe have a scalar array where you save the densities that you wanna have on your solid nodes… anyway … Using the bounce-back “dynamic” of OpenLB you should have rho fixed = to 1 on your bounce-back nodes … but I’m not sure… maybe something is already changed in the Official Release version of OpenLB. Actually a small change in OpenLB that Jonas did for me is to give me the possibility to set a any value I like for rho on the bounce-back nodes… but I’m not sure is already in the official release.

I’m sorry If I wasn’t clear
I made a try …


Ciao And,

You should be Russian with tovarish nickname :slight_smile:

Thank you for your information, I will try to implement everything and buffer physics in that case and let you know if you are interested.

It’s really strange that everything is OK when I have periodic boundary conditions, but as soon as I add bounceback wall the droplet begins to move :frowning:

Thank you,