TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Modele_turbulence_hyd_LES_Fst_sel_VEF.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_Fst_sel_VEF.h>
18#include <VEF_discretisation.h>
19#include <Domaine_VEF.h>
20#include <Champ_P1NC.h>
21#include <math.h>
22
23Implemente_instanciable_sans_constructeur(Modele_turbulence_hyd_LES_Fst_sel_VEF, "Modele_turbulence_hyd_sous_maille_fst_selectif_VEF", Modele_turbulence_hyd_LES_Fst_VEF);
24
26{
27 C1_ = 0.777 * 0.18247 * 0.18247 * 1.356; // C_Fst_sel=C_Fst*1.356 car modele selectif
28}
29
31{
32 return s << que_suis_je() << " " << le_nom();
33}
34
36{
38}
39
41{
42 if (dimension != 3)
43 {
44 Cerr << " The model sous_maille_fst_selectif has sense only for dimension 3." << finl;
46
47 }
49 const VEF_discretisation& dis = ref_cast(VEF_discretisation, mon_equation_->discretisation());
50 dis.vorticite(mon_equation_->domaine_dis(), mon_equation_->inconnue(), la_vorticite_);
51}
52
54 OBS_PTR(Champ_base) &ch_ref) const
55{
56 Motcles les_motcles(3);
57 {
58 les_motcles[0] = "viscosite_turbulente";
59 les_motcles[1] = "k";
60 les_motcles[2] = "vorticite";
61
62 }
63 int rang = les_motcles.search(mot);
64 switch(rang)
65 {
66 case 0:
67 {
68 ch_ref = la_viscosite_turbulente_.valeur();
69 return 1;
70 }
71 case 1:
72 {
73 ch_ref = energie_cinetique_turb_.valeur();
74 return 1;
75 }
76 case 2:
77 {
78 ch_ref = la_vorticite_.valeur();
79 return 1;
80 }
81 default:
82 return 0;
83 }
84}
85
87{
88 // Modele_turbulence_hyd_LES_VEF::calculer_fonction_structure(FS,delta_c);
90 cutoff();
91}
92
93// Fonction qui permet d'appliquer un filtre sur la fonction de structure
94// La fonction de structure d'un element est mise a zero si il existe une
95// deviation inferieure a N degres entre son vecteur vorticite et le
96// vecteur moyen des vorticites des 6 elements les plus proches
97// l angle de coupure varie en fonction du delta c (regression log)
98
100{
101 double Sin2Angl;
102 const Champ_P1NC& vitesse = ref_cast(Champ_P1NC, mon_equation_->inconnue());
103 const Domaine_VEF& domaine_VEF = ref_cast(Domaine_VEF, le_dom_VF_.valeur());
104 const int nb_elem = domaine_VEF.nb_elem();
105 const IntTab& elem_faces = domaine_VEF.elem_faces();
106 const IntTab& face_voisins = domaine_VEF.face_voisins();
107 // const Domaine& domaine = domaine_VEF.domaine();
108 // int nfac = domaine.nb_faces_elem();
109 // int nfac = 4; // en 3D 4 faces!!!
110 DoubleTab& vorticite = la_vorticite_->valeurs();
111 const DoubleTab& xp = domaine_VEF.xp();
112
113 la_vorticite_->mettre_a_jour(vitesse.temps());
114 vorticite.echange_espace_virtuel();
115
116 // int el0,el1,el2,el3;
117 double norme, norme_moyen, prod, angle, delta;
118 DoubleVect vorti_moyen(3);
119 IntVect elem_nn(4);
120 IntVect elem_autour(4);
121 DoubleVect dist(4);
122 int nb_elem_nn, compteur, elem;
123 double d;
124
125 for (int num_elem = 0; num_elem < nb_elem; num_elem++)
126 {
127 delta = l_[num_elem];
128 angle = 0.494 * pow(delta, 0.4075);
129 Sin2Angl = sin(angle);
130 Sin2Angl *= Sin2Angl;
131
132 elem_autour[0] = face_voisins(elem_faces(num_elem, 0), 0);
133 if (elem_autour[0] == num_elem)
134 elem_autour[0] = face_voisins(elem_faces(num_elem, 0), 1);
135 elem_autour[1] = face_voisins(elem_faces(num_elem, 1), 0);
136 if (elem_autour[1] == num_elem)
137 elem_autour[1] = face_voisins(elem_faces(num_elem, 1), 1);
138 elem_autour[2] = face_voisins(elem_faces(num_elem, 2), 0);
139 if (elem_autour[2] == num_elem)
140 elem_autour[2] = face_voisins(elem_faces(num_elem, 2), 1);
141 elem_autour[3] = face_voisins(elem_faces(num_elem, 3), 0);
142 if (elem_autour[3] == num_elem)
143 elem_autour[3] = face_voisins(elem_faces(num_elem, 3), 1);
144
145 // double d0,d1,d2,d3,d;
146 double x, y, z;
147 x = xp(num_elem, 0);
148 y = xp(num_elem, 1);
149 z = xp(num_elem, 2);
150
151 nb_elem_nn = -1;
152 elem_nn = 0;
153 compteur = 0;
154 d = 0.;
155
156 while (compteur < 4)
157 {
158 if (elem_autour[compteur] != -1)
159 {
160 nb_elem_nn++;
161 elem_nn[nb_elem_nn] = elem_autour[compteur];
162 }
163 compteur++;
164 }
165
166 for (elem = 0; elem < nb_elem_nn; elem++)
167 {
168 dist[elem] = (x - xp(elem_nn[elem], 0)) * (x - xp(elem_nn[elem], 0)) + (y - xp(elem_nn[elem], 1)) * (y - xp(elem_nn[elem], 1)) + (z - xp(elem_nn[elem], 2)) * (z - xp(elem_nn[elem], 2));
169 dist[elem] = 1. / dist[elem];
170 d += dist[elem];
171 }
172
173 vorti_moyen = 0.;
174 for (elem = 0; elem < nb_elem_nn; elem++)
175 {
176 for (int k = 0; k < 3; k++)
177 vorti_moyen(k) += dist[elem] * vorticite(elem_nn[elem], k) / d;
178 }
179
180 // On rend nul le vecteur vorti_moyen(k) ce qui provoquera la mise a zero de FS
181 if (nb_elem_nn == -1) // Cas d'un element coin ; on met FS a zero
182 {
183 for (int k = 0; k < 3; k++)
184 vorti_moyen(k) = 0;
185 }
186
187 // Calcul du produit vectoriel entre la vorticite dans l'element
188 // et le vecteur des vorticites des elements voisins
189
190 norme = 0;
191 int k;
192 for (k = 0; k < 3; k++)
193 norme += carre(vorticite(num_elem, k));
194
195 norme_moyen = 0;
196 for (k = 0; k < 3; k++)
197 norme_moyen += carre(vorti_moyen(k));
198
199 if ((norme > 1.e-10) && (norme_moyen > 1.e-10))
200 {
201 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))
202 + carre(vorti_moyen(0) * vorticite(num_elem, 1) - vorti_moyen(1) * vorticite(num_elem, 0));
203 prod /= (norme * norme_moyen);
204
205 if (prod <= Sin2Angl)
206 Racine_(num_elem) = 0;
207 }
208 else
209 // bruit numerique ou element de coin
210 Racine_(num_elem) = 0;
211 Racine_.echange_espace_virtuel();
212
213 }
214}
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.
class Domaine_VEF
Definition Domaine_VEF.h:53
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
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_Fst_VEF Cette classe correspond a la mise en oeuvre du modele sous
classe Modele_turbulence_hyd_LES_Fst_sel_VEF Cette classe correspond a la mise en oeuvre du modele so...
void discretiser() override
Discretizes the turbulence model.
int a_pour_Champ_Fonc(const Motcle &, OBS_PTR(Champ_base)&) const
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
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
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