TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Traitement_particulier_Solide_canal_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_Solide_canal_VDF.h>
17#include <EcrFicCollecteBin.h>
18#include <communications.h>
19#include <Champ_Uniforme.h>
20#include <Champ_Face_VDF.h>
21#include <Probleme_base.h>
22#include <Domaine_Cl_VDF.h>
23#include <Conduction.h>
24#include <TRUSTTrav.h>
25#include <Domaine_VDF.h>
26
28{
29 return is;
30}
31
32
34{
35 return is;
36}
37
42
43
44
45
46
47Implemente_instanciable(Traitement_particulier_Solide_canal_VDF,"Traitement_particulier_Solide_canal_VDF",Traitement_particulier_Solide_canal);
48
49
50
51// #################### Postraitement Statistique du Champ de Temperature #########
52
54{
55
56 DoubleTrav Tmoy(N);
57 Tmoy=0.;
58 DoubleTrav Trms(N);
59 Trms=0.;
60
61 double tps = mon_equation->inconnue().temps();
62
63 // Moyennes spatiales :
65
66 static double temps_dern_post_inst = -100.;
67 if (std::fabs(tps-temps_dern_post_inst)>=dt_post_inst)
68 {
70 temps_dern_post_inst = tps;
71 }
72
73
74 // Moyennes temporelles :
75 if ((tps>=temps_deb)&&(tps<=temps_fin))
76 {
77 static int init_stat_temps = 0;
78 if(init_stat_temps==0)
79 {
80 double dt_v = mon_equation->schema_temps().pas_de_temps();
81 temps_deb = tps-dt_v;
82 init_stat_temps++;
83 }
84
87
88 static double temps_dern_post_stat = -100.;
89 if (std::fabs(tps-temps_dern_post_stat)>=dt_post_stat)
90 {
91 double dt = tps-temps_deb;
93 temps_dern_post_stat = tps;
94 }
95 }
96}
97
98
99
100
101
102// #################### Calcul Moyennes Spatiales #################################
103
104void Traitement_particulier_Solide_canal_VDF::calculer_moyennes_spatiales_thermo(DoubleVect& tmoy, DoubleVect& trms,const DoubleVect& tabY, IntVect& tab_corresp, IntVect& tab_compt)
105{
106
107 const Domaine_dis_base& zdisbase=mon_equation->inconnue().domaine_dis_base();
108 const Domaine_VDF& domaine_VDF=ref_cast(Domaine_VDF, zdisbase);
109
110 // Le nombre d'elements du domaine VDF.
111 int nb_elems = domaine_VDF.domaine().nb_elem();
112
113 // On veut acceder aux valeurs de la temperature a partir de mon_equation_NRJ.
114 const DoubleTab& Temp = mon_equation->inconnue().valeurs();
115
116 // t2moy correspond
117 DoubleTrav t2moy(N);
118 t2moy = 0.;
119
120
121 int num_elem,j;
122
123 // tmoy est la moyenne de T : <T>(y,t)
124 tmoy = 0.;
125 // trms est l'ecart-type de la temperature : sqrt(<Tp*Tp>)(y,t)=<T*T>-<T*T>
126 trms = 0.;
127
128 // On parcourt tous les elements pour faire toutes les moyennes au centre des elements.
129 for (num_elem=0; num_elem<nb_elems; num_elem++)
130 {
131 // <T>
132 tmoy[tab_corresp[num_elem]] += Temp[num_elem];
133 // Trms : en fait ici on calcule <T*T> mais ensuite on va soustraire la partie <T*T>
134 trms[tab_corresp[num_elem]] += Temp[num_elem]*Temp[num_elem];
135 }
136
137
138 // POUR LE PARALLELE !!
139 IntVect compt_p(tab_compt);
140 envoyer(compt_p,Process::me(),0,Process::me());
141
142 DoubleVect tmoy_p(tmoy);
143 envoyer(tmoy_p,Process::me(),0,Process::me());
144
145 DoubleVect trms_p(trms);
146 envoyer(trms_p,Process::me(),0,Process::me());
147
148 if(je_suis_maitre())
149 {
150 IntVect compt_tot(tab_compt);
151 DoubleVect tmoy_tot(tmoy);
152 DoubleVect trms_tot(trms);
153
154 compt_tot=0;
155 tmoy_tot=0.;
156 trms_tot=0.;
157
158 for(int p=0; p<Process::nproc(); p++)
159 {
160 recevoir(compt_p,p,0,p);
161 compt_tot+=compt_p;
162
163 recevoir(tmoy_p,p,0,p);
164 tmoy_tot+=tmoy_p;
165
166 recevoir(trms_p,p,0,p);
167 trms_tot+=trms_p;
168 }
169
170 // compt[j] correspond au nombre d'elements qui ont ete utilises pour calculer une meme valeur de temperature moyenne,
171 // ie le nombre d'elements ayant la meme coordonnee Y.
172 for (j=0; j<N; j++)
173 {
174 tmoy[j] = tmoy_tot[j] / compt_tot[j];
175 trms[j] = trms_tot[j] / compt_tot[j];
176
177 trms[j] -= tmoy[j]*tmoy[j];
178 }
179 }
180
181}
182
183
184
185// #################### Calcul Integrale Temporelle ###############################
186
187void Traitement_particulier_Solide_canal_VDF::calculer_integrales_temporelles(DoubleVect& moy_temp, const DoubleVect& moy_spat)
188{
189 double dt_v = mon_equation->schema_temps().pas_de_temps();
190 if(je_suis_maitre())
191 ////moy_temp.ajoute(dt_v,moy_spat);
192 moy_temp.ajoute_sans_ech_esp_virt(dt_v,moy_spat);
193}
194
195
196
197
198
199// #################### Ecriture Moyennes Spatiales dans Fichier ##################
200
201void Traitement_particulier_Solide_canal_VDF::ecriture_fichier_moy_spat_thermo(const DoubleVect& Tmoy, const DoubleVect& Trms,const DoubleVect& tabY)
202{
203 Nom nom_fic = "Solid_spat_";
204 double tps = mon_equation->inconnue().temps();
205 Nom temps = Nom(tps);
206
207 nom_fic+= temps;
208 nom_fic+=".dat";
209
210 if(je_suis_maitre())
211 {
212 SFichier fic (nom_fic);
213 fic << "# Space Averaged Statistics in the Solid" << finl ;
214 fic << "# Y <T> Trms " << finl ;
215 fic.precision(6);
216
217 for (int j=0; j<N ; j++)
218 fic << tabY[j] << " " << Tmoy[j] << " " << sqrt(Trms[j]) << finl;
219
220 fic.flush();
221 fic.close();
222 } // FIN du maitre
223}
224
225
226
227
228
229// #################### Ecriture Moyennes temporelles dans Fichier ################
230
231void Traitement_particulier_Solide_canal_VDF::ecriture_fichier_moy_temp_thermo(const DoubleVect& Tmoy, const DoubleVect& Trms, const DoubleVect& tabY, const double dt)
232{
233 Nom nom_fic = "Solid_temp_";
234 double tps = mon_equation->inconnue().temps();
235 Nom temps = Nom(tps);
236
237 nom_fic+= temps;
238 nom_fic+=".dat";
239
240 if(je_suis_maitre())
241 {
242 SFichier fic (nom_fic);
243 fic << "# Time Averaged Statistics in the Solid" << finl ;
244 fic << "# Y <T> Trms " << finl ;
245 fic.precision(6);
246
247 for (int j=0; j<N ; j++)
248 fic << tabY[j] << " " << Tmoy[j]/dt << " " << sqrt(Trms[j]/dt) << finl;
249 fic.flush();
250 fic.close();
251
252 } // FIN du maitre
253}
254
255
256
264
265
266
268{
269 const Domaine_dis_base& zdisbase=mon_equation->inconnue().domaine_dis_base();
270 const Domaine_VDF& domaine_VDF=ref_cast(Domaine_VDF, zdisbase);
271
272 const DoubleTab& xp = domaine_VDF.xp();
273
274 int nb_elems = domaine_VDF.domaine().nb_elem();
275
276 int num_elem,j,indic,trouve;
277 double y;
278 j=0;
279 indic = 0;
280
281 // dimensionnement aux valeurs rentrees dans le jeu de donnees
282 Y.resize(N);
283 compt.resize(N);
284 corresp.resize(nb_elems);
285
286 Y = -100.;
287 compt = 0;
288 corresp = -1;
289
290 for (num_elem=0; num_elem<nb_elems; num_elem++)
291 {
292 y = xp(num_elem,1);
293 trouve = 0;
294
295 for (j=0; j<indic+1; j++)
296 {
297 if(y==Y[j])
298 {
299 corresp[num_elem] = j;
300 compt[j] ++;
301 j=indic+1;
302 trouve = 1;
303 break;
304 }
305 }
306 if (trouve==0)
307 {
308 corresp[num_elem] = indic;
309 Y[indic]=y;
310 compt[indic] ++;
311 indic++;
312 }
313 }
314 N = indic; // nombre de y pour Temperature
315
316 Y.resize(N);
317
318 compt.resize(N);
319}
320
321
322
323
int_t nb_elem() const
Definition Domaine.h:131
class Domaine_VDF
Definition Domaine_VDF.h:64
double xp(int num_elem, int k) const
Definition Domaine_VF.h:77
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
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 int nproc()
renvoie le nombre de processeurs dans le groupe courant Voir Comm_Group::nproc() et PE_Groups::curren...
Definition Process.cpp:104
static int me()
renvoie mon rang dans le groupe de communication courant.
Definition Process.cpp:125
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
Definition Process.cpp:86
Cette classe est a la classe C++ ofstream ce que la classe Sortie est a la classe C++ ostream Elle re...
Definition SFichier.h:27
Sortie & flush() override
Force l'ecriture sur disque des donnees dans le tampon Utilise l'implementation de la classe ofstream...
void precision(int pre) override
Classe de base des flux de sortie.
Definition Sortie.h:52
void ajoute_sans_ech_esp_virt(_SCALAR_TYPE_ alpha, const TRUSTVect &y, Mp_vect_options opt=VECT_REAL_ITEMS)
classe Traitement_particulier_Solide_canal_VDF Cette classe permet de faire les traitements particuli...
void ecriture_fichier_moy_spat_thermo(const DoubleVect &, const DoubleVect &, const DoubleVect &)
void ecriture_fichier_moy_temp_thermo(const DoubleVect &, const DoubleVect &, const DoubleVect &, const double)
void calculer_integrales_temporelles(DoubleVect &moy_temp, const DoubleVect &moy_spat)
void calculer_moyennes_spatiales_thermo(DoubleVect &tmoy, DoubleVect &trms, const DoubleVect &Y, IntVect &corresp, IntVect &compt)
classe Traitement_particulier_Solide_canal