TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Traitement_particulier_NS_Profils_thermo_VDF.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 <Traitement_particulier_NS_Profils_thermo_VDF.h>
17#include <Domaine_VDF.h>
18#include <Probleme_base.h>
19#include <LecFicDistribueBin.h>
20#include <EcrFicCollecteBin.h>
21#include <Navier_Stokes_std.h>
22#include <Convection_Diffusion_Temperature.h>
23#include <Convection_Diffusion_Chaleur_QC.h>
24#include <communications.h>
25
26Implemente_instanciable_sans_constructeur(Traitement_particulier_NS_Profils_thermo_VDF,"Traitement_particulier_NS_Profils_thermo_VDF",Traitement_particulier_NS_Profils_VDF);
27// XD profils_thermo traitement_particulier_base profils_thermo NO_BRACE non documente
28// XD attr bloc bloc_lecture bloc REQ not_set
29
30Traitement_particulier_NS_Profils_thermo_VDF::Traitement_particulier_NS_Profils_thermo_VDF():oui_repr_stats_thermo(0)
31{
32}
33
35{
36 return is;
37}
38
40{
41 return is;
42}
43
48
50{
51 // By default, no statistics are computed on the temperature.
52
53 if (motlu=="stats_thermo")
54 {
55 //Statistics on the temperature field
57 }
58 else
59 {
60 if(motlu=="reprise_thermo")
61 {
62 // Restart of statistics for the temperature field
63 oui_repr_stats_thermo = 1; // We want to restart the statistics on temperature
64 is >> fich_repr_stats_thermo ; // Name of the restart file for the temperature field statistics
65 Cerr << "Restarting statistics on the thermal field" << finl;
66 }
67 else
68 {
69 if(motlu=="tmin_tmax")
70 {
71 // The user requests max and min temperature values in a file
72 tmin_tmax = 1;
73 Cerr << "User asked to monitor min and max of temperature" << finl;
74 Cerr << "in channel flow computation." << finl;
75 }
76 else
77 {
79 }
80 }
81 }
82 return is;
83}
84
86{
88
89 const Probleme_base& pb = mon_equation->probleme();
90 int flag=0;
91 for(int i=0; i<pb.nombre_d_equations(); i++)
92 {
94 {
95 mon_equation_NRJ = ref_cast(Convection_Diffusion_Temperature,pb.equation(i));
96 flag=1;
97 }
98 else if(sub_type(Convection_Diffusion_Chaleur_QC,pb.equation(i)))
99 {
100 mon_equation_NRJ = ref_cast(Convection_Diffusion_Chaleur_QC,pb.equation(i));
101 flag=1;
102 }
103
104 }
105 if (flag==0)
106 {
107 Cerr << "Error : Equation of NRJ was not found..." << finl;
108 Cerr << "User can not ask for statistics on temperature" << finl;
109 Cerr << "if we do not solve a heat equation." << finl;
110 Cerr << "Try to remove the '_thermo' part at key-word 'Profils'" << finl;
111 exit();
112 }
113}
114
115// #################### Postraitement Statistique du Champ de Temperature #########
116
118{
120
121 DoubleTab Tmoy_m(n_probes,Nap);
122 Tmoy_m=0.;
123 DoubleTab Trms_m(n_probes,Nap);
124 Trms_m=0.;
125 DoubleTab upTp_m(n_probes,Nap);
126 upTp_m=0.;
127 DoubleTab vpTp_m(n_probes,Nap);
128 vpTp_m=0.;
129 DoubleTab wpTp_m(n_probes,Nap);
130 wpTp_m=0.;
131
132 DoubleTab Tmoy_p(n_probes,Nap);
133 Tmoy_p=0.;
134 DoubleTab Trms_p(n_probes,Nap);
135 Trms_p=0.;
136 DoubleTab upTp_p(n_probes,Nap);
137 upTp_p=0.;
138 DoubleTab vpTp_p(n_probes,Nap);
139 vpTp_p=0.;
140 DoubleTab wpTp_p(n_probes,Nap);
141 wpTp_p=0.;
142
143 double tps = mon_equation->inconnue().temps();
144
145
146 // Statistics on the thermal field are only computed simultaneously with statistics on the dynamic field.
147 if ((oui_u_inst != 0)&&(oui_stats_thermo != 0))
148 {
149 calculer_moyennes_spatiales_thermo(Tmoy_m,Trms_m,upTp_m,vpTp_m,wpTp_m,corresp_uv_m,compt_uv_m,Nuv,xUVm);
150 calculer_moyennes_spatiales_thermo(Tmoy_p,Trms_p,upTp_p,vpTp_p,wpTp_p,corresp_uv_p,compt_uv_p,Nuv,xUVp);
151
152 static double temps_dern_post_inst = -100.;
153 if (std::fabs(tps-temps_dern_post_inst)>=dt_post_inst)
154 {
155 ecriture_fichier_moy_spat_thermo(Tmoy_m,Trms_m,upTp_m,vpTp_m,wpTp_m,Tmoy_p,Trms_p,upTp_p,vpTp_p,wpTp_p,Yuv_m,Nuv,delta_UVm, delta_UVp);
156
157 temps_dern_post_inst = tps;
158 }
159 }
160
161
162 // Temporal averages:
163
164 // Statistics on the thermal field are only computed simultaneously with statistics on the dynamic field.
165 if ((oui_u_inst != 0)&&(oui_stats_thermo != 0)&&(oui_stat != 0))
166 {
167 double tpsbis = mon_equation->inconnue().temps();
168 if ((tpsbis>=temps_deb)&&(tpsbis<=temps_fin))
169 {
170 static int init_stat_temps = 0;
171 if((init_stat_temps==0)&&( oui_repr != 1)) // if this is not a restart: otherwise values are read from the file
172 {
173 double dt_v = mon_equation->schema_temps().pas_de_temps();
174 temps_deb = tpsbis-dt_v;
175 init_stat_temps++;
176 }
177
183
184 static double temps_dern_post_stat = -100.;
185 if (std::fabs(tpsbis-temps_dern_post_stat)>=dt_post_stat)
186 {
187 double dt = tpsbis-temps_deb;
189 temps_dern_post_stat = tpsbis;
190 }
191 }
192 }
193}
194
195
196
197
198
199// #################### Compute Averages #################################
200
201void Traitement_particulier_NS_Profils_thermo_VDF::calculer_moyennes_spatiales_thermo(DoubleTab& tmoy, DoubleTab& trms, DoubleTab& uptp, DoubleTab& vptp, DoubleTab& wptp, const IntTab& corresp, const IntTab& compt, const IntVect& NN, const DoubleTab& xUV)
202{
203
204 const Domaine_dis_base& zdisbase=mon_equation->inconnue().domaine_dis_base();
205 const Domaine_VDF& domaine_VDF=ref_cast(Domaine_VDF, zdisbase);
206 const IntTab& elem_faces = domaine_VDF.elem_faces();
207
208 // To find the coordinates of the max and min temperature points:
209 const DoubleTab& xp = domaine_VDF.xp();
210
211 // The number of elements in the VDF domain.
212 int nb_elems = domaine_VDF.domaine().nb_elem();
213
214 // Access the values of the 3 velocity components from mon_equation.
215 const DoubleTab& vitesse = mon_equation->inconnue().valeurs();
216
217 // Access the temperature values from mon_equation_NRJ.
218 const DoubleTab& Temp = mon_equation_NRJ->inconnue().valeurs();
219
220
221
222 // These 3 vectors hold the values of the 3 velocity components U, V and W averaged at element centers over the entire space.
223 // They correspond to <U>, <V> and <W>.
224 DoubleTab u_moy_cent(n_probes,Nap);
225 u_moy_cent= 0.;
226 DoubleTab v_moy_cent(n_probes,Nap);
227 v_moy_cent= 0.;
228 DoubleTab w_moy_cent(n_probes,Nap);
229 w_moy_cent= 0.;
230
231 // t2moy corresponds to
232 DoubleTab t2moy(n_probes,Nap);
233 t2moy = 0.;
234
235 // vitu, vitv and vitw are the values of the 3 velocity components taken at element centers,
236 // i.e. averaged.
237 double vitu,vitv,vitw;
238
239 // For checking temperature bounds in plane channel flow
240 double Tmin=1000000000.,Tmax=0.;
241 int elem_min=0, elem_max=0;
242
243 // face_ui_j is used to get the face number carrying the velocity component ui,
244 // with 0 and 1 being the two opposing faces used to average at the element center.
245 // This approach is necessary among other reasons because we iterate over elements.
246 int face_u_0,face_u_1,face_v_0,face_v_1,face_w_0,face_w_1;
247
248 int i,j,deja_fait=0;
249 int num_elem;
250
251 // tmoy is the mean of T : <T>(y,t)
252 tmoy = 0.;
253 // trms is the standard deviation of temperature : sqrt(<Tp^2>)(y,t)=<T^2>-<T>^2
254 trms = 0.;
255 // uptp : <U><T>-<UT>
256 uptp = 0.;
257 // vptp : <V><T>-<VT>
258 vptp = 0.;
259 // wptp : <W><T>-<WT>
260 wptp = 0.;
261
262 for(i=0; i<n_probes; i++)
263 {
264 // We iterate over all elements to compute all averages at element centers.
265 for (num_elem=0; num_elem<nb_elems; num_elem++)
266 {
267 // <T>
268 if(xp(num_elem,dir_profil)==xUV(i))
269 {
270 tmoy(i,corresp(i,num_elem)) += Temp[num_elem];
271 face_u_0 = elem_faces(num_elem,0);
272 face_u_1 = elem_faces(num_elem,dimension);
273 vitu = 0.5*(vitesse[face_u_0]+vitesse[face_u_1]);
274
275 face_v_0 = elem_faces(num_elem,1);
276 face_v_1 = elem_faces(num_elem,dimension+1);
277 vitv = 0.5*(vitesse[face_v_0]+vitesse[face_v_1]);
278
279 face_w_0 = elem_faces(num_elem,2);
280 face_w_1 = elem_faces(num_elem,dimension+2);
281 vitw = 0.5*(vitesse[face_w_0]+vitesse[face_w_1]);
282 // <U>
283 u_moy_cent(i,corresp(i,num_elem)) += vitu;
284 // <V>
285 v_moy_cent(i,corresp(i,num_elem)) += vitv;
286 // <W>
287 w_moy_cent(i,corresp(i,num_elem)) += vitw;
288 // Trms : here we compute <T^2> but then subtract the <T>^2 part
289 trms(i,corresp(i,num_elem)) += Temp[num_elem]*Temp[num_elem];
290 // Compute <uT>, <vT>, and <wT>
291 uptp(i,corresp(i,num_elem)) += vitu*Temp[num_elem];
292 vptp(i,corresp(i,num_elem)) += vitv*Temp[num_elem];
293 wptp(i,corresp(i,num_elem)) += vitw*Temp[num_elem];
294 }
295
296 // To find the max and min temperatures in the flow.
297 if(Temp[num_elem]<Tmin)
298 {
299 Tmin=Temp[num_elem];
300 elem_min=num_elem;
301 }
302 if(Temp[num_elem]>Tmax)
303 {
304 Tmax=Temp[num_elem];
305 elem_max=num_elem;
306 }
307
308 }//END loop over elements
309
310 if((tmin_tmax==1)&&(deja_fait==0))
311 {
312 SFichier fic1("T_min_max.dat",ios::app);
313 double tps = mon_equation->inconnue().temps();
314 fic1 << tps << " " << Tmin << " " << xp(elem_min,0) << " " << xp(elem_min,1);
315 fic1 << " " << Tmax << " " << xp(elem_max,0) << " " << xp(elem_max,1) <<finl;
316 fic1.flush();
317 fic1.close();
318 deja_fait=1;
319 }
320 } // All profiles have been iterated over
321
322 // NN is the number of distinct Y values, i.e. the number of points in the final curve after averaging.
323
324 // compt[j] is the number of elements that were used to compute a given mean temperature value,
325 // i.e. the number of elements sharing the same Y coordinate.
326 // FOR PARALLEL !!
327 IntTab compt_p(compt);
328 envoyer(compt_p,Process::me(),0,Process::me());
329
330 DoubleTab tmoy_p(tmoy);
331 envoyer(tmoy_p,Process::me(),0,Process::me());
332
333 DoubleTab trms_p(trms);
334 envoyer(trms_p,Process::me(),0,Process::me());
335
336 DoubleTab uptp_p(uptp);
337 envoyer(uptp_p,Process::me(),0,Process::me());
338
339 DoubleTab vptp_p(vptp);
340 envoyer(vptp_p,Process::me(),0,Process::me());
341
342 DoubleTab wptp_p(wptp);
343 envoyer(wptp_p,Process::me(),0,Process::me());
344
345 DoubleTab u_moy_cent_p(u_moy_cent);
346 envoyer(u_moy_cent_p,Process::me(),0,Process::me());
347
348 DoubleTab v_moy_cent_p(v_moy_cent);
349 envoyer(v_moy_cent_p,Process::me(),0,Process::me());
350
351 DoubleTab w_moy_cent_p(w_moy_cent);
352 envoyer(w_moy_cent_p,Process::me(),0,Process::me());
353
354 if(je_suis_maitre())
355 {
356 IntTab compt_tot(compt);
357 DoubleTab tmoy_tot(tmoy);
358 DoubleTab trms_tot(trms);
359 DoubleTab uptp_tot(uptp);
360 DoubleTab vptp_tot(vptp);
361 DoubleTab wptp_tot(wptp);
362 DoubleTab u_moy_cent_tot(u_moy_cent);
363 DoubleTab v_moy_cent_tot(v_moy_cent);
364 DoubleTab w_moy_cent_tot(w_moy_cent);
365
366 compt_tot=0;
367 tmoy_tot=0.;
368 trms_tot=0.;
369 uptp_tot=0.;
370 vptp_tot=0.;
371 wptp_tot=0.;
372 u_moy_cent_tot=0.;
373 v_moy_cent_tot=0.;
374 w_moy_cent_tot=0.;
375
376 for(int p=0; p<Process::nproc(); p++)
377 {
378 recevoir(compt_p,p,0,p);
379 compt_tot+=compt_p;
380
381 recevoir(tmoy_p,p,0,p);
382 tmoy_tot+=tmoy_p;
383
384 recevoir(trms_p,p,0,p);
385 trms_tot+=trms_p;
386
387 recevoir(uptp_p,p,0,p);
388 uptp_tot+=uptp_p;
389
390 recevoir(vptp_p,p,0,p);
391 vptp_tot+=vptp_p;
392
393 recevoir(wptp_p,p,0,p);
394 wptp_tot+=wptp_p;
395
396 recevoir(u_moy_cent_p,p,0,p);
397 u_moy_cent_tot+=u_moy_cent_p;
398
399 recevoir(v_moy_cent_p,p,0,p);
400 v_moy_cent_tot+=v_moy_cent_p;
401
402 recevoir(w_moy_cent_p,p,0,p);
403 w_moy_cent_tot+=w_moy_cent_p;
404
405
406 }
407
408 for(i=0; i<n_probes; i++)
409 {
410 for (j=0; j<NN(i); j++)
411 {
412 tmoy(i,j) = tmoy_tot(i,j) / compt_tot(i,j);
413 trms(i,j) = trms_tot(i,j) / compt_tot(i,j);
414 uptp(i,j) = uptp_tot(i,j) / compt_tot(i,j);
415 vptp(i,j) = vptp_tot(i,j) / compt_tot(i,j);
416 wptp(i,j) = wptp_tot(i,j) / compt_tot(i,j);
417 u_moy_cent(i,j) = u_moy_cent_tot(i,j) / compt_tot(i,j);
418 v_moy_cent(i,j) = v_moy_cent_tot(i,j) / compt_tot(i,j);
419 w_moy_cent(i,j) = w_moy_cent_tot(i,j) / compt_tot(i,j);
420
421 trms(i,j) -= tmoy(i,j)*tmoy(i,j);
422 uptp(i,j) -= u_moy_cent(i,j)*tmoy(i,j);
423 vptp(i,j) -= v_moy_cent(i,j)*tmoy(i,j);
424 wptp(i,j) -= w_moy_cent(i,j)*tmoy(i,j);
425 }
426 }// End loop over profiles
427
428 }// END Parallel section
429
430}
431
432
433
434// #################### Compute Temporal Integral ###############################
435
436void Traitement_particulier_NS_Profils_thermo_VDF::calculer_integrales_temporelles(DoubleTab& moy_temp, const DoubleTab& moy_spat_m, const DoubleTab& moy_spat_p, const DoubleVect& delta_m, const DoubleVect& delta_p)
437{
438 int i,j;
439 double dt_v = mon_equation->schema_temps().pas_de_temps();
440 DoubleTab moy(moy_temp);
441 for(i=0; i<n_probes; i++)
442 {
443 for(j=0; j<Nap; j++)
444 {
445 moy(i,j)=moy_spat_m(i,j)*delta_m(i)/(delta_m(i)+delta_p(i));
446 moy(i,j)+=moy_spat_p(i,j)*delta_p(i)/(delta_m(i)+delta_p(i));
447 }
448 }
449 if(je_suis_maitre())
450 ////moy_temp.ajoute(dt_v,moy);
451 moy_temp.ajoute_sans_ech_esp_virt(dt_v,moy);
452
453}
454
455
456
457
458
459// #################### Writing Spatial Averages to File ##################
460
461
462void Traitement_particulier_NS_Profils_thermo_VDF::ecriture_fichier_moy_spat_thermo(const DoubleTab& Tmoy_m, const DoubleTab& Trms_m, const DoubleTab& upTp_m, const DoubleTab& vpTp_m, const DoubleTab& wpTp_m, const DoubleTab& Tmoy_p, const DoubleTab& Trms_p, const DoubleTab& upTp_p, const DoubleTab& vpTp_p, const DoubleTab& wpTp_p, const DoubleTab& Y, const IntVect& NN, const DoubleVect& delta_m, const DoubleVect& delta_p)
463{
464
465 int i,j;
466 double tps = mon_equation->inconnue().temps();
467 Nom temps = Nom(tps);
468
469 for(i=0; i<n_probes; i++)
470 {
471 Nom nom_fic = "./Space_Avg/Avg_temp_";
472 switch(dir_profil)
473 {
474 case 0:
475 {
476 nom_fic +="X_";
477 break;
478 }
479 case 1:
480 {
481 nom_fic +="Y_";
482 break;
483 }
484 case 2:
485 {
486 nom_fic +="Z_";
487 break;
488 }
489 }
490 Nom pos = Nom(positions(i));
491 nom_fic += pos;
492 nom_fic += "_t_";
493 nom_fic += temps;
494 nom_fic += ".dat";
495
496 if(je_suis_maitre())
497 {
498 SFichier fic (nom_fic);
499 fic << "# Space Averaged Statistics" << finl ;
500 fic << "# Y <T> Trms <upTp> -<vpTp> -<wpTp>" << finl ;
501
502 DoubleTab Tmoy(Tmoy_m);
503 DoubleTab Trms(Trms_m);
504 DoubleTab upTp(upTp_m);
505 DoubleTab vpTp(vpTp_m);
506 DoubleTab wpTp(wpTp_m);
507
508 for(j=0; j<NN(i); j++)
509 {
510 Tmoy(i,j)=Tmoy_m(i,j)*delta_m(i)/(delta_m(i)+delta_p(i));
511 Tmoy(i,j)+=Tmoy_p(i,j)*delta_p(i)/(delta_m(i)+delta_p(i));
512 Trms(i,j)=Trms_m(i,j)*delta_m(i)/(delta_m(i)+delta_p(i));
513 Trms(i,j)+=Trms_p(i,j)*delta_p(i)/(delta_m(i)+delta_p(i));
514 upTp(i,j)=upTp_m(i,j)*delta_m(i)/(delta_m(i)+delta_p(i));
515 upTp(i,j)+=upTp_p(i,j)*delta_p(i)/(delta_m(i)+delta_p(i));
516 vpTp(i,j)=vpTp_m(i,j)*delta_m(i)/(delta_m(i)+delta_p(i));
517 vpTp(i,j)+=vpTp_p(i,j)*delta_p(i)/(delta_m(i)+delta_p(i));
518 wpTp(i,j)=wpTp_m(i,j)*delta_m(i)/(delta_m(i)+delta_p(i));
519 wpTp(i,j)+=wpTp_p(i,j)*delta_p(i)/(delta_m(i)+delta_p(i));
520 }
521
522 for (j=0; j<NN(i); j++)
523 fic << Y(i,j) << " " << Tmoy(i,j) << " " << sqrt(std::max(Trms(i,j),0.0)) << " " << upTp(i,j) << " " << -vpTp(i,j) << " " << -wpTp(i,j) << finl;
524 fic.flush();
525 fic.close();
526 } //End of "if I am master"
527 }//END loop over probes
528}
529
530
531
532
533
534// #################### Writing Temporal Averages to File ################
535
536void Traitement_particulier_NS_Profils_thermo_VDF::ecriture_fichier_moy_temp_thermo(const DoubleTab& Tmoy, const DoubleTab& Trms, const DoubleTab& upTp, const DoubleTab& vpTp, const DoubleTab& wpTp, const DoubleTab& Y, const double dt, const IntVect& NN)
537{
538
539 int i,j;
540 for(i=0; i<n_probes; i++)
541 {
542 Nom nom_fic = "./Time_Avg/Avg_time_temp_";
543 double tps = mon_equation->inconnue().temps();
544
545 switch(dir_profil)
546 {
547 case 0:
548 {
549 nom_fic +="X_";
550 break;
551 }
552 case 1:
553 {
554 nom_fic +="Y_";
555 break;
556 }
557 case 2:
558 {
559 nom_fic +="Z_";
560 break;
561 }
562 }
563 Nom pos = Nom(positions(i));
564 nom_fic += pos;
565 nom_fic +="_t_";
566
567 Nom temps = Nom(tps);
568 nom_fic+= temps;
569
570 nom_fic+=".dat";
571
572 if(je_suis_maitre())
573 {
574 SFichier fic (nom_fic);
575 fic << "# Time Averaged Statistics" << finl ;
576 fic << "# Y <T> Trms <upTp> -<vpTp> -<wpTp>" << finl ;
577
578
579 for (j=0; j<NN(i) ; j++)
580 fic << Y(i,j) << " " << Tmoy(i,j)/dt << " " << sqrt(std::max(Trms(i,j)/dt,0.0)) << " " << upTp(i,j)/dt << " " << -vpTp(i,j)/dt << " " << -wpTp(i,j)/dt << finl;
581 fic.flush();
582 fic.close();
583 }
584 }//END loop over probes
585}
586
587
588
589
590
591// #################### Saving temporal statistics ###################
592
594{
595
597 double tps = mon_equation->inconnue().temps();
598
599 if ( (oui_stat == 1)&&(tps>=temps_deb)&&(tps<=temps_fin) )
600 {
601 Cerr << "In Traitement_particulier_NS_Profils_thermo_VDF::sauver_stat" << finl;
602 // Save the sum (without dividing by dt)
603 int i,j;
604 Nom temps = Nom(tps);
605 Nom fich_sauv_temp ="temperature_field_avg_time_";
606 fich_sauv_temp+=temps;
607 fich_sauv_temp+=".sauv";
608
609 // Save u_moy!!
610 EcrFicCollecteBin fict (fich_sauv_temp);
611 fict << temps << finl;
612 for(i=0; i<n_probes; i++)
613 {
614 fict << Nuv(i) << finl;
615 for (j=0; j<Nuv(i); j++)
616 {
617 fict << Tmoy_temp(i,j) << " " << finl;
618 fict << Trms_temp(i,j) << " " << finl;
619 fict << upTp_temp(i,j) << " " << finl;
620 fict << vpTp_temp(i,j) << " " << finl;
621 fict << wpTp_temp(i,j) << " " << finl;
622 }
623 }
624 fict << temps_deb << finl;
625 fict.flush();
626 fict.close();
627 Cerr << "Temperature statistics saved at t=" << tps << finl;
628 }
629}
630
631
632
633
634
636{
638 double tps = mon_equation->inconnue().temps();
639 int i,j;
640 double ti;
641 // double ti2;
642 Nom temps;
643 if (oui_stat == 1)
644 {
645 ifstream fict(fich_repr_stats_thermo);
646 if (fict)
647 {
649 fict2 >> temps;
650 Tmoy_temp.resize(n_probes,Nap);
651 Trms_temp.resize(n_probes,Nap);
652 upTp_temp.resize(n_probes,Nap);
653 vpTp_temp.resize(n_probes,Nap);
654 wpTp_temp.resize(n_probes,Nap);
655
656 for(i=0; i<n_probes; i++)
657 {
658 fict2 >> Nuv(i);
659 for (j=0; j<Nuv(i); j++)
660 {
661 fict2 >> Tmoy_temp(i,j) ;
662 fict2 >> Trms_temp(i,j);
663 fict2 >> upTp_temp(i,j) ;
664 fict2 >> vpTp_temp(i,j) ;
665 fict2 >> wpTp_temp(i,j) ;
666 }
667 }
668 fict2 >> ti ;
669 Cerr << "ti=" << ti << finl;
670 Nom chc_ti = Nom(ti), chc_temps_deb = Nom(temps_deb);
671 Cerr << "chc_ti=" << chc_ti << " chc_temps_deb=" << chc_temps_deb << finl;
672 if (chc_ti!=chc_temps_deb)
673 {
674 if (ti > temps_deb)
675 {
676 Cerr << "Problem restarting thermal field statistics:" << finl;
677 Cerr << "The requested start time for stats " << temps_deb << finl;
678 Cerr << "is less than the start time of the saved stats!" << ti << finl;
679 exit();
680 }
681 else
682 {
683 if (temps_deb>=tps)
684 {
685 Cerr << "Restarting thermal statistics computation from t=" << temps_deb << "s." << finl;
686 Tmoy_temp = 0.;
687 Trms_temp = 0.;
688 upTp_temp = 0.;
689 vpTp_temp = 0.;
690 wpTp_temp = 0.;
692 }
693 else
694 {
695 Cerr << "The time at which you want to start thermal statistics has already been passed!" << finl;
696 exit();
697 }
698 }
699 }
700 else
701 {
702 Cerr << "Continuing thermal statistics computation, started at t=" << ti << "s." << finl;
703 temps_deb = ti;
704 }
705 }
706 else
707 {
708 if (tps<=temps_deb)
709 {
710 Cerr << "Thermal statistics computation has not started yet." << finl;
712 }
713 else
714 {
715 Cerr << "A file must be provided to restart thermal statistics!" << finl;
716 exit();
717 }
718 }
719 }
720 else
721 {
722 // Cerr << "Pas de calcul des stats commence." << finl;
723 // Cerr << "Pas de reprise des statistiques thermiques." << finl;
724 }
725}
726
727
728
729
730
735
736
738{
739 if ((oui_u_inst != 0)||(oui_profil_nu_t != 0))
740 // Call only the method in NS_Profils_VDF to initialize
741 // the averaging computation, since only the correspondence tables
742 // and the sizing of Yuv and Nuv quantities are done there.
743
745
746 if (oui_stat != 0)
747 // However, to start computing the stats a small processing step is needed
748 // for the thermo since the arrays for the temporal averages
749 // specific to thermo, as well as those of the classical hydraulics in NS_Profils, must be sized.
750
752}
753
754
755
756
758{
760
762 {
763 // The user does not request a restart, meaning there will be no reading
764 // from a file and the arrays must therefore be sized manually to start the statistics.
765 // These arrays are declared in Traitement_particulier_NS_Profils_thermo_VDF.h
766
767 Tmoy_temp.resize(n_probes,Nap);
768 Tmoy_temp=0;
769 Trms_temp.resize(n_probes,Nap);
770 Trms_temp=0;
771 upTp_temp.resize(n_probes,Nap);
772 upTp_temp=0;
773 vpTp_temp.resize(n_probes,Nap);
774 vpTp_temp=0;
775 wpTp_temp.resize(n_probes,Nap);
776 wpTp_temp=0;
777 }
778}
Particular case of Convection_Diffusion_Chaleur_Fluide_Dilatable_base for a quasi-compressible fluid,...
Convection_Diffusion_Temperature Special case of Convection_Diffusion_std.
int_t nb_elem() const
Definition Domaine.h:131
class Domaine_VDF
Definition Domaine_VDF.h:61
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
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Domaine & domaine() const
Writing to a file in binary format. This class implements the operators and virtual methods of the SF...
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....
Reading from a file in binary format.
A character string (Nom) in uppercase.
Definition Motcle.h:26
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
static int dimension
Definition Objet_U.h:94
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
class Probleme_base It is a Probleme_U that is not a coupling.
virtual int nombre_d_equations() const =0
virtual const Equation_base & equation(int) const =0
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 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.
Base class for output streams.
Definition Sortie.h:52
void ajoute_sans_ech_esp_virt(_SCALAR_TYPE_ alpha, const TRUSTVect &y, Mp_vect_options opt=VECT_REAL_ITEMS)
class Trait_part_NS_Profils_VDF This class enables a particular treatment
Entree & lire(const Motcle &, Entree &) override
Traitement_particulier_NS_Profils_thermo_VDF class.
void ecriture_fichier_moy_spat_thermo(const DoubleTab &, const DoubleTab &, const DoubleTab &, const DoubleTab &, const DoubleTab &, const DoubleTab &, const DoubleTab &, const DoubleTab &, const DoubleTab &, const DoubleTab &, const DoubleTab &, const IntVect &, const DoubleVect &, const DoubleVect &)
void calculer_moyennes_spatiales_thermo(DoubleTab &, DoubleTab &, DoubleTab &, DoubleTab &, DoubleTab &, const IntTab &, const IntTab &, const IntVect &, const DoubleTab &)
void calculer_integrales_temporelles(DoubleTab &, const DoubleTab &, const DoubleTab &, const DoubleVect &, const DoubleVect &)
void ecriture_fichier_moy_temp_thermo(const DoubleTab &, const DoubleTab &, const DoubleTab &, const DoubleTab &, const DoubleTab &, const DoubleTab &, const double, const IntVect &)
virtual void associer_eqn(const Equation_base &)