I just implemented the 2D selective filter1 in Palabos. Because of the non-local calculation when filtering the collision operator, it takes Miguel and me some time to think about a way to implement it in Palabos.

  • We first thought about the integrateProcessingFunctional but it might only do the post-collision operation (though we could apply a -1 level and call executeInternalProcessors(-1) manually).

  • Then Miguel found the DynamicProcessor could be a candidate,something in src/basicDynamics/dynamicsProcessorXD.hh where there is ExternalRhoJcollideAndStream2D for external macroscopic variable cases (examples/codesByTopic/externalMacroscopicVariables).

  • I then found the nonLocalDynamicsXD written in src/core/nonLocalDynamicsXD.h/hh. This doesn't seems to be complete and neither is there a show case. However, you can find something related in ExecuteNonLocalDynamics3D, a functional inherited from BoxProcessingFunctional3D_L in src/boundaryCondition/NLD_boundaries3D.h/hh.

I finally decide to go to the last direction because I consider nonLocalDynamicsXD as a good interface to start with. So, the basic idea here is to keep every variables and function of the dynamics in the dynamics class and create each member function a functional for data processor. Likely, I write SelectiveFilterBGKDynamics2D.nonLocalAction() and SelectiveFilterBGKDynamics2D.prepareFNeq() and two functional inherited from BoxProcessingFunctional2D_L. In addition, the dynamics class has two private members for the original and the filtered \(f_{neq}\). applyProcessingFunctional would be used in the main function.

Another important thing I found when writing a new dynamics is about the serialize and unserialize. It is extremely importantto deal with the additional allocated data (member variables) in the dynamics using serializer.addValues() and unserializer.readValues(). Otherwise, one will run into problems when running the program with multiple cores. I found this article helpful talking about serialization and unserialization. In general, serialization helps flatten the objects so that make non built-in data type transmittable.

  1. Ricot, Denis, Simon Marié, Pierre Sagaut, and Christophe Bailly. 2009. “Lattice Boltzmann Method with Selective Viscosity Filter.” Journal of Computational Physics 228 (12): 4478–4490.