TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Viscosite_turbulente_k_tau.cpp
1/****************************************************************************
2* Copyright (c) 2021, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <Viscosite_turbulente_k_tau.h>
17#include <Param.h>
18#include <Probleme_base.h>
19#include <Champ_base.h>
20#include <TRUSTTab_parts.h>
21
22Implemente_instanciable(Viscosite_turbulente_k_tau, "Viscosite_turbulente_k_tau", Viscosite_turbulente_base);
23// XD type_diffusion_turbulente_multiphase_k_tau type_diffusion_turbulente_multiphase_deriv k_tau BRACE not_set
25{
26 return os;
27}
28
30{
31 Param param(que_suis_je());
32 param.ajouter("limiter|limiteur", &limiter_); // XD_ADD_P chaine
33 // XD_CONT not_set
34 param.ajouter("sigma", &sigma_); // XD_ADD_P floattant
35 // XD_CONT not_set
36 param.ajouter("beta_k", &beta_k_); // XD_ADD_P floattant
37 // XD_CONT not_set
38 param.lire_avec_accolades_depuis(is);
39 return is;
40}
41
43{
44 //tout en explicite
45 const DoubleTab& k = pb_->get_champ("k").passe(), &tau = pb_->get_champ("tau").passe(),
46 &nu = pb_->get_champ("viscosite_cinematique").passe();
47 const int cnu = nu.dimension(0) == 1;
48 //il faut que nu_t et k aient la meme localisation et que nu_t ait au moins autant de composantes que k
49 assert((k.dimension(1) <= nu_t.dimension(1)));
50 //on met 0 pour les composantes au-dela de k.dimension(1) (ex. : vapeur dans Pb_Multiphase)
51 for (int i = 0; i < nu_t.dimension(0); i++)
52 for (int n = 0; n < nu_t.dimension(1); n++)
53 nu_t(i, n) = (n < k.dimension(1)) ? sigma_ * std::max(k(i, n) * tau(i, n), limiter_ * nu(!cnu * i, n)) : 0;
54}
55
56void Viscosite_turbulente_k_tau::reynolds_stress(DoubleTab& R_ij) const // Renvoie <u_i'u_j'>
57{
58 const DoubleTab& k = pb_->get_champ("k").passe(), &tau = pb_->get_champ("tau").passe(),
59 &nu = pb_->get_champ("viscosite_cinematique").passe(), &grad_u = pb_->get_champ("gradient_vitesse").passe();
60 ConstDoubleTab_parts p_gu(grad_u); //en PolyMAC_MPFA, grad_u contient (nf.grad)u_i aux faces, puis (d_j u_i) aux elements
61 int i, d, db, D = dimension, i_part = -1, n, N = nu.dimension(1), Nk = k.dimension(1);
62 for (i = 0; i < p_gu.size(); i++)
63 if (p_gu[i].get_md_vector() == R_ij.get_md_vector()) i_part = i; //on cherche une partie ayant le meme support que k
64 if (i_part < 0) Process::exit("Viscosite_turbulente_k_tau : inconsistency between velocity gradient and k!");
65 const DoubleTab& gu = p_gu[i_part]; //le bon tableau
66 for (i = 0; i < R_ij.dimension(0); i++)
67 for (n = 0; n < N; n++)
68 {
69 double sum_diag = 0.;
70 double nut_loc = n < Nk ? std::max(k(i, n) * tau(i, n), limiter_ * nu(i, n)) : 0 ;
71 for (d = 0; d < D; d++) sum_diag += gu(i, d, D * n + d) ;
72 for (d = 0; d < D; d++)
73 for (db = 0; db < D; db++) //on ne remplit que les phases concernees par k
74 R_ij(i, n, d, db) = n < Nk ? sigma_ * (2. / 3. * (k(i, n) + nut_loc * sum_diag) * (d ==db) - nut_loc * (gu(i, d, D * n + db) + gu(i, db, D * n + d))) : 0;
75 }
76}
77
78void Viscosite_turbulente_k_tau::k_over_eps(DoubleTab& k_sur_eps) const
79{
80 const DoubleTab& tau = pb_->get_champ("tau").passe();
81 int i, nl = k_sur_eps.dimension(0), n, N = k_sur_eps.dimension(1), Nt = tau.dimension(1);
82 assert(nl == tau.dimension(0) && Nt <= N);
83 /* comme tau = 1 / omega et omega = epsilon / (k*beta_k), k / epsilon = tau/beta_k ! */
84 for (i = 0; i < nl; i++)
85 for (n = 0; n < N; n++) k_sur_eps(i, n) = n < Nt ? tau(i, n)/beta_k_ : 0;
86}
87
88void Viscosite_turbulente_k_tau::eps(DoubleTab& eps_) const
89{
90 const DoubleTab& tau = pb_->get_champ("tau").passe(),
91 &k = pb_->get_champ("k").passe(),
92 &nu = pb_->get_champ("viscosite_cinematique").passe();
93 int i, nl = eps_.dimension(0), n, N = eps_.dimension(1), Nt = tau.dimension(1);
94 assert(nl == tau.dimension(0) && Nt <= N);
95 /* comme tau = 1 / omega et omega = epsilon / (k*beta_k), epsilon = beta_k_ * k / tau ! */
96 for (i = 0; i < nl; i++)
97 for (n = 0; n < N; n++) eps_(i, n) = beta_k_ * ( ((n < Nt) && (k(i, n)>1.e-8) ) ? k(i, n)*k(i, n)/ std::max(k(i, n) * tau(i, n), limiter_ * nu(i, n)) : 0 );
98}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
static int dimension
Definition Objet_U.h:99
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
classe Viscosite_turbulente_base correlations de viscosite turbulente decrivant le tenseur de Reynold...
classe Viscosite_turbulente_k_tau Viscosite turbulente pour un modele "k-tau" : nu_t = k * tau
void reynolds_stress(DoubleTab &R_ij) const override
void k_over_eps(DoubleTab &k_sur_eps) const override
void eddy_viscosity(DoubleTab &nu_t) const override
void eps(DoubleTab &eps) const override