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
- This topic has 8 replies, 2 voices, and was last updated 2 days, 14 hours ago by mwkim.
-
AuthorPosts
-
February 5, 2025 at 7:57 am #9842mwkimParticipant
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?
February 6, 2025 at 1:02 am #9849YujiParticipantThank 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.Addcell.template setField<descriptors::SCALAR>(tauEff);
in src/dynamics directory file where you want to see tauEff.
4.AddSuperLatticeField3D<T, DESCRIPTOR, SCALAR> viscosiy(sLattice);
viscosiy.getName() = "viscosiy";
in your cpp in getResult function.Best regards,
YujiFebruary 6, 2025 at 1:09 am #9854YujiParticipantSorry and you need to add
vtmWriter.addFunctor(viscosiy);
afterviscosiy.getName() = "viscosiy";
February 6, 2025 at 3:44 am #9857mwkimParticipantI 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,
MKimFebruary 6, 2025 at 3:52 am #9858YujiParticipantI forgot mentioning important thing
#define DISABLE_CSE
is
prior to including the OpenLB header files.February 6, 2025 at 3:59 am #9859mwkimParticipantYes, I already add
#define DISABLE_CSE
at the very first line in the cpp file.February 6, 2025 at 11:25 am #9863mwkimParticipantDear 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,
MKimFebruary 6, 2025 at 3:26 pm #9866YujiParticipantOK. I can suggest another step No.3.
Step 3-1. Implemetate new struct
SmagorinskyEffectiveOmegaToWatchSGSv
in src/dynamics/collisionLES.hstruct 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,
YujiFebruary 11, 2025 at 3:34 am #9874mwkimParticipantSorry 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. -
AuthorPosts
- You must be logged in to reply to this topic.