TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Traitement_particulier_NS_Profils.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.h>
17#include <LecFicDistribueBin.h>
18#include <EcrFicCollecteBin.h>
19#include <Modele_turbulence_hyd_base.h>
20#include <Navier_Stokes_std.h>
21
22Implemente_base(Traitement_particulier_NS_Profils,"Traitement_particulier_NS_Profils",Traitement_particulier_NS_base);
23
24
25/*! @brief
26 *
27 * @param (Sortie& is) un flot de sortie
28 * @return (Sortie&) le flot de sortie modifie
29 */
31{
32 return is;
33}
34
35
36/*! @brief
37 *
38 * @param (Entree& is) un flot d'entree
39 * @return (Entree&) le flot d'entree modifie
40 */
42{
43 return is;
44}
45
47{
48 // Initialisation
49 IntVect Verif(8);
50 Verif=0;
51
52 // END Initialisation
53 Motcle accouverte = "{" , accfermee = "}" ;
54 Motcle motbidon, motlu;
55 is >> motbidon ;
56 if (motbidon == accouverte)
57 {
58 Motcles les_mots(8);
59 les_mots[0] = "const_profile";
60 les_mots[1] = "num_probes";
61 les_mots[2] = "dt_output";
62 les_mots[3] = "stats";
63 les_mots[4] = "profil_nu_t";
64 les_mots[5] = "reprise";
65 les_mots[6] = "reprise_nu_t";
66 les_mots[7] = "homog_dir";
67 is >> motlu;
68 while(motlu != accfermee)
69 {
70 int rang=les_mots.search(motlu);
71 switch(rang)
72 {
73 case 0 :
74 {
75 // For const_profile Constant Profile value : X, Y, Z
76 is >> motlu; // Direction of constant profile
77 if((motlu=="x")||(motlu=="X")) dir_profil = 0;
78 else if((motlu=="y")||(motlu=="Y")) dir_profil = 1;
79 else if((motlu=="z")||(motlu=="Z")) dir_profil = 2;
80 else
81 {
82 Cerr << "Wrong value for direction of profile !" << finl;
83 exit();
84 }
85 Cerr << "Profiles at constant " << motlu << finl;
86 break;
87 }
88 case 1 :
89 {
90 // Number of probes and reading of the values of the postions
91 is >> n_probes;
92 if(n_probes<1)
93 {
94 Cerr << "Error in Traitement_particulier_NS_Profils::lire" << finl;
95 Cerr << "Wrong value for number of probes (" << n_probes << ") :" << finl;
96 Cerr << "There must be at least one profile !" << finl;
97 exit();
98 }
99 positions.resize(n_probes);
100 for(int i=0; i<n_probes; i++)
101 {
102 is >> positions(i);
103 Cerr << " Probe_" << i+1 << " = " << positions(i) << finl;
104 }
105 break;
106 }
107 case 2 :
108 {
109 // Pour u_inst
110 is >> dt_post_inst; // intervalle de temps de sortie des moyennes spatiales
111 // initialisation pour le calcul des stats spat.
112 oui_u_inst = 1;
113 Cerr << "Spatial average parameters read..." << finl;
114 Cerr << "dt_post_inst : " << dt_post_inst << finl;
115 break;
116 }
117 case 3 :
118 {
119 // For Time average
120 is >> temps_deb; // Initial time for time average statistics.
121 is >> temps_fin; // Final time for time average statistics.
122 is >> dt_post_stat; // Output intervalfor time average statistics.
123 oui_stat=1; // =1 : on calcule des stats temp.
124 Cerr << "Reading time statitics parameters..." << finl;
125 Cerr << "Initial time : " << temps_deb << " End time : " << temps_fin << finl;
126 Cerr << "Time interval for output : " << dt_post_stat << finl;
127 // Verif ensuite pour voir si on a rentrer les valeurs specifiques aux calculs des stats spat.
128 break;
129 }
130 case 4 :
131 {
132 // For eddy viscosity profile
133 oui_profil_nu_t = 1;
134 Cerr << "User asked for statistics on eddy-viscosity..." << finl;
135 const RefObjU& modele_turbulence = mon_equation->get_modele(TURBULENCE);
136 const Modele_turbulence_hyd_base& mod_turb = ref_cast(Modele_turbulence_hyd_base,modele_turbulence.valeur());
137 if(sub_type(Modele_turbulence_hyd_base,mod_turb))
138 Cerr << "Statistics for eddy-viscosity : OK !" << finl;
139 else
140 {
141 Cerr << "User asked for eddy-viscosity profile," << finl;
142 Cerr << "but is not defined in laminar case !" << finl;
143 Cerr << "Please check the problem type..." << finl;
144 exit();
145 }
146 break;
147 }
148 case 5 :
149 {
150 oui_repr = 1;
151 is >> fich_repr_u ; // indication du nom du fichier de reprise des stats
152 Cerr << "The time statistics file is : " << fich_repr_u << finl;
153 break;
154 }
155 case 6 :
156 {
157 // For eddy viscosity profile Reprise
158 oui_repr_nu_t = 1;
159 is >> fich_repr_nu_t ; // indication du nom du fichier de reprise des stats de nut
160 Cerr << "Continuing statistics on eddy-viscosity : OK!" << finl;
161 break;
162 }
163 case 7 :
164 {
165 // For homogeneous direction specification : X, Y, Z
166 is >> motlu; // Direction of homogeneity
167 if((motlu=="x")||(motlu=="X")) homo_dir = 0;
168 else if((motlu=="y")||(motlu=="Y")) homo_dir = 1;
169 else if((motlu=="z")||(motlu=="Z")) homo_dir = 2;
170 else
171 {
172 Cerr << "Wrong value for homogeneous direction !" << finl;
173 exit();
174 }
175 Cerr << "Homogeneous direction : " << motlu << finl;
176 break;
177 }
178 default :
179 {
180 lire(motlu,is);
181 break;
182 }
183 }
184 is >> motlu;
185 }
186 is >> motlu;
187 if (motlu != accfermee)
188 {
189 Cerr << "Error while reading in Traitement_particulier_NS_Profils::lire" << finl;
190 Cerr << "We were expecting a }" << finl;
191 exit();
192 }
193 }
194 else
195 {
196 Cerr << "Error while reading in Traitement_particulier_NS_Profils" << finl;
197 Cerr << "We were expecting a {" << finl;
198 exit();
199 }
200
201 if ((oui_u_inst!=1)&&(oui_stat!=0))
202 {
203 Cerr << "User asked for time statistics :" << finl;
204 Cerr << "To do so, you also need to specify the parameters for space statistics," << finl;
205 Cerr << "since it is used for the time stats.." << finl;
206 exit();
207 }
208 if ((oui_profil_nu_t!=1)&&(oui_repr_nu_t!=0))
209 {
210 Cerr << "User asked for time statistics on nu_t :" << finl;
211 Cerr << "pour cela il faut egalement demander le calcul des stats spatiales," << finl;
212 Cerr << "puisque il est necessaire au calcul des stats temp." << finl;
213 exit();
214 }
215 return is;
216}
217
218// Entree& Traitement_particulier_NS_canal::lire(const Motcle& motlu, Entree& is)
219// {
220// return is;
221// }
222
230
232{
233 if (oui_repr!=1) // ce n'est pas une reprise des stats specifiques = pas de lecture dans un fichier
234 {
235 u_moy_temp_x.resize(n_probes,Nap);
236 u_moy_temp_x=0;
237 u_moy_temp_y.resize(n_probes,Nap);
238 u_moy_temp_y=0;
239 u_moy_temp_z.resize(n_probes,Nap);
240 u_moy_temp_z=0;
241
242 uv_moy_temp.resize(n_probes,Nap);
243 uv_moy_temp=0; // uv_moy moyenne en temps
244
245 u2_moy_temp.resize(n_probes,Nap);
246 u2_moy_temp=0;
247 v2_moy_temp.resize(n_probes,Nap);
248 v2_moy_temp=0;
249 w2_moy_temp.resize(n_probes,Nap);
250 w2_moy_temp=0;
251
252 u3_moy_temp.resize(n_probes,Nap);
253 u3_moy_temp=0;
254 v3_moy_temp.resize(n_probes,Nap);
255 v3_moy_temp=0;
256 w3_moy_temp.resize(n_probes,Nap);
257 w3_moy_temp=0;
258
259 u4_moy_temp.resize(n_probes,Nap);
260 u4_moy_temp=0;
261 v4_moy_temp.resize(n_probes,Nap);
262 v4_moy_temp=0;
263 w4_moy_temp.resize(n_probes,Nap);
264 w4_moy_temp=0;
265
266 nu_t_temp.resize(n_probes,Nap);
267 nu_t_temp=0;
268 }
269}
270
272{
273 double tps = mon_equation->inconnue().temps();
274 int j,num_prof;
275 double ti,ti2;
276 Nom temps;
277 if (oui_stat == 1)
278 {
279 ifstream ficu0(fich_repr_u);
280 if (ficu0)
281 {
283 ficu >> temps;
284 u_moy_temp_x.resize(n_probes,Nap);
285 u_moy_temp_y.resize(n_probes,Nap);
286 u_moy_temp_z.resize(n_probes,Nap);
287
288 uv_moy_temp.resize(n_probes,Nap);
289 u2_moy_temp.resize(n_probes,Nap);
290 v2_moy_temp.resize(n_probes,Nap);
291 w2_moy_temp.resize(n_probes,Nap);
292
293 u3_moy_temp.resize(n_probes,Nap);
294 v3_moy_temp.resize(n_probes,Nap);
295 w3_moy_temp.resize(n_probes,Nap);
296
297 u4_moy_temp.resize(n_probes,Nap);
298 v4_moy_temp.resize(n_probes,Nap);
299 w4_moy_temp.resize(n_probes,Nap);
300
301 for(num_prof=0; num_prof<n_probes; num_prof++)
302 {
303 ficu >> Nxy(num_prof) >> Nyy(num_prof) >> Nzy(num_prof) >> Nuv(num_prof);
304 for (j=0; j<Nxy(num_prof); j++)
305 {
306 ficu >> u_moy_temp_x(num_prof,j) ;
307 ficu >> u2_moy_temp(num_prof,j);
308 }
309 for (j=0; j<Nyy(num_prof); j++)
310 {
311 ficu >> u_moy_temp_y(num_prof,j) ;
312 ficu >> v2_moy_temp(num_prof,j);
313 }
314 for (j=0; j<Nzy(num_prof); j++)
315 {
316 ficu >> u_moy_temp_z(num_prof,j);
317 ficu >> w2_moy_temp(num_prof,j);
318 }
319 for (j=0; j<Nuv(num_prof); j++)
320 ficu >> uv_moy_temp(num_prof,j) ;
321 }
322 //END reading "n_probes" profiles
323 ficu >> ti ;
324 Cerr << "ti=" << ti << finl;
325 Nom chc_ti = Nom(ti), chc_temps_deb = Nom(temps_deb);
326 Cerr << "chc_ti=" << chc_ti << " chc_temps_deb=" << chc_temps_deb << finl;
327 if (chc_ti!=chc_temps_deb)
328 {
329 if (ti > temps_deb)
330 {
331 Cerr << "pb de reprise des stats de la vitesse!!" << finl;
332 Cerr << "Le temps de debut des stats demande " << temps_deb << finl;
333 Cerr << "est inferieur a celui de debut des stats sauvees !" << ti << finl;
334 exit();
335 }
336 else
337 {
338 if (temps_deb>=tps)
339 {
340 Cerr << "On recommence le calcul des stats de la vitesse a partir de t=" << temps_deb << "s" << finl;
341 u_moy_temp_x = 0.;
342 u_moy_temp_y = 0.;
343 u_moy_temp_z = 0.;
344 uv_moy_temp = 0.;
345 u2_moy_temp = 0.;
346 v2_moy_temp = 0.;
347 w2_moy_temp = 0.;
348 oui_repr = 0;
349 }
350 else
351 {
352 Cerr << "On a deja depasse le temps auquel vous voulez commencer les stats!!" << finl;
353 exit();
354 }
355 }
356 }
357 else
358 {
359 Cerr << "On continue le calcul des stats de la vitesse, debute a t=" << ti << "s" << finl;
360 temps_deb = ti;
361 }
362 }
363 else
364 {
365 if (tps<=temps_deb)
366 {
367 Cerr << "On n a pas encore debute le calcul des stats" << finl;
368 oui_repr = 0;
369 }
370 else
371 {
372 Cerr << "Il faut donner le fichier pour reprendre les stats!!" << finl;
373 exit();
374 }
375 }
376
377 if ((oui_profil_nu_t!=0)&&(oui_repr_nu_t!=0))
378 {
379 ifstream ficu1(fich_repr_nu_t);
380 if (ficu1)
381 {
383 ficu >> temps;
384 nu_t_temp.resize(n_probes,Nap);
385 for(num_prof=0; num_prof<n_probes; num_prof++)
386 {
387 ficu >> Nuv(num_prof);
388 for (j=0; j<Nuv(num_prof); j++)
389 ficu >> nu_t_temp(num_prof,j) ;
390 }
391 ficu >> ti2 ;
392 if (ti2!=ti)
393 {
394 Cerr << "Pbs : les stats de nut et de la vitesse sont decalees!!" << finl;
395 exit();
396 }
397 Cerr << "ti2=" << ti2 << finl;
398 Nom chc_ti2 = Nom(ti2), chc_temps_deb = Nom(temps_deb);
399 Cerr << "chc_ti2=" << chc_ti2 << " chc_temps_deb=" << chc_temps_deb << finl;
400 if (chc_ti2!=chc_temps_deb)
401 {
402 if (ti2 > temps_deb)
403 {
404 Cerr << "pb de reprise des stats de nu_t!!" << finl;
405 Cerr << "Le temps de debut des stats demande " << temps_deb << finl;
406 Cerr << "est inferieur a celui de debut des stats sauvees !" << ti << finl;
407 exit();
408 }
409 else
410 {
411 if (temps_deb>=tps)
412 {
413 Cerr << "On recommence le calcul des stats de nu_t a partir de t=" << temps_deb << "s" << finl;
414 nu_t_temp = 0.;
415 oui_repr_nu_t = 0;
416 }
417 else
418 {
419 Cerr << "On a deja depasse le temps auquel vous voulez commencer les stats !" << finl;
420 exit();
421 }
422 }
423 }
424 else
425 {
426 Cerr << "On continue le calcul des stats de nu_t, debute a t=" << ti << "s" << finl;
427 temps_deb = ti2;
428 }
429 }
430 else
431 {
432 if (tps<=temps_deb)
433 {
434 Cerr << "On n a pas encore debute le calcul des stats" << finl;
435 oui_repr_nu_t = 0;
436 }
437 else
438 {
439 Cerr << "Il faut donner le fichier pour reprendre les stats !" << finl;
440 exit();
441 }
442 }
443 }
444 }
445 else
446 {
447 Cerr << "Pas de Calcul des stats commence !" << finl;
448 Cerr << "Pas de reprise de u_moy_temp,u_et_temp et teta_moy_temp" << finl;
449 }
450}
451
453{
454 double tps = mon_equation->inconnue().temps();
455 if ( (oui_stat == 1)&&(tps>=temps_deb)&&(tps<=temps_fin) )
456 {
457 Cerr << "Dans Traitement_particulier_NS_canal::sauver_stat!!" << finl;
458 // On sauve la somme (sans diviser par dt)
459 int j;
460 Nom temps = Nom(tps);
461 Nom fich_sauv_u ="u_moy_temp_";
462 fich_sauv_u+=temps;
463 fich_sauv_u+=".sauv";
464
465 // On sauve u_moy!!
466 EcrFicCollecteBin ficu (fich_sauv_u);
467 // EcrFicCollecte ficu (fich_sauv_u);
468 // EcrFicCollecteBin ficu ("u_moy_temp.sauv");
469 ficu << temps << finl;
470 int num_prof;
471 for(num_prof=0; num_prof<n_probes; num_prof++)
472 {
473 ficu << Nxy(num_prof) << Nyy(num_prof) << Nzy(num_prof) << Nuv(num_prof) << finl;
474 for (j=0; j<Nxy(num_prof); j++)
475 {
476 ficu << u_moy_temp_x(num_prof,j) << finl;
477 ficu << u2_moy_temp(num_prof,j) << finl;
478 }
479 for (j=0; j<Nyy(num_prof); j++)
480 {
481 ficu << u_moy_temp_y(num_prof,j) << finl;
482 ficu << v2_moy_temp(num_prof,j) << finl;
483 }
484 for (j=0; j<Nzy(num_prof); j++)
485 {
486 ficu << u_moy_temp_z(num_prof,j) << finl;
487 ficu << w2_moy_temp(num_prof,j) << finl;
488 }
489 for (j=0; j<Nuv(num_prof); j++)
490 ficu << uv_moy_temp(num_prof,j) << finl;
491 }
492 ficu << temps_deb << finl;
493 Cerr << "Sauvegarde de u_moy_temp a t=" << tps << finl;
494 Cerr << "Debut du calcul des stats a t=" << temps_deb << " a noter pour la reprise des stats !" << finl;
495
496 if (oui_profil_nu_t!=0)
497 {
498 Nom fich_sauv_nut ="nut_temp_";
499 fich_sauv_nut+=temps;
500 fich_sauv_nut+=".sauv";
501 // On sauve nut!!
502 EcrFicCollecteBin ficu2 (fich_sauv_nut);
503 ficu2 << temps << finl;
504 for(num_prof=0; num_prof<n_probes; num_prof++)
505 {
506 ficu2 << Nuv(num_prof) << finl;
507 for (j=0; j<Nuv(num_prof); j++)
508 ficu2 << nu_t_temp(num_prof,j) << finl;
509 }
510 ficu2 << temps_deb << finl;
511 Cerr << "Sauvegarde de nu_t_temp a t=" << tps << finl;
512 Cerr << "Debut du calcul des stats a t=" << temps_deb << " a noter pour la reprise des stats !" << finl;
513 }
514 }
515}
516
Ecriture dans un fichier au format binaire Cette classe implemente les operateurs et les methodes vir...
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Lecture dans un fichier au format binaire.
Classe Modele_turbulence_hyd_base Cette classe sert de base a la hierarchie des classes.
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
friend class Entree
Definition Objet_U.h:76
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
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
const Objet_U & valeur() const
Definition TRUST_Ref.h:134
virtual void init_calcul_moyenne()=0
classe Traitement_particulier_NS_base Derive de Support_Champ_Masse_Volumique: utilisation de rho