Skip to content

OnePointBoundaryCondition

Sebastian Schmieschek edited this page Aug 12, 2015 · 2 revisions

#409 concerns the implementation of the so-called one-point boundary condition (1PBC) by Junk and Yang. See Phys. Rev. E 72, 066701 (2005).

There are a couple of design decisions that need to be taken. One to do with the need of breaking streaming into two phases and another to doing some linear algebra with small matrices.

== Two phase streaming == Very roughly, 1PBC needs to do a theta-method-like averaging of the current distribution in a given direction with the post-streaming distribution in the same direction. The result of this operation is further manipulated to eventually be applied as a correction to the standard bounce-back rule.

As far as I can tell, this requires doing the streaming step in two phases. First of all stream all the bulk sites and the boundary sites along the directions that lead to a neighbour. Once this is complete, do a second pass over the boundary sites and apply the corrected bounce-back as described above.

After some preliminary panic, I think this is quite doable using DoStreamAndCollide for the first pass and DoPostStep for the second one. In fact, the FInterpolation BC does something similar already.

== Linear algebra with small matrices ==

For a D3QY lattice, 1PBC needs to assemble a YxY matrix (named K) and a ZxZ, 0<Z<Y, matrix (named L). Matrix-vector products need to be computed with subblocks of K and a linear system solved with L every time step. We currently don't have data structures that can hold K and L or algorithms that perform the linear solve (I would suggest LU factorisation at setup time and backward/forward substitution every time step).

Some of the options that come to my mind (in order of preference) are:

  • Using a C++ library like boost::ublas (or armadillo or eigen or ...).
  • Using raw calls to BLAS and LAPACK.
  • Implementing the algorithms ourselves (I strongly oppose).

Most C++ libraries can be interfaced with ATLAS (or GotoBLAS) so you get the speed with a reasonable amount of syntactic sugar on top:

  • uBlas is a BLAS with STL-like data structures plus a LU factorisation. I have used it extensively. Another point for uBlas is that it implements matrix views (i.e. operating with matrix subblocks), which would make the implementation of 1PBC much cleaner.
  • Armadillo has a wider collection of Linear Algebra algorithms implemented. The authors claim it is easier to use. I have never tried.
  • Other libraries include: eigen, mtl, etc.

Googling for which library is best is pointless as there are all kind of pros and cons:

Clone this wiki locally