TrioCFD 1.9.9_beta
TrioCFD documentation
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 // Temporal averages:
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// #################### Compute Spatial Averages #################################
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 // The number of elements in the VDF domain.
111 int nb_elems = domaine_VDF.domaine().nb_elem();
112
113 // Access the temperature values from mon_equation_NRJ.
114 const DoubleTab& Temp = mon_equation->inconnue().valeurs();
115
116 // t2moy corresponds to
117 DoubleTrav t2moy(N);
118 t2moy = 0.;
119
120
121 int num_elem,j;
122
123 // tmoy is the mean of T : <T>(y,t)
124 tmoy = 0.;
125 // trms is the standard deviation of temperature : sqrt(<Tp*Tp>)(y,t)=<T*T>-<T*T>
126 trms = 0.;
127
128 // We iterate over all elements to compute all averages at element centers.
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 : here we actually compute <T*T> but then we will subtract the <T*T> part
134 trms[tab_corresp[num_elem]] += Temp[num_elem]*Temp[num_elem];
135 }
136
137
138 // FOR PARALLEL !!
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] is the number of elements used to compute a given mean temperature value,
171 // i.e. the number of elements sharing the same Y coordinate.
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// #################### Compute Temporal Integral ###############################
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// #################### Writing Spatial Averages to File ##################
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 } // END of master
223}
224
225
226
227
228
229// #################### Writing Temporal Averages to File ################
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 } // END of master
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 // sizing according to the values provided in the data set
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; // number of y values for 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:61
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
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:71
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 int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
Definition Process.cpp:122
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 precision(int pre) override
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)
Traitement_particulier_Solide_canal_VDF class This class performs special post-processing operations.
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)
Special post-processing treatment for solid channel configurations.