TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Modele_turbulence_hyd_LES_axi_VDF.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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
17#include <Modele_turbulence_hyd_LES_axi_VDF.h>
18#include <Dirichlet_entree_fluide_leaves.h>
19#include <Neumann_sortie_libre.h>
20#include <Schema_Temps_base.h>
21#include <Domaine_Cl_VDF.h>
22#include <Equation_base.h>
23#include <Domaine_VDF.h>
24#include <Periodique.h>
25#include <TRUSTTrav.h>
26#include <Symetrie.h>
27#include <Debog.h>
28
29Implemente_instanciable(Modele_turbulence_hyd_LES_axi_VDF, "Modele_turbulence_hyd_sous_maille_axi_VDF", Modele_turbulence_hyd_LES_VDF);
30
31Sortie& Modele_turbulence_hyd_LES_axi_VDF::printOn(Sortie& s) const { return s << que_suis_je() << " " << le_nom(); }
32
34
36{
37 const Domaine_VDF& domaine_VDF = ref_cast(Domaine_VDF, le_dom_VF_.valeur());
38 const IntTab& elem_faces = domaine_VDF.elem_faces();
39 static const double Csm1 = CSM1;
40 double temps = mon_equation_->inconnue().temps();
41 DoubleTab& visco_turb = la_viscosite_turbulente_->valeurs();
42 int nb_poly = domaine_VDF.domaine().nb_elem();
43 int nb_poly_tot = domaine_VDF.domaine().nb_elem_tot();
44 int numfa[6];
45 double delta_C_axi;
46 double h_x, h_y, h_z;
47 double un_tiers = 1. / 3.;
48
49 F2_.resize(nb_poly_tot);
51
52 if (visco_turb.size() != nb_poly)
53 {
54 Cerr << "erreur dans la taille du DoubleTab valeurs de la viscosite" << finl;
56 }
57
58 Debog::verifier("Modele_turbulence_hyd_LES_axi_VDF::calculer_viscosite_turbulente visco_turb 0", visco_turb);
59
60 for (int elem = 0; elem < nb_poly; elem++)
61 {
62 for (int i = 0; i < 6; i++)
63 numfa[i] = elem_faces(elem, i);
64 h_x = domaine_VDF.dist_face_axi(numfa[0], numfa[3], 0);
65 h_y = domaine_VDF.dist_face_axi(numfa[1], numfa[4], 1);
66 h_z = domaine_VDF.dist_face_axi(numfa[2], numfa[5], 2);
67 // filter width by bardina
68 // delta_C_axi = sqrt(h_x*h_x + h_y*h_y + h_z*h_z) ;
69 // filter lesieur
70 delta_C_axi = pow(h_x * h_y * h_z, un_tiers);
71 visco_turb[elem] = Csm1 * delta_C_axi * sqrt(F2_[elem]);
72 }
73
74 Debog::verifier("Modele_turbulence_hyd_LES_axi_VDF::calculer_viscosite_turbulente visco_turb 1", visco_turb);
75
76 la_viscosite_turbulente_->changer_temps(temps);
77 return la_viscosite_turbulente_;
78}
79
81{
82 const DoubleTab& vitesse = mon_equation_->inconnue().valeurs();
83 const Domaine_VDF& domaine_VDF = ref_cast(Domaine_VDF, le_dom_VF_.valeur());
84 int nb_poly = domaine_VDF.domaine().nb_elem();
85 const IntTab& face_voisins = domaine_VDF.face_voisins();
86 const IntTab& elem_faces = domaine_VDF.elem_faces();
87 const IntTab& Qdm = domaine_VDF.Qdm();
88 const IntVect& orientation = domaine_VDF.orientation();
89 DoubleTrav F_Elem(nb_poly, dimension);
90 int num0, num1, num2, num3;
91 int k1, k2;
92 double diff1, diff2, aux;
93
94 // Dans le tableau F_Elem on stocke les fonctions de structure dans
95 // chacune des directions d'espace
96 // F_Elem(num_elem,0) Fonction de structure dans la direction X
97 // au noeud num_elem
98 // F_Elem(num_elem,1) Fonction de structure dans la direction Y
99 // F_Elem(num_elem,2) Fonction de structure dans la direction Z
100 //
101 // Principe de calcul des Fonctions de structure directionnelles:
102 //
103 // 2
104 // F_X = (Ug-Ud) + 1/4[ F_X(arete_XY_1) + F_X(arete_XY_2 ) +
105 // F_X(arete_XY_3) + F_X(arete_XY_4)]
106 //
107 // On va calculer 0.25*F_X(arete_XY) et le distribuer aux 4
108 // elements adjacents
109
110 double diff;
111
112 if (dimension == 3) //dimension == 3
113 {
114 int num_elem;
115 for (num_elem = 0; num_elem < nb_poly; num_elem++)
116 {
117 diff = vitesse[elem_faces(num_elem, 0)] - vitesse[elem_faces(num_elem, 3)];
118 F_Elem(num_elem, 0) = diff * diff;
119 diff = vitesse[elem_faces(num_elem, 1)] - vitesse[elem_faces(num_elem, 4)];
120 F_Elem(num_elem, 1) = diff * diff;
121 diff = vitesse[elem_faces(num_elem, 2)] - vitesse[elem_faces(num_elem, 5)];
122 F_Elem(num_elem, 2) = diff * diff;
123 }
124
125 int ndeb0 = domaine_VDF.premiere_arete_interne();
126 int nfin0 = ndeb0 + domaine_VDF.nb_aretes_internes();
127 int num_arete0;
128
129 for (num_arete0 = ndeb0; num_arete0 < nfin0; num_arete0++)
130 {
131 num0 = Qdm(num_arete0, 0);
132 num1 = Qdm(num_arete0, 1);
133 num2 = Qdm(num_arete0, 2);
134 num3 = Qdm(num_arete0, 3);
135
136 aux = vitesse[num1] - vitesse[num0];
137 diff1 = 0.25 * aux * aux;
138 aux = vitesse[num3] - vitesse[num2];
139 diff2 = 0.25 * aux * aux;
140 k1 = orientation(num0);
141 k2 = orientation(num2);
142
143 F_Elem(face_voisins(num0, 0), k2) += diff1;
144 F_Elem(face_voisins(num0, 1), k2) += diff1;
145 F_Elem(face_voisins(num1, 0), k2) += diff1;
146 F_Elem(face_voisins(num1, 1), k2) += diff1;
147 F_Elem(face_voisins(num2, 0), k1) += diff2;
148 F_Elem(face_voisins(num2, 1), k1) += diff2;
149 F_Elem(face_voisins(num3, 0), k1) += diff2;
150 F_Elem(face_voisins(num3, 1), k1) += diff2;
151
152 }
153
154 ndeb0 = domaine_VDF.premiere_arete_mixte();
155 nfin0 = ndeb0 + domaine_VDF.nb_aretes_mixtes();
156
157 for (num_arete0 = ndeb0; num_arete0 < nfin0; num_arete0++)
158 {
159 num0 = Qdm(num_arete0, 0);
160 num1 = Qdm(num_arete0, 1);
161 num2 = Qdm(num_arete0, 2);
162 num3 = Qdm(num_arete0, 3);
163
164 aux = vitesse[num1] - vitesse[num0];
165 diff1 = 0.25 * aux * aux;
166 aux = vitesse[num3] - vitesse[num2];
167 diff2 = 0.25 * aux * aux;
168 k1 = orientation(num0);
169 k2 = orientation(num2);
170
171 //int num_elem;
172 num_elem = face_voisins(num0, 0);
173 if (num_elem != -1)
174 F_Elem(num_elem, k2) += diff1;
175 num_elem = face_voisins(num0, 1);
176 if (num_elem != -1)
177 F_Elem(num_elem, k2) += diff1;
178 num_elem = face_voisins(num1, 0);
179 if (num_elem != -1)
180 F_Elem(num_elem, k2) += diff1;
181 num_elem = face_voisins(num1, 1);
182 if (num_elem != -1)
183 F_Elem(num_elem, k2) += diff1;
184 num_elem = face_voisins(num2, 0);
185 if (num_elem != -1)
186 F_Elem(num_elem, k1) += diff2;
187 num_elem = face_voisins(num2, 1);
188 if (num_elem != -1)
189 F_Elem(num_elem, k1) += diff2;
190 num_elem = face_voisins(num3, 0);
191 if (num_elem != -1)
192 F_Elem(num_elem, k1) += diff2;
193 num_elem = face_voisins(num3, 1);
194 if (num_elem != -1)
195 F_Elem(num_elem, k1) += diff2;
196 }
197
198 // ATTENTION!!!!!!!!!!! Modifs periodicite DEBUT
199 //
200 // Les aretes bords sont considerees comme des faces internes
201 // par modification du tableau Qdm ( dans Domaine_VDF.cpp )
202
203 const Domaine_Cl_VDF& domaine_Cl_VDF = ref_cast(Domaine_Cl_VDF, le_dom_Cl_.valeur());
204 const int nb_cond_lim = domaine_Cl_VDF.nb_cond_lim();
205
206 for (int i = 0; i < nb_cond_lim; i++)
207 {
208 const Cond_lim_base& cl = domaine_Cl_VDF.les_conditions_limites(i).valeur();
209
210 // Cerr << "les_conditions_limites(i).valeur() : " << cl << finl;
211
212 if (sub_type(Periodique, cl))
213 {
214 // const Domaine_Cl_VDF& domaine_Cl_VDF = le_dom_Cl_VDF.valeur();
215
216 int ndeb = domaine_VDF.premiere_arete_bord();
217 int nfin = ndeb + domaine_VDF.nb_aretes_bord();
218 int num_arete;
219
220 for (num_arete = ndeb; num_arete < nfin; num_arete++)
221 {
222 int n_type = domaine_Cl_VDF.type_arete_bord(num_arete - ndeb);
223
224 if (n_type == TypeAreteBordVDF::PERIO_PERIO) // arete de type periodicite
225 {
226
227 num0 = Qdm(num_arete, 0);
228 num1 = Qdm(num_arete, 1);
229 num2 = Qdm(num_arete, 2);
230 num3 = Qdm(num_arete, 3);
231
232 aux = vitesse[num1] - vitesse[num0];
233 diff1 = 0.25 * aux * aux;
234 aux = vitesse[num3] - vitesse[num2];
235 diff2 = 0.25 * aux * aux;
236 k1 = orientation(num0);
237 k2 = orientation(num2);
238
239 F_Elem(face_voisins(num0, 0), k2) += diff1;
240 F_Elem(face_voisins(num0, 1), k2) += diff1;
241 F_Elem(face_voisins(num1, 0), k2) += diff1;
242 F_Elem(face_voisins(num1, 1), k2) += diff1;
243 F_Elem(face_voisins(num2, 0), k1) += diff2;
244 F_Elem(face_voisins(num2, 1), k1) += diff2;
245 F_Elem(face_voisins(num3, 0), k1) += diff2;
246 F_Elem(face_voisins(num3, 1), k1) += diff2;
247 }
248
249 }
250 }
251 }
252 // ATTENTION!!!!!!!!!!! Modifs periodicite FIN
253
254 // Calcul de la Fonction de structure a partir de ses
255 // composantes directionnelles
256
257 double un_tiers = 1. / 3.;
258 double deux_tiers = 2. / 3.;
259 double delta_C_axi;
260 double h_x, h_y, h_z;
261 int numfa[6];
262
263 for (num_elem = 0; num_elem < nb_poly; num_elem++)
264 {
265 for (int i = 0; i < 6; i++)
266 numfa[i] = elem_faces(num_elem, i);
267 h_x = domaine_VDF.dist_face_axi(numfa[0], numfa[3], 0);
268 h_y = domaine_VDF.dist_face_axi(numfa[1], numfa[4], 1);
269 h_z = domaine_VDF.dist_face_axi(numfa[2], numfa[5], 2);
270 // filter width by bardina
271 // delta_C_axi = sqrt(h_x*h_x + h_y*h_y + h_z*h_z) ;
272 // filter lesieur
273 delta_C_axi = pow(h_x * h_y * h_z, un_tiers);
274 F2_[num_elem] = un_tiers
275 * (F_Elem(num_elem, 0) * pow(delta_C_axi / h_x, deux_tiers) + F_Elem(num_elem, 1) * pow(delta_C_axi / h_y, deux_tiers) + F_Elem(num_elem, 2) * pow(delta_C_axi / h_z, deux_tiers));
276 }
277
278 // On traite les bords pour completer la fonction de structure
279 // sur les mailles de bord
280 // Rq: il est inutile de completer la fonction de structure
281 // sur les mailles de bord qui correspondent aux conditions limites
282 // de paroi puisque la viscosite turbulente est calculee a partir des
283 // lois de paroi sur ces mailles et non a partir de la fonction de
284 // structure
285
286 int num_face;
287 int elem, n0, n1;
288
289 for (int n_bord = 0; n_bord < domaine_VDF.nb_front_Cl(); n_bord++)
290 {
291
292 // pour chaque Condition Limite on regarde son type
293
294 const Cond_lim& la_cl = domaine_Cl_VDF.les_conditions_limites(n_bord);
295 if (sub_type(Dirichlet_entree_fluide, la_cl.valeur()))
296 {
297 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
298 ndeb0 = le_bord.num_premiere_face();
299 nfin0 = ndeb0 + le_bord.nb_faces();
300 for (num_face = ndeb0; num_face < nfin0; num_face++)
301 if ((n0 = face_voisins(num_face, 0)) != -1)
302 {
303 elem = domaine_VDF.elem_voisin(n0, num_face, 0);
304 F2_[n0] = F2_[elem];
305 }
306 else
307 {
308 n1 = face_voisins(num_face, 1);
309 elem = domaine_VDF.elem_voisin(n1, num_face, 1);
310 F2_[n1] = F2_[elem];
311 }
312 }
313 else if (sub_type(Neumann_sortie_libre, la_cl.valeur()))
314 {
315 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
316 ndeb0 = le_bord.num_premiere_face();
317 nfin0 = ndeb0 + le_bord.nb_faces();
318 for (num_face = ndeb0; num_face < nfin0; num_face++)
319 if ((n0 = face_voisins(num_face, 0)) != -1)
320 {
321 elem = domaine_VDF.elem_voisin(n0, num_face, 0);
322 F2_[n0] = F2_[elem];
323 }
324 else
325 {
326 n1 = face_voisins(num_face, 1);
327 elem = domaine_VDF.elem_voisin(n1, num_face, 1);
328 F2_[n1] = F2_[elem];
329 }
330 }
331 else if (sub_type(Symetrie, la_cl.valeur()))
332 {
333 /* Do nothing */
334 }
335 else
336 {
337 const Front_VF& le_bord = ref_cast(Front_VF, la_cl->frontiere_dis());
338 ndeb0 = le_bord.num_premiere_face();
339 nfin0 = ndeb0 + le_bord.nb_faces();
340 for (num_face = ndeb0; num_face < nfin0; num_face++)
341 if ((n0 = face_voisins(num_face, 0)) != -1)
342 F2_[n0] = 0;
343 else
344 {
345 n1 = face_voisins(num_face, 1);
346 F2_[n1] = 0;
347 }
348 }
349 }
350 }
351 else
352 {
353 Cerr << "Le modele sous maille fonction de structure" << finl;
354 Cerr << "est utilisable uniquement en dimension 3" << finl;
356 }
357}
class Champ_Fonc_base Base class of fields that are functions of a calculated quantity
class Cond_lim_base Base class for the hierarchy of classes that represent the different boundary con...
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
static void verifier(const char *const msg, double)
Definition Debog.cpp:21
Dirichlet_entree_fluide This class represents a boundary condition imposing a quantity.
int_t nb_elem_tot() const
Definition Domaine.h:132
int_t nb_elem() const
Definition Domaine.h:131
class Domaine_Cl_VDF
int type_arete_bord(int num_arete) const
int nb_cond_lim() const
Returns the number of boundary conditions.
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
class Domaine_VDF
Definition Domaine_VDF.h:61
int orientation(int) const override
inline DoubleVect& Domaine_VDF::porosite_face() {
int premiere_arete_bord() const
int nb_aretes_internes() const
int premiere_arete_interne() const
int nb_aretes_bord() const
int nb_aretes_mixtes() const
double dist_face_axi(int, int, int k) const
Returns the distance between two face centers in direction k (cylindrical coordinates).
int premiere_arete_mixte() const
int Qdm(int num_arete, int) const
int elem_voisin(int, int, int) const
int elem_faces(int i, int j) const
Returns the index of the i-th face of element num_elem; the face numbering convention is.
Definition Domaine_VF.h:542
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
int nb_front_Cl() const
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
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 Modele_turbulence_hyd_LES_VDF Cette classe correspond a la mise en oeuvre du modele sous
classe Modele_turbulence_hyd_LES_axi_VDF Cette classe correspond a la mise en oeuvre du modele sous
Neumann_sortie_libre This class represents an open boundary without imposed velocity.
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 const Nom & le_nom() const
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
Definition Objet_U.cpp:317
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
class Periodique This class represents a periodic boundary condition.
Definition Periodique.h:31
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
Symetrie On symmetry faces, the following properties hold:
Definition Symetrie.h:37
_SIZE_ size() const
Definition TRUSTVect.tpp:45