Streaming Scalar Data

I see the tutorial about defining scalar fields, but is there a way to stream them? For example if I have a concentration C defined as 0 over the lattice domain, except for in the center where the concentration is higher, say 10, then how would I let this naturally diffuse in the lattice? Thank you in advance for your help!


One way to do it is to decompose your scalar onto the main axis (4 in 2D, 6 in 3D). Similar to the way distribution functions work.
In 2D, the concentration C will become:


For instance, C1 represents the amount of the concentration moving in the direction (1,0)
Then these 4 “concentration distribution functions” will have a streaming and collision steps.
During the streaming step, they are just moved to they neighbours as usual.
During the collision step, a local equilibrium is computed as:

     Ci_eq = C/4 * ( 1 + 2* scalar_product( u, Ei ) )
          C = C1+C2+C3+C4
          Ei is the direction of the Ci
          u is the velocity from your LBM simulation (running on another lattice, probably D2Q9)

You then relax all Cis towards their local equilibrium using a custom relaxation time (I call it tauD as it represents the diffusion of the concentration.

     Ci_new = (1-1/tauD) * Ci_old + 1/tauD * Ci_eq

An alternative way is to use method inspired from finite difference method.
Using only 2 array for the concentration C (old and new), you can advect the concentration like this:

     C_new(x,y) = C_old( x - u*dt, y - u*dt)

You basically “look-back” in the direction of the velocity to see where the concentration is coming from. This will require interpolating C(x-udt,y-udt) from its neightbourgs as it is unlikely that (x-udt,y-udt) is an integer.

Good luck