TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Production_energie_cin_turb_VDF.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 <Production_energie_cin_turb_VDF.h>
17
18#include <Dissipation_type_helpers.h>
19#include <Viscosite_turbulente_base.h>
20#include <Navier_Stokes_std.h>
21#include <Domaine_Cl_VDF.h>
22#include <Champ_Face_VDF.h>
23#include <Pb_Multiphase.h>
24#include <Domaine_VF.h>
25
26Implemente_instanciable(Production_energie_cin_turb_VDF,"Production_energie_cin_turb_VDF_P0_VDF", Source_Production_energie_cin_turb);
27
30
32{
33 const Navier_Stokes_std& eq_qdm = ref_cast(Navier_Stokes_std, equation().probleme().equation(0));
34 if (ref_cast(Operateur_Diff_base, eq_qdm.operateur(0).l_op_base()).correlation_viscosite_turbulente() == nullptr)
35 Process::exit(que_suis_je() + " : the momentum diffusion must be turbulent !");
36}
37
38
39void Production_energie_cin_turb_VDF::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
40{
41 const Domaine_VF& domaine = ref_cast(Domaine_VF, equation().domaine_dis());
42 const Probleme_base& pb = ref_cast(Probleme_base, equation().probleme());
43 const Navier_Stokes_std& eq_qdm = ref_cast(Navier_Stokes_std, pb.equation(0));
44 const Viscosite_turbulente_base& visc_turb = ref_cast(Viscosite_turbulente_base, (*ref_cast(Operateur_Diff_base, eq_qdm.operateur(0).l_op_base()).correlation_viscosite_turbulente()));
45 const DoubleVect& pe = equation().milieu().porosite_elem();
46 const DoubleVect& ve = domaine.volumes();
47
48 const std::string Type_diss = find_dissipation_type(pb);
49
50 const int Nph = pb.get_champ("vitesse").valeurs().dimension(1);
51 const int nb_elem = domaine.nb_elem();
52 const int D = dimension;
53 const int N = equation().inconnue().valeurs().line_size();
54 const int Na = sub_type(Pb_Multiphase,equation().probleme()) ? equation().probleme().get_champ("alpha").valeurs().line_size() : 1;
55
56 const double limiter_ = visc_turb.limiteur();
57 double nut_l = 0.;
58
59 const DoubleTab& tab_rho = equation().probleme().get_champ("masse_volumique").passe();
60 const DoubleTab& palp = equation().probleme().get_champ("alpha").passe();
61 const DoubleTab& alp = equation().probleme().get_champ("alpha").valeurs();
62 const DoubleTab& nu = equation().probleme().get_champ("viscosite_cinematique").passe();
63 const DoubleTab& k = equation().probleme().get_champ("k").valeurs();
64 const DoubleTab& tab_grad = equation().probleme().get_champ("gradient_vitesse").passe();
65 const DoubleTab *diss = equation().probleme().has_champ(Type_diss) ? &equation().probleme().get_champ(Type_diss).valeurs() : nullptr;
66 const DoubleTab *pdiss = equation().probleme().has_champ(Type_diss) ? &equation().probleme().get_champ(Type_diss).passe() : nullptr;
67
68 int n;
69
70 if (Type_diss == "")
71 {
72 DoubleTrav nut(0, Nph);
73 MD_Vector_tools::creer_tableau_distribue(eq_qdm.pression().valeurs().get_md_vector(), nut); //Necessary to compare size in eddy_viscosity()
74 visc_turb.eddy_viscosity(nut);
75
76 for (int e = 0; e < nb_elem; e++)
77 for (n = 0; n < N; n++)
78 {
79 double secmem_en = 0.;
80 for (int d_U = 0; d_U < D; d_U++)
81 for (int d_X = 0; d_X < D; d_X++)
82 secmem_en += (tab_grad(e, N * (D*d_U + d_X) + n)
83 + tab_grad(e, N * (D*d_X + d_U) + n)) * tab_grad(e, N * (D*d_U + d_X) + n);
84 secmem_en *= pe(e) * ve(e) * palp(e, n) * tab_rho(e, n) * nut(e, n);
85
86 secmem(e, n) += std::max(secmem_en, 0.);
87 }
88 }
89 else
90 {
91 for(int e = 0 ; e < nb_elem ; e++)
92 for(n = 0; n < N; n++)
93 {
94 double grad_grad = 0.;
95 for (int d_U = 0; d_U < D; d_U++)
96 for (int d_X = 0; d_X < D; d_X++)
97 grad_grad += (tab_grad( e, N * (D*d_U + d_X) + n)
98 + tab_grad( e, N * (D*d_X + d_U) + n))
99 * tab_grad( e, N * ( D*d_U+d_X ) + n) ;
100
101 const double fac = std::max(grad_grad, 0.) * pe(e) * ve(e) ;
102
103 if (Type_diss == "tau")
104 nut_l = k(e, n) * (*diss)(e, n) + limiter_ * nu(e, n);
105 else if (Type_diss == "omega")
106 nut_l = ((*pdiss)(e,n) > 0.) ? std::max(k(e, n) / (*pdiss)(e, n)*(2 - (*diss)(e, n)/(*pdiss)(e, n)), limiter_ * nu(e, n)) : limiter_ * nu(e, n);
107
108 secmem(e, n) += fac * nut_l * alp(e,n); // *alpha pour reduire la production de KTE a haut taux de vide
109 for (auto &&i_m : matrices)
110 {
111 Matrice_Morse& mat = *i_m.second;
112 if (i_m.first == "alpha")
113 mat(N * e + n, Na * e + n) -= fac * nut_l ; // derivee par rapport au taux de vide
114 }
115
116 if (Type_diss == "tau")
117 for (auto &&i_m : matrices)
118 {
119 Matrice_Morse& mat = *i_m.second;
120 if (i_m.first == "k")
121 mat(N * e + n, N * e + n) -= fac * alp(e, n) *(*diss)(e, n);
122 if (i_m.first == "tau")
123 mat(N * e + n, N * e + n) -= fac * alp(e, n) * k(e,n);
124 }
125 if ((Type_diss == "omega")
126 && ((*pdiss)(e, n) > 0.)
127 && ((k(e, n)/(*pdiss)(e, n)*(2 - (*diss)(e, n)/(*pdiss)(e, n)) > (limiter_*nu(e, n))) ) )
128 for (auto &&i_m : matrices)
129 {
130 Matrice_Morse& mat = *i_m.second;
131 if (i_m.first == "k")
132 mat(N * e + n, N * e + n) -= fac * alp(e,n) * 1./(*pdiss)(e, n)*(2 - (*diss)(e, n)/(*pdiss)(e, n));
133 if (i_m.first == "omega")
134 mat(N * e + n, N * e + n) -= fac * alp(e,n) * -k(e,n)/((*pdiss)(e, n)*(*pdiss)(e, n));
135 }
136 }
137 }
138}
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
virtual const Champ_Inc_base & inconnue() const =0
Probleme_base & probleme()
Renvoie le probleme associe a l'equation.
static void creer_tableau_distribue(const MD_Vector &, Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
transforme v en un tableau parallele ayant la structure md.
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.
Champ_Inc_base & pression()
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
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...
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
const Champ_base & get_champ(const Motcle &nom) const override
virtual const Equation_base & equation(int) const =0
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe Production_energie_cin_turb_VDF.
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
void completer() override
Met a jour les references internes a l'objet Source_base.
Classe de base des flux de sortie.
Definition Sortie.h:52
Classe Source_Production_energie_cin_turb Classe de base pour les operateur de production d'énergie c...
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
int line_size() const
Definition TRUSTVect.tpp:67
virtual const MD_Vector & get_md_vector() const
Definition TRUSTVect.h:123
classe Viscosite_turbulente_base correlations de viscosite turbulente decrivant le tenseur de Reynold...
virtual void eddy_viscosity(DoubleTab &nu_t) const =0