TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Traitement_particulier_NS_canal.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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 <Traitement_particulier_NS_canal.h>
17#include <LecFicDistribue.h>
18#include <EcrFicCollecte.h>
19#include <Navier_Stokes_std.h>
20#include <Modele_turbulence_hyd_base.h>
21#include <Probleme_base.h>
22#include <Discretisation_base.h>
23#include <Domaine_VF.h>
24#include <Domaine_Cl_dis_base.h>
25#include <Dirichlet_paroi_fixe.h>
26#include <Schema_Temps_base.h>
27#include <communications.h>
28#include <Fluide_base.h>
29#include <Champ_Uniforme.h>
30
31Implemente_base_sans_constructeur(Traitement_particulier_NS_canal,"Traitement_particulier_NS_canal",Traitement_particulier_NS_base);
32// XD canal traitement_particulier_base canal INHERITS_BRACE Keyword for statistics on a periodic plane channel.
33// XD attr dt_impr_moy_spat floattant dt_impr_moy_spat OPT Period to print the spatial average (default value is 1e6).
34// XD attr dt_impr_moy_temp floattant dt_impr_moy_temp OPT Period to print the temporal average (default value is 1e6).
35// XD attr debut_stat floattant debut_stat OPT Time to start the temporal averaging (default value is 1e6).
36// XD attr fin_stat floattant fin_stat OPT Time to end the temporal averaging (default value is 1e6).
37// XD attr pulsation_w floattant pulsation_w OPT Pulsation for phase averaging (in case of pulsating forcing term) (no
38// XD_CONT default value).
39// XD attr nb_points_par_phase entier nb_points_par_phase OPT Number of samples to represent phase average all along a
40// XD_CONT period (no default value).
41// XD attr reprise chaine reprise OPT val_moy_temp_xxxxxx.sauv : Keyword to resume a calculation with previous averaged
42// XD_CONT quantities. NL2 Note that for thermal and turbulent problems, averages on temperature and turbulent viscosity
43// XD_CONT are automatically calculated. To resume a calculation with phase averaging, val_moy_temp_xxxxxx.sauv_phase
44// XD_CONT file is required on the directory where the job is submitted (this last file will be then automatically
45// XD_CONT loaded by TRUST).
46
66
67
68/*! @brief Prints the object to an output stream.
69 *
70 * @param is an output stream
71 * @return the modified output stream
72 */
74{
75 return is;
76}
77
78
79/*! @brief Reads the object from an input stream.
80 *
81 * @param is an input stream
82 * @return the modified input stream
83 */
85{
86 return is;
87}
88
90{
91 if(!sub_type(Navier_Stokes_std,mon_equation.valeur()))
92 {
93 Cerr << " Traitement_particulier_canal has to be called from a Navier_Stokes problem " << finl;
94 exit();
95 }
96
97 Motcle accouverte = "{" , accfermee = "}" ;
98 Motcle motbidon, motlu;
99 is >> motbidon ;
100 if (motbidon == accouverte)
101 {
102 Motcles les_mots(7);
103 les_mots[0] = "dt_impr_moy_spat";
104 les_mots[1] = "dt_impr_moy_temp";
105 les_mots[2] = "debut_stat";
106 les_mots[3] = "fin_stat";
107 les_mots[4] = "reprise";
108 les_mots[5] = "pulsation_w";
109 les_mots[6] = "nb_points_par_phase";
110
111 is >> motlu;
112 while(motlu != accfermee)
113 {
114 int rang=les_mots.search(motlu);
115 switch(rang)
116 {
117 case 0 :
118 {
119 is >> dt_impr_moy_spat; // time interval for printing spatial averages
120 Cerr << "Spatial averages are printed for : dt_impr_moy_spat = " << dt_impr_moy_spat << finl;
121 break;
122 }
123 case 1 :
124 {
125 is >> dt_impr_moy_temp; // time interval for printing temporal averages
126 Cerr << "Temporal averages are printed for : dt_impr_moy_temp = " << dt_impr_moy_temp << finl;
127 break;
128 }
129 case 2 :
130 {
131 is >> temps_deb; // start time for temporal averages
132 Cerr << "Temporal averages start at : temps_deb = " << temps_deb << finl;
133 break;
134 }
135 case 3 :
136 {
137 is >> temps_fin; // end time for temporal averages
138 Cerr << "Temporal averages finish at : temps_fin = " << temps_fin << finl;
139 break;
140 }
141 case 4 :
142 {
143 oui_repr = 1;
144 is >> fich_repr ; // name of the stats restart file
145 Cerr << "The time statistics file is : " << fich_repr << finl;
146 break;
147 }
148 case 5 :
149 {
150 oui_pulse = 1;
151 is >> w ; // angular frequency
152 freq = w/(2.*3.141592653); // associated frequency
153 break;
154 }
155 case 6 :
156 {
157 oui_pulse = 1;
158 is >> Nphase ; // number of points to describe a phase
159 break;
160 }
161 default :
162 {
163 Cerr << motlu << " is not a keyword for Traitement_particulier_NS_canal " << finl;
164 Cerr << "Since the TRUST v1.5, the syntax of Canal option has changed." << finl;
165 Cerr << "Check the reference manual." << finl;
166 exit();
167 }
168 }
169 is >> motlu;
170 }
171 is >> motlu;
172 if (motlu != accfermee)
173 {
174 Cerr << "Error while reading in Traitement_particulier_NS_canal" << finl;;
175 Cerr << "We were expecting a }" << finl;
176 exit();
177 }
178 }
179 else
180 {
181 Cerr << "Error while reading in Traitement_particulier_NS_canal" << finl;
182 Cerr << "We were expecting a {" << finl;
183 exit();
184 }
185
186 return is;
187}
188
190{
191// overridden in VDF
192 Cerr << "Traitement_particulier_NS_canal::remplir_Tab_recap does not work for VEF" << finl;
193// Process::exit();
194}
195
197{
198 const RefObjU& modele_turbulence = mon_equation->get_modele(TURBULENCE);
199 if (modele_turbulence && sub_type(Modele_turbulence_hyd_base,modele_turbulence.valeur()))
200 {
201 oui_profil_nu_t = 1;
202 Nval=13;
203 }
204
205 if (mon_equation->probleme().nombre_d_equations()>1)
206 if (mon_equation->probleme().equation(1).has_champ("temperature"))
207 {
208 Temp = mon_equation->probleme().equation(1).get_champ("temperature");
209 oui_profil_Temp = 1 ;
210 Nval=18;
211 }
212
213 remplir_Y(Y,compt,Ny); // dispatched to Traitement_particulier_NS_canal_VDF or Traitement_particulier_NS_canal_VEF
216
217 int NN=Y_tot.size();
218 compt_tot.resize(NN);
219 val_moy_tot.resize(NN,Nval,1);
220
221 if (oui_repr!=1)
222 {
223 val_moy_temp.resize(Y_tot.size(),Nval,1);
224 val_moy_temp=0.;
225
226 if (oui_pulse==1)
227 {
228 val_moy_phase.resize(Y_tot.size(),Nval,Nphase);
229 val_moy_phase=0.;
230 Nb_ech_phase.resize(Nphase);
231 Nb_ech_phase=0;
232 }
233 }
234}
235
236void Traitement_particulier_NS_canal::remplir_reordonne_Y_tot(const DoubleVect& tab_Y, DoubleVect& tab_Y_tot) const
237{
238 DoubleVect Y_p(tab_Y);
239 int j_tot=1;
240
241 envoyer(Y_p, Process::me(), 0, Process::me());
242
243 if(je_suis_maitre())
244 {
245 tab_Y_tot.resize(1);
246 tab_Y_tot(0) = tab_Y(0);
247
248 for(int p=0; p<Process::nproc(); p++)
249 {
250 recevoir(Y_p,p,0,p);
251 for (int k=0; k<Y_p.size(); k++)
252 {
253 if(!est_egal(Y_p(k),-100.)) // check whether Y_p(k) is already present in Y_tot
254 {
255 int ok_new=1;
256
257 for (int j=0; j<tab_Y_tot.size(); j++)
258 if (est_egal(tab_Y_tot(j),Y_p(k)))
259 ok_new=0;
260
261 if(ok_new==1)
262 {
263 tab_Y_tot.resize(j_tot+1);
264 tab_Y_tot(j_tot) = Y_p(k);
265 j_tot++;
266 }
267 }
268 }
269 }
270
271 if(est_egal(tab_Y_tot(0),1.e12))
272 {
273 Cerr << "Problem while building Y_tot" << finl;
274 exit();
275 }
276
277 tab_Y_tot.ordonne_array();
278 // Send Y_tot to other processors
279 for(int p=1; p<Process::nproc(); p++)
280 envoyer(tab_Y_tot, 0, p, 0);
281 }
282 else
283 {
284 recevoir(tab_Y_tot,0,Process::me(),0);
285 }
286}
287
289{
290 if (je_suis_maitre())
291 {
292 Cerr << "Traitement_particulier_NS_canal::reprendre_stat!!" << flush << finl;
293
294 if (oui_repr==1)
295 {
297 Nval=val_moy_temp.dimension(1);
298 }
299
300 if (oui_repr==1 && oui_pulse==1)
301 {
302 Nom fich_repr_phase;
303 fich_repr_phase = fich_repr;
304 fich_repr_phase +="_phase";
305
306 reprendre_stat_canal(val_moy_phase,fich_repr_phase);
307 Nphase=val_moy_phase.dimension(2);
308 }
309 }
310}
311
313{
314 double tps,tps_deb_moy;
315 int NN,Nv,Np;
316 //Nom temps;
317
318 EFichier fic(fichier);
319 fic.setf(ios::scientific);
320
321 if(fic.fail())
322 {
323 Cerr << "Cannot open the file " << fichier << finl;
324 exit();
325 }
326
327 fic >> tps;
328 fic >> tps_deb_moy;
329 fic >> debut_phase;
330 fic >> ind_phase;
331 fic >> NN;
332 fic >> Nv;
333 fic >> Np;
334
335 val.resize(NN,Nv,Np);
336 Nb_ech_phase.resize(Np);
337
338 for (int k=0; k<Np; k++)
339 fic >> Nb_ech_phase(k);
340
341 for (int k=0; k<Np; k++)
342 for (int j=0; j<Nv; j++)
343 for (int i=0; i<NN; i++)
344 fic >> val(i,j,k);
345
346 if(!est_egal(tps_deb_moy,temps_deb,0.1))
347 {
348 Cerr << "ERROR : the start time of the stats in the data file differs greatly" << finl;
349 Cerr << "from the time defined in the restart file : " << fichier << finl;
350 exit();
351 }
352
353 temps_deb=tps_deb_moy;
354}
355
357{
358 double tps = mon_equation->inconnue().temps();
359
360 if (je_suis_maitre() && (tps>=temps_deb) && (tps<=temps_fin) )
361 {
362 Cerr << "Traitement_particulier_NS_canal::sauver_stat!!" << flush << finl;
363
364 Nom temps = Nom(tps);
365 Nom fich_sauv1 ="val_moy_temp_";
366 fich_sauv1+=temps;
367 fich_sauv1+=".sauv";
368 Nom fich_sauv2 = fich_sauv1;
369 fich_sauv2+="_phase";
370
372 if(oui_pulse==1) sauver_stat_canal(val_moy_phase,fich_sauv2);
373 }
374}
375
376void Traitement_particulier_NS_canal::sauver_stat_canal(const DoubleTab& val, const Nom& fichier) const
377{
378 double tps = mon_equation->inconnue().temps();
379 int NN,Nv,Np;
380 NN=val.dimension(0);
381 Nv=val.dimension(1);
382 Np=val.dimension(2);
383
384 SFichier fic(fichier);
385 fic.setf(ios::scientific);
386
387 fic << tps << finl;
388 fic << temps_deb << finl;
389 fic << debut_phase << finl;
390 fic << ind_phase << finl;
391 fic << NN << finl;
392 fic << Nv << finl;
393 fic << Np << finl;
394
395 for (int k=0; k<Np; k++)
396 fic <<Nb_ech_phase(k) << finl;
397
398 for (int k=0; k<Np; k++)
399 for (int j=0; j<Nv; j++)
400 for (int i=0; i<NN; i++)
401 fic << val(i,j,k) << finl;
402}
403
405{
406
407 // Spatial averaging
408 //////////////////////////////////////////////////////////
409
410 DoubleTrav val_moy(Ny,Nval);
411
412 val_moy=0.;
413
415
416 if (oui_profil_nu_t != 0)
418
419 if (oui_profil_Temp != 0)
421
422
423 // Data exchange between processors
424 //////////////////////////////////////////////////////////
425
426 DoubleVect Y_p(Y);
427 DoubleVect compt_p(compt);
428 DoubleTab val_moy_p(val_moy);
429
430 const int NN = Y_tot.size();
431
432 envoyer(Y_p,Process::me(),0,Process::me());
433 envoyer(compt_p,Process::me(),0,Process::me());
434 envoyer(val_moy_p,Process::me(),0,Process::me());
435
436 if(je_suis_maitre())
437 {
438 compt_tot=0;
439 val_moy_tot=0.;
440 int j;
441 for(int p=0; p<Process::nproc(); p++)
442 {
443 recevoir(Y_p,p,0,p);
444 recevoir(compt_p,p,0,p);
445 recevoir(val_moy_p,p,0,p);
446
447 int Y_p_size = Y_p.size();
448 for (int i=0; i<Y_p_size; i++)
449 {
450 for (j=0; j<NN; j++)
451 if(est_egal(Y_tot[j],Y_p[i])) break;
452
453 compt_tot(j) += compt_p(i);
454
455 for (int k=0; k<Nval; k++)
456 val_moy_tot(j,k,0) += val_moy_p(i,k);
457 }
458 }
459
460 for (int i=0; i<NN; i++)
461 for (int k=0; k<Nval; k++)
462 val_moy_tot(i,k,0) /= compt_tot[i];
463 }
464
465
466 // Computation and output of wall quantities
467 ///////////////////////////////////////////////////////////////////
468
470
471 // Temporal averaging
472 //////////////////////////////////////////////////////////////////
473
474 double tps = mon_equation->inconnue().temps();
475
476 if(je_suis_maitre())
477 {
478 if ((tps>=temps_deb)&&(tps<=temps_fin))
479 {
480 static int init_stat_temps = 0;
481
482 double dt_v = mon_equation->schema_temps().pas_de_temps();
483 int NN2 = Y_tot.size();
484
485 if(init_stat_temps==0 && oui_repr!=1) // otherwise, val_moy_temp values were read from reprendre_stat()
486 {
487 temps_deb = tps-dt_v;
488
489 val_moy_temp.resize(NN2,Nval,1);
490 val_moy_temp=0.;
491
492 init_stat_temps++;
493 }
494
495 for (int j=0; j<Nval; j++)
496 for (int i=0; i<NN2; i++)
497 {
498 if ((j!=3) && (j!=4) && (j!=5) && (j!=6) && (j!=7) && (j!=8) && (j!=14) && (j!=15) && (j!=16) && (j!=17))
499 val_moy_temp(i,j,0)+= dt_v*val_moy_tot(i,j,0);
500
501 if (j==3)
502 val_moy_temp(i,j,0)+= dt_v*(val_moy_tot(i,3,0)-val_moy_tot(i,0,0)*val_moy_tot(i,0,0));
503 if (j==4)
504 val_moy_temp(i,j,0)+= dt_v*(val_moy_tot(i,4,0)-val_moy_tot(i,1,0)*val_moy_tot(i,1,0));
505 if (j==5)
506 val_moy_temp(i,j,0)+= dt_v*(val_moy_tot(i,5,0)-val_moy_tot(i,2,0)*val_moy_tot(i,2,0));
507
508 if (j==6)
509 val_moy_temp(i,j,0)+= dt_v*(val_moy_tot(i,6,0)-val_moy_tot(i,0,0)*val_moy_tot(i,1,0));
510 if (j==7)
511 val_moy_temp(i,j,0)+= dt_v*(val_moy_tot(i,7,0)-val_moy_tot(i,0,0)*val_moy_tot(i,2,0));
512 if (j==8)
513 val_moy_temp(i,j,0)+= dt_v*(val_moy_tot(i,8,0)-val_moy_tot(i,1,0)*val_moy_tot(i,2,0));
514
515
516 if (j==14)
517 //val_moy_temp(i,j,0)+= dt_v*val_moy_tot(i,13,0)*val_moy_tot(i,13,0);
518 val_moy_temp(i,j,0)+= dt_v*(val_moy_tot(i,14,0)-val_moy_tot(i,13,0)*val_moy_tot(i,13,0));
519 if (j==15)
520 val_moy_temp(i,j,0)+= dt_v*(val_moy_tot(i,15,0)-val_moy_tot(i,0,0)*val_moy_tot(i,13,0));
521 if (j==16)
522 val_moy_temp(i,j,0)+= dt_v*(val_moy_tot(i,16,0)-val_moy_tot(i,1,0)*val_moy_tot(i,13,0));
523 if (j==17)
524 val_moy_temp(i,j,0)+= dt_v*(val_moy_tot(i,17,0)-val_moy_tot(i,2,0)*val_moy_tot(i,13,0));
525
526 }
527 }
528 }
529
530 // Phase averaging
531 //////////////////////////////////////////////////////////////////
532
533 if(je_suis_maitre() && oui_pulse==1)
534 {
535 if ((tps>=temps_deb)&&(tps<=temps_fin))
536 {
537 double dt_v = mon_equation->schema_temps().pas_de_temps();
538
539 if ( (cos(w*tps) > cos(w*(tps+dt_v))) && (cos(w*tps) > cos(w*(tps-dt_v))) ) // beginning of a period
540 {
541 debut_phase=tps;
542 ind_phase=1;
543 }
544
545 if(ind_phase==1)
546 {
547 for(int k=0; k<Nphase; k++)
548 {
549 double tps_k=debut_phase+k/(Nphase*freq);
550
551 if( (tps > tps_k-0.5*dt_v) && (tps < tps_k+0.5*dt_v) ) // find the corresponding k-phase
552 {
553 for (int j=0; j<Nval; j++)
554 for (int i=0; i<NN; i++)
555 val_moy_phase(i,j,k) += val_moy_tot(i,j,0);
556
557 Nb_ech_phase(k)++;
558
559 if(k==Nphase-1) ind_phase=2; // marker for writing phase averages (see below)
560 }
561 }
562 }
563 }
564 }
565
566 // Output of spatial and temporal averages
567 ///////////////////////////////////////////////////////////////
568
569 if(je_suis_maitre())
570 {
571 double stationnaire_atteint=mon_equation->schema_temps().stationnaire_atteint();
572 double tps_passe=mon_equation->schema_temps().temps_courant();
573 double nb_pas_dt_max=mon_equation->schema_temps().nb_pas_dt_max();
574 double nb_pas_dt=mon_equation->schema_temps().nb_pas_dt();
575 double temps_max=mon_equation->schema_temps().temps_max();
576 int impr_inst;
577 if (dt_impr_moy_spat<=(tps-tps_passe))
578 impr_inst=1;
579 else
580 {
581 // See Schema_Temps_base::limpr for information on epsilon and modf
582 double i, j, epsilon = 1.e-8;
583 modf(tps/dt_impr_moy_spat + epsilon, &i);
584 modf(tps_passe/dt_impr_moy_spat + epsilon, &j);
585 impr_inst=(i>j);
586 }
587 int impr_stat;
588 if (dt_impr_moy_temp<=(tps-tps_passe))
589 impr_stat=1;
590 else
591 {
592 // See Schema_Temps_base::limpr for information on epsilon and modf
593 double i, j, epsilon = 1.e-8;
594 modf(tps/dt_impr_moy_temp + epsilon, &i);
595 modf(tps_passe/dt_impr_moy_temp + epsilon, &j);
596 impr_stat=(i>j);
597 }
598
599 // periodic saving of spatial averages
600
601 if ((nb_pas_dt+1<=1) || impr_inst || (temps_max <= tps) || (nb_pas_dt_max <= nb_pas_dt+1) || stationnaire_atteint)
602 {
603 double dt = 1.;
604
605 Nom fichier1 = "Moyennes_spatiales_vitesse_rho_mu_";
606 Nom fichier2 = "Moyennes_spatiales_nut_";
607 Nom fichier3 = "Moyennes_spatiales_Temp_";
608 Nom temps = Nom(tps);
609
610 fichier1 += temps;
611 fichier2 += temps;
612 fichier3 += temps;
613
614 /*
615 ecriture_fichiers_moy_vitesse_rho_mu(val_moy_tot,fichier1,dt,0);
616 if (oui_profil_nu_t == 1) ecriture_fichiers_moy_nut(val_moy_tot,fichier2,dt,0);
617 if (oui_profil_Temp == 1) ecriture_fichiers_moy_Temp(val_moy_tot,fichier3,dt,0);
618 */
619
623 }
624
625 // periodic saving of temporal averages
626
627 if ((tps>temps_deb) && ((nb_pas_dt+1<=1) || impr_stat || (temps_max <= tps) || (nb_pas_dt_max <= nb_pas_dt+1) || stationnaire_atteint))
628 {
629 double dt = tps-temps_deb;
630
631 Nom fichier1 = "Moyennes_temporelles_vitesse_rho_mu_";
632 Nom fichier2 = "Moyennes_temporelles_nut_";
633 Nom fichier3 = "Moyennes__temporelles_Temp_";
634 Nom temps = Nom(tps);
635
636 fichier1 += temps;
637 fichier2 += temps;
638 fichier3 += temps;
639
643 }
644
645 // continuous saving of temporal averages
646
647 if (tps>temps_deb)
648 {
649 double dt = tps-temps_deb;
650
651 Nom fichier1 = "Moyennes_temporelles_vitesse_rho_mu";
652 Nom fichier2 = "Moyennes_temporelles_nut";
653 Nom fichier3 = "Moyennes__temporelles_Temp";
654
658 }
659
660 // continuous saving of phase averages (at end of cycle)
661
662 if ( (ind_phase==2) && (tps>temps_deb) )
663 {
664 ind_phase=0;
665
666 for(int k=0; k<Nphase; k++)
667 {
668 double dt = Nb_ech_phase(k);
669
670 Nom fichier1 = "Moyennes_de_phase_vitesse_rho_mu_";
671 Nom fichier2 = "Moyennes_de_phase_nut_";
672 Nom fichier3 = "Moyennes_de_phase_Temp_";
673 Nom phase = Nom(k);
674
675 fichier1 += phase;
676 fichier2 += phase;
677 fichier3 += phase;
678
679
683 }
684 }
685 }
686}
687
688
690{
691 // Mesh geometry
692 /////////////////////////////////////////////////////////
693 // !!!!! Assumptions: mesh symmetric about the half-height, extending from Y=0 to Y=H
694
695 Nom nom_discr=mon_equation->discretisation().que_suis_je();
696 // index of the first off-wall point
697 int kmin=(nom_discr=="VEFPreP1B" || nom_discr=="VEF") ? 1 : 0;
698 int kmax=Y_tot.size()-1-kmin; // index of the last off-wall point
699 double ymin=Y_tot(kmin); // position of the first point
700 double ymax=Y_tot(kmax); // position of the last point
701 double hs2=0.5*(ymin+ymax); // half-height
702
703 // check that the canal is in the good bounds
704 if ( ymin < 0. || ymax < 0.)
705 {
706 Cerr << "Error Traitement_particulier_NS_canal" << finl;
707 Cerr << "Invalid mesh: Y must be between 0 and H>0" << finl;
708 Cerr << "In addition, the mesh must be symmetric along the half-height." << finl;
709 exit() ;
710 }
711
712 // dynamic viscosity
713 double mu_bas = val_moy_tot(kmin,11,0);
714 double mu_haut = val_moy_tot(kmax,11,0);
715
716 // mass density
717 double rho_bas = val_moy_tot(kmin,10,0);
718 double rho_haut = val_moy_tot(kmax,10,0);
719
720 // wall shear stress
721 double tauwb, tauwh, tauwm;
722// int nbfaces_tot=0;
723
724 int nb_cl_diri=0;
725 double tauw_diri_m=0.;
726 double retau_diri_m=0.;
727 double utau_diri_m=0.;
728
729 int nb_cl_robin=0;
730 double tauw_robin_m=0.;
731 double retau_robin_m=0.;
732 double utau_robin_m=0.;
733
734 const RefObjU& modele_turbulence = mon_equation->get_modele(TURBULENCE);
735 const Equation_base& eqn = ref_cast(Equation_base,mon_equation.valeur()) ;
736 const Domaine_Cl_dis_base& domaine_Cl_dis_base = ref_cast(Domaine_Cl_dis_base,eqn.domaine_Cl_dis());
737 const Conds_lim& les_cl = domaine_Cl_dis_base.les_conditions_limites();
738 const Domaine_VF& domaine_VF = ref_cast(Domaine_VF,eqn.domaine_dis());
739 double tps = mon_equation->inconnue().temps();
740
741 double nb_pas_dt=mon_equation->schema_temps().nb_pas_dt();
742 int reprise = mon_equation->probleme().reprise_effectuee();
743 bool new_file = ( nb_pas_dt == 0 && reprise == 0 );
744 IOS_OPEN_MODE mode;
745 if (new_file == 0)
746 mode = (ios::out | ios::app);
747 else
748 mode = ios::out;
749
750 for (auto& itr : les_cl)
751 {
752 const Cond_lim& la_cl = itr;
753 if (la_cl->que_suis_je() == "Paroi_decalee_Robin")
754 nb_cl_robin+=1;
755 if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()))
756 nb_cl_diri+=1;
757 }
758
759 if (modele_turbulence && !ref_cast(Modele_turbulence_hyd_base,modele_turbulence.valeur()).loi_paroi().que_suis_je().debute_par("negligeable"))
760 {
761 // PQ : 13/07/05 : wall laws accounted for when computing u_tau
762 // Assumptions : 1st Dirichlet condition = lower wall
763 // 2nd Dirichlet condition = upper wall
764 // regular mesh in x
765 const Fluide_base& fluide = ref_cast(Fluide_base,mon_equation->probleme().equation(0).milieu());
766 const Turbulence_paroi_base& loipar = ref_cast(Modele_turbulence_hyd_base,modele_turbulence.valeur()).loi_paroi();
767 DoubleTab tau_tan;
768 tau_tan.ref(loipar.Cisaillement_paroi());
769
770// int num_cl_rep=0;
771// int nbfaces=0;
772 tauwb=0.;
773 tauwh=0.;
774
775// dirichlet
776 if ( nb_cl_diri != 0 )
777 {
778 DoubleVect tauw_diri(nb_cl_diri);
779 DoubleVect retau_diri(nb_cl_diri);
780 DoubleVect utau_diri(nb_cl_diri);
781// search of cl diri
782// nb cl diri
783 double tauw_diri_tmp=0.;
784 int numero_bord_diri=0;
785 int nbfaces_bord_diri=0;
786
787 double rho = 0.;
788 double mu = 0.;
789
790 if ( sub_type(Champ_Uniforme,fluide.masse_volumique()) )
791 {
792 rho = fluide.masse_volumique().valeurs()(0,0);
793 }
794 if ( sub_type(Champ_Uniforme,fluide.viscosite_dynamique()) )
795 {
796 mu = fluide.viscosite_dynamique().valeurs()(0,0);
797 }
798
799// for each cl, calculation of the mean tauw
800// loop on boundaries
801 for (auto& itr : les_cl)
802 {
803 tauw_diri_tmp=0.;
804 if ( !sub_type(Champ_Uniforme,fluide.masse_volumique()) )
805 rho = 0.;
806 if ( !sub_type(Champ_Uniforme,fluide.viscosite_dynamique()) )
807 mu = 0.;
808 const Cond_lim& la_cl = itr;
809 if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()))
810 {
811 const Front_VF& la_front_dis = ref_cast(Front_VF,la_cl->frontiere_dis());
812 nbfaces_bord_diri = la_front_dis.nb_faces();
813 int ndeb = la_front_dis.num_premiere_face();
814 int nfin = ndeb + nbfaces_bord_diri;
815 if (Objet_U::dimension == 2 )
816 {
817// loop on faces in 2D
818 for (int fac=ndeb; fac<nfin ; fac++)
819 {
820 tauw_diri_tmp += sqrt(tau_tan(fac,0)*tau_tan(fac,0));
821
822 int elem = domaine_VF.face_voisins(fac,0);
823 if (elem == -1)
824 elem = domaine_VF.face_voisins(fac,1);
825 if ( !sub_type(Champ_Uniforme,fluide.masse_volumique()) )
826 rho += fluide.masse_volumique().valeurs()[elem];
827 if ( !sub_type(Champ_Uniforme,fluide.viscosite_dynamique()) )
828 mu += fluide.viscosite_dynamique().valeurs()[elem];
829 }
830 }
831 else
832 {
833// loop on faces on 3D
834 for (int fac=ndeb; fac<nfin ; fac++)
835 {
836 tauw_diri_tmp += sqrt(tau_tan(fac,0)*tau_tan(fac,0)+tau_tan(fac,2)*tau_tan(fac,2));
837
838 int elem = domaine_VF.face_voisins(fac,0);
839 if (elem == -1)
840 elem = domaine_VF.face_voisins(fac,1);
841 if ( !sub_type(Champ_Uniforme,fluide.masse_volumique()) )
842 rho += fluide.masse_volumique().valeurs()[elem];
843 if ( !sub_type(Champ_Uniforme,fluide.viscosite_dynamique()) )
844 mu += fluide.viscosite_dynamique().valeurs()[elem];
845 }
846 }
847 double nb_fac_bord_diri_tot = mp_sum_as_double(nbfaces_bord_diri);
848 tauw_diri_tmp=mp_sum(tauw_diri_tmp)/nb_fac_bord_diri_tot;
849 if(!(mon_equation->probleme().is_dilatable()))
850 tauw_diri_tmp *= rho ;
851
852 if ( !sub_type(Champ_Uniforme,fluide.masse_volumique()) )
853 rho=mp_sum(rho)/nb_fac_bord_diri_tot;
854 if ( !sub_type(Champ_Uniforme,fluide.viscosite_dynamique()) )
855 mu=mp_sum(mu)/nb_fac_bord_diri_tot;
856
857 tauw_diri(numero_bord_diri) = tauw_diri_tmp;
858 utau_diri(numero_bord_diri) = sqrt(tauw_diri_tmp/rho);
859 retau_diri(numero_bord_diri)= rho*utau_diri(numero_bord_diri)*hs2/mu;
860
861 tauw_diri_m += tauw_diri(numero_bord_diri);
862 utau_diri_m += utau_diri(numero_bord_diri);
863 retau_diri_m += retau_diri(numero_bord_diri);
864
865 numero_bord_diri+=1;
866 }
867 } // loop on boundaries
868
869 tauw_diri_m =tauw_diri_m/nb_cl_diri;
870 retau_diri_m =retau_diri_m/nb_cl_diri;
871 utau_diri_m =utau_diri_m/nb_cl_diri;
872
873// prints
874 if (je_suis_maitre())
875 {
876 SFichier fic7("tauw.dat", mode);
877 SFichier fic8("reynolds_tau.dat", mode);
878 SFichier fic9("u_tau.dat", mode);
879 fic7 << tps << " " << tauw_diri_m << " ";
880 fic8 << tps << " " << retau_diri_m << " ";
881 fic9 << tps << " " << utau_diri_m << " ";
882 for ( int num=0 ; num<nb_cl_diri ; num++)
883 {
884 fic7 << tauw_diri(num) << " ";
885 fic8 << retau_diri(num) << " ";
886 fic9 << utau_diri(num) << " ";
887 }
888 fic7 << finl;
889 fic8 << finl;
890 fic9 << finl;
891 fic7.flush();
892 fic8.flush();
893 fic9.flush();
894 fic7.close();
895 fic8.close();
896 fic9.close();
897 }
898 } // end dirichlet
899
900// robin
901 if ( nb_cl_robin != 0 )
902 {
903 DoubleVect tauw_robin(nb_cl_robin);
904 DoubleVect retau_robin(nb_cl_robin);
905 DoubleVect utau_robin(nb_cl_robin);
906// search of cl robin
907// nb cl robin
908 double tauw_robin_tmp=0.;
909 int numero_bord_robin=0;
910 int nbfaces_bord_robin=0;
911 double rho = 0.;
912 double mu = 0.;
913
914 if ( sub_type(Champ_Uniforme,fluide.masse_volumique()) )
915 {
916 rho = fluide.masse_volumique().valeurs()(0,0);
917 }
918 if ( sub_type(Champ_Uniforme,fluide.viscosite_dynamique()) )
919 {
920 mu = fluide.viscosite_dynamique().valeurs()(0,0);
921 }
922
923// for each cl, calculation of the mean tauw
924// loop on boundaries
925 for (auto& itr : les_cl)
926 {
927 tauw_robin_tmp=0.;
928 if ( !sub_type(Champ_Uniforme,fluide.masse_volumique()) )
929 rho = 0.;
930 if ( !sub_type(Champ_Uniforme,fluide.viscosite_dynamique()) )
931 mu = 0.;
932 const Cond_lim& la_cl = itr;
933 if (la_cl->que_suis_je() == "Paroi_decalee_Robin")
934 {
935 const Front_VF& la_front_dis = ref_cast(Front_VF,la_cl->frontiere_dis());
936 nbfaces_bord_robin = la_front_dis.nb_faces();
937 int ndeb = la_front_dis.num_premiere_face();
938 int nfin = ndeb + nbfaces_bord_robin;
939 if (Objet_U::dimension == 2 )
940 {
941// loop on faces in 2D
942 for (int fac=ndeb; fac<nfin ; fac++)
943 {
944 tauw_robin_tmp+=sqrt(tau_tan(fac,0)*tau_tan(fac,0));
945
946 int elem = domaine_VF.face_voisins(fac,0);
947 if (elem == -1)
948 elem = domaine_VF.face_voisins(fac,1);
949 if ( !sub_type(Champ_Uniforme,fluide.masse_volumique()) )
950 rho+=fluide.masse_volumique().valeurs()[elem];
951 if ( !sub_type(Champ_Uniforme,fluide.viscosite_dynamique()) )
952 mu+=fluide.viscosite_dynamique().valeurs()[elem];
953 }
954 }
955 else
956 {
957// loop on faces on 3D
958 for (int fac=ndeb; fac<nfin ; fac++)
959 {
960 tauw_robin_tmp+=sqrt(tau_tan(fac,0)*tau_tan(fac,0)+tau_tan(fac,2)*tau_tan(fac,2));
961
962 int elem = domaine_VF.face_voisins(fac,0);
963 if (elem == -1)
964 elem = domaine_VF.face_voisins(fac,1);
965 if ( !sub_type(Champ_Uniforme,fluide.masse_volumique()) )
966 rho+=fluide.masse_volumique().valeurs()[elem];
967 if ( !sub_type(Champ_Uniforme,fluide.viscosite_dynamique()) )
968 mu+=fluide.viscosite_dynamique().valeurs()[elem];
969 }
970 }
971 double nb_fac_bord_rob_tot = mp_sum_as_double(nbfaces_bord_robin);
972 tauw_robin_tmp=mp_sum(tauw_robin_tmp)/nb_fac_bord_rob_tot;
973 if(!(mon_equation->probleme().is_dilatable()))
974 tauw_robin_tmp *= rho ;
975
976 if ( !sub_type(Champ_Uniforme,fluide.masse_volumique()) )
977 rho=mp_sum(rho)/nb_fac_bord_rob_tot;
978 if ( !sub_type(Champ_Uniforme,fluide.viscosite_dynamique()) )
979 mu=mp_sum(mu)/nb_fac_bord_rob_tot;
980
981 tauw_robin(numero_bord_robin) = tauw_robin_tmp;
982 utau_robin(numero_bord_robin) = sqrt(tauw_robin_tmp/rho);
983 retau_robin(numero_bord_robin)= rho*utau_robin(numero_bord_robin)*hs2/mu;
984
985 tauw_robin_m += tauw_robin(numero_bord_robin);
986 utau_robin_m += utau_robin(numero_bord_robin);
987 retau_robin_m += retau_robin(numero_bord_robin);
988
989 numero_bord_robin+=1;
990 }
991 } // loop on boundaries
992
993 tauw_robin_m = tauw_robin_m/nb_cl_robin;
994 retau_robin_m = retau_robin_m/nb_cl_robin;
995 utau_robin_m = utau_robin_m/nb_cl_robin;
996
997// prints
998 if (je_suis_maitre())
999 {
1000 SFichier fic4("tauw_robin.dat", mode);
1001 SFichier fic5("reynolds_tau_robin.dat", mode);
1002 SFichier fic6("u_tau_robin.dat", mode);
1003 fic4 << tps << " " << tauw_robin_m << " ";
1004 fic5 << tps << " " << retau_robin_m << " ";
1005 fic6 << tps << " " << utau_robin_m << " ";
1006 for ( int num=0 ; num<nb_cl_robin ; num++)
1007 {
1008 fic4 << tauw_robin(num) << " ";
1009 fic5 << retau_robin(num) << " ";
1010 fic6 << utau_robin(num) << " ";
1011 }
1012 fic4 << finl;
1013 fic5 << finl;
1014 fic6 << finl;
1015 fic4.flush();
1016 fic5.flush();
1017 fic6.flush();
1018 fic4.close();
1019 fic5.close();
1020 fic6.close();
1021 }
1022 } // end robin
1023
1024//// begin old
1025//// search of cl dirichlet
1026// for (int num_cl=0; num_cl<nb_cl; num_cl++)
1027// {
1028// //Loop on boundaries
1029// const Cond_lim& la_cl = les_cl[num_cl];
1030// if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()))
1031// {
1032// const Front_VF& la_front_dis = ref_cast(Front_VF,la_cl->frontiere_dis());
1033// nbfaces = la_front_dis.nb_faces();
1034// int ndeb = la_front_dis.num_premiere_face();
1035// int nfin = ndeb + nbfaces;
1036// if (Objet_U::dimension == 2 )
1037// for (int fac=ndeb; fac<nfin ; fac++)
1038// {
1039// tauwb+=sqrt(tau_tan(fac,0)*tau_tan(fac,0));
1040// }
1041// else
1042// for (int fac=ndeb; fac<nfin ; fac++)
1043// {
1044// tauwb+=sqrt(tau_tan(fac,0)*tau_tan(fac,0)+tau_tan(fac,2)*tau_tan(fac,2));
1045// }
1046// num_cl_rep=num_cl+1;
1047// break;
1048// }
1049// } //Loop on boundaries
1050// nbfaces_tot=mp_sum(nbfaces);
1051// if (nbfaces_tot)
1052// tauwb=mp_sum(tauwb)/nbfaces_tot;
1053//// on cherche la deuxieme cl dirichlet
1054// nbfaces=0;
1055// for (int num_cl=num_cl_rep; num_cl<nb_cl; num_cl++)
1056// {
1057// //Boucle sur les bords
1058// const Cond_lim& la_cl = les_cl[num_cl];
1059// if (sub_type(Dirichlet_paroi_fixe,la_cl.valeur()))
1060// {
1061// const Front_VF& la_front_dis = ref_cast(Front_VF,la_cl->frontiere_dis());
1062// nbfaces = la_front_dis.nb_faces();
1063// int ndeb = la_front_dis.num_premiere_face();
1064// int nfin = ndeb + nbfaces;
1065// if (Objet_U::dimension == 2 )
1066// for (int fac=ndeb; fac<nfin ; fac++)
1067// {
1068// tauwh+=sqrt(tau_tan(fac,0)*tau_tan(fac,0));
1069// }
1070// else
1071// for (int fac=ndeb; fac<nfin ; fac++)
1072// {
1073// tauwh+=sqrt(tau_tan(fac,0)*tau_tan(fac,0)+tau_tan(fac,2)*tau_tan(fac,2));
1074// }
1075// break;
1076// }
1077// } //Boucle sur les bords
1078// nbfaces_tot=mp_sum(nbfaces);
1079// if (nbfaces_tot)
1080// tauwh=mp_sum(tauwh)/nbfaces_tot;
1081// if(!(mon_equation->probleme().is_QC()))
1082// {
1083// tauwb*=rho_bas;
1084// tauwh*=rho_haut;
1085// }
1086// if (je_suis_maitre())
1087// {
1088// // compute and write the various wall quantities
1089// //////////////////////////////////////////////////////
1090// // vitesse de frottement
1091// double utaub=sqrt(tauwb/rho_bas);
1092// if(val_moy_tot(kmin,0,0)<=0) utaub*=-1.;
1093// double utauh=sqrt(tauwh/rho_haut);
1094// if(val_moy_tot(kmax,0,0)<=0) utauh*=-1.;
1095// double utaum=0.5*(utauh+utaub);
1096// // friction Reynolds number
1097// double retaub=rho_bas*utaub*hs2/mu_bas;
1098// double retauh=rho_haut*utauh*hs2/mu_haut;
1099// double retaum=0.5*(retauh+retaub);
1100// tauwm=0.5*(tauwh+tauwb);
1101// SFichier fic1("reynolds_tau_old.dat",ios::app);
1102// SFichier fic2("u_tau_old.dat",ios::app);
1103// SFichier fic3("tauw_old.dat",ios::app);
1104// fic1 << tps << " " << retaum << " " << retaub << " " << retauh << finl;
1105// fic2 << tps << " " << utaum << " " << utaub << " " << utauh << finl;
1106// fic3 << tps << " " << tauwm << " " << tauwb << " " << tauwh << finl;
1107// fic1.close();
1108// fic2.close();
1109// fic3.close();
1110// }
1111//// end old
1112
1113 } // end if turbul
1114 else
1115 {
1116 // norm of the wall-tangential velocity
1117 double utang_bas = val_moy_tot(kmin,9,0);
1118 double utang_haut = val_moy_tot(kmax,9,0);
1119 // computation of wall shear stress from the tangential velocity
1120 //////////////////////////////////////////////////////
1121 // linear approximation: Tau_w = mu * ||u_t||(y1) / dy1
1122 tauwb= mu_bas * utang_bas / ymin;
1123 tauwh= mu_haut* utang_haut / ymin;
1124
1125 if (je_suis_maitre())
1126 {
1127 // computation and output of the various wall quantities
1128 //////////////////////////////////////////////////////
1129 // friction velocity
1130 double utaub=sqrt(tauwb/rho_bas);
1131 if(val_moy_tot(kmin,0,0)<=0) utaub*=-1.;
1132 double utauh=sqrt(tauwh/rho_haut);
1133 if(val_moy_tot(kmax,0,0)<=0) utauh*=-1.;
1134 double utaum=0.5*(utauh+utaub);
1135
1136 // friction Reynolds number
1137 double retaub=rho_bas*utaub*hs2/mu_bas;
1138 double retauh=rho_haut*utauh*hs2/mu_haut;
1139 double retaum=0.5*(retauh+retaub);
1140 tauwm=0.5*(tauwh+tauwb);
1141
1142 SFichier fic1("reynolds_tau.dat", mode);
1143 SFichier fic2("u_tau.dat", mode);
1144 SFichier fic3("tauw.dat", mode);
1145 fic1 << tps << " " << retaum << " " << retaub << " " << retauh << finl;
1146 fic2 << tps << " " << utaum << " " << utaub << " " << utauh << finl;
1147 fic3 << tps << " " << tauwm << " " << tauwb << " " << tauwh << finl;
1148 fic1.close();
1149 fic2.close();
1150 fic3.close();
1151 }
1152
1153 } // end if not-turbul
1154
1155
1156}
1157
1158
1159void Traitement_particulier_NS_canal::ecriture_fichiers_moy_vitesse_rho_mu(const DoubleTab& val_moy, const Nom& fichier, const double dt, const int k) const
1160{
1161 SFichier fic (fichier);
1162
1163 double tps = mon_equation->inconnue().temps();
1164 double u,v,wl,u2,v2,w2,uv,uw,vw,rho,mu;
1165
1166 fic << "# Temps : " << tps << finl;
1167 fic << " " << finl;
1168
1169 fic << "# (0) : Y " << finl;
1170 fic << "# (1) : <u> " << finl;
1171 fic << "# (2) : <v> " << finl;
1172 fic << "# (3) : <w> " << finl;
1173 fic << "# (4) : sqrt(<u.u>-<u>*<u>) " << finl;
1174 fic << "# (5) : sqrt(<v.v>-<v>*<v>) " << finl;
1175 fic << "# (6) : sqrt(<w.w>-<w>*<w>) " << finl;
1176 fic << "# (7) : <u.v>-<u>*<v> " << finl;
1177 fic << "# (8) : <u.w>-<u>*<w> " << finl;
1178 fic << "# (9) : <v.w>-<v>*<w> " << finl;
1179 fic << "# (10) : <rho> " << finl;
1180 fic << "# (11) : <mu> " << finl;
1181
1182 fic << "# " << finl;
1183 fic << "# Nombre minimum de points par plan Y=cste ayant servi au calcul de la moyenne spatiale : " << min_array(compt_tot) << finl;
1184 fic << "# " << finl;
1185
1186 for (int i=0; i<Y_tot.size(); i++)
1187 {
1188 u = val_moy(i,0,k)/dt;
1189 v = val_moy(i,1,k)/dt;
1190 wl = val_moy(i,2,k)/dt;
1191 u2 = val_moy(i,3,k)/dt;
1192 v2 = val_moy(i,4,k)/dt;
1193 w2 = val_moy(i,5,k)/dt;
1194 uv = val_moy(i,6,k)/dt;
1195 uw = val_moy(i,7,k)/dt;
1196 vw = val_moy(i,8,k)/dt;
1197 rho = val_moy(i,10,k)/dt;
1198 mu = val_moy(i,11,k)/dt;
1199
1200
1201 fic << Y_tot(i) << " " ;
1202 fic << u << " " << v << " " << wl << " " ;
1203 // To avoid NaN, take std::max(,0):
1204 fic << sqrt(std::max(0.,u2)) << " " << sqrt(std::max(v2,0.)) << " " << sqrt(std::max(w2,0.)) << " " ;
1205 fic << -uv << " " << -uw << " " << -vw << " " ;
1206 fic << rho << " " << mu << " " ;
1207 fic << finl;
1208 }
1209 fic.flush();
1210 fic.close();
1211}
1212
1213void Traitement_particulier_NS_canal::ecriture_fichiers_moy_nut(const DoubleTab& val_moy, const Nom& fichier, const double dt, const int k) const
1214{
1215 SFichier fic (fichier);
1216
1217 double tps = mon_equation->inconnue().temps();
1218
1219 fic << "# Temps : " << tps << finl;
1220 fic << " " << finl;
1221
1222 fic << "# (0) : Y " << finl;
1223 fic << "# (1) : <nu_t> " << finl;
1224
1225 fic << "# " << finl;
1226 fic << "# Nombre minimum de points par plan Y=cste ayant servi au calcul de la moyenne spatiale : " << min_array(compt_tot) << finl;
1227 fic << "# " << finl;
1228
1229 for (int i=0; i<Y_tot.size(); i++)
1230 fic << Y_tot(i) << " " << val_moy(i,12,k)/dt << finl;
1231
1232 fic.flush();
1233 fic.close();
1234}
1235
1236void Traitement_particulier_NS_canal::ecriture_fichiers_moy_Temp(const DoubleTab& val_moy, const Nom& fichier, const double dt, const int k) const
1237{
1238 SFichier fic (fichier);
1239
1240 double tps = mon_equation->inconnue().temps();
1241 double T,T2,uT,vT,wT;
1242
1243 fic << "# Temps : " << tps << finl;
1244 fic << " " << finl;
1245
1246 fic << "# (0) : Y " << finl;
1247 fic << "# (1) : <T> " << finl;
1248 fic << "# (2) : sqrt(<T.T>-<T>*<T>) " << finl;
1249 fic << "# (3) : <u.T>-<u>*<T> " << finl;
1250 fic << "# (4) : <v.T>-<v>*<T> " << finl;
1251 fic << "# (5) : <w.T>-<w>*<T> " << finl;
1252
1253 fic << "# " << finl;
1254 fic << "# Nombre minimum de points par plan Y=cste ayant servi au calcul de la moyenne spatiale : " << min_array(compt_tot) << finl;
1255 fic << "# " << finl;
1256
1257 for (int i=0; i<Y_tot.size(); i++)
1258 {
1259 //u = val_moy(i,0,k)/dt;
1260 //v = val_moy(i,1,k)/dt;
1261 //w = val_moy(i,2,k)/dt;
1262 T = val_moy(i,13,k)/dt;
1263 T2 = val_moy(i,14,k)/dt;
1264 uT = val_moy(i,15,k)/dt;
1265 vT = val_moy(i,16,k)/dt;
1266 wT = val_moy(i,17,k)/dt;
1267
1268
1269 fic << Y_tot(i) << " " ;
1270 // To avoid NaN, take std::max(,0):
1271 fic << T << " " <<sqrt(std::max(T2,0.))<<" ";
1272 fic << -uT << " " << -vT << " " << -wT << " ";
1273 fic << finl;
1274 }
1275 fic.flush();
1276 fic.close();
1277}
1278
1279//After correcting the expression of the temporal average and the writing methods for temporal averages
1280//these two writing methods are kept in the "old" version for writing phase averages
1281
1282void Traitement_particulier_NS_canal::ecriture_fichiers_moy_vitesse_rho_mu_old(const DoubleTab& val_moy, const Nom& fichier, const double dt, const int k) const
1283{
1284 SFichier fic (fichier);
1285
1286 double tps = mon_equation->inconnue().temps();
1287 double u,v,wl,u2,v2,w2,uv,uw,vw,rho,mu;
1288
1289 fic << "# Temps : " << tps << finl;
1290 fic << " " << finl;
1291
1292 fic << "# (0) : Y " << finl;
1293 fic << "# (1) : <u> " << finl;
1294 fic << "# (2) : <v> " << finl;
1295 fic << "# (3) : <w> " << finl;
1296 fic << "# (4) : sqrt(<u.u>-<u>*<u>) " << finl;
1297 fic << "# (5) : sqrt(<v.v>-<v>*<v>) " << finl;
1298 fic << "# (6) : sqrt(<w.w>-<w>*<w>) " << finl;
1299 fic << "# (7) : <u.v>-<u>*<v> " << finl;
1300 fic << "# (8) : <u.w>-<u>*<w> " << finl;
1301 fic << "# (9) : <v.w>-<v>*<w> " << finl;
1302 fic << "# (10) : <rho> " << finl;
1303 fic << "# (11) : <mu> " << finl;
1304
1305 fic << "# " << finl;
1306 fic << "# Nombre minimum de points par plan Y=cste ayant servi au calcul de la moyenne spatiale : " << min_array(compt_tot) << finl;
1307 fic << "# " << finl;
1308
1309 for (int i=0; i<Y_tot.size(); i++)
1310 {
1311 u = val_moy(i,0,k)/dt;
1312 v = val_moy(i,1,k)/dt;
1313 wl = val_moy(i,2,k)/dt;
1314 u2 = val_moy(i,3,k)/dt;
1315 v2 = val_moy(i,4,k)/dt;
1316 w2 = val_moy(i,5,k)/dt;
1317 uv = val_moy(i,6,k)/dt;
1318 uw = val_moy(i,7,k)/dt;
1319 vw = val_moy(i,8,k)/dt;
1320 rho = val_moy(i,10,k)/dt;
1321 mu = val_moy(i,11,k)/dt;
1322
1323
1324 fic << Y_tot(i) << " " ;
1325 fic << u << " " << v << " " << wl << " " ;
1326 // To avoid NaN, take std::max(,0):
1327 fic << sqrt(std::max(0.,u2-u*u)) << " " << sqrt(std::max(v2-v*v,0.)) << " " << sqrt(std::max(w2-wl*wl,0.)) << " " ;
1328 fic << u*v-uv << " " << u*wl-uw << " " << v*wl-vw << " " ;
1329
1330
1331 fic << rho << " " << mu << " " ;
1332 fic << finl;
1333 }
1334 fic.flush();
1335 fic.close();
1336}
1337
1338
1339
1340void Traitement_particulier_NS_canal::ecriture_fichiers_moy_Temp_old(const DoubleTab& val_moy, const Nom& fichier, const double dt, const int k) const
1341{
1342 SFichier fic (fichier);
1343 fic.setf(ios::scientific);
1344 double tps = mon_equation->inconnue().temps();
1345 double u,v,wl,T,T2,uT,vT,wT;
1346
1347 fic << "# Temps : " << tps << finl;
1348 fic << " " << finl;
1349
1350 fic << "# (0) : Y " << finl;
1351 fic << "# (1) : <T> " << finl;
1352 fic << "# (2) : sqrt(<T.T>-<T>*<T>) " << finl;
1353 fic << "# (3) : <u.T>-<u>*<T> " << finl;
1354 fic << "# (4) : <v.T>-<v>*<T> " << finl;
1355 fic << "# (5) : <w.T>-<w>*<T> " << finl;
1356
1357 fic << "# " << finl;
1358 fic << "# Nombre minimum de points par plan Y=cste ayant servi au calcul de la moyenne spatiale : " << min_array(compt_tot) << finl;
1359 fic << "# " << finl;
1360
1361 for (int i=0; i<Y_tot.size(); i++)
1362 {
1363 u = val_moy(i,0,k)/dt;
1364 v = val_moy(i,1,k)/dt;
1365 wl = val_moy(i,2,k)/dt;
1366 T = val_moy(i,13,k)/dt;
1367 T2 = val_moy(i,14,k)/dt;
1368 uT = val_moy(i,15,k)/dt;
1369 vT = val_moy(i,16,k)/dt;
1370 wT = val_moy(i,17,k)/dt;
1371
1372
1373 fic << Y_tot(i) << " " ;
1374 // To avoid NaN, take std::max(,0):
1375 fic << T << " " << sqrt(std::max(T2-T*T,0.)) << " " ;
1376 fic << u*T-uT << " " << v*T-vT << " " << wl*T-wT << " ";
1377
1378 fic << finl;
1379 }
1380 fic.flush();
1381 fic.close();
1382}
1383
1384
1385
DoubleTab & valeurs() override
Overrides Champ_base::valeurs() Returns the array of values.
virtual DoubleTab & valeurs()=0
Champ_Uniforme Represents a field that is constant in space and time.
class Cond_lim Generic class used to represent any class
Definition Cond_lim.h:31
class Conds_lim This class represents a vector of boundary conditions.
Definition Conds_lim.h:32
Dirichlet_paroi_fixe Represents a fixed wall in a Navier-Stokes type equation.
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
class Domaine_VF
Definition Domaine_VF.h:44
int face_voisins(int num_face, int i) const
Returns the neighbouring element of num_face in direction i.
Definition Domaine_VF.h:418
File for reading. This class is to the C++ ifstream class what the Entree class is to the.
Definition EFichier.h:29
void setf(IOS_FORMAT code)
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Equation_base The role of an equation is the calculation of one or more fields....
virtual const Milieu_base & milieu() const =0
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
Base class for an incompressible fluid and its properties:
Definition Fluide_base.h:36
const Champ_Don_base & viscosite_dynamique() const
Definition Fluide_base.h:58
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
virtual const Equation_base & equation(const std::string &nom_inc) const
virtual const Champ_base & masse_volumique() const
Returns the mass density of the medium (const version).
Base class for the turbulence model hierarchy for Navier-Stokes equations.
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
Navier_Stokes_std This class carries the terms of the momentum equation.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:71
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 Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
Definition Process.cpp:102
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
Definition Process.cpp:145
static double mp_sum_as_double(int v)
Definition Process.h:97
static int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
Definition Process.cpp:122
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
Definition Process.cpp:82
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
Definition SFichier.h:29
Sortie & flush() override
Forces the data in the buffer to be written to disk. Uses the ofstream class implementation.
void setf(IOS_FORMAT code) override
Base class for output streams.
Definition Sortie.h:52
void ordonne_array()
virtual void ref(const TRUSTTab &)
Definition TRUSTTab.tpp:308
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
_SIZE_ size() const
Definition TRUSTVect.tpp:45
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTVect.tpp:91
const Objet_U & valeur() const
Definition TRUST_Ref.h:134
Traitement_particulier_NS_base Derives from Support_Champ_Masse_Volumique: use of rho.
Traitement_particulier_NS_canal This class performs specific post-processing treatments.
void ecriture_fichiers_moy_Temp_old(const DoubleTab &, const Nom &, const double, const int) const
virtual void calculer_moyenne_spatiale_Temp(DoubleTab &) const =0
virtual void calculer_moyenne_spatiale_nut(DoubleTab &) const =0
void ecriture_fichiers_moy_Temp(const DoubleTab &, const Nom &, const double, const int) const
void sauver_stat_canal(const DoubleTab &, const Nom &) const
virtual void calculer_moyenne_spatiale_vitesse_rho_mu(DoubleTab &) const =0
void ecriture_fichiers_moy_vitesse_rho_mu(const DoubleTab &, const Nom &, const double, const int) const
void reprendre_stat_canal(DoubleTab &, const Nom &)
virtual void remplir_Y(DoubleVect &, DoubleVect &, int &) const =0
void ecriture_fichiers_moy_vitesse_rho_mu_old(const DoubleTab &, const Nom &, const double, const int) const
void ecriture_fichiers_moy_nut(const DoubleTab &, const Nom &, const double, const int) const
void remplir_reordonne_Y_tot(const DoubleVect &, DoubleVect &) const
Base class for the hierarchy of wall-law models computing turbulent quantities near walls....
const DoubleTab & Cisaillement_paroi() const