TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Traitement_particulier_NS_THI_thermo_VDF.cpp
1/****************************************************************************
2* Copyright (c) 2015 - 2016, 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_THI_thermo_VDF.h>
17#include <Domaine_VDF.h>
18#include <Navier_Stokes_std.h>
19#include <Convection_Diffusion_Temperature.h>
20#include <Convection_Diffusion_Chaleur_QC.h>
21#include <Probleme_base.h>
22#include <SFichier.h>
23
24/*! @brief
25 *
26 * @param (Sortie& is) un flot de sortie
27 * @return (Sortie&) le flot de sortie modifie
28 */
30{
31 return is;
32}
33
34
35/*! @brief
36 *
37 * @param (Entree& is) un flot d'entree
38 * @return (Entree&) le flot d'entree modifie
39 */
41{
42 return is;
43}
44
45
46
47
48Implemente_instanciable(Traitement_particulier_NS_THI_thermo_VDF,"Traitement_particulier_NS_THI_thermo_VDF",Traitement_particulier_NS_THI_VDF);
49
50
52{
53
54
55 const Probleme_base& pb = mon_equation->probleme();
56 int flag=0;
57 for(int i=0; i<pb.nombre_d_equations(); i++)
58 {
59 if(sub_type(Convection_Diffusion_Temperature,pb.equation(i)))
60 {
61 mon_equation_NRJ = ref_cast(Convection_Diffusion_Temperature,pb.equation(i));
62 flag=1;
63 }
64 else if(sub_type(Convection_Diffusion_Chaleur_QC,pb.equation(i)))
65 {
66 mon_equation_NRJ = ref_cast(Convection_Diffusion_Chaleur_QC,pb.equation(i));
67 flag=1;
68 }
69 }
70 if (flag==0)
71 {
72 Cerr << "Erreur dans Traitement_particulier_NS_THI_thermo_VDF::init_calc_spectre " << finl;
73 Cerr << "L'equation d'energie n'a pas ete trouvee...!" << finl;
74 Cerr << "On ne peut pas demander de spectres sur la temperature" << finl;
75 Cerr << "si on ne resout pas une equation de la chaleur." << finl;
76 Cerr << "Solution : enlever le suffixe '_thermo'." << finl;
78 }
79
81
82}
83
84
85
86
87
89{
90
91 const Domaine_dis_base& zdis = mon_equation->domaine_dis();
92 const Domaine& domaine = zdis.domaine();
93 int nb_elem = domaine.nb_elem();
94 // double nb=pow(nb_elem*1.,1./3.);
95 // int nb_elem_dir = (int)(nb)+1;
96 calcul_nb_elem_dir(domaine);
97
98 double temps_crt = mon_equation->inconnue().temps();
99 const DoubleTab& Temp = mon_equation_NRJ->inconnue().valeurs();
100
101 int i,k;
102
103 ////////////////
104 // Ecriture du champ de temperature dans un fichier
105 // pour les calculs de spectres.
106 ////////////////
107 if (je_suis_maitre())
108 {
109 Nom fichier_temp = "chp_temperature_";
110 Nom tps = Nom(temps_crt);
111 fichier_temp += tps;
112 SFichier fic12 (fichier_temp);
113 fic12 << nb_elem_dir <<finl;
114 fic12 << nb_elem_dir <<finl;
115 fic12 << nb_elem_dir <<finl;
116
117 for (k=0; k<3; k++)
118 for (i=0; i<nb_elem; i++)
119 fic12 << Temp(i) <<finl;
120
121 sorties_fichiers();
122 }
124
125}
126
127
128
129
130void Traitement_particulier_NS_THI_thermo_VDF::sorties_fichiers()
131{
132 const Domaine_dis_base& zdis = mon_equation->domaine_dis();
133 const Domaine& domaine = zdis.domaine();
134 int nb_elem = domaine.nb_elem();
135 int i;
136
137 double temps_crt = mon_equation->inconnue().temps();
138 const DoubleTab& Temp = mon_equation_NRJ->inconnue().valeurs();
139
140 SFichier fic45("Sorties_THI_Thermo.dat",ios::app);
141
142 // Tmean est la temperature moyenne dans le bocal.
143 // Tmax_mean est le rapport entre la temperature maximale et la temperature moyenne.
144 // Tmin_mean ___________________________________ minimale _________________________.
145 // Tp2 est le carre de l'ecart de temperature local a la moyenne.
146 // ie : Tp = T-Tmean et Tp2 = Tp^2.
147 // DT est l'enstrophie sur la temperature.
148
149 double Tmean=0.,Tmax_mean=-10000.,Tmin_mean=10000.,Tp2=0.;
150 double DT=0;
151 for (i=0; i<nb_elem; i++)
152 {
153 Tmean+=Temp(i);
154 if(Temp(i)>Tmax_mean) Tmax_mean=Temp(i);
155 if(Temp(i)<Tmin_mean) Tmin_mean=Temp(i);
156 }
157
158 Tmean/=nb_elem;
159 Tmax_mean/=Tmean;
160 Tmin_mean/=Tmean;
161
162 for (i=0; i<nb_elem; i++)
163 {
164 Tp2+=(Temp(i)-Tmean)*(Temp(i)-Tmean);
165 }
166
167 Tp2/=nb_elem;
168
169 DT=calcul_enstrophie();
170
171 fic45 << temps_crt << " " << Tmean << " " << Tmax_mean << " " << Tmin_mean << " " << Tp2 << " " << DT << finl;
172
173
174 // Calcul de la PDF :
175
176 DoubleVect PDF(50);
177 PDF=1.e-10;
178 int ni=50;
179 double delta=(Tmax_mean-Tmin_mean)/ni;
180 int k;
181
182 Nom fichier_pdf = "PDF_";
183 Nom tps = Nom(temps_crt);
184 fichier_pdf += tps;
185 fichier_pdf += ".dat";
186 SFichier fic46 (fichier_pdf);
187
188 for (i=0; i<nb_elem; i++)
189 {
190 // On ne peut pas utiliser modf (voir Schema_Temps_base::limpr) car k sert d'indice de tableau
191 k=(int)(((Temp(i)/Tmean)-Tmin_mean)/delta);
192 if(k>=ni) k=ni-1;
193 if(k<0) k=0;
194 PDF[k]+=1.;
195 }
196
197 // On divise par le nombre d'elements
198 // et par la plage d'integration
199 // pour que l'integrale de la PDF soit egale a 1.
200
201 PDF/=nb_elem;
202 PDF/=delta;
203
204 for(i=0; i<ni; i++)
205 {
206 fic46 << (Tmin_mean+i*delta) << " " << PDF[i] <<finl;
207 }
208
209
210}
211
212
213double Traitement_particulier_NS_THI_thermo_VDF::calcul_enstrophie()
214{
215 const Domaine_dis_base& zdis = mon_equation->domaine_dis();
216 const Domaine& domaine = zdis.domaine();
217 const Domaine_VDF& domaine_VDF = ref_cast(Domaine_VDF,zdis);
218 int nb_elem = domaine.nb_elem();
219 const IntTab& face_voisins = domaine_VDF.face_voisins();
220 const IntTab& elem_faces = domaine_VDF.elem_faces();
221
222 const DoubleTab& Temp = mon_equation_NRJ->inconnue().valeurs();
223
224 double DT=0;
225 double gradT=0.;
226
227 int face0,face1;
228 int element0,element1;
229
230 for(int elem=0; elem<nb_elem; elem++)
231 {
232 for(int ori=0; ori<dimension; ori++)
233 {
234 gradT = 0.;
235 face0 = elem_faces(elem,ori);
236 face1 = elem_faces(elem,ori+dimension);
237 element0 = face_voisins(face0,0);
238 element1 = face_voisins(face1,1);
239 gradT += pow((Temp(element0)-Temp(elem))/domaine_VDF.dist_elem(element0,elem,ori),2);
240 gradT += pow((Temp(element1)-Temp(elem))/domaine_VDF.dist_elem(element1,elem,ori),2);
241
242 DT+=0.5*gradT;
243 }
244 }
245
246 DT=0.5*DT/nb_elem;
247
248 return DT;
249}
250
251
double dist_elem(int, int, int) const
int elem_faces(int i, int j) const
renvoie le numero de le ieme face de la maille num_elem la facon dont ces faces sont numerotees est
Definition Domaine_VF.h:543
int face_voisins(int num_face, int i) const
renvoie l'element voisin de numface dans la direction i.
Definition Domaine_VF.h:418
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
static int dimension
Definition Objet_U.h:99
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
virtual int nombre_d_equations() const =0
virtual const Equation_base & equation(int) const =0
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
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
Classe de base des flux de sortie.
Definition Sortie.h:52
classe Traitement_particulier_NS_THI_VDF Cette classe permet de faire les traitements particuliers
classe Traitement_particulier_NS_THI_thermo_VDF Cette classe permet de faire les traitements particul...
virtual void init_calc_spectre()=0
virtual void calcul_spectre()=0