TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Paroi_TBLE_QDM_Scal.cpp
1/****************************************************************************
2* Copyright (c) 2015 - 2016, 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#include <Paroi_TBLE_QDM_Scal.h>
16#include <Paroi_TBLE_QDM.h>
17#include <Domaine_dis_base.h>
18#include <EcrFicPartage.h>
19#include <Front_VF.h>
20#include <Domaine_VF.h>
21#include <EFichier.h>
22#include <Dirichlet_paroi_fixe.h>
23#include <Probleme_base.h>
24#include <Diffu_totale_hyd_base.h>
25#include <Diffu_totale_scal_base.h>
26#include <Domaine_Cl_dis_base.h>
27#include <Cond_lim.h>
28
30{
31 Motcles les_mots(10);
32 {
33 les_mots[0]="N";
34 les_mots[1]="modele_visco";
35 les_mots[2]="facteur";
36 les_mots[3]="stats";
37 les_mots[4]="epsilon";
38 les_mots[5]="max_it";
39 les_mots[6]="sonde_tble";
40 les_mots[7]="restart";
41 les_mots[8]="stationnaire";
42 les_mots[9]="Prandtl";
43 }
44 int rang=les_mots.search(mot_lu);
45 switch(rang)
46 {
47 case 0 :
48 is >> nb_pts;
49 Cerr << "N = " << nb_pts << finl;
50 break;
51 case 1 :
52 is >> modele_visco;
53 Cerr << "Le modele de viscosite turbulente dans le maillge fin est "
54 << modele_visco << finl;
55 break;
56 case 2 :
57 is >> fac;
58 Cerr << "Raison geometrique du maillage fin : " << fac << finl;
59 break;
60 case 3 :
61 oui_stats=1;
62 is >> tps_deb_stats;
63 is >> tps_fin_stats;
64
65 Cerr << "tps_deb_stats = " << tps_deb_stats << finl;
66 Cerr << "tps_fin_stats = " << tps_fin_stats << finl;
67
68 if((tps_deb_stats!=-1) && tps_fin_stats!=-1)
69 Cerr << "Temps stats TBLE : OK" << finl;
70 else
71 Cerr << "WARNING !!!!! Temps stats TBLE INCORRECTS" << finl;
72 break;
73 case 4 :
74 is >> epsilon;
75 Cerr << "Seuil de convergence pour les equations de couche limites : " << epsilon << finl;
76 break;
77 case 5 :
78 is >> max_it;
79 Cerr << "Le maximum d'iterations pour la resolution des equations TBLE est de : " << max_it << finl;
80 break;
81 case 6 :
82 is >> nb_post_pts;
84 for(int i=0; i<nb_post_pts; i++)
85 {
86 nom_pts.dimensionner(nb_post_pts);
87 is >> nom_pts[i];
88 Cerr << "Nom"<<i<<"=" << nom_pts[i] <<finl;
89 for(int j=0; j<Objet_U::dimension ; j++)
90 {
91 is >> sonde_tble(i,j);
92 Cerr << "sonde_tble( "<< i << "," << j <<" ) =" << sonde_tble(i,j) << finl;
93 }
94 }
95 break;
96 case 7 :
97 restart = 1;
98 break;
99 case 8 :
100 statio = 1;
101 is >> max_it_statio >> eps_statio;
102 if (max_it_statio<0 || eps_statio<0)
103 {
104 Cerr << "Vous devez choisir le nombre maximum d'iterations pour attendre la convergence en temps de TBLE" << finl;
105 Cerr << "ainsi que la valeur du critere d'arret" << finl;
106 Cerr << "Syntaxe : statio max_it_statio eps_statio" << finl;
108 }
109 break;
110 case 9:
111 is >> Prandtl;
112 break;
113 default :
114 {
115 Cerr << mot_lu << " n'est pas un mot compris par Paroi_TBLE_scal" << finl;
116 Cerr << "Les mots compris sont : " << les_mots << finl;
118 }
119 }
120 return is;
121}
122
124{
125 nb_pts=-1; // nb de pts dans le maillage fin
126 modele_visco = "Diffu_scal_lm"; //modele de viscosite turbulente
127 nb_comp = 1; //nb de composantes dans le maillage fin
128 fac=1.; // facteur de raffinement du maillage fin
129 oui_stats=0; // stats (1=oui/0=non)
130 tps_deb_stats=-1; // debut calcul des moyennes stats dans le maillage fin
131 tps_fin_stats=-1; // fin des stats
132 epsilon = 1.e-5; // seuil de resolution dans le maillage fin
133 max_it = 1000; // max d'iterations dans le maillage fin
134 nb_post_pts = 0;
135 reprise_ok = 0; // par defaut, reprise des champs TBLE
136 restart = 0;
137
138 statio = 0;
139 max_it_statio = -1;
140 eps_statio = -1.;
141
142 is_init=0;
143
144 Prandtl=1.;
145}
146
148{
149 is_init=1;
150 int compteur_faces_paroi = 0;
153 for (int n_bord=0; n_bord<domaine_dis.nb_front_Cl(); n_bord++)
154 {
155 const Cond_lim& la_cl = le_dom_Cl.les_conditions_limites(n_bord);
156 if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()) )
157 {
158 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
159 compteur_faces_paroi += le_bord.nb_faces();
160 }
161 }
162 eq_temp.dimensionner(compteur_faces_paroi); //Dimensionnement du vecteur eq_couch_lim
163
164 for(int j=0; j<nb_post_pts; j++)
165 {
166 double d0=1.e9;
167 int face=-1,face2=-1;
168 int i_bord=-1;
169 int ind_face2=-1;
170 compteur_faces_paroi=0;
171 for (int n_bord=0; n_bord<domaine_dis.nb_front_Cl(); n_bord++)
172 {
173 const Cond_lim& la_cl = le_dom_Cl.les_conditions_limites(n_bord);
174
175 if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()) )
176 {
177 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
178 int size=le_bord.nb_faces();
179 for (int ind_face=0; ind_face<size; ind_face++)
180 {
181 int num_face = le_bord.num_face(ind_face);
182 double d1=0.;
183 for (int d=0; d<Objet_U::dimension; d++)
184 {
185 double x=domaine_dis.xv(num_face,d)-sonde_tble(j,d);
186 d1+=x*x;
187 }
188
189 if (d1<d0)
190 {
191 d0=d1;
192 face=compteur_faces_paroi;
193 ind_face2=ind_face;
194 i_bord=n_bord;
195 face2=le_bord.num_face(ind_face2);
196 }
197 compteur_faces_paroi++;
198 }
199 }
200 }
201 num_faces_post(j)=face;
202 num_global_faces_post(j,0)=i_bord;
203 num_global_faces_post(j,1)=ind_face2;
204 num_global_faces_post(j,2)=face2;
205 }
206
207
209 Tmean_sum.resize(nb_post_pts,nb_pts+1);
210 UTmean_sum.resize(nb_post_pts,nb_pts+1);
211 VTmean_sum.resize(nb_post_pts,nb_pts+1);
212 WTmean_sum.resize(nb_post_pts,nb_pts+1);
214
215 // associer les "MuLambda_TBLE" au diffu_scal
216 for (int i=0; i<compteur_faces_paroi; i++)
217 {
218 eq_temp[i].associer_milieu(getPbBase().milieu());
219 eq_temp[i].set_diffu(modele_visco); //modele de viscosite turbulente
220 Diffu_totale_scal_base& diffu_scal = ref_cast_non_const(Diffu_totale_scal_base, eq_temp[i].get_diffu()); //modele de viscosite turbulente
221 Diffu_totale_hyd_base& diffu_hyd = ref_cast_non_const(Diffu_totale_hyd_base, get_eq_couch_lim(i).get_diffu()); //modele de viscosite turbulente
222 diffu_scal.set_visco_tot(diffu_hyd);
223 diffu_scal.associer_mulambda(getMuLambda());
224 // on a de la temperature : on complete les Diffu_hyd
225 diffu_hyd.associer_eqn_T(eq_temp[i]);
226 diffu_scal.setPrandtl(Prandtl);
227 }
228
229 return 1;
230}
231
232
233int Paroi_TBLE_QDM_Scal::reprendre(Entree&, const Domaine_dis_base& domaine_dis, const Domaine_Cl_dis_base& le_dom_Cl, double tps_reprise)
234{
235 if (restart == 0) // Si on ne souhaite pas repartir de zero
236 {
237 Cerr << "Reprise du champ TBLE T au temps = " << tps_reprise<< finl;
238 int compteur_faces_paroi = 0; //Reinitialisation de compteur_faces_paroi
239 const int ME=Process::me();
240 Nom nom_fic="sauvegarde_tble_scal_";
241 nom_fic+=Nom(ME);
242 nom_fic+=Nom("_");
243 nom_fic+=Nom(tps_reprise,getPbBase().reprise_format_temps());
244 EFichier fic_sauve(nom_fic);
245
246 if (fic_sauve.fail())
247 {
248 Cerr << "Erreur a l'ouverture du fichier " << nom_fic << finl;
249 Cerr << "Si vous ne souhaitez pas reprendre les quantites TBLE, utilisez le mot-cle 'restart' dans les options TBLE" << finl;
251 }
252
253
254 // On compte avant pour dimensionner
255 for (int n_bord=0; n_bord<domaine_dis.nb_front_Cl(); n_bord++)
256 {
257 const Cond_lim& la_cl = le_dom_Cl.les_conditions_limites(n_bord);
258
259 if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()) )
260
261 {
262 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
263 compteur_faces_paroi+=le_bord.nb_faces();
264 }
265 }
266
267
268 valeurs_reprises.resize(compteur_faces_paroi, nb_pts+1);
269 compteur_faces_paroi=0;
270 assert(nb_comp==1);
271 for (int n_bord=0; n_bord<domaine_dis.nb_front_Cl(); n_bord++)
272 {
273 const Cond_lim& la_cl = le_dom_Cl.les_conditions_limites(n_bord);
274 if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()) )
275 {
276 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
277 int ndeb = le_bord.num_premiere_face();
278 int nfin = ndeb + le_bord.nb_faces();
279 for (int num_face=ndeb; num_face<nfin; num_face++)
280 {
281 for (int comp=0; comp<nb_comp; comp++) // en principe nb_comp=1 !!!
282 {
283 for (int itble=0; itble<nb_pts+1; itble++)
284 {
285 fic_sauve >> valeurs_reprises(compteur_faces_paroi,itble);
286 }
287 }
288 compteur_faces_paroi++;
289 }
290 }
291 }
292 fic_sauve.close();
293 Cerr << "Reprise du champ TBLE T OK" << finl;
294 reprise_ok=1;
295 }
296 return 1;
297}
298
299
300
301
302int Paroi_TBLE_QDM_Scal::sauvegarder(Sortie&, const Domaine_dis_base& domaine_dis, const Domaine_Cl_dis_base& le_dom_Cl,double tps) const
303{
304 Cerr << "Sauvegarde du champ TBLE T au temps = " << tps << finl;
305 const int ME=Process::me();
306 Nom nom_fic="sauvegarde_tble_scal_";
307 nom_fic+=Nom(ME);
308 nom_fic+=Nom("_");
309 nom_fic+=Nom(tps,"%e");
310
311 EcrFicPartage fic_sauve(nom_fic);
312 int compteur_faces_paroi=0;
313 for (int n_bord=0; n_bord<domaine_dis.nb_front_Cl(); n_bord++)
314 {
315 const Cond_lim& la_cl = le_dom_Cl.les_conditions_limites(n_bord);
316 if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()) )
317 {
318 const Front_VF& le_bord = ref_cast(Front_VF,la_cl->frontiere_dis());
319 int ndeb = le_bord.num_premiere_face();
320 int nfin = ndeb + le_bord.nb_faces();
321 for (int num_face=ndeb; num_face<nfin; num_face++)
322 {
323 for (int comp=0; comp<nb_comp; comp++)
324 {
325 for (int itble=0; itble<nb_pts+1; itble++)
326 fic_sauve << eq_temp[compteur_faces_paroi].get_Unp1(comp,itble) << " " ;
327 }
328 fic_sauve << finl;
329 compteur_faces_paroi++;
330 }
331 }
332 }
333 fic_sauve.syncfile();
334 fic_sauve.close();
335 return 0;
336}
337
338
340{
341 if (oui_stats==1)
342 {
343 for(int j=0; j<nb_post_pts; j++)
344 {
345 double coeff = 1./(tps-tps_deb_stats);
346 Nom tmp;
347 tmp="tble_T_stats_";
348 tmp+=nom_pts[j];
349 tmp+=".dat";
350
351 EcrFicPartage fic_post(tmp, ios::app);
352 if (Objet_U::dimension==2)
353 {
354 fic_post << "# "<< tps << " T T^2 UT VT "<< finl;
355 for(int i=0; i<nb_pts+1; i++)
356 fic_post << coeff*Tmean_sum(j,i) << " " << coeff*Tmean_2_sum(j,i) << finl;
357 }
358 else if (Objet_U::dimension==3)
359 {
360 fic_post << "# "<< tps << " T T^2 UT VT WT "<< finl;
361 for(int i=0; i<nb_pts+1; i++)
362 {
363 fic_post << coeff*Tmean_sum(j,i) << " " << coeff*Tmean_2_sum(j,i) << " " ;
364 fic_post << coeff*UTmean_sum(j,i) << " " << coeff*VTmean_sum(j,i)<< " " << coeff*WTmean_sum(j,i)<< finl;
365 }
366 }
367 fic_post.syncfile();
368 fic_post.close();
369 }
370 }
371}
372
373
374void Paroi_TBLE_QDM_Scal::imprimer_sondes(Sortie&, double tps, const VECT(DoubleVect)& distance_equivalente) const
375{
376 for(int j=0; j<nb_post_pts; j++)
377 {
378 Nom tmp;
379 tmp="T_tble_post_";
380 tmp+=nom_pts[j];
381 tmp+=".dat";
382
383 EcrFicPartage fic_T(tmp, ios::app);
384 fic_T << "# " << tps << " " << "deq= " << distance_equivalente[num_global_faces_post(j,0)](num_global_faces_post(j,1)) << finl;
385 for(int i=0 ; i<nb_pts+1 ; i++)
386 {
387 fic_T << eq_temp[num_faces_post(j)].get_y(i)<< " " << eq_temp[num_faces_post(j)].get_Unp1(0,i) << finl;
388 }
389 fic_T << finl;
390 fic_T.syncfile();
391 fic_T.close();
392 }
393}
394
395void Paroi_TBLE_QDM_Scal::imprimer_sondes(Sortie&, double tps, const DoubleVect& tab_d_equiv_) const
396{
397 for(int j=0; j<nb_post_pts; j++)
398 {
399 Nom tmp;
400 tmp="T_tble_post_";
401 tmp+=nom_pts[j];
402 tmp+=".dat";
403
404 EcrFicPartage fic_T(tmp, ios::app);
405 fic_T << "# " << tps << " " << "deq= " << tab_d_equiv_[num_global_faces_post(j,2)] << finl;
406 for(int i=0 ; i<nb_pts+1 ; i++)
407 {
408 fic_T << eq_temp[num_faces_post(j)].get_y(i)<< " " << eq_temp[num_faces_post(j)].get_Unp1(0,i) << finl;
409 }
410 fic_T << finl;
411 fic_T.syncfile();
412 fic_T.close();
413 }
414}
415
416void Paroi_TBLE_QDM_Scal::calculer_stat(int j, int i, double u, double v, double w, double T, double dt)
417{
418 Tmean_sum(j,i) += T*dt;
419 UTmean_sum(j,i) += u*T*dt;
420 VTmean_sum(j,i) += v*T*dt;
421 WTmean_sum(j,i) += w*T*dt;
422 Tmean_2_sum(j,i) += T*T*dt;
423 Alpha_mean_sum(j,i) += eq_temp[num_faces_post(j)].get_nut(i)*dt;
424}
classe Cond_lim Classe generique servant a representer n'importe quelle classe
Definition Cond_lim.h:31
void associer_mulambda(const MuLambda_TBLE_base &m)
Classe Diffu_totale_hyd_base Classe abstraite calculant la diffusivite totale (somme diffusivite.
void associer_eqn_T(Eq_couch_lim &e)
Classe Diffu_totale_scal_base Classe abstraite calculant la diffusivite totale (somme diffusivite.
void set_visco_tot(Diffu_totale_base &a)
classe Dirichlet_paroi_fixe Represente une paroi immobile dans une equation de type Navier_Stokes.
classe Domaine_Cl_dis_base Les objets Domaine_Cl_dis_base representent les conditions aux limites
const Cond_lim & les_conditions_limites(int) const
Renvoie la i-ieme condition aux limites.
class Domaine_VF
Definition Domaine_VF.h:44
double xv(int num_face, int k) const
Definition Domaine_VF.h:76
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
int nb_front_Cl() const
Fichier en lecture Cette classe est a la classe C++ ifstream ce que la classe Entree est a la.
Definition EFichier.h:29
Sortie & syncfile() override
Provoque l'ecriture sur disque des donnees accumulees sur les differents processeurs depuis le dernie...
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
int num_face(const int) const
Definition Front_VF.h:68
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
Un tableau d'objets de la classe Motcle.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:321
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
static int dimension
Definition Objet_U.h:99
VECT(Eq_couch_lim) eq_temp
int reprendre(Entree &, const Domaine_dis_base &, const Domaine_Cl_dis_base &, double tps)
void imprimer_sondes(Sortie &, double, const VECT(DoubleVect)&) const
Entree & lire_donnees(const Motcle &motlu, Entree &s)
virtual const Probleme_base & getPbBase() const =0
virtual Eq_couch_lim & get_eq_couch_lim(int)=0
virtual MuLambda_TBLE_base & getMuLambda()=0
int sauvegarder(Sortie &, const Domaine_dis_base &, const Domaine_Cl_dis_base &, double tps) const
int init_lois_paroi(const Domaine_VF &, const Domaine_Cl_dis_base &)
void calculer_stat(int j, int i, double u, double v, double w, double T, double dt)
void imprimer_stat(Sortie &, double) const
static int me()
renvoie mon rang dans le groupe de communication courant.
Definition Process.cpp:125
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52