How to create a custom OnLatticeBoundaryCondition?

Hi,

I have a question regarding the OnLatticeBoundaryCondition interface provided by Palabos. From the documentation: “Some of the implemented boundary conditions are local (and are therefore implemented as dynamics classes), some are non-local (and are therefore implemented as data processors), and some have both local and non- local components. To offer a uniform interface to the various possibilities, Palabos offers the interface OnLatticeBoundaryConditionXD which is responsible for instantiating dynamics objects, adding data processors, or both, depending on the chosen boundary condition”.

Can anyone explain or give an example on how to create your own OnLatticeBoundaryCondition which uses a dataprocessor to create some non-local interaction (I am trying to implement the Lees-Edwards boundary condition). I already have a working data processor, I just don’t know how to couple this with the OnLatticeBoundaryCondition interface. I tried looking at the files within the boundaryCondition directory of Palabos, specifically the Zou/He boundary condition, but this hasn’t helped me.

I hope someone can help me :slight_smile:

Kind regards, DVI

2 Likes

Hi, DVI. I’m also doing a BC, which method do you use for the process?
In my condition I use BoxProcessingFunctional3D, but how to define the boundary in it?

Hello,

the files you are looking for are boundaryConditionXd.h/hh. In particular if your boundary condition is ProcessingFunctional based you want to have a BC looking like createInterpBoundaryCondition3D (you basically have to create something similar to InterpolationBoundaryManager3D where you will need to replace all the getVelocity/PressureFunctionals by your processing functionals.

Hope it helps.

Hi Ichn1, thanks for your reply. Did you create your own version of the InterpolationBoundaryManager3D as @orestis mentioned? Or do you just have a single BoxProcessingFunctional3D_L like me?

In the process function I convert the local coordinates of the data processor to global ones using:

    Dot3D absoluteOffset = lattice.getLocation();

I then loop over the blockLattice and use the offset to calculate where I am in terms of global coordinates. This is also in the documentation. I am curious to see what you have I case you implemented your own InterpolationBoundaryManager3D.

Hi orestis, thanks for your reply, this looks quite complex. Do you think it is possible to just use createLocalBoundaryCondition3D, setting the velocityConditions from there and using a data processor to override the local boundary interactions?

FYI: I have a rectangular domain which is periodic in the x and y-direction. In the z-direction I want to implement a form of periodicity where cells stream to the other side of the lattice but this includes a shift by an amount due to shearing (some part of the population streams to cell R and the remainder streams to cell R + 1). Right now my simulations become unstable. I am not sure what all the implications are of the described approach. For example the documentation mentions: In Palabos, all outer boundaries of a lattice which are not periodic automatically implement a version of the bounce- back boundary algorithm. It would be nice if you could point me towards which method I should use and why.

Yeah, that’s what I do now. In fact I want to make my boundary as a circle. But it seems too much difficult to treat. So I choose a cubic BC. And I also do with a ix==N.
What I want is to improve it to circle BC, but too difficult to decide which is conner and which is the outside and find the neighbor cell.

Hmmm… It indeed is complex.

I would recommend you rather inspire yourself from the Interp one, because it only uses processing functionals for the actual BC algorithms and are not dynamics based.

The difficulty is that there are many different cases to be treated when your boundary condition is non-local (inner/outer edges and corners).

If you only care about “plane” boundary conditions (without caring about no-slip for example) I would rather advise that you integrate your processing functional manually without using the BC interface. Otherwise you might encounter nasty bugs at some point.

Could you describe your BC a bit better? I don’t really understand what you want to achieve.

The Lees Edwards boundary condition (LEbc) is an extension to the periodic boundary condition for a sheared environment. For example in a rectangular 2D environment we could have a sliding top wall with velocity -v, and a bottom wall with velocity v. To still get a perfectly sheared environment and produce stable velocity gradients across the domain we’ll stream the particles/densities crossing the sheared boundary according to a Galilean transformation.

This might sound complicated, but in the end the only thing I need to achieve within Palabos is to stream some part of the density crossing the Lees-Edwards boundary to a cell X on the other side of the domain, and the remaining density to a neighbour of X. The location of X depends on the elapsed time and the velocity of the moving walls. So some part s2 streams to the first cell, and some parts s1 streams to the second cell (The other cell show how densities should be reflected which is not relevant for our discussion at the moment). In my case the densities would stream to the other side of the domain (only densities crossing the boundary get this transformation by the way).

I am not sure how to best achieve this in Palabos, right now I set it up like this:

        lattice.periodicity().toggle(0, true);
        lattice.periodicity().toggle(1, true);
        lattice.periodicity().toggle(2, false);

        boundaryCondition.setVelocityConditionOnBlockBoundaries ( lattice, top );
        boundaryCondition.setVelocityConditionOnBlockBoundaries ( lattice, bottom );

        setBoundaryVelocity(lattice, top, plb::Array<T,3>(LE_vel_top, 0.0, 0.0));
        setBoundaryVelocity(lattice, bottom, plb::Array<T,3>(LE_vel_bottom, 0.0, 0.0));

But as I mentioned before I don’t know if Palabos will automatically implement bounce-back on the non periodic boundary. So I would be nice if you could point me towards the best solution. Conceptually I don’t see how the corner/edges need any different treatment except accounting for out of bounds errors.

EDIT: also found these images, thought it might help:

Hi lchn1, did you receive my direct message?