TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Source_Dissipation_energie_cin_turb.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 <Source_Dissipation_energie_cin_turb.h>
17
18#include <Dissipation_type_helpers.h>
19#include <Viscosite_turbulente_base.h>
20#include <Pb_Multiphase.h>
21
22Implemente_base(Source_Dissipation_energie_cin_turb,"Source_Dissipation_energie_cin_turb", Sources_Multiphase_base);
23// XD Terme_dissipation_energie_cinetique_turbulente source_base Terme_dissipation_energie_cinetique_turbulente BRACE
24// XD_CONT Dissipation source term used in the TKE equation
25// XD attr beta_k floattant beta_k OPT Constant for the used model
26
27// XD Production_echelle_temp_taux_diss_turb source_base Production_echelle_temp_taux_diss_turb INHERITS_BRACE
28// XD_CONT Production source term used in the tau and omega equations
29// XD attr alpha_omega floattant alpha_omega OPT Constant for the used model
30
31// XD Dissipation_echelle_temp_taux_diss_turb source_base Dissipation_echelle_temp_taux_diss_turb INHERITS_BRACE
32// XD_CONT Dissipation source term used in the tau and omega equations
33// XD attr beta_omega floattant beta_omega OPT Constant for the used model
34
35// XD Diffusion_croisee_echelle_temp_taux_diss_turb source_base Diffusion_croisee_echelle_temp_taux_diss_turb INHERITS_BRACE Cross-diffusion source term used in the tau and omega equations
36// XD attr sigma_d floattant sigma_d OPT Constant for the used model
37
38
40{
41 return os;
42}
43
45{
46 Param param(que_suis_je());
47 param.ajouter("beta_k", &beta_k_);
48 param.lire_avec_accolades_depuis(is);
49 return is;
50}
51
53{
54 const Navier_Stokes_std& eq_qdm = ref_cast(Navier_Stokes_std, equation().probleme().equation(0));
55 if (ref_cast(Operateur_Diff_base, eq_qdm.operateur(0).l_op_base()).correlation_viscosite_turbulente() == nullptr)
56 Process::exit(que_suis_je() + " : the momentum diffusion must be turbulent !");
57}
58
59void Source_Dissipation_energie_cin_turb::dimensionner_blocs(matrices_t matrices, const tabs_t& semi_impl) const
60{
61 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
62 const DoubleTab& k = equation().inconnue().valeurs();
63 const int ne = domaine.nb_elem(), ne_tot = domaine.nb_elem_tot(), Nk = k.line_size();
64
65 const std::string Type_diss = find_dissipation_type(equation().probleme());
66
67 assert(Nk == 1);
68 assert(equation().probleme().get_champ(Type_diss.c_str()).valeurs().line_size() == 1);
69
70 dimensionner_blocs_diagonal(matrices, equation().probleme(), ne, ne_tot, Nk,
71 {"alpha", "tau", "omega", "temperature"}, /* handle_pression */ true);
72}
73
74void Source_Dissipation_energie_cin_turb::ajouter_blocs(matrices_t matrices, DoubleTab& secmem,
75 const tabs_t& semi_impl) const
76{
77 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
78 const DoubleTab& k = equation().inconnue().valeurs();
79 const Champ_Inc_base& ch_alpha_rho_k = equation().champ_conserve();
80 const DoubleTab& alpha_rho_k = ch_alpha_rho_k.passe();
81 const tabs_t& der_alpha_rho_k = ref_cast(Champ_Inc_base, ch_alpha_rho_k).derivees();
82 const Navier_Stokes_std& eq_qdm = ref_cast(Navier_Stokes_std, equation().probleme().equation(0));
83 const Viscosite_turbulente_base& visc_turb = ref_cast(Viscosite_turbulente_base,
84 (*ref_cast(Operateur_Diff_base, eq_qdm.operateur(0).l_op_base()).correlation_viscosite_turbulente()));
85 const DoubleTab& nu = equation().probleme().get_champ("viscosite_cinematique").passe();
86 const DoubleVect& pe = equation().milieu().porosite_elem(), &ve = domaine.volumes();
87 const int cnu = nu.dimension(0) == 1;
88
89 const std::string Type_diss = find_dissipation_type(equation().probleme());
90
91 const DoubleTab& diss = equation().probleme().get_champ(Nom(Type_diss.c_str())).passe();
92
93 Matrice_Morse *Ma = matrices.count("alpha") ? matrices.at("alpha") : nullptr;
94 Matrice_Morse *Mk = matrices.count("k") ? matrices.at("k") : nullptr;
95 Matrice_Morse *Mdiss = matrices.count(Type_diss) ? matrices.at(Type_diss) : nullptr;
96 Matrice_Morse *Mp = matrices.count("pression") ? matrices.at("pression") : nullptr;
97 Matrice_Morse *Mt = matrices.count("temperature") ? matrices.at("temperature") : nullptr;
98
99 const int Nk = k.line_size();
100 const int Np = equation().probleme().get_champ("pression").valeurs().line_size();
101 const int Na = sub_type(Pb_Multiphase, equation().probleme())
102 ? ref_cast(Pb_Multiphase, equation().probleme()).get_champ("alpha").valeurs().line_size() : 1;
103 const int Nt = Mt ? equation().probleme().get_champ("temperature").valeurs().line_size() : 1;
104 const int nb_elem = domaine.nb_elem();
105
106 // Helper to get derivative of (alpha * rho * k) with respect to a given variable
107 auto get_deriv = [&](const std::string& var, int e, int n) -> double
108 {
109 return der_alpha_rho_k.count(var) ? der_alpha_rho_k.at(var)(e, n) : 0.;
110 };
111
112 for (int e = 0; e < nb_elem; e++)
113 for (int mk = 0, mp = 0; mk < Nk; mk++, mp += (Np > 1))
114 {
115 const double peve = pe(e) * ve(e);
116
117 if (Type_diss == "tau")
118 {
119 const double lim = visc_turb.limiteur() * nu(!cnu * e, mk);
120 const bool limited = !(k(e, mk) * diss(e, mk) > lim);
121 const double inv_tau = limited ? k(e, mk) / lim : 1. / diss(e, mk);
122
123 secmem(e, mk) -= peve * beta_k_ * alpha_rho_k(e, mk) * inv_tau;
124
125 if (Ma)
126 (*Ma)(Nk * e + mk, Na * e + mk) += peve * beta_k_ * get_deriv("alpha", e, mk) * inv_tau;
127
128 if (Mt)
129 (*Mt)(Nk * e + mk, Nt * e + mk) += peve * beta_k_ * get_deriv("temperature", e, mk) * inv_tau;
130
131 if (Mp)
132 (*Mp)(Nk * e + mk, Np * e + mp) += peve * beta_k_ * get_deriv("pression", e, mp) * inv_tau;
133
134 if (Mk)
135 {
136 if (limited)
137 (*Mk)(Nk * e + mk, Nk * e + mk) += peve * 2 * beta_k_ * alpha_rho_k(e, mk) / lim;
138 else
139 (*Mk)(Nk * e + mk, Nk * e + mk) += peve * beta_k_ * get_deriv("k", e, mk) * inv_tau;
140 }
141
142 if (Mdiss)
143 {
144 if (!limited)
145 (*Mdiss)(Nk * e + mk, Nk * e + mk) -= peve * beta_k_ * alpha_rho_k(e, mk) / (diss(e, mk) * diss(e, mk));
146 // When limited, dissipation (tau) does not appear in the expression => derivative is 0
147 }
148 }
149 else if (Type_diss == "omega")
150 {
151 // Source: -beta_k * k * omega
152 secmem(e, mk) -= peve * beta_k_ * k(e, mk) * diss(e, mk);
153
154 // Jacobian w.r.t. k: d/dk(-beta_k * k * omega) = -beta_k * omega
155 if (Mk)
156 (*Mk)(Nk * e + mk, Nk * e + mk) += peve * beta_k_ * diss(e, mk);
157 }
158 }
159}
Classe Champ_Inc_base.
DoubleTab & passe(int i=1) override
Renvoie les valeurs du champs a l'instant t-i.
DoubleTab & valeurs() override
Renvoie le tableau des valeurs du champ au temps courant.
virtual DoubleTab & valeurs()=0
virtual DoubleTab & passe(int i=1)
Definition Champ_Proto.h:50
class Domaine_VF
Definition Domaine_VF.h:44
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
virtual const Milieu_base & milieu() const =0
Champ_Inc_base & champ_conserve() const
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
DoubleVect & porosite_elem()
Definition Milieu_base.h:58
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
classe Navier_Stokes_std Cette classe porte les termes de l'equation de la dynamique
const Operateur & operateur(int) const override
Renvoie le i-eme operateur de l'equation: - le terme_diffusif si i = 0.
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
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
classe Operateur_Diff_base Cette classe est la base de la hierarchie des operateurs representant
virtual Operateur_base & l_op_base()=0
classe Pb_Multiphase Cette classe represente un probleme de thermohydraulique multiphase de type "3*N...
const Champ_base & get_champ(const Motcle &nom) const override
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
class Source_Dissipation_energie_cin_turb
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl={}) const override
void completer() override
Met a jour les references internes a l'objet Source_base.
const Champ_base & get_champ(const Motcle &nom) const override
static void dimensionner_blocs_diagonal(matrices_t matrices, const Probleme_base &pb, int ne, int ne_tot, int Nk, const std::set< std::string > &diagonal_fields, bool handle_pression)
Allocates diagonal stencils in the given matrices for field names listed in diagonal_fields (and opti...
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67
classe Viscosite_turbulente_base correlations de viscosite turbulente decrivant le tenseur de Reynold...