Skip to content

mrtCollision operator in OpenLB

OpenLB – Open Source Lattice Boltzmann Code Forums on OpenLB General Topics mrtCollision operator in OpenLB

  • This topic has 2 replies, 2 voices, and was last updated 4 years ago by Eric.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1982
    Eric
    Participant

    Dear OpenLB team,

    I have a question about the mrtCollision solver implemented in OpenLB. As far as I understand, the original code first compute momenta and momenta_eq, but I can see that only 6 of 9 parameters are calculated here:

    Code:
    template<typename T>
    38 struct mrtHelpers<T, descriptors::MRTD2Q9Descriptor> {
    39
    41 static void computeEquilibrium( T momentaEq[9],
    42 T rho, const T u[2],
    43 const T uSqr )
    44 {
    45 // momentaEq[0] = T();
    46 momentaEq[1] = -(T)2*rho + (T)3*uSqr;
    47 momentaEq[2] = rho – (T)3*uSqr;
    48 // momentaEq[3] = T();
    49 momentaEq[4] = -u[0];
    50 // momentaEq[5] = T();
    51 momentaEq[6] = -u[1];
    52 momentaEq[7] = u[0]*u[0] – u[1]*u[1];
    53 momentaEq[8] = u[0]*u[1];
    54 }
    55
    57 static void computeMomenta(T momenta[9], Cell<T,MRTD2Q9Descriptor> &cell)
    58 {
    59 // momenta[0] = cell[0] + cell[1] + cell[2] + cell[3] +
    60 // cell[4] + cell[5] + cell[6] + cell[7] + cell[8] + (T)1;
    61
    62 momenta[1] = -(T)4*cell[0] +(T)2*cell[1] – cell[2] + (T)2*cell[3] – cell[4] +
    63 (T)2*cell[5] – cell[6] + (T)2*cell[7] – cell[8] – (T)2;
    64
    65 momenta[2] = (T)4*cell[0] + cell[1] – (T)2*cell[2] + cell[3] – (T)2*cell[4] +
    66 cell[5] – (T)2*cell[6] + cell[7] – (T)2*cell[8] + (T)1;
    67
    68 // momenta[3] = – cell[1] – cell[2] – cell[3] +
    69 // cell[5] + cell[6] + cell[7];
    70
    71 momenta[4] = – cell[1] + (T)2*cell[2] – cell[3] +
    72 cell[5] – (T)2*cell[6] + cell[7];
    73
    74 // momenta[5] = cell[1] – cell[3] – cell[4] –
    75 // cell[5] + cell[7] + cell[8];
    76
    77 momenta[6] = cell[1] – cell[3] + (T)2*cell[4] –
    78 cell[5] + cell[7] – (T)2*cell[8];
    79
    80 momenta[7] = cell[2] – cell[4] + cell[6] – cell[8];
    81
    82 momenta[8] = – cell[1] + cell[3] – cell[5] + cell[7];
    83 }

    May I ask why there’s no need to calculate index 0,3, and 5? I guess it might help reduce computation time, but when updating

    Code:
    cell[iPop] -= invM_S[iPop][jPop]*momX

    the deleted element in invM_S is not always 0. So will this affect the computation?

    P.S. Could you also explain why we need to add 2 to the momenta[1] when calculating momenta in the following code? I understand this is energy momenta, but the matrix multiplication should not produce 2?

    Code:
    62 momenta[1] = -(T)4*cell[0] +(T)2*cell[1] – cell[2] + (T)2*cell[3] – cell[4] +
    63 (T)2*cell[5] – cell[6] + (T)2*cell[7] – cell[8] – (T)2;

    Looking forward to hearing from you.

    Best regards,
    Eric

    #2864
    mathias
    Keymaster

    Dear Eric,

    1/ Actually 0,3, and 5 are ZERO:

    template<typename T>
    const T MRTD2Q9DescriptorBase<T>::S[MRTD2Q9DescriptorBase<T>::q_] =
    { T(), (T)1.1, (T)1.1, T(), (T)1.1, T(), (T)1.1, T(), T() };
    // s7=s8 to have a shear viscosity nu
    // and the bulk viscosity depends on s2.

    2/ In openLB we save f_OLB = f – f^eq. So \sum_q f_OLB + 1 = rho.

    Best
    Mathias

    #2881
    Eric
    Participant

    Dear Mathias,

    Thank you very much for you explanation!

    Best regards,
    Eric

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.