Skip to content

Method to generate effective relaxation time as output in VTK

OpenLB – Open Source Lattice Boltzmann Code Forums on OpenLB General Topics Method to generate effective relaxation time as output in VTK

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #9842
    mwkim
    Participant

    Dear OpenLB community members.

    I am struggling to access the effective relaxation time, tau_eff, during turbulent simulation.

    I want to get tau_eff in vtk files while I have no idea how to access tau_eff.
    If it is hard, at least, I want to check min & max of tau_eff.

    Could you suggest any materials or code lines that I refer?

    #9849
    Yuji
    Participant

    Thank you for commenting.
    I can suggest how to get vtk files below steps.

    1.Add #define DISABLE_CSE in your cpp file.
    2.Add FILED in DESCRIPTOR. for example, using DESCRIPTOR = D3Q19<SCALAR>; in your cpp file.
    3.Add cell.template setField<descriptors::SCALAR>(tauEff);in src/dynamics directory file where you want to see tauEff.
    4.Add SuperLatticeField3D<T, DESCRIPTOR, SCALAR> viscosiy(sLattice);
    viscosiy.getName() = "viscosiy";
    in your cpp in getResult function.

    Best regards,
    Yuji

    • This reply was modified 1 week ago by Yuji.
    • This reply was modified 1 week ago by Yuji.
    • This reply was modified 1 week ago by Yuji.
    • This reply was modified 1 week ago by Yuji.
    #9854
    Yuji
    Participant

    Sorry and you need to add
    vtmWriter.addFunctor(viscosiy);
    after viscosiy.getName() = "viscosiy";

    #9857
    mwkim
    Participant

    I really appreciate your reply. Now I get tauEff in VTK files.

    The value of tauEff is not properly saved (it returns 1.2e-38 and is unchanged). Something is going wrong, so I am checking any missing parts or mistakes.

    Your help is the big hand for me. Again, thanks a lot.

    Sincerely,
    MKim

    #9858
    Yuji
    Participant

    I forgot mentioning important thing
    #define DISABLE_CSE is
    prior to including the OpenLB header files.

    #9859
    mwkim
    Participant

    Yes, I already add #define DISABLE_CSE at the very first line in the cpp file.

    #9863
    mwkim
    Participant

    Dear Yuji:

    I follow your suggestion while tauEff is not saved in the VTK.

    I add the code line given in Step 3 to computeEffectiveOmega in src/dynamics/collisionLES.h (function start from line 53)

    As I understand, Step 4 just generates the variable named “viscosiy” in VTK files, and the key point is Step 3.

    But, my results show “viscosiy” is filled with dummy values, not the target value, tauEff. (The code worked fine even when I remove the code line of Step 3)

    I guess I am doing wrong with Step 3, but I cannot find any solutions or similar problems by searching myself.

    Could you help me one more time?

    Sincerely,
    MKim

    #9866
    Yuji
    Participant

    OK. I can suggest another step No.3.

    Step 3-1. Implemetate new struct SmagorinskyEffectiveOmegaToWatchSGSv in src/dynamics/collisionLES.h

    
    struct SmagorinskyEffectiveOmegaToWatchSGSv {
      using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
      using CollisionO = typename COLLISION::template type<DESCRIPTOR, MOMENTA, EQUILIBRIUM>;
    
      template <concepts::Cell CELL, concepts::Parameters PARAMETERS, typename V=typename CELL::value_t>
      V computeEffectiveOmega(CELL& cell, PARAMETERS& parameters) any_platform {
        V piNeqNormSqr { };
        MomentaF().computePiNeqNormSqr(cell, piNeqNormSqr);
        const V rho = MomentaF().computeRho(cell);
        const V omega = parameters.template get<descriptors::OMEGA>();
        const V smagorinsky = parameters.template get<collision::LES::SMAGORINSKY>();
        V piNeqNorm = util::sqrt(piNeqNormSqr);
        V preFactor = smagorinsky*smagorinsky
                    * descriptors::invCs2<V,DESCRIPTOR>()*descriptors::invCs2<V,DESCRIPTOR>()
                    * 2 * util::sqrt(2);
        /// Molecular realaxation time
        V tauMol = V{1} / omega;
        /// Turbulent realaxation time
        V tauTurb = V{0.5} * (util::sqrt(tauMol*tauMol + preFactor / rho * piNeqNorm) - tauMol);
        /// Effective realaxation time
        V tauEff = tauMol + tauTurb;
        cell.template setField<descriptors::SCALAR>(tauEff);
        return  V{1} / tauEff;
      }
      
      template <concepts::Cell CELL, concepts::Parameters PARAMETERS, typename V=typename CELL::value_t>
      CellStatistic<V> apply(CELL& cell, PARAMETERS& parameters) any_platform {
        parameters.template set<descriptors::OMEGA>(
          computeEffectiveOmega(cell, parameters));
    
        return CollisionO().apply(cell, parameters);
      }
    };
    
    template <typename COLLISION>
    struct SmagorinskyEffectiveOmegaToWatchSGSv {
      using parameters = typename COLLISION::parameters::template include<
        descriptors::OMEGA, LES::SMAGORINSKY
      >;
    
      static_assert(COLLISION::parameters::template contains<descriptors::OMEGA>(),
                    "COLLISION must be parametrized using relaxation frequency OMEGA");
    
      static std::string getName() {
        return "SmagorinskyEffectiveOmegaToWatchSGSv<" + COLLISION::getName() + ">";
      }
    
      template <typename DESCRIPTOR, typename MOMENTA, typename EQUILIBRIUM>
      using type = detail::SmagorinskyEffectiveOmegaToWatchSGSv<COLLISION,DESCRIPTOR,MOMENTA,EQUILIBRIUM>;
    };

    Step 3-2. Define BulkDynamics in your cpp, for example
    using BulkDynamics = SmagorinskyEffectiveOmegaToWatchSGSv<T,DESCRIPTOR>;

    If you get something, let me know.

    Best regards,
    Yuji

    #9874
    mwkim
    Participant

    Sorry for the late reply.
    I was on a business trip :<

    A little modification is needed to your suggested code lines.
    After successful implementation, I will share the results.

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