TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Terme_Source_Canal_RANS_LES_VDF_Elem.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#include <Terme_Source_Canal_RANS_LES_VDF_Elem.h>
17#include <Champ_Uniforme.h>
18#include <Domaine_VDF.h>
19#include <Domaine_Cl_VDF.h>
20#include <Pb_Hydraulique.h>
21#include <Pb_Thermohydraulique.h>
22#include <EFichier.h>
23#include <Interprete.h>
24#include <SFichier.h>
25
26Implemente_instanciable_sans_destructeur(Terme_Source_Canal_RANS_LES_VDF_Elem,"Canal_RANS_LES_VDF_P0_VDF",Source_base);
27
28
29
31{
32 //Le destructeur est appele a l'initialisation alors
33 //la sauvegarde du champ se fait hors initialisation
34
35 if(umoy.size()!=0)
36 {
37 SFichier vit_sauv ("Ttemp_sum.dat");
38 vit_sauv << utemp_sum;
39 SFichier vit_sauv2 ("Tmoy.dat");
40 vit_sauv2 << umoy;
41 }
42}
43
44//// printOn
45//
46
48{
49 return s << que_suis_je() ;
50}
51
52
53//// readOn
54//
55
57{
58 int compteur = 0;
59 Motcle mot_lu;
60 Motcle acc_ouverte("{");
61 Motcle acc_fermee("}");
62 nom_pb_rans="non_couple";
63
64 // 0 => moyenne spatiale
65 // 1 => moyenne temporelle glissante (moyenne en alpha)
66 // 2 => moyenne temporelle
67
68 Motcles les_mots(6);
69 {
70 les_mots[0]="alpha_tau"; //coeff de relaxation du terme source
71 les_mots[1]="Ly"; //Hauteur du canal plan (utile pour la moyenne spatiale)
72 les_mots[2]="f_start"; //temps a partir duquel le terme source est active
73 les_mots[3]="t_av"; //temps de prise de moyenne (moyenne temporelle glissante)
74 les_mots[4]="type_moyenne"; //
75 les_mots[5]="nom_pb_rans"; //
76 }
77 is >> mot_lu;
78 if(mot_lu != acc_ouverte)
79 {
80 Cerr << "On attendait { a la place de " << mot_lu
81 << " lors de la lecture des parametres de la loi de paroi " << finl;
82 }
83 is >> mot_lu;
84 while(mot_lu != acc_fermee)
85 {
86 int rang=les_mots.search(mot_lu);
87 switch(rang)
88 {
89 case 0 :
90 is >> alpha_tau;
91 Cerr << "alpha_tau = " << alpha_tau << finl;
92 compteur++;
93 break;
94 case 1 :
95 is >> Ly;
96 Cerr << "Ly = "<< Ly << finl;
97 compteur++;
98 break;
99 case 2 :
100 is >> f_start;
101 Cerr << "f_start = "<< f_start << finl;
102 compteur++;
103 break;
104 case 3 :
105 is >> t_av;
106 Cerr << "t_av = " << t_av << finl;
107 Cerr << "type_moyenne : " << moyenne << finl;
108 if((moyenne==1)&&(t_av<=0))
109 {
110 Cerr << "La periode en temps de la moyenne temporelle glissante est non precisee !"
111 << finl;
112 exit();
113 }
114 compteur++;
115 break;
116 case 4 :
117 is >> moyenne;
118 Cerr << "type_moyenne : " << moyenne << finl;
119 compteur++;
120 break;
121 case 5 :
122 is >> nom_pb_rans;
123
124 compteur++;
125 break;
126 default :
127 {
128 Cerr << mot_lu << " n'est pas un mot compris" << finl;
129 Cerr << "Les mots compris sont : " << les_mots << finl;
130 exit();
131 }
132 }
133 is >> mot_lu;
134 }
135 Cerr << "nom_pb_rans = " << nom_pb_rans << finl;
136 Cerr << compteur << " motcles ont ete lus dans le readOn du terme de forcage thermique" << finl;
137
138 init();
139
140 return is;
141
142}
143
145 const Domaine_Cl_dis_base& domaine_Cl_dis)
146{
147 le_dom_VDF = ref_cast(Domaine_VDF, domaine_dis);
148 le_dom_Cl_VDF = ref_cast(Domaine_Cl_VDF, domaine_Cl_dis);
149}
150
155
157{
158 const Domaine_dis_base& zdisbase=mon_equation->inconnue().domaine_dis_base();
159 const Domaine_VDF& domaine_VDF=ref_cast(Domaine_VDF, zdisbase);
160 const double tps = mon_equation->schema_temps().temps_courant();
161
162 int nb_elems = domaine_VDF.nb_elem();
163
164
165 tau.resize(nb_elems);
166 U_RANS.resize(nb_elems);
167 if(nom_pb_rans == "non_couple")
168 {
169 SFichier fic_verif("Tverif.RANS");
170 EFichier fic_vit("temperature_RANS.dat");
171
172 for(int num_elem=0 ; num_elem<nb_elems ; num_elem++)
173 {
174 int elem;
175 fic_vit >> elem ;
176 fic_vit >> U_RANS(elem) ;
177 fic_verif << elem << " " << U_RANS(elem) << finl;
178 }
179 }
180
181 for(int num_elem=0 ; num_elem<nb_elems ; num_elem++)
182 {
183 tau(num_elem) = alpha_tau;
184 }
185
186 utemp_gliss.resize(nb_elems);
187 utemp.resize(nb_elems);
188 utemp_sum.resize(nb_elems);
189
190 utemp_gliss = 0.;
191 utemp = 0.;
192 utemp_sum = 0.;
193
194 umoy.resize(nb_elems);
195
196 if (tps > f_start)
197 {
198 EFichier vit_umoy ("Ttemp_sum.dat");
199 EFichier vit_umoy2 ("Tmoy.dat");
200 SFichier vit_reprise ("TLES.reprise");
201 SFichier vit_reprise2 ("TLES2.reprise");
202
203 int trash;
204 vit_umoy >> trash;
205 Cerr << "trash = " << trash << finl;
206 vit_umoy2 >> trash;
207 Cerr << "trash = " << trash << finl;
208
209 for(int num_elem = 0 ; num_elem<nb_elems ; num_elem++)
210 {
211 vit_umoy >> utemp_sum(num_elem);
212 vit_umoy2 >> umoy(num_elem);
213
214 vit_reprise << num_elem << " " << utemp_sum(num_elem) << finl;
215 vit_reprise2 << num_elem << " " << umoy(num_elem) << finl;
216 }
217 }
218}//fin init
219
220
221///////////// Modif elem a partir d'ici///////////////
222
224{
225 //Cerr << "Je suis dans le mettre_a_jour" << finl;
226
227 const Domaine_VDF& domaine_VDF = le_dom_VDF.valeur();
228
229 //vitesse=temperature
230
231 const DoubleTab& vitesse = mon_equation->inconnue().valeurs();
232 const double dt = mon_equation->schema_temps().pas_de_temps();
233 const double tps = mon_equation->schema_temps().temps_courant();
234 int nb_elems = domaine_VDF.nb_elem();
235 const double dt_min = mon_equation->schema_temps().pas_temps_min();
236
237 int cptbis=0;
238
239 //****************************************************
240 //******* MaJ de la vitesse cible (RANS) ***********
241 //**************************************************
242 if(nom_pb_rans != "non_couple")
243 {
244 OBS_PTR(Probleme_base) pb_rans;
245 Objet_U& obj=Interprete::objet(nom_pb_rans);
246
247 if( sub_type(Probleme_base, obj) )
248 {
249 pb_rans = ref_cast(Probleme_base, obj);
250 }
251
252 U_RANS = pb_rans->equation(1).inconnue().valeurs();
253
254 }
255 //***************************************************
256
257 if(moyenne==2)
258 {
259 //******************************************************
260 //*************** MOYENNE TEMPORELLE *******************
261 //******************************************************
262
263 //Calcul d'une premiere moyenne temporelle significative
264
265 if((tps>(f_start-t_av))&&(tps<f_start))
266 {
267 if (cptbis==0)
268 {
269 for (int num_elem=0; num_elem<nb_elems; num_elem++)
270 {
271 utemp_sum(num_elem) = vitesse(num_elem)*(tps-(f_start-t_av));
272 umoy(num_elem) = vitesse(num_elem);
273 }
274 cptbis = 3;
275 }
276 else
277 {
278 for (int num_elem=0; num_elem<nb_elems; num_elem++)
279 {
280 utemp_sum(num_elem) += vitesse(num_elem)*dt;
281 umoy(num_elem) = utemp_gliss(num_elem)/(tps-(f_start-t_av));
282 }
283 }
284
285 }
286
287
288 if(tps>=f_start)
289 {
290 for (int num_elem=0; num_elem<nb_elems; num_elem++)
291 {
292 utemp_sum(num_elem) += dt*vitesse(num_elem);
293 umoy(num_elem)=utemp_sum(num_elem)/(tps-(f_start-t_av));
294 }
295 cptbis=4;
296 }
297
298
299 //***********************************************************
300 //*************** FIN MOYENNE TEMPORELLE ***************
301 //*******************************************************
302 }
303
304 else if(moyenne==3)
305 {
306 if (tps>0)
307 {
308 if (cptbis==0)
309 {
310 for (int num_elem=0; num_elem<nb_elems; num_elem++)
311 {
312 utemp_sum(num_elem) = vitesse(num_elem)*dt;
313 umoy(num_elem) = vitesse(num_elem);
314 }
315 cptbis ++;
316 }
317 else
318 {
319 for (int num_elem=0; num_elem<nb_elems; num_elem++)
320 {
321 utemp_sum(num_elem) += vitesse(num_elem)*dt;
322 umoy(num_elem) = utemp_sum(num_elem)/(tps-dt_min+dt);
323 }
324 }
325 }
326
327 }
328 else
329 {
330 Cerr << "moyenne = " << moyenne << finl;
331 Cerr << "Probleme pour le choix du type de moyenne" << finl;
332 }
333 compteur_reprise++;
334
335}//fin mettre_a_jour
336
337
338void Terme_Source_Canal_RANS_LES_VDF_Elem::ajouter_blocs(matrices_t matrices, DoubleTab& secmem, const tabs_t& semi_impl) const
339{
340 const Domaine_VDF& domaine_VDF = le_dom_VDF.valeur();
341 int nb_elems = domaine_VDF.nb_elem();
342 const DoubleVect& volume = domaine_VDF.volumes();
343 const double tps = mon_equation->schema_temps().temps_courant();
344 const double dt = mon_equation->schema_temps().pas_de_temps();
345 const double dt_min = mon_equation->schema_temps().pas_temps_min();
346
347 //vitesse=temperature
348 const DoubleTab& vitesse = mon_equation->inconnue().valeurs();
349
350 double vol=0.;
351 SFichier fic_f("f_temp.dat", ios::app);
352 SFichier fic_finst("f_temp_inst.dat", ios::app);
353
354 double mbf = 0.; //maximum body force
355 double mbf2 = 0.; //maximum body force
356
357 static int cpt2=0;
358
359 // Calcul de la norme des vitesses au centre des elements
360
361 if(((tps>f_start)&&(compteur_reprise > 1))||((moyenne==3)&&(tps>dt_min)))
362 {
363 for(int num_elem = 0 ; num_elem<nb_elems ; num_elem++)
364 {
365 vol = volume(num_elem);
366
367 secmem(num_elem) += ((U_RANS(num_elem)-umoy(num_elem))/(tau(num_elem)*dt))*vol;
368
369 mbf2 +=((U_RANS(num_elem)-umoy(num_elem))/(tau(num_elem)*dt))*vol;
370
371 cpt2++;
372 }
373
374 mbf2 = mbf2/cpt2;
375
376 int num_elem=12;
377
378 mbf = (U_RANS(num_elem)-umoy(num_elem))
379 /(tau(num_elem)*dt)*vol;
380
381 fic_finst << tps << " " << mbf << " " << U_RANS(num_elem)
382 << " " << umoy(num_elem) << " " << vitesse(num_elem) << finl;
383
384 fic_f << tps << " " << mbf2 << " "
385 << U_RANS(num_elem) << " " << umoy(num_elem) << " "
386 << utemp_sum(num_elem) << " " << dt <<finl;
387 }//fin if f_start
388
389}
390
391DoubleTab& Terme_Source_Canal_RANS_LES_VDF_Elem::calculer(DoubleTab& resu) const
392{
393 resu = 0;
394 return ajouter(resu);
395}
class Domaine_Cl_VDF
classe Domaine_Cl_dis_base Les objets Domaine_Cl_dis_base representent les conditions aux limites
class Domaine_VDF
Definition Domaine_VDF.h:64
double volumes(int i) const
Definition Domaine_VF.h:113
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
Fichier en lecture Cette classe est a la classe C++ ifstream ce que la classe Entree est a la.
Definition EFichier.h:29
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
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
Objet_U()
Constructeur par defaut : attribue un numero d'identifiant unique a l'objet (object_id_),...
Definition Objet_U.cpp:55
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.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Cette classe est a la classe C++ ofstream ce que la classe Sortie est a la classe C++ ostream Elle re...
Definition SFichier.h:27
Classe de base des flux de sortie.
Definition Sortie.h:52
classe Source_base Un objet Source_base est un terme apparaissant au second membre d'une
Definition Source_base.h:42
virtual DoubleTab & ajouter(DoubleTab &) const
class Terme_Source_Canal_RANS_LES_VDF_Elem Cette classe concerne un terme source calcule en partie gr...
OBS_PTR(Domaine_VDF) le_dom_VDF
void associer_domaines(const Domaine_dis_base &, const Domaine_Cl_dis_base &) override
void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl) const override
void mettre_a_jour(double) override
DOES NOTHING - to override in derived classes.