TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Viscosite_turbulente_k_omega.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_omega.h>
17#include <Masse_ajoutee_base.h>
18#include <Milieu_composite.h>
19#include <TRUSTTab_parts.h>
20#include <Pb_Multiphase.h>
21#include <Champ_base.h>
22#include <Param.h>
23
24Implemente_instanciable(Viscosite_turbulente_k_omega, "Viscosite_turbulente_k_omega", Viscosite_turbulente_base);
25// XD type_diffusion_turbulente_multiphase_k_omega type_diffusion_turbulente_multiphase_deriv k_omega BRACE not_set
26
28{
29 return os;
30}
31
33{
34 Param param(que_suis_je());
35 param.ajouter("limiter|limiteur", &limiter_); // XD_ADD_P chaine
36 // XD_CONT not_set
37 param.ajouter("sigma", &sigma_); // XD_ADD_P floattant
38 // XD_CONT not_set
39 param.ajouter("beta_k", &beta_k_); // XD_ADD_P floattant
40 // XD_CONT not_set
41 param.ajouter("gas_turb", &gas_turb_); // XD_ADD_P flag
42 // XD_CONT not_set
43 param.lire_avec_accolades_depuis(is);
44
45 return is;
46}
47
49{
50 const Pb_Multiphase* pbm = sub_type(Pb_Multiphase, pb_.valeur()) ? &ref_cast(Pb_Multiphase, pb_.valeur()) : nullptr ;
51 if ( (gas_turb_) && !(pbm) )
52 Process::exit(que_suis_je() + " : there must be multiphase problem if you want gas phase turbulence !");
53
54 if ( (gas_turb_) && (!pb_->has_correlation("masse_ajoutee")) )
55 Process::exit(que_suis_je() + " : there must be an added mass correlation if you want gas phase turbulence !");
56
57 if ( (gas_turb_) && (!int(pb_->has_champ("alpha"))) )
58 Process::exit(que_suis_je() + " : there must be void fraction if you want gas phase turbulence !");
59
60 if (pb_->has_correlation("masse_ajoutee"))
61 correlation_ = pb_->get_correlation("masse_ajoutee");
62}
63
65{
66 //tout en explicite
67 const DoubleTab& k = pb_->get_champ("k").passe();
68 const DoubleTab& omega = pb_->get_champ("omega").passe();
69 const DoubleTab& nu = pb_->get_champ("viscosite_cinematique").passe();
70 const DoubleTab& rho = pb_->get_champ("masse_volumique").passe();
71 const DoubleTab *alpha = pb_->has_champ("alpha") ? &(pb_->get_champ("alpha").passe()) : nullptr ;
72 const int cnu = nu.dimension(0) == 1;
73
74 //il faut que nu_t et k aient la meme localisation et que nu_t ait au moins autant de composantes que k
75 assert(k.dimension(1) <= nu_t.dimension(1));
76 //on met 0 pour les composantes au-dela de k.dimension(1) (ex. : vapeur dans Pb_Multiphase)
77 for (int i = 0; i < nu_t.dimension(0); i++)
78 for (int n = 0; n < nu_t.dimension(1); n++)
79 nu_t(i, n) = (n < k.dimension(1))
80 ? sigma_ * ( (omega(i,n) > 0.) ? std::max(k(i, n) / omega(i, n), limiter_ * nu(!cnu * i, n)): limiter_ * nu(!cnu * i, n) )
81 : 0. ;
82
83 if (gas_turb_)
84 {
85 const Milieu_composite& mil = ref_cast(Milieu_composite, ref_cast(Pb_Multiphase, pb_.valeur()).milieu());
87 {
88 DoubleTrav coeff(nu_t.dimension(1));
89 for (int i = 0; i < nu_t.dimension(0); i++)
90 {
91 const Masse_ajoutee_base& corr_ma_ = ref_cast(Masse_ajoutee_base, correlation_.valeur());
92 corr_ma_.coefficient( & (*alpha)(i,0), &rho(i,0), coeff);
93 for (int n = k.dimension(1) ; n < nu_t.dimension(1) ; n++)
94 nu_t(i, n) = nu_t(i, 0.) * (1. + coeff(n)* rho(i,0)/rho(i,n)) * std::min((*alpha)(i,n)*10, 1.) ;
95 }
96 }
97 }
98}
99
100void Viscosite_turbulente_k_omega::reynolds_stress(DoubleTab& R_ij) const // Renvoie <u_i'u_j'>
101{
102 const DoubleTab& k = pb_->get_champ("k").passe();
103 const DoubleTab& omega = pb_->get_champ("omega").passe();
104 const DoubleTab& nu = pb_->get_champ("viscosite_cinematique").passe();
105 const DoubleTab& grad_u = pb_->get_champ("gradient_vitesse").passe();
106
107 const int cnu = nu.dimension(0) == 1;
108 const int D = dimension;
109 const int N = nu.dimension(1);
110 const int Nk = k.dimension(1);
111
112 int i_part = -1;
113 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
114 for (int i = 0; i < p_gu.size(); i++)
115 if (p_gu[i].get_md_vector() == R_ij.get_md_vector())
116 i_part = i; //on cherche une partie ayant le meme support que k
117
118 if (i_part < 0)
119 Process::exit("Viscosite_turbulente_k_omega : inconsistency between velocity gradient and k!");
120
121 const DoubleTab& gu = p_gu[i_part]; //le bon tableau
122 for (int i = 0; i < R_ij.dimension(0); i++)
123 for (int n = 0; n < N; n++)
124 {
125 double sum_diag = 0.;
126 double nut_loc {0.0};
127 if (n < Nk)
128 {
129 if (omega(i, n) > 0.)
130 nut_loc = std::max(k(i, n) / omega(i, n), limiter_ * nu(!cnu * i, n));
131 else
132 nut_loc = limiter_*nu(!cnu*i, n);
133 }
134
135 for (int d = 0; d < D; d++)
136 sum_diag += gu(i, d, D * n + d) ;
137
138 for (int d = 0; d < D; d++)
139 for (int db = 0; db < D; db++) //on ne remplit que les phases concernees par k
140 R_ij(i, n, d, db) = (n < Nk)
141 ? 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)))
142 : 0;
143 }
144}
145
146void Viscosite_turbulente_k_omega::k_over_eps(DoubleTab& k_sur_eps) const
147{
148 const DoubleTab& omega = pb_->get_champ("omega").passe();
149 const int nl = k_sur_eps.dimension(0);
150 const int N = k_sur_eps.dimension(1);
151 const int Nt = omega.dimension(1);
152 assert(nl == omega.dimension(0) && Nt <= N);
153
154 for (int i = 0; i < nl; i++)
155 for (int n = 0; n < N; n++)
156 k_sur_eps(i, n) = (n < Nt)
157 ? ((omega(i,n) > 0.) ? 1/(omega(i, n)*beta_k_) : 0)
158 : 0;
159}
160
161void Viscosite_turbulente_k_omega::eps(DoubleTab& eps_) const
162{
163 const DoubleTab& omega = pb_->get_champ("omega").passe();
164 const DoubleTab& k = pb_->get_champ("k").passe();
165 const int nl = eps_.dimension(0);
166 const int N = eps_.dimension(1);
167 const int Nt = omega.dimension(1);
168 assert(nl == omega.dimension(0) && Nt <= N);
169
170 for (int i = 0; i < nl; i++)
171 for (int n = 0; n < N; n++)
172 eps_(i, n) = beta_k_ * ((n < Nt) ? k(i,n) * omega(i, n) : 0);
173}
174
176{
177 // compute_blending_F1();
178}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Added-mass correlation of the form: alpha_k rho_k Dv_k / Dt -> alpha_k rho_k Dv_k / Dt + sum_l ma(k,...
virtual void coefficient(const double *alpha, const double *rho, DoubleTab &coeff) const
Composite medium representing a multiphase fluid and its properties:
bool are_fluid_properties_initialised() const
static int dimension
Definition Objet_U.h:94
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Multiphase thermohydraulics problem of type "3*N equations":
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
Turbulent viscosity correlations describing the Reynolds stress tensor R_{ij} = - <u'_i u'_j>.
classe Viscosite_turbulente_k_omega Turbulent viscosity for a "k-omega" model : nu_t = k / omega
void eps(DoubleTab &eps) const override
void reynolds_stress(DoubleTab &R_ij) const override
void eddy_viscosity(DoubleTab &nu_t) const override
void k_over_eps(DoubleTab &k_sur_eps) const override