TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Production_energie_cin_turb_PolyMAC_MPFA.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_PolyMAC_MPFA.h>
17
18#include <Op_Diff_Turbulent_PolyMAC_MPFA_Face.h>
19#include <Dissipation_type_helpers.h>
20#include <Viscosite_turbulente_base.h>
21#include <Domaine_PolyMAC_MPFA.h>
22#include <Navier_Stokes_std.h>
23#include <Pb_Multiphase.h>
24
25Implemente_instanciable(Production_energie_cin_turb_PolyMAC_MPFA,"Production_energie_cin_turb_Elem_PolyMAC_MPFA", Source_Production_energie_cin_turb);
26
29
30void Production_energie_cin_turb_PolyMAC_MPFA::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
31{
32 const Domaine_PolyMAC_MPFA& domaine = ref_cast(Domaine_PolyMAC_MPFA, equation().domaine_dis());
33 const Probleme_base& pb = ref_cast(Probleme_base, equation().probleme());
34 const Navier_Stokes_std& eq_qdm = ref_cast(Navier_Stokes_std, pb.equation(0));
35 const Viscosite_turbulente_base& visc_turb = ref_cast(Viscosite_turbulente_base, ref_cast(Op_Diff_Turbulent_PolyMAC_MPFA_Face, eq_qdm.operateur(0).l_op_base()).correlation());
36 const DoubleVect& pe = equation().milieu().porosite_elem();
37 const DoubleVect& ve = domaine.volumes();
38
39 const std::string Type_diss = find_dissipation_type(equation().probleme());
40
41 const int Nph = pb.get_champ("vitesse").valeurs().dimension(1);
42 const int nb_elem = domaine.nb_elem();
43 const int D = dimension;
44 const int nf_tot = domaine.nb_faces_tot();
45 const int N = equation().inconnue().valeurs().line_size();
46 const int Na = sub_type(Pb_Multiphase,equation().probleme()) ? equation().probleme().get_champ("alpha").valeurs().line_size() : 1;
47 int n;
48
49 double limiter_ = visc_turb.limiteur();
50 const bool is_multi = sub_type(Pb_Multiphase,equation().probleme());
51 const DoubleTab& tab_rho = equation().probleme().get_champ("masse_volumique").passe();
52 const DoubleTab *palp = is_multi ? &equation().probleme().get_champ("alpha").passe() : nullptr;
53 const DoubleTab *alp = is_multi ? &equation().probleme().get_champ("alpha").valeurs() : nullptr;
54 const DoubleTab& nu = equation().probleme().get_champ("viscosite_cinematique").passe();
55 const DoubleTab& k = equation().probleme().get_champ("k").valeurs();
56 const DoubleTab& tab_grad = pb.get_champ("gradient_vitesse").passe();
57 const DoubleTab *diss = equation().probleme().has_champ(Type_diss) ? &equation().probleme().get_champ(Type_diss).valeurs() : nullptr;
58 const DoubleTab *pdiss = equation().probleme().has_champ(Type_diss) ? &equation().probleme().get_champ(Type_diss).passe() : nullptr;
59
60 const int cnu = nu.dimension(0) == 1;
61 if (Type_diss == "")
62 {
63 DoubleTrav nut(0, Nph);
64 MD_Vector_tools::creer_tableau_distribue(eq_qdm.pression().valeurs().get_md_vector(), nut); //Necessary to compare size in eddy_viscosity()
65 visc_turb.eddy_viscosity(nut);
66
67 for (int e = 0 ; e < nb_elem ; e++)
68 for (n = 0; n < N ; n++)
69 {
70 double secmem_en = 0.;
71 for (int d_U = 0; d_U < D; d_U++)
72 for (int d_X = 0; d_X < D; d_X++)
73 secmem_en += ( tab_grad(nf_tot + d_U + e * D , D * n + d_X) + tab_grad(nf_tot + d_X + e * D , D * n + d_U) ) * tab_grad(nf_tot + d_X + e * D , D * n + d_U) ;
74 secmem_en *= pe(e) * ve(e) * (palp ? (*palp)(e, n) : 1.0) * tab_rho(e, n) * nut(e, n) ;
75
76 secmem(e, n) += std::max(secmem_en, 0.);
77 }
78 }
79 else
80 {
81 for (int e = 0 ; e < nb_elem ; e++)
82 for (n = 0; n < N ; n++)
83 {
84 double grad_grad = 0.;
85 for (int d_U = 0; d_U < D; d_U++)
86 for (int d_X = 0; d_X < D; d_X++)
87 grad_grad += ( tab_grad(nf_tot + d_U + e * D , D * n + d_X) + tab_grad(nf_tot + d_X + e * D , D * n + d_U) ) * tab_grad(nf_tot + d_X + e * D , D * n + d_U) ;
88
89 const double fac = std::max(grad_grad, 0.) * pe(e) * ve(e) ;
90 double nut_l {0};
91
92 if (Type_diss == "tau")
93 nut_l = k(e, n) * (*diss)(e, n) + limiter_ * nu(!cnu * e, n);
94 else if (Type_diss == "omega")
95 nut_l = k(e, n) / std::max((*pdiss)(e, n), omega_min_) + limiter_ * nu(!cnu * e, n);
96 else
97 Process::exit(que_suis_je() + " : ajouter_blocs : probleme !!!") ;
98
99 const double alp_en = (alp ? (*alp)(e, n) : 1.0);
100 secmem(e, n) += fac * nut_l;
101
102 if (is_multi)
103 for (auto &&i_m : matrices)
104 {
105 Matrice_Morse& mat = *i_m.second;
106 if (i_m.first == "alpha")
107 mat(N * e + n, Na * e + n) -= fac * nut_l; // derivee par rapport au taux de vide
108 }
109
110 if (Type_diss == "tau")
111 for (auto &&i_m : matrices)
112 {
113 Matrice_Morse& mat = *i_m.second;
114 if (i_m.first == "k")
115 mat(N * e + n, N * e + n) -= fac * alp_en *(*diss)(e,n);
116 if (i_m.first == "tau")
117 mat(N * e + n, N * e + n) -= fac * alp_en * k(e,n);
118 }
119 else if (Type_diss == "omega")
120 for (auto &&i_m : matrices)
121 {
122 Matrice_Morse& mat = *i_m.second;
123 if (i_m.first == "k")
124 mat(N * e + n, N * e + n) -= fac * alp_en / std::max((*pdiss)(e, n), omega_min_);
125 }
126 }
127 }
128}
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 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
: class Op_Diff_Turbulent_PolyMAC_MPFA_Face
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_PolyMAC_MPFA Cette classe implemente dans PolyMAC_MPFA un operateu...
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={}) const override
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