TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Statistiques_dns_ijk_monophasique.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 <Statistiques_dns_ijk_monophasique.h>
17#include <IJK_Field_vector.h>
18#include <Domaine_IJK.h>
19#include <TRUSTTab.h>
20#include <communications.h>
21#include <Param.h>
22
23
24Implemente_instanciable_sans_constructeur(Statistiques_dns_ijk_monophasique,"Statistiques_dns_ijk_monophasique",Statistiques_dns_ijk);
25
26#define U_MOY 0
27#define V_MOY 1
28#define W_MOY 2
29#define P_MOY 3
30#define UU_MOY 4
31#define VV_MOY 5
32#define WW_MOY 6
33#define UV_MOY 7
34#define VW_MOY 8
35#define UW_MOY 9
36#define UP_MOY 10
37#define VP_MOY 11
38#define WP_MOY 12
39#define UUU_MOY 13
40#define VVV_MOY 14
41#define WWW_MOY 15
42#define UUV_MOY 16
43#define WWV_MOY 17
44#define U4_MOY 18
45#define V4_MOY 19
46#define W4_MOY 20
47#define dUdx_MOY 21
48#define dUdy_MOY 22
49#define dUdz_MOY 23
50#define dVdx_MOY 24
51#define dVdy_MOY 25
52#define dVdz_MOY 26
53#define dWdx_MOY 27
54#define dWdy_MOY 28
55#define dWdz_MOY 29
56#define EPS_MOY 30
57#define dUdx2_MOY 31
58#define dUdy2_MOY 32
59#define dUdz2_MOY 33
60#define dVdx2_MOY 34
61#define dVdy2_MOY 35
62#define dVdz2_MOY 36
63#define dWdx2_MOY 37
64#define dWdy2_MOY 38
65#define dWdz2_MOY 39
66
67//thermal fields
68#define T_MOY 40
69#define TU_MOY 41
70#define TV_MOY 42
71#define TW_MOY 43
72#define TUU_MOY 44
73#define TVV_MOY 45
74#define TWW_MOY 46
75#define TUV_MOY 47
76#define TUW_MOY 48
77#define TVW_MOY 49
78#define TdPdx_MOY 50
79#define TdPdy_MOY 51
80#define TdPdz_MOY 52
81#define TdUdx2_MOY 53
82#define TdUdy2_MOY 54
83#define TdUdz2_MOY 55
84#define TdVdx2_MOY 56
85#define TdVdy2_MOY 57
86#define TdVdz2_MOY 58
87#define TdWdx2_MOY 59
88#define TdWdy2_MOY 60
89#define TdWdz2_MOY 61
90#define dTdx2_MOY 62
91#define dTdy2_MOY 63
92#define dTdz2_MOY 64
93#define UdTdx2_MOY 65
94#define VdTdy2_MOY 66
95#define WdTdz2_MOY 67
96
97
98Statistiques_dns_ijk_monophasique::Statistiques_dns_ijk_monophasique()
99{
100
101 const char *noms_moyennes_prov[] =
102 {
103 "U",
104 "V",
105 "W",
106 "P",
107 "UU",
108 "VV",
109 "WW",
110 "UV",
111 "VW",
112 "UW",
113 "UP",
114 "VP",
115 "WP",
116 "UUU",
117 "VVV",
118 "WWW",
119 "UUV",
120 "WWV",
121 "U4",
122 "V4",
123 "W4",
124 "dUdx",
125 "dUdy",
126 "dUdz",
127 "dVdx",
128 "dVdy",
129 "dVdz",
130 "dWdx",
131 "dWdy",
132 "dWdz",
133 "eps",
134 "dUdx2",
135 "dUdy2",
136 "dUdz2",
137 "dVdx2",
138 "dVdy2",
139 "dVdz2",
140 "dWdx2",
141 "dWdy2",
142 "dWdz2",
143//thermal terms
144 "T",
145 "TU",
146 "TV",
147 "TW",
148 "TUU",
149 "TVV",
150 "TWW",
151 "TUV",
152 "TUW",
153 "TVW",
154 "TdPdx",
155 "TdPdy",
156 "TdPdz",
157 "TdUdx2",
158 "TdUdy2",
159 "TdUdz2",
160 "TdVdx2",
161 "TdVdy2",
162 "TdVdz2",
163 "TdWdx2",
164 "TdWdy2",
165 "TdWdz2",
166 "dTdx2",
167 "dTdy2",
168 "dTdz2",
169 "UdTdx2",
170 "VdTdy2",
171 "WdTdz2",
172 };
173 nval_=40;
174 nval_+=28; //nb of thermal fields
175 noms_moyennes_.dimensionner_force(nval_);
176 for (int i=0; i<nval_; i++)
177 noms_moyennes_[i]=noms_moyennes_prov[i];
178}
179void Statistiques_dns_ijk_monophasique::update_stat(const IJK_Field_vector3_double& vitesse,
180 const IJK_Field_double& pression,
181 const IJK_Field_double& temperature,
182 double dt)
183{
184 if (elem_coord_.size_array() == 0)
185 {
186 Cerr << "Erreur dans Statistiques_dns_ijk::update_stat: non initialise" << finl;
188 }
189 const IJK_Field_double& vitesse_i = vitesse[0];
190 const IJK_Field_double& vitesse_j = vitesse[1];
191 const IJK_Field_double& vitesse_k = vitesse[2];
192
193
194
195
196 // Nombre total de mailles en K
197 const int nktot = pression.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
198
199 // Nombre local de mailles en K
200 const int kmax = pression.nk();
201 const int offset = pression.get_domaine().get_offset_local(DIRECTION_K);
202
203 DoubleTab tmp(nktot, nval_);
204 const int imax = pression.ni();
205 const int jmax = pression.nj();
206
207 for (int k = 0; k < kmax; k++)
208 {
209 const double dz = tab_dz_[k+offset];
210 bool on_the_first_cell = false;
211 bool on_the_last_cell = false;
212 if (k + offset == 0)
213 on_the_first_cell = true;
214 if (k + offset == nktot)
215 on_the_last_cell = true;
216 // Calcul des moyennes spatiales sur le plan ij
217
218 // On y stocke la somme de toutes les valeurs sur le plan ij, on divisera apres
219 ArrOfDouble moy(nval_);
220 for (int i = 0; i < nval_; i++)
221 {
222 moy[i] = 0.;
223 }
224 for (int j = 0; j < jmax; j++)
225 {
226 for (int i = 0; i < imax; i++)
227 {
228 // Vitesses au centre de la maille i,j,k
229 // On peut ici interpoler plus finement si on veut:
230 double u = (vitesse_i(i,j,k) + vitesse_i(i+1, j, k)) * 0.5;
231 double v = (vitesse_j(i,j,k) + vitesse_j(i, j+1, k)) * 0.5;
232 double w = (vitesse_k(i,j,k) + vitesse_k(i, j, k+1)) * 0.5;
233 double p = pression(i,j,k);
234 double T = temperature(i,j,k);
235
236 // ******************************** //
237 // double duidx, dujdx, dukdx, duidy, dujdy, dukdy, duidz, dujdz, dukdz, dissip;
238 double duidx=0., dujdx=0., dukdx=0., duidy=0., dujdy=0., dukdy=0., duidz=0., dujdz=0., dukdz=0., dissip;
239 dissip = face_to_cell_gradient(vitesse_i, vitesse_j, vitesse_k,
240 i,j,k,
241 dz,
242 duidx, dujdx, dukdx,
243 duidy, dujdy, dukdy,
244 duidz, dujdz, dukdz,
245 on_the_first_cell, on_the_last_cell,
246 0 /* bc_type for velocity : 0 at the wall */);
247
248#define AJOUT(somme,val) moy[somme] += val
249 // moyennes
250 AJOUT(U_MOY,u);
251 AJOUT(V_MOY,v);
252 AJOUT(W_MOY,w);
253 AJOUT(P_MOY,p);
254 // moyennes des carres
255 AJOUT(UU_MOY,u*u);
256 AJOUT(VV_MOY,v*v);
257 AJOUT(WW_MOY,w*w);
258 // correlations
259 AJOUT(UV_MOY,u*v);
260 AJOUT(VW_MOY,v*w);
261 AJOUT(UW_MOY,u*w);
262 AJOUT(UP_MOY,u*p);
263 AJOUT(VP_MOY,v*p);
264 AJOUT(WP_MOY,w*p);
265 // 3 eme ordre
266 AJOUT(UUU_MOY,u*u*u);
267 AJOUT(VVV_MOY,v*v*v);
268 AJOUT(WWW_MOY,w*w*w);
269 AJOUT(UUV_MOY,u*u*v);
270 AJOUT(WWV_MOY,w*w*v);
271 // 4 eme ordre
272 AJOUT(U4_MOY,u*u*u*u);
273 AJOUT(V4_MOY,v*v*v*v);
274 AJOUT(W4_MOY,w*w*w*w);
275 // derivees
276 AJOUT(dUdx_MOY, duidx);
277 AJOUT(dUdy_MOY, duidy);
278 AJOUT(dUdz_MOY, duidz);
279 AJOUT(dVdx_MOY, dujdx);
280 AJOUT(dVdy_MOY, dujdy);
281 AJOUT(dVdz_MOY, dujdz);
282 AJOUT(dWdx_MOY, dukdx);
283 AJOUT(dWdy_MOY, dukdy);
284 AJOUT(dWdz_MOY, dukdz);
285 AJOUT(EPS_MOY, dissip);
286 AJOUT(dUdx2_MOY, duidx*duidx);
287 AJOUT(dUdy2_MOY, duidy*duidy);
288 AJOUT(dUdz2_MOY, duidz*duidz);
289 AJOUT(dVdx2_MOY, dujdx*dujdx);
290 AJOUT(dVdy2_MOY, dujdy*dujdy);
291 AJOUT(dVdz2_MOY, dujdz*dujdz);
292 AJOUT(dWdx2_MOY, dukdx*dukdx);
293 AJOUT(dWdy2_MOY, dukdy*dukdy);
294 AJOUT(dWdz2_MOY, dukdz*dukdz);
295
296 //thermique
297 AJOUT(T_MOY,T);
298
299
300#undef AJOUT
301 }
302 }
303 // facteur 1./(ni*nj) car sommation de ni*nj valeurs sur des mailles de meme taille
304 // facteur delta_z / taille_totale_en_z car mailles non uniformes en z
305 const int ni_tot = pression.get_domaine().get_nb_elem_tot(DIRECTION_I);
306 const int nj_tot = pression.get_domaine().get_nb_elem_tot(DIRECTION_J);
307
308 double facteur = 1./(double)(ni_tot * nj_tot);
309
310 for (int i = 0; i < nval_; i++)
311 tmp(k + offset, i) = moy[i] * facteur;
312 }
313 // Somme sur tous les processeurs:
315
316 // Sur processeur 0, ajout de la contribution a l'integrale temporelle:
318 {
319 for (int i = 0; i < nval_; i++)
320 {
321 for (int k = 0; k < nktot; k++)
322 {
323 integrale_temporelle_[i][k] += tmp(k, i) * dt;
324 moyenne_spatiale_instantanee_[i][k] = tmp(k, i);
325 }
326 }
327 t_integration_ += dt;
328 }
329}
330
331
332// Impression des donnees pour reprise
334{
336 return os;
337}
338
339// Reprise des donnees stat dans un fichier reprise
340// Attention, cette methode peut etre appelee avant initialize() !
342{
344 return is;
345}
346// Attention, cette methode est appelee apres readOn(),
347// il ne faut pas casser les donnees lues
349{
350 dx_=geom.get_constant_delta(0); //modif AT 20/06/2013
351 dy_=geom.get_constant_delta(1); //modif AT 20/06/2013
352 tab_dz_=geom.get_delta(2); //modif GB 30/10/2014
353 // dz_=geom.get_constant_delta(2); //modif GB 07/05/2014
354 const int n = geom.get_nb_elem_tot(DIRECTION_K);
355 elem_coord_.resize_array(n);
356 int i;
357 const ArrOfDouble& coord_z = geom.get_node_coordinates(DIRECTION_K);
358 for (i = 0; i < n; i++)
359 elem_coord_[i] = (coord_z[i] + coord_z[i+1]) * 0.5;
360
362 {
363 moyenne_spatiale_instantanee_.dimensionner(nval_);
364 for (i = 0; i < nval_; i++)
365 {
366 moyenne_spatiale_instantanee_[i].resize_array(n);
367 }
368 // moyenne_spatiale_instantanee_[WFACE_MOY].resize_array(n+1);//En effet, il y a une face de plus que d'elem et ce tableau est au face
369 }
370
371 int flag = 0;
372 if (integrale_temporelle_.size() == 0)
373 {
374 integrale_temporelle_.dimensionner(nval_);
375 t_integration_ = 0.;
376 }
377 else
378 flag = 1;
379 for (i = 0; i < nval_; i++)
380 {
381 if (flag)
382 {
383 if (integrale_temporelle_[i].size_array() != n)
384 {
385 Cerr << "Erreur dans Statistiques_dns_ijk::initialize: reprise avec mauvais nombre de mailles en z" << finl;
387 }
388 }
389 else
390 {
391 integrale_temporelle_[i].resize_array(n);
392
393 }
394 }
395 //modif AT 20/06/2013
396 if (check_converge_)
397 {
398 //on recupere les vitesses moyennes aux faces pour calculerles fluctuations de vitesse.
399 vit_moy_.dimensionner(3);
400 for (i = 0; i < 3; i++)
401 vit_moy_[i].resize_array(n);
402
403 vit_moy_[0]=integrale_temporelle_[0];
404 vit_moy_[1]=integrale_temporelle_[1];
405 vit_moy_[2]=integrale_temporelle_[40];//car on veut w aux faces !
406
407
408 }
409
410}
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
Definition Domaine_IJK.h:47
double get_constant_delta(int direction) const
Returns the size of cells in a direction.
const ArrOfDouble & get_delta(int direction) const
Returns the array of mesh cell sizes in requested direction.
int get_nb_elem_tot(int direction) const
Returns the total (global) number of mesh cells in requested direction.
const ArrOfDouble & get_node_coordinates(int direction) const
Returns an array with the coordinates of all nodes in the mesh in requested direction.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
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 mp_sum_for_each_item(TRUSTArray< _TYPE_ > &x, int n=-1)
Definition Process.cpp:193
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
void update_stat(const IJK_Field_vector3_double &vitesse, const IJK_Field_double &pression, const IJK_Field_double &temperature, double dt)
double face_to_cell_gradient(const IJK_Field_double &vitesse_i, const IJK_Field_double &vitesse_j, const IJK_Field_double &vitesse_k, const int i, const int j, const int k, const double dz, double &duidx, double &dujdx, double &dukdx, double &duidy, double &dujdy, double &dukdy, double &duidz, double &dujdz, double &dukdz, const bool on_the_first_cell, const bool on_the_last_cell, const int bc_type) const