TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Modele_turbulence_hyd_LES_selectif_mod_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_selectif_mod_VDF.h>
18#include <VDF_discretisation.h>
19#include <Champ_Face_VDF.h>
20#include <Domaine_VDF.h>
21#include <Equation_base.h>
22#include <TRUSTTrav.h>
23#include <Param.h>
24#include <math.h>
25
26#define K_DEF 0.415
27
28Implemente_instanciable_sans_constructeur(Modele_turbulence_hyd_LES_selectif_mod_VDF, "Modele_turbulence_hyd_sous_maille_selectif_mod_VDF", Modele_turbulence_hyd_LES_VDF);
29
31{
32 return s << que_suis_je() << " " << le_nom();
33}
34
36{
38}
39
41{
43 param.ajouter_non_std("Canal", (this));
44 param.ajouter_non_std("THI", (this));
45}
46
48{
49 if (mot == "Canal")
50 {
51 is >> demi_h_;
52 is >> dir_par_;
53 canal_ = 1;
54 Cerr << "The half height of the chanel is :" << demi_h_ << " m" << finl;
55 Cerr << "Orientation of the walls is : " << dir_par_ << finl;
56 return 1;
57 }
58 else if (mot == "THI")
59 {
60 is >> ki_;
61 is >> kc_;
62 thi_ = 1;
63 Cerr << "At initial time, the spectrum peak is located at : " << ki_ << " m-1" << finl;
64 Cerr << "The spectrum cut-off is located at : " << kc_ << " m-1" << finl;
65 return 1;
66 }
67 else
69}
70
71
73{
75 const VDF_discretisation& dis = ref_cast(VDF_discretisation, mon_equation_->discretisation());
76 dis.vorticite(mon_equation_->domaine_dis(), mon_equation_->inconnue(), la_vorticite_);
77}
78
80 OBS_PTR(Champ_base) &ch_ref) const
81{
82 Motcles les_motcles(7);
83 {
84 les_motcles[0] = "viscosite_turbulente";
85 les_motcles[1] = "k";
86 les_motcles[2] = "vorticite";
87
88 }
89 int rang = les_motcles.search(mot);
90 switch(rang)
91 {
92 case 0:
93 {
94 ch_ref = la_viscosite_turbulente_.valeur();
95 return 1;
96 }
97 case 1:
98 {
99 ch_ref = energie_cinetique_turb_.valeur();
100 return 1;
101 }
102 case 2:
103 {
104 ch_ref = la_vorticite_.valeur();
105 return 1;
106 }
107 default:
108 return 0;
109 }
110}
111
118
119// Fonction qui permet d'appliquer un filtre sur la fonction de structure
120// La fonction de structure d'un element est mise a zero si il existe une
121// deviation inferieure a N degres entre son vecteur vorticite et le
122// vecteur moyen des vorticites des 6 elements les plus proches
123// l angle de coupure varie en fonction du delta c (2 expressions possibles :
124// lineaire ou log)
125
127{
128 double Sin2Angl;
129 const Champ_Face_VDF& vitesse = ref_cast(Champ_Face_VDF, mon_equation_->inconnue());
130 const Domaine_VDF& domaine_VDF = ref_cast(Domaine_VDF, le_dom_VF_.valeur());
131 const IntTab& face_voisins = domaine_VDF.face_voisins();
132 const IntTab& elem_faces = domaine_VDF.elem_faces();
133 const DoubleTab& xp = domaine_VDF.xp();
134 int nb_poly = domaine_VDF.domaine().nb_elem();
135 DoubleTab& vorticite = la_vorticite_->valeurs();
136
137 la_vorticite_->mettre_a_jour(vitesse.temps());
138 vorticite.echange_espace_virtuel();
139
140 int elx0, elx1, ely0, ely1, elz0, elz1;
141 double norme, norme_moyen, prod, angle;
142 DoubleTrav vorti_moyen(3);
143 int i;
144 int num_elem;
145
146 double lm, rapport;
147 double dy, y_elem;
148 static double kappa = K_DEF;
149 static double a = 23. * M_PI / 180.;
150 static double b = -0.4;
151 static double borne_y;
152 if (canal_ != 0)
153 borne_y = 0.2 * demi_h_;
154
155 if ((thi_ == 0) && (canal_ == 0))
156 {
157 Cerr << "Problem with the input data of the sous_maille_selectif_mod model." << finl;
158 Cerr << "A necessary parameter : THI or Canal has not been specified." << finl;
160 }
161
162 if ((nb_points_ == 4) && (dir_par_ != dir3_))
163 {
164 Cerr << "WARNING!!! WARNING!!! Modele_turbulence_hyd_LES_selectif_mod_VDF" << finl;
165 Cerr << "A 4 points formulation is used." << finl;
166 Cerr << "Your planes are orthogonal to the direction : " << dir3_ << finl;
167 Cerr << "while the given direction for the walls is :" << dir_par_ << finl;
168 Cerr << "Check that you really wish these directions to be different ..." << finl;
169 Cerr << "WARNING!!! WARNING!!! dans Modele_turbulence_hyd_LES_selectif_mod_VDF" << finl;
170 }
171
172 for (num_elem = 0; num_elem < nb_poly; num_elem++)
173 {
174
175 if (thi_ != 0)
176 {
177 rapport = 2. * kc_ / ki_;
178 }
179 else
180 {
181 // y_elem : distance entre le centre de l element et la paroi!!
182 y_elem = xp(num_elem, dir_par_);
183 if (y_elem >= demi_h_)
184 y_elem = 2. * demi_h_ - y_elem;
185
186 // lm : longueur de melange dans le canal
187 if (y_elem < borne_y)
188 lm = kappa * y_elem;
189 else
190 lm = 0.2 * kappa * demi_h_;
191
192 // dy : pas de maillage local en y (largeur de filtre local)
193 dy = domaine_VDF.dim_elem(num_elem, dir_par_);
194
195 // rapport pour la dependance de l angle
196 rapport = lm / (2. * dy);
197 }
198
199 if (rapport <= 1.)
200 angle = a;
201 else if ((rapport >= 1.) && (rapport < 10.))
202 angle = a * pow(rapport, b);
203 else
204 angle = 9. * M_PI / 180.;
205
206 Sin2Angl = sin(angle);
207 Sin2Angl *= Sin2Angl;
208
209 elx0 = face_voisins(elem_faces(num_elem, 0), 0);
210 elx1 = face_voisins(elem_faces(num_elem, 3), 1);
211 ely0 = face_voisins(elem_faces(num_elem, 1), 0);
212 ely1 = face_voisins(elem_faces(num_elem, 4), 1);
213 elz0 = face_voisins(elem_faces(num_elem, 2), 0);
214 elz1 = face_voisins(elem_faces(num_elem, 5), 1);
215 //dist_elem_period(int n1, int n2, int k)
216 double dx0 = 0., dx1 = 0., dy0 = 0., dy1 = 0., dz0 = 0., dz1 = 0.;
217
218 for (i = 0; i < 3; i++)
219 {
220 if (elx0 != -1)
221 dx0 += domaine_VDF.dist_elem_period(num_elem, elx0, i) * domaine_VDF.dist_elem_period(num_elem, elx0, i);
222 if (elx1 != -1)
223 dx1 += domaine_VDF.dist_elem_period(num_elem, elx1, i) * domaine_VDF.dist_elem_period(num_elem, elx1, i);
224 if (ely0 != -1)
225 dy0 += domaine_VDF.dist_elem_period(num_elem, ely0, i) * domaine_VDF.dist_elem_period(num_elem, ely0, i);
226 if (ely1 != -1)
227 dy1 += domaine_VDF.dist_elem_period(num_elem, ely1, i) * domaine_VDF.dist_elem_period(num_elem, ely1, i);
228 if (elz0 != -1)
229 dz0 += domaine_VDF.dist_elem_period(num_elem, elz0, i) * domaine_VDF.dist_elem_period(num_elem, elz0, i);
230 if (elz1 != -1)
231 dz1 += domaine_VDF.dist_elem_period(num_elem, elz1, i) * domaine_VDF.dist_elem_period(num_elem, elz1, i);
232 }
233
234 if (std::fabs(dx0) > DMINFLOAT)
235 dx0 = 1. / sqrt(dx0);
236 if (std::fabs(dx1) > DMINFLOAT)
237 dx1 = 1. / sqrt(dx1);
238 if (std::fabs(dy0) > DMINFLOAT)
239 dy0 = 1. / sqrt(dy0);
240 if (std::fabs(dy1) > DMINFLOAT)
241 dy1 = 1. / sqrt(dy1);
242 if (std::fabs(dz0) > DMINFLOAT)
243 dz0 = 1. / sqrt(dz0);
244 if (std::fabs(dz1) > DMINFLOAT)
245 dz1 = 1. / sqrt(dz1);
246
247 if ((elx0 != -1) && (elx1 != -1) && (ely0 != -1) && (ely1 != -1) && (elz0 != -1) && (elz1 != -1))
248 // Cas d'un element interne
249 {
250 for (int k = 0; k < 3; k++)
251 vorti_moyen(k) = (dx0 * vorticite(elx0, k) + dx1 * vorticite(elx1, k) + dy0 * vorticite(ely0, k) + dy1 * vorticite(ely1, k) + dz0 * vorticite(elz0, k) + dz1 * vorticite(elz1, k))
252 / (dx0 + dx1 + dy0 + dy1 + dz0 + dz1);
253 }
254 else if ((elx0 != -1) && (elx1 != -1) && (ely0 != -1) && (ely1 != -1))
255 {
256 for (int k = 0; k < 3; k++)
257 vorti_moyen(k) = (dx0 * vorticite(elx0, k) + dx1 * vorticite(elx1, k) + dy0 * vorticite(ely0, k) + dy1 * vorticite(ely1, k)) / (dx0 + dx1 + dy0 + dy1);
258 }
259 else if ((elx0 != -1) && (elx1 != -1) && (elz0 != -1) && (elz1 != -1))
260 {
261 for (int k = 0; k < 3; k++)
262 vorti_moyen(k) = (dx0 * vorticite(elx0, k) + dx1 * vorticite(elx1, k) + dz0 * vorticite(elz0, k) + dz1 * vorticite(elz1, k)) / (dx0 + dx1 + dz0 + dz1);
263 }
264 else if ((ely0 != -1) && (ely1 != -1) && (elz0 != -1) && (elz1 != -1))
265 {
266 for (int k = 0; k < 3; k++)
267 vorti_moyen(k) = (dy0 * vorticite(ely0, k) + dy1 * vorticite(ely1, k) + dz0 * vorticite(elz0, k) + dz1 * vorticite(elz1, k)) / (dy0 + dy1 + dz0 + dz1);
268 }
269 else if ((elx0 != -1) && (elx1 != -1))
270 {
271 for (int k = 0; k < 3; k++)
272 vorti_moyen(k) = (dx0 * vorticite(elx0, k) + dx1 * vorticite(elx1, k)) / (dx0 + dx1);
273 }
274 else if ((ely0 != -1) && (ely1 != -1))
275 {
276 for (int k = 0; k < 3; k++)
277 vorti_moyen(k) = (dy0 * vorticite(ely0, k) + dy1 * vorticite(ely1, k)) / (dy0 + dy1);
278 }
279 else if ((elz0 != -1) && (elz1 != -1))
280 {
281 for (int k = 0; k < 3; k++)
282 vorti_moyen(k) = (dz0 * vorticite(elz0, k) + dz1 * vorticite(elz1, k)) / (dz0 + dz1);
283 }
284 else // Cas d'un element coin ; on met FS a zero
285 // On rend nul le vecteur vorti_moyen(k) ce qui provoquera la mise a zero de FS
286 {
287 for (int k = 0; k < 3; k++)
288 vorti_moyen(k) = 0;
289 }
290
291 // Calcul du produit vectoriel entre la vorticite dans l'element
292 // et le vecteur des vorticites des elements voisins
293
294 norme = 0;
295 int k;
296 for (k = 0; k < 3; k++)
297 norme += carre(vorticite(num_elem, k));
298
299 norme_moyen = 0;
300 for (k = 0; k < 3; k++)
301 norme_moyen += carre(vorti_moyen(k));
302
303 if ((norme > 1.e-10) && (norme_moyen > 1.e-10))
304 {
305 prod = carre(vorti_moyen(1) * vorticite(num_elem, 2) - vorti_moyen(2) * vorticite(num_elem, 1)) + carre(vorti_moyen(2) * vorticite(num_elem, 0) - vorti_moyen(0) * vorticite(num_elem, 2))
306 + carre(vorti_moyen(0) * vorticite(num_elem, 1) - vorti_moyen(1) * vorticite(num_elem, 0));
307 prod /= (norme * norme_moyen);
308
309 if (prod <= Sin2Angl)
310 F2_(num_elem) = 0;
311 }
312 else
313 // bruit numerique ou element de coin
314 F2_(num_elem) = 0;
315
316 }
317 F2_.echange_espace_virtuel();
318}
class Champ_Face_VDF
class Champ_base This class is the base of the fields hierarchy.
Definition Champ_base.h:43
double temps() const
Returns the time of the field.
int_t nb_elem() const
Definition Domaine.h:131
class Domaine_VDF
Definition Domaine_VDF.h:61
double dim_elem(int, int) const
double dist_elem_period(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
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
void discretiser() override
Discretizes the turbulence model.
classe Modele_turbulence_hyd_LES_VDF Cette classe correspond a la mise en oeuvre du modele sous
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
void set_param(Param &param) const override
classe Modele_turbulence_hyd_LES_selectif_VDF Cette classe correspond a la mise en oeuvre du modele s...
int a_pour_Champ_Fonc(const Motcle &, OBS_PTR(Champ_base)&) const
void discretiser() override
Discretizes the turbulence model.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
A character string (Nom) in uppercase.
Definition Motcle.h:26
An array of Motcle objects.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:319
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
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
Definition Param.cpp:489
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
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")
void vorticite(Domaine_dis_base &, const Champ_Inc_base &, OWN_PTR(Champ_Fonc_base)&) const