TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Modele_turbulence_hyd_LES_1elt_selectif_mod_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_1elt_selectif_mod_VEF.h>
18#include <VEF_discretisation.h>
19#include <Domaine_VEF.h>
20#include <Champ_P1NC.h>
21
22Implemente_instanciable_sans_constructeur(Modele_turbulence_hyd_LES_1elt_selectif_mod_VEF, "Modele_turbulence_hyd_sous_maille_1elt_selectif_mod_VEF", Modele_turbulence_hyd_LES_1elt_VEF);
23
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_1elt_selectif_mod has no sense if dimension is not 3." << finl;
46 }
48 const VEF_discretisation& dis = ref_cast(VEF_discretisation, mon_equation_->discretisation());
49 dis.vorticite(mon_equation_->domaine_dis(), mon_equation_->inconnue(), la_vorticite_);
50}
51
53 OBS_PTR(Champ_base) &ch_ref) const
54{
55 Motcles les_motcles(7);
56 {
57 les_motcles[0] = "viscosite_turbulente";
58 les_motcles[1] = "k";
59 les_motcles[2] = "vorticite";
60
61 }
62 int rang = les_motcles.search(mot);
63 switch(rang)
64 {
65 case 0:
66 {
67 ch_ref = la_viscosite_turbulente_.valeur();
68 return 1;
69 }
70 case 1:
71 {
72 ch_ref = energie_cinetique_turb_.valeur();
73 return 1;
74 }
75 case 2:
76 {
77 ch_ref = la_vorticite_.valeur();
78 return 1;
79 }
80 default:
81 return 0;
82 }
83}
84
90
91// Fonction qui permet d'appliquer un filtre sur la fonction de structure
92// La fonction de structure d'un element est mise a zero si il existe une
93// deviation inferieure a N degres entre son vecteur vorticite et le
94// vecteur moyen des vorticites des 6 elements les plus proches
95// l angle de coupure varie en fonction du delta c (regression log)
96
98{
99 double Sin2Angl;
100 const Champ_P1NC& vitesse = ref_cast(Champ_P1NC, mon_equation_->inconnue());
101 const Domaine_VEF& domaine_VEF = ref_cast(Domaine_VEF, le_dom_VF_.valeur());
102 const int nb_elem = domaine_VEF.nb_elem();
103 const IntTab& elem_faces = domaine_VEF.elem_faces();
104 const IntTab& face_voisins = domaine_VEF.face_voisins();
105 // const Domaine& domaine = domaine_VEF.domaine();
106 // int nfac = domaine.nb_faces_elem();
107 // int nfac = 4; // en 3D 4 faces!!!
108 DoubleTab& vorticite = la_vorticite_->valeurs();
109 const DoubleTab& xp = domaine_VEF.xp();
110
111 la_vorticite_->mettre_a_jour(vitesse.temps());
112 vorticite.echange_espace_virtuel();
113
114 // int el0,el1,el2,el3;
115 double norme, norme_moyen, prod, angle; //,delta;
116 DoubleVect vorti_moyen(3);
117 IntVect elem_nn(4);
118 IntVect elem_autour(4);
119 DoubleVect dist(4);
120 int nb_elem_nn, compteur, elem, k, num_elem;
121 double d;
122
123 //////**************************************
124 // Nouveau modele selectif modifie *********
125 //////**************************************
126
127 // Pour l'instant, on met k_I en dur !!
128 // k_I(0)=5 --> k_I = 3
129 static double ki = 2.5;
130 double kc, rapport;
131
132 for (num_elem = 0; num_elem < nb_elem; num_elem++)
133 {
134 // Calcul de k_c=(\pi)/(l[elem])
135 kc = M_PI / l_[num_elem];
136 rapport = kc / ki;
137 calculer_angle_limite(rapport, angle);
138
139 Sin2Angl = sin(angle);
140 Sin2Angl *= Sin2Angl;
141
142 elem_autour[0] = face_voisins(elem_faces(num_elem, 0), 0);
143 if (elem_autour[0] == num_elem)
144 elem_autour[0] = face_voisins(elem_faces(num_elem, 0), 1);
145 elem_autour[1] = face_voisins(elem_faces(num_elem, 1), 0);
146 if (elem_autour[1] == num_elem)
147 elem_autour[1] = face_voisins(elem_faces(num_elem, 1), 1);
148 elem_autour[2] = face_voisins(elem_faces(num_elem, 2), 0);
149 if (elem_autour[2] == num_elem)
150 elem_autour[2] = face_voisins(elem_faces(num_elem, 2), 1);
151 elem_autour[3] = face_voisins(elem_faces(num_elem, 3), 0);
152 if (elem_autour[3] == num_elem)
153 elem_autour[3] = face_voisins(elem_faces(num_elem, 3), 1);
154
155 // double d0,d1,d2,d3,d;
156 double x, y, z;
157 x = xp(num_elem, 0);
158 y = xp(num_elem, 1);
159 z = xp(num_elem, 2);
160
161 nb_elem_nn = 0;
162 elem_nn = 0;
163 compteur = 0;
164 d = 0.;
165
166 while (compteur < 4) // nb_elem_nn = nbr d elts autour non nuls!!!
167 {
168 if (elem_autour[compteur] != -1)
169 {
170 elem_nn[nb_elem_nn] = elem_autour[compteur];
171 nb_elem_nn++;
172 }
173 compteur++;
174 }
175
176 for (elem = 0; elem < nb_elem_nn; elem++)
177 {
178 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));
179 dist[elem] = 1. / sqrt(dist[elem]);
180 d += dist[elem];
181 }
182
183 vorti_moyen = 0.;
184 for (elem = 0; elem < nb_elem_nn; elem++)
185 {
186 for (k = 0; k < 3; k++)
187 vorti_moyen(k) += dist[elem] * vorticite(elem_nn[elem], k) / d;
188 }
189
190 if (nb_elem_nn == 0) // Cas d'un element coin ; on met F2 a zero
191 // On rend nul le vecteur vorti_moyen(k) ce qui provoquera la mise a zero de F2
192 {
193 for (k = 0; k < 3; k++)
194 vorti_moyen(k) = 0;
195 }
196
197 // Calcul du produit vectoriel entre la vorticite dans l'element
198 // et le vecteur des vorticites des elements voisins
199
200 norme = 0;
201 int kk;
202 for (kk = 0; kk < 3; kk++)
203 norme += carre(vorticite(num_elem, kk));
204
205 norme_moyen = 0;
206 for (kk = 0; kk < 3; kk++)
207 norme_moyen += carre(vorti_moyen(kk));
208
209 if ((norme > 1.e-10) && (norme_moyen > 1.e-10))
210 {
211 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))
212 + carre(vorti_moyen(0) * vorticite(num_elem, 1) - vorti_moyen(1) * vorticite(num_elem, 0));
213 prod /= (norme * norme_moyen);
214
215 if (prod <= Sin2Angl)
216 F2_(num_elem) = 0;
217 }
218 else
219 // bruit numerique ou element de coin
220 F2_(num_elem) = 0;
221
222 }
223 F2_.echange_espace_virtuel();
224}
225
227{
228 if (rapport < 10.)
229 angle = 23. * pow(rapport, -0.4);
230 else
231 angle = 9.;
232
233 angle *= M_PI / 180.;
234}
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_1elt_selectif_mod_VEF Cette classe correspond a la mise en oeuvre du...
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