TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Source_Transport_K_KEps_VDF_Elem.cpp
1/****************************************************************************
2* Copyright (c) 2019, 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_Transport_K_KEps_VDF_Elem.h>
17#include <Convection_Diffusion_Temperature.h>
18#include <Modele_turbulence_scal_base.h>
19#include <Dirichlet_paroi_defilante.h>
20#include <Dirichlet_paroi_fixe.h>
21#include <Paroi_std_hyd_VDF.h>
22#include <Transport_K_KEps.h>
23#include <Champ_Uniforme.h>
24#include <Probleme_base.h>
25#include <Fluide_base.h>
26#include <Domaine_Cl_VDF.h>
27#include <Champ_Face_VDF.h>
28#include <TRUSTTrav.h>
29
30Implemente_instanciable_sans_constructeur(Source_Transport_K_KEps_VDF_Elem,"Source_Transport_K_KEps_VDF_P0_VDF",Source_Transport_VDF_Elem_base);
31
34
40
41void Source_Transport_K_KEps_VDF_Elem::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
42{
43 const Domaine_VDF& domaine_VDF = le_dom_VDF.valeur();
44 const Domaine_VDF& domaine_VDF_NS = ref_cast(Domaine_VDF,eq_hydraulique->domaine_dis());
45 const Domaine_Cl_VDF& domaine_Cl_VDF_NS = ref_cast(Domaine_Cl_VDF,eq_hydraulique->domaine_Cl_dis());
46 const DoubleTab& K_eps = mon_eq_transport_K_Eps->inconnue().valeurs();
47 const DoubleTab& visco_turb = mon_eq_transport_K_Eps->modele_turbulence().viscosite_turbulente().valeurs();
48 const DoubleTab& vit = eq_hydraulique->inconnue().valeurs();
49 const DoubleVect& volumes = domaine_VDF.volumes();
50 const DoubleVect& porosite_vol = le_dom_Cl_VDF->equation().milieu().porosite_elem();
51 const IntTab& face_voisins = domaine_VDF.face_voisins();
52 const IntTab& elem_faces = domaine_VDF.elem_faces();
53 const int nbcouches = mon_eq_transport_K_Eps->get_nbcouches();
54 int ndeb,nfin,elem,face_courante,elem_courant;
55 double dist, d_visco,y_etoile, critere_switch=0.;
56 Loi_2couches_base& loi2couches =ref_cast_non_const(Transport_K_KEps,mon_eq_transport_K_Eps.valeur()).loi2couches();
57 int valswitch, icouche;
58 const int impr2 = mon_eq_transport_K_Eps->get_impr();
59
60 const int typeswitch = mon_eq_transport_K_Eps->get_switch();
61 if ( typeswitch == 0 ) valswitch = mon_eq_transport_K_Eps->get_yswitch();
62 else valswitch = mon_eq_transport_K_Eps->get_nutswitch();
63
64 const int nb_elem = domaine_VDF.nb_elem(), nb_elem_tot = domaine_VDF.nb_elem_tot();
65 DoubleTrav P(nb_elem_tot), Eps(nb_elem_tot), tab_couches(nb_elem_tot);
66
67 //Extraction de la viscosite moleculaire
68 const Fluide_base& le_fluide = ref_cast(Fluide_base,eq_hydraulique->milieu());
69 const Champ_Don_base& ch_visco_cin = le_fluide.viscosite_cinematique();
70 const DoubleTab& tab_visco = ch_visco_cin.valeurs();
71 double visco=-1;
72 int l_unif;
73 if (sub_type(Champ_Uniforme,ch_visco_cin))
74 {
75 visco = std::max(tab_visco(0,0),DMINFLOAT);
76 l_unif = 1;
77 }
78 else
79 l_unif = 0;
80
81 //essayer de calculer u+d+ ici pour chaque elt du bord?!
82 for (elem=0; elem<nb_elem; elem++)
83 {
84 Eps[elem] = K_eps(elem,1);
85 tab_couches[elem]=0;
86 }
87
88 // Boucle sur les bords
89 for (int n_bord=0; n_bord<domaine_VDF_NS.nb_front_Cl(); n_bord++)
90 {
91 const Cond_lim& la_cl = domaine_Cl_VDF_NS.les_conditions_limites(n_bord);
92 if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()) || sub_type(Dirichlet_paroi_defilante,la_cl.valeur()))
93 {
94 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
95 ndeb = le_bord.num_premiere_face();
96 nfin = ndeb + le_bord.nb_faces();
97 if (dimension == 2 )
98 for (int num_face=ndeb; num_face<nfin; num_face++)
99 {
100 if ( (elem =face_voisins(num_face,0)) != -1) ;
101 else
102 elem = face_voisins(num_face,1);
103 if (l_unif)
104 d_visco = visco;
105 else
106 d_visco = tab_visco[elem];
107 dist=domaine_VDF_NS.distance_normale(num_face);
108 //Cerr << "dist = " << dist << finl;
109
110 face_courante = num_face;
111 elem_courant = elem;
112
113
114 for(icouche=0; (icouche<nbcouches) && (elem_courant != -1); icouche++)
115 {
116 double kSqRt=1.e-3;
117 if (K_eps(elem_courant,0)>0)
118 kSqRt=sqrt(K_eps(elem_courant,0));
119 y_etoile = kSqRt*dist/d_visco;
120 if (typeswitch == 0) //selon le critere de switch choisit:y* ou nu_t
121 critere_switch = y_etoile;
122 else
123 critere_switch = visco_turb[elem_courant]/d_visco;
124 if (critere_switch < valswitch) // si on est en proche paroi
125 {
126 tab_couches[elem_courant]=1;
127 double Leps,Lmu,vvSqRt;
128 if (K_eps(elem_courant,0)>0)
129 loi2couches.LepsLmu(K_eps(elem_courant,0),d_visco,dist,y_etoile,Leps,Lmu,vvSqRt);
130 else
131 loi2couches.LepsLmu(1.e-3,d_visco,dist,y_etoile,Leps,Lmu,vvSqRt);
132
133 if ( Leps!=0.)
134 Eps[elem_courant] = K_eps(elem_courant,0)*kSqRt/Leps;
135 else Eps[elem_courant] = 1.e-3;
136 }
137 else
138 {
139 break;
140 }
141 if ( elem_faces(elem_courant,0) == face_courante)
142 face_courante = elem_faces(elem_courant,2);
143 else if ( elem_faces(elem_courant,1) == face_courante)
144 face_courante = elem_faces(elem_courant,3);
145 else if ( elem_faces(elem_courant,2) == face_courante)
146 face_courante = elem_faces(elem_courant,0);
147 else if ( elem_faces(elem_courant,3) == face_courante)
148 face_courante = elem_faces(elem_courant,1);
149 if ( face_voisins(face_courante,0) != elem_courant)
150 elem_courant = face_voisins(face_courante,0);
151 else
152 elem_courant = face_voisins(face_courante,1);
153 dist+=domaine_VDF_NS.distance_normale(face_courante);
154
155 }
156 if ((eq_hydraulique->schema_temps().limpr()) && (impr2 == 1) )
157 {
158 if ( (typeswitch == 0) ) //selon le critere de switch choisit:y* ou nu_t
159 Cout << "Changement de couche a la maille " << icouche << " (" << domaine_VDF_NS.xp(elem_courant,0) << ";" << domaine_VDF_NS.xp(elem_courant,1) << ") y* = " << critere_switch << finl;
160 else
161 Cout << "Changement de couche a la maille " << icouche << " (" << domaine_VDF_NS.xp(elem_courant,0) << ";" << domaine_VDF_NS.xp(elem_courant,1) << ") nu_t/nu = " << critere_switch << finl;
162 }
163
164 }
165
166 else if (dimension == 3)
167 for (int num_face=ndeb; num_face<nfin; num_face++)
168 {
169 if ( (elem =face_voisins(num_face,0)) != -1) ;
170 else
171 elem = face_voisins(num_face,1);
172 if (l_unif)
173 d_visco = visco;
174 else
175 d_visco = tab_visco[elem];
176 dist=domaine_VDF_NS.distance_normale(num_face);
177
178 face_courante = num_face;
179 elem_courant = elem;
180
181 for(icouche=0; (icouche<nbcouches) && (elem_courant != -1); icouche++)
182 {
183 double kSqRt=1.e-3;
184 if (K_eps(elem_courant,0)>0)
185 kSqRt=sqrt(K_eps(elem_courant,0));
186 y_etoile = kSqRt*dist/d_visco;
187 if (typeswitch == 0) //selon le critere de switch choisit:y* ou nu_t
188 critere_switch = y_etoile;
189 else
190 critere_switch = visco_turb[elem_courant]/d_visco;
191 if (critere_switch < valswitch) // si on est en proche paroi
192 {
193 tab_couches[elem_courant]=1;
194 double Leps,Lmu,vvSqRt;
195 if (K_eps(elem_courant,0)>0)
196 loi2couches.LepsLmu(K_eps(elem_courant,0),d_visco,dist,y_etoile,Leps,Lmu,vvSqRt);
197 else
198 loi2couches.LepsLmu(1.e-3,d_visco,dist,y_etoile,Leps,Lmu,vvSqRt);
199 if ( Leps!=0.)
200 Eps[elem_courant] = K_eps(elem_courant,0)*kSqRt/Leps;
201 else Eps[elem_courant] = 1.e-3;
202 }
203 else
204 {
205 break;
206 }
207
208
209 if ( elem_faces(elem_courant,0) == face_courante)
210 face_courante = elem_faces(elem_courant,3);
211 else if ( elem_faces(elem_courant,1) == face_courante)
212 face_courante = elem_faces(elem_courant,4);
213 else if ( elem_faces(elem_courant,2) == face_courante)
214 face_courante = elem_faces(elem_courant,5);
215 else if ( elem_faces(elem_courant,3) == face_courante)
216 face_courante = elem_faces(elem_courant,0);
217 else if ( elem_faces(elem_courant,4) == face_courante)
218 face_courante = elem_faces(elem_courant,1);
219 else if ( elem_faces(elem_courant,5) == face_courante)
220 face_courante = elem_faces(elem_courant,2);
221
222 if ( face_voisins(face_courante,0) != elem_courant)
223 elem_courant = face_voisins(face_courante,0);
224 else
225 elem_courant = face_voisins(face_courante,1);
226 dist+=domaine_VDF_NS.distance_normale(face_courante);
227 }
228 if ((eq_hydraulique->schema_temps().limpr()) && (impr2 == 1) && (elem_courant != -1))
229 {
230 if ( (typeswitch == 0) ) //selon le critere de switch choisit:y* ou nu_t
231 Cout << "Changement de couche a la maille " << icouche << " (" << domaine_VDF_NS.xp(elem_courant,0) << ";" << domaine_VDF_NS.xp(elem_courant,1) << ";" << domaine_VDF_NS.xp(elem_courant,2) << ") y* = " << critere_switch << finl;
232 else
233 Cout << "Changement de couche a la maille " << icouche << " (" << domaine_VDF_NS.xp(elem_courant,0) << ";" << domaine_VDF_NS.xp(elem_courant,1) << ";" << domaine_VDF_NS.xp(elem_courant,2) << ") nu_t/nu = " << critere_switch << finl;
234 }
235 }
236 }
237 }
238
239 if (axi)
240 {
241 Champ_Face_VDF& vitesse = ref_cast_non_const(Champ_Face_VDF,eq_hydraulique->inconnue());
242 calculer_terme_production_K_Axi(domaine_VDF,vitesse,P,K_eps,visco_turb);
243 }
244 else
245 {
246 Champ_Face_VDF& vitesse = ref_cast_non_const(Champ_Face_VDF,eq_hydraulique->inconnue());
247 calculer_terme_production_K(domaine_VDF,domaine_Cl_VDF_NS,P,K_eps,vit,vitesse,visco_turb);
248 }
249
250 for (elem=0; elem<nb_elem; elem++)
251 {
252 secmem(elem,0) += (P(elem)-Eps(elem))*volumes(elem)*porosite_vol(elem);
253 if (K_eps(elem,0) >= 10.e-10)
254 secmem(elem,1) += (C1*P(elem)- C2*Eps(elem))*volumes(elem)*porosite_vol(elem)*Eps(elem)/K_eps(elem,0);
255 }
256
257}
DoubleVect & calculer_terme_production_K(const Domaine_VDF &, const Domaine_Cl_VDF &, DoubleVect &, const DoubleTab &, const DoubleTab &, const Champ_Face_VDF &, const DoubleTab &) const
DoubleVect & calculer_terme_production_K_Axi(const Domaine_VDF &, const Champ_Face_VDF &, DoubleVect &, const DoubleTab &, const DoubleTab &) const
classe Champ_Don_base classe de base des Champs donnes (non calcules)
DoubleTab & valeurs() override
Surcharge Champ_base::valeurs() Renvoie le tableau des valeurs.
class Champ_Face_VDF Cette classe sert a representer un champ vectoriel dont on ne calcule
classe Champ_Uniforme Represente un champ constant dans l'espace et dans le temps.
classe Cond_lim Classe generique servant a representer n'importe quelle classe
Definition Cond_lim.h:31
classe Dirichlet_paroi_defilante Impose la vitesse de paroi dnas une equation de type Navier_Stokes.
classe Dirichlet_paroi_fixe Represente une paroi immobile dans une equation de type Navier_Stokes.
class Domaine_Cl_VDF
const Cond_lim & les_conditions_limites(int) const
Renvoie la i-ieme condition aux limites.
class Domaine_VDF
Definition Domaine_VDF.h:64
double distance_normale(int num_face) const
double volumes(int i) const
Definition Domaine_VF.h:113
int elem_faces(int i, int j) const
renvoie le numero de le ieme face de la maille num_elem la facon dont ces faces sont numerotees est
Definition Domaine_VF.h:543
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
int face_voisins(int num_face, int i) const
renvoie l'element voisin de numface dans la direction i.
Definition Domaine_VF.h:418
int nb_elem_tot() const
int nb_front_Cl() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Fluide_base Cette classe represente un d'un fluide incompressible ainsi que
Definition Fluide_base.h:38
const Champ_Don_base & viscosite_cinematique() const
Definition Fluide_base.h:58
class Front_VF
Definition Front_VF.h:36
int nb_faces() const
Definition Front_VF.h:53
int num_premiere_face() const
Definition Front_VF.h:63
classe Loi_2couches_base Cette classe de base represente les modeles 1 equation pour le modele a deux...
virtual void LepsLmu(double k, double nu, double dist, double y_etoile, double &Leps, double &Lmu, double &vvSqRt)=0
const Equation_base & equation() const
Renvoie la reference sur l'equation pointe par MorEqn::mon_equation.
Definition MorEqn.h:62
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
static int axi
Definition Objet_U.h:101
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
Classe de base des flux de sortie.
Definition Sortie.h:52
class Source_Transport_K_KEps_VDF_Elem Cette classe represente le terme source qui figure dans l'equa...
void associer_pb(const Probleme_base &pb) override
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl) const override
void associer_pb(const Probleme_base &) override
classe Transport_K_KEps Cette classe represente l'equation de transport de l'energie cinetique