TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
DNS.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#include <DNS.h>
16#include <IJK_Field_vector.h>
17#include <Param.h>
18#include <Interprete_bloc.h>
19#include <SFichier.h>
20#include <algorithm>
21#include <alloca.h>
22#include <IJK_Lata_writer.h>
23#include <IJK_Navier_Stokes_tools.h>
24#include <communications.h>
25#include <LecFicDiffuse_JDD.h>
26#include <SFichier.h>
27#include <EFichier.h>
28#include <Boundary_Conditions.h>
29#include <DebogIJK.h>
30#include <Perf_counters.h>
31#include <Turbulent_viscosity.h>
32#include <Filter_kernel.h>
33using std::min;
34using std::max;
35// Reste a faire:
36// ajouter terme u_div_rho_u dans convection vitesse
37// verifier quick en paroi (=> passer a l'ordre 1)
38
39Implemente_instanciable(DNS_QC_double, "DNS_QC_double", Interprete);
40// XD DNS_QC_double interprete DNS_QC_double INHERITS_BRACE not_set
41// XD attr bloc bloc_lecture bloc REQ not_set
42
43
45{
46 return s;
47}
49{
50 return s;
51}
52
53
54// Programme principal pour le calcul DNS QC sur SuperMUC
55
56// formule pour gnuplot
57// lambda(x)=(((((x*(-5.05628e-18)+2.469e-14 ) *x-4.98344e-11)*x)+7.06714e-08)*x+1.0894e-06)*1.93198026315789000e-3 / 1.461e-6
58// mu(x)=(((((x*(-5.05628e-18)+2.469e-14 ) *x-4.98344e-11)*x)+7.06714e-08)*x+1.0894e-06)
59static inline double calculer_lambda_air(double temperature)
60{
61 const double fac_a = -5.05628e-18;
62 const double fac_b = 2.469e-14;
63 const double fac_c = -4.98344e-11;
64 const double fac_d = 7.06714e-08;
65 const double fac_e = 1.0894e-06;
66 const double facteur = 1.93198026315789000e-3 / 1.461e-6;
67
68 double val = temperature;
69 double calc = val * fac_a + fac_b;
70 calc = val * calc + fac_c;
71 calc = val * calc + fac_d;
72 calc = val * calc + fac_e;
73 return calc * facteur;
74}
75
76static inline void choix_filter_kernel(const int ghost_size,
77 const Nom& filter_kernel_name,
78 Filter_kernel_base*& filter_kernel)
79{
80 // Choose a filter_kernel to compute the filter.
81 // Note: THE CALLER _MUdouble_ FREE THE MEMORY USING DELETE.
82 // example of use :
83 // Filter_kernel_base* filter_kernel = nullptr;
84 // choix_filter_kernel(ghost_size, filter_kernel_name, filter_kernel);
85 // /* do something with filter_kernel */
86 // delete filter_kernel;
87
88 if ( filter_kernel_name == Nom("box") )
89 {
90 filter_kernel = new Filter_kernel_box(ghost_size);
91 }
92 else if ( filter_kernel_name == Nom("weight_13_13_pondere") )
93 {
94 filter_kernel = new Filter_kernel_weight_13_13_pondere(ghost_size);
95 }
96 else if ( filter_kernel_name == Nom("weight_13_13_sansponderation") )
97 {
98 filter_kernel = new Filter_kernel_weight_13_13_sansponderation(ghost_size);
99 }
100 else if ( filter_kernel_name == Nom("weight_13_13_conservatif") )
101 {
102 filter_kernel = new Filter_kernel_weight_13_13_conservatif(ghost_size);
103 }
104 else if ( filter_kernel_name == Nom("weight_12_14_pondere") )
105 {
106 filter_kernel = new Filter_kernel_weight_12_14_pondere(ghost_size);
107 }
108 else if ( filter_kernel_name == Nom("weight_12_14_sansponderation") )
109 {
110 filter_kernel = new Filter_kernel_weight_12_14_sansponderation(ghost_size);
111 }
112 else if ( filter_kernel_name == Nom("weight_12_14_conservatif") )
113 {
114 filter_kernel = new Filter_kernel_weight_12_14_conservatif(ghost_size);
115 }
116 else if ( filter_kernel_name == Nom("weight_23_16_pondere") )
117 {
118 filter_kernel = new Filter_kernel_weight_23_16_pondere(ghost_size);
119 }
120 else if ( filter_kernel_name == Nom("weight_23_16_sansponderation") )
121 {
122 filter_kernel = new Filter_kernel_weight_23_16_sansponderation(ghost_size);
123 }
124 else if ( filter_kernel_name == Nom("weight_23_16_conservatif") )
125 {
126 filter_kernel = new Filter_kernel_weight_23_16_conservatif(ghost_size);
127 }
128 else if ( filter_kernel_name == Nom("weight_14_14_18_pondere") )
129 {
130 filter_kernel = new Filter_kernel_weight_14_14_18_pondere(ghost_size);
131 }
132 else if ( filter_kernel_name == Nom("weight_14_14_18_sansponderation") )
133 {
134 filter_kernel = new Filter_kernel_weight_14_14_18_sansponderation(ghost_size);
135 }
136 else if ( filter_kernel_name == Nom("weight_14_14_18_conservatif") )
137 {
138 filter_kernel = new Filter_kernel_weight_14_14_18_conservatif(ghost_size);
139 }
140 else if ( filter_kernel_name == Nom("weight_15_15_15_pondere") )
141 {
142 filter_kernel = new Filter_kernel_weight_15_15_15_pondere(ghost_size);
143 }
144 else if ( filter_kernel_name == Nom("weight_15_15_15_sansponderation") )
145 {
146 filter_kernel = new Filter_kernel_weight_15_15_15_sansponderation(ghost_size);
147 }
148 else if ( filter_kernel_name == Nom("weight_15_15_15_conservatif") )
149 {
150 filter_kernel = new Filter_kernel_weight_15_15_15_conservatif(ghost_size);
151 }
152 else if ( filter_kernel_name == Nom("weight_16_16_16_112_pondere") )
153 {
154 filter_kernel = new Filter_kernel_weight_16_16_16_112_pondere(ghost_size);
155 }
156 else if ( filter_kernel_name == Nom("weight_16_16_16_112_sansponderation") )
157 {
158 filter_kernel = new Filter_kernel_weight_16_16_16_112_sansponderation(ghost_size);
159 }
160 else if ( filter_kernel_name == Nom("weight_16_16_16_112_conservatif") )
161 {
162 filter_kernel = new Filter_kernel_weight_16_16_16_112_conservatif(ghost_size);
163 }
164 else if ( filter_kernel_name == Nom("weight_14_38_pondere") )
165 {
166 filter_kernel = new Filter_kernel_weight_14_38_pondere(ghost_size);
167 }
168 else if ( filter_kernel_name == Nom("weight_14_38_sansponderation") )
169 {
170 filter_kernel = new Filter_kernel_weight_14_38_sansponderation(ghost_size);
171 }
172 else if ( filter_kernel_name == Nom("weight_14_38_conservatif") )
173 {
174 filter_kernel = new Filter_kernel_weight_14_38_conservatif(ghost_size);
175 }
176 else if ( filter_kernel_name == Nom("laplacian") )
177 {
178 filter_kernel = new Filter_kernel_laplacian(ghost_size);
179 }
180 else
181 {
182 Cerr << "Error: (Inconsistent parameters) "
183 << "The large eddy simulation model requires filtering but the filter kernel name is unknown or unspecified. "
184 << "To specify a filter kernel, you may use the keyword FILTER_KERNEL_NAME with the parameters BOX, GAUSSIAN, GAUSSIAN2, LAPLACIAN_SIMPLE, LAPLACIAN or NONE." << finl;
186 }
187}
188
189static inline void choix_modele(const Nom& turbulent_viscosity_model,
191{
192 // Choose a model to compute the turbulent viscosity.
193 // Note: THE CALLER _MUdouble_ FREE THE MEMORY USING DELETE.
194 // example of use :
195 // Turbulent_viscosity_base* model = nullptr;
196 // choix_modele(turbulent_viscosity_model, model);
197 // /* do something with model */
198 // delete model;
199
200 if ( turbulent_viscosity_model == Nom("constant") )
201 {
203 }
204 else if ( turbulent_viscosity_model == Nom("unsrho") )
205 {
206 model = new Turbulent_viscosity_unsrho;
207 }
208 else if ( turbulent_viscosity_model == Nom("smagorinsky") )
209 {
211 }
212 else if ( turbulent_viscosity_model == Nom("vreman") )
213 {
214 model = new Turbulent_viscosity_vreman;
215 }
216 else if ( turbulent_viscosity_model == Nom("sigma") )
217 {
218 model = new Turbulent_viscosity_sigma;
219 }
220 else if ( turbulent_viscosity_model == Nom("wale") )
221 {
222 model = new Turbulent_viscosity_wale;
223 }
224 else if ( turbulent_viscosity_model == Nom("amd") )
225 {
226 model = new Turbulent_viscosity_amd;
227 }
228 else if ( turbulent_viscosity_model == Nom("amd_comp") )
229 {
231 }
232 else if ( turbulent_viscosity_model == Nom("amdnoclip") )
233 {
235 }
236 else if ( turbulent_viscosity_model == Nom("amdscalar") )
237 {
239 }
240 else if ( turbulent_viscosity_model == Nom("amdscalarnoclip") )
241 {
243 }
244 else if ( turbulent_viscosity_model == Nom("rds") )
245 {
246 model = new Turbulent_viscosity_rds;
247 }
248 else if ( turbulent_viscosity_model == Nom("vss") )
249 {
250 model = new Turbulent_viscosity_vss;
251 }
252 else if ( turbulent_viscosity_model == Nom("kobayashi") )
253 {
255 }
256 else
257 {
258 Cerr << "The turbulent diffusion model name is unknown." << finl;
260 }
261}
262
263void calculer_delta_z_pour_delta(const Domaine_IJK& splitting,
264 const Domaine_IJK& geom_pour_delta,
265 const int ghost_size,
266 ArrOfDouble_with_ghost& delta_z_pour_delta)
267{
268 const int nktot = splitting.get_nb_elem_tot(DIRECTION_K);
269 const ArrOfDouble& coord_z = splitting.get_node_coordinates(DIRECTION_K);
270 ArrOfDouble elem_coord(nktot);
271 for (int i = 0; i < nktot; i++)
272 {
273 elem_coord[i] = 0.5 * (coord_z[i] + coord_z[i+1]);
274 }
275
276 const int nktot_pour_delta = geom_pour_delta.get_nb_elem_tot(DIRECTION_K);
277 const ArrOfDouble& global_delta_pour_delta = geom_pour_delta.get_delta(DIRECTION_K);
278 const ArrOfDouble& coord_z_pour_delta = geom_pour_delta.get_node_coordinates(DIRECTION_K);
279 ArrOfDouble elem_coord_pour_delta(nktot_pour_delta);
280 for (int i = 0; i < nktot_pour_delta; i++)
281 {
282 elem_coord_pour_delta[i] = 0.5 * (coord_z_pour_delta[i] + coord_z_pour_delta[i+1]);
283 }
284
285 const int offset = splitting.get_offset_local(DIRECTION_K);
286 const int nk = splitting.get_nb_elem_local(DIRECTION_K);
287 delta_z_pour_delta.resize(nk, ghost_size);
288
289 double d0 = 0.;
290 double d1 = 0.;
291 double coord_0 = 0.;
292 double coord_1 = 0.;
293 int kg_1 = - ghost_size;
294 for (int k = -ghost_size; k < nk + ghost_size; k++)
295 {
296 const int kg = k + offset;
297
298 double coord;
299 if (kg < 0)
300 {
301 coord = elem_coord[0];
302 }
303 else if (kg >= nktot)
304 {
305 coord = elem_coord[nktot - 1];
306 }
307 else
308 {
309 coord = elem_coord[kg];
310 }
311
312 while (coord_1 < coord)
313 {
314 d0 = d1;
315 coord_0 = coord_1;
316
317 if (kg_1 < 0)
318 {
319 d1 = 0.;
320 coord_1 = coord_z_pour_delta[0];
321 }
322 else if (kg_1 >= nktot_pour_delta)
323 {
324 d1 = 0.;
325 coord_1 = coord_z_pour_delta[nktot_pour_delta];
326 }
327 else
328 {
329 d1 = global_delta_pour_delta[kg_1];
330 coord_1 = elem_coord_pour_delta[kg_1];
331 }
332
333 kg_1++;
334 }
335
336 if (coord_1 == coord_0)
337 {
338 if (coord_1 != coord || d0 != d1)
339 {
340 Cerr << "Ce n'est pas normal." << finl;
342 }
343 else
344 {
345 delta_z_pour_delta[k] = d0;
346 }
347 }
348 else
349 {
350 delta_z_pour_delta[k] = d0 + (d1 - d0)/(coord_1 - coord_0)*(coord - coord_0);
351 }
352 }
353}
354
355void calculer_delta_z_filtre_identique(const Domaine_IJK& splitting,
356 const ArrOfDouble_with_ghost& delta_z_pour_delta,
357 ArrOfDouble_with_ghost& delta_z_filtre)
358{
359 const int nk = splitting.get_nb_items_local(Domaine_IJK::FACES_K, DIRECTION_K);
360 const int nktot = splitting.get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
361 const int offset = splitting.get_offset_local(DIRECTION_K);
362
363 for (int k = 0; k < nk; k++)
364 {
365 const int kg = k + offset;
366 const double dz_pour_delta = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
367 delta_z_filtre[k] = sqrt(dz_pour_delta*dz_pour_delta + dz_pour_delta*dz_pour_delta);
368 }
369}
370
371void calculer_delta_z_filtre_n_mailles(const int taille_filtre,
372 const Domaine_IJK& splitting,
373 const ArrOfDouble_with_ghost& delta_z,
374 const ArrOfDouble_with_ghost& delta_z_pour_delta,
375 ArrOfDouble_with_ghost& delta_z_filtre)
376{
377 Cerr << "Taille du filtre explicite fixee a " << taille_filtre << " mailles." << finl;
378
379 const int nk = splitting.get_nb_items_local(Domaine_IJK::FACES_K, DIRECTION_K);
380 const int nktot = splitting.get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
381 const int offset = splitting.get_offset_local(DIRECTION_K);
382
383 const bool impair = (taille_filtre%2 != 0);
384 const int kp_min = impair ? (taille_filtre-1)/2 : (taille_filtre-2)/2;
385 const int kp_max = impair ? (taille_filtre-1)/2 : (taille_filtre-2)/2;
386
387 for (int k = 0; k < nk; k++)
388 {
389 const int kg = k + offset;
390
391 double longueur_elem = 0.;
392 for (int kp = -kp_min; kp < kp_max+1; kp++)
393 {
394 const int kpg = kg + kp;
395 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
396 longueur_elem += dz;
397 }
398
399 if (!impair)
400 {
401 {
402 const int kp = -kp_min - 1;
403 const int kpg = kg + kp;
404 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
405 longueur_elem += dz;
406 }
407 {
408 const int kp = kp_max + 1;
409 const int kpg = kg + kp;
410 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
411 longueur_elem += dz;
412 }
413 }
414 const double dz_pour_delta = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
415 delta_z_filtre[k] = sqrt(longueur_elem*longueur_elem + dz_pour_delta*dz_pour_delta);
416 }
417}
418
419// On suppose que rho a un espace virtuel a jour sur au moins l'epaisseur de joint demandee.
420void calculer_temperature_mu_lambda_air(const double P_th,
421 const double constante_specifique_gaz,
422 const IJK_Field_double& rho,
423 IJK_Field_double& temperature,
424 IJK_Field_double& molecular_mu,
425 IJK_Field_double& molecular_lambda,
426 int epaisseur_joint)
427{
428 const int imax = rho.ni() + epaisseur_joint;
429 const int jmax = rho.nj() + epaisseur_joint;
430 const int kmax = rho.nk() + epaisseur_joint;
431
432 const double fac_a = -5.05628e-18;
433 const double fac_b = 2.469e-14;
434 const double fac_c = -4.98344e-11;
435 const double fac_d = 7.06714e-08;
436 const double fac_e = 1.0894e-06;
437
438 const double facteur = 1.93198026315789000e-3 / 1.461e-6;
439
440 const double facteur_temperature = P_th / constante_specifique_gaz;
441
442 for (int k = -epaisseur_joint; k < kmax; k++)
443 {
444 for (int j = -epaisseur_joint; j < jmax; j++)
445 {
446 for (int i = -epaisseur_joint; i < imax; i++)
447 {
448 const double r = rho(i, j, k);
449 const double temp = facteur_temperature / r;
450 temperature(i,j,k) = temp;
451 double calc = temp * fac_a + fac_b;
452 calc = temp * calc + fac_c;
453 calc = temp * calc + fac_d;
454 calc = temp * calc + fac_e;
455 molecular_lambda(i,j,k) = calc * facteur;
456 molecular_mu(i,j,k) = calc;
457 }
458 }
459 }
460}
461
462void multiplier_champ(const double coefficient,
463 const IJK_Field_double& champ_in,
464 IJK_Field_double& champ_out)
465{
466 const int ni = champ_out.ni();
467 const int nj = champ_out.nj();
468 const int nk = champ_out.nk();
469
470 for (int k = 0; k < nk; k++)
471 {
472 for (int j = 0; j < nj; j++)
473 {
474 for (int i = 0; i < ni; i++)
475 {
476 champ_out(i,j,k) = coefficient * champ_in(i,j,k);
477 }
478 }
479 }
480}
481
482void multiplier_champ(const IJK_Field_double& champ_rho,
483 IJK_Field_double& champ)
484{
485 const int ni = champ.ni();
486 const int nj = champ.nj();
487 const int nk = champ.nk();
488
489 for (int k = 0; k < nk; k++)
490 {
491 for (int j = 0; j < nj; j++)
492 {
493 for (int i = 0; i < ni; i++)
494 {
495 champ(i,j,k) = champ_rho(i,j,k) * champ(i,j,k);
496 }
497 }
498 }
499}
500
501
502
503// Adds field1 to field2 by reference
504void add_fields(const IJK_Field_double& field1, IJK_Field_double& field2)
505{
506 const int ni = field2.ni();
507 const int nj = field2.nj();
508 const int nk = field2.nk();
509 for (int k = 0; k < nk; k++)
510 {
511 for (int j = 0; j < nj; j++)
512 {
513 for (int i = 0; i < ni; i++)
514 {
515 field2(i,j,k) += field1(i,j,k);
516 }
517 }
518 }
519}
520
521// Adds field1 to field2 by reference, on the k^{th} layer of the channel
522void add_fields_k(const IJK_Field_double& field1, IJK_Field_double& field2, const int k)
523{
524 const int ni = field2.ni();
525 const int nj = field2.nj();
526 for (int j = 0; j < nj; j++)
527 {
528 for (int i = 0; i < ni; i++)
529 {
530 field2(i,j,k) += field1(i,j,k);
531 }
532 }
533}
534
535void multiplier_champ_rho_arete_ij(const IJK_Field_double& champ_rho,
536 IJK_Field_double& champ)
537{
538 const int ni = champ.ni();
539 const int nj = champ.nj();
540 const int nk = champ.nk();
541
542 for (int k = 0; k < nk; k++)
543 {
544 for (int j = 0; j < nj; j++)
545 {
546 for (int i = 0; i < ni; i++)
547 {
548 const double rho = champ_rho(i,j,k);
549 const double rho_im1 = champ_rho(i-1,j,k);
550 const double rho_jm1 = champ_rho(i,j-1,k);
551 const double rho_im1_jm1 = champ_rho(i-1,j-1,k);
552 const double rho_ij = 0.25 * (rho + rho_im1 + rho_jm1 + rho_im1_jm1);
553 champ(i,j,k) = rho_ij * champ(i,j,k);
554 }
555 }
556 }
557}
558
559void multiplier_champ_rho_arete_ik(const IJK_Field_double& champ_rho,
560 double rho_kmin,
561 IJK_Field_double& champ)
562{
563 const int offset = champ_rho.get_domaine().get_offset_local(DIRECTION_K);
564
565 const int ni = champ.ni();
566 const int nj = champ.nj();
567 const int nk = champ.nk();
568
569 for (int k = 0; k < nk; k++)
570 {
571 for (int j = 0; j < nj; j++)
572 {
573 for (int i = 0; i < ni; i++)
574 {
575 const int kg = k + offset;
576 const double rho = champ_rho(i,j,k);
577 const double rho_im1 = champ_rho(i-1,j,k);
578 const double rho_ik = kg==0 ? rho_kmin : 0.25 * (rho + rho_im1 + champ_rho(i,j,k-1) + champ_rho(i-1,j,k-1));
579 champ(i,j,k) = rho_ik * champ(i,j,k);
580 }
581 }
582 }
583}
584
585void multiplier_champ_rho_arete_jk(const IJK_Field_double& champ_rho,
586 double rho_kmin,
587 IJK_Field_double& champ)
588{
589 const int offset = champ_rho.get_domaine().get_offset_local(DIRECTION_K);
590
591 const int ni = champ.ni();
592 const int nj = champ.nj();
593 const int nk = champ.nk();
594
595 for (int k = 0; k < nk; k++)
596 {
597 for (int j = 0; j < nj; j++)
598 {
599 for (int i = 0; i < ni; i++)
600 {
601 const int kg = k + offset;
602 const double rho = champ_rho(i,j,k);
603 const double rho_jm1 = champ_rho(i,j-1,k);
604 const double rho_jk = kg==0 ? rho_kmin : 0.25 * (rho + rho_jm1 + champ_rho(i,j,k-1) + champ_rho(i,j-1,k-1));
605 champ(i,j,k) = rho_jk * champ(i,j,k);
606 }
607 }
608 }
609}
610
611void multiplier_champ(const IJK_Field_double& champ_rho,
612 const double& constant,
613 IJK_Field_double& champ)
614{
615 const int ni = champ.ni();
616 const int nj = champ.nj();
617 const int nk = champ.nk();
618
619 for (int k = 0; k < nk; k++)
620 {
621 for (int j = 0; j < nj; j++)
622 {
623 for (int i = 0; i < ni; i++)
624 {
625 champ(i,j,k) = champ_rho(i,j,k) * champ(i,j,k) * constant;
626 }
627 }
628 }
629}
630
631void multiplier_champ_rho_face_i(const int flag_add,
632 const IJK_Field_double& champ_rho,
633 const double& constant,
634 const IJK_Field_double& champ_in,
635 IJK_Field_double& champ_out)
636{
637 const int ni = champ_in.ni();
638 const int nj = champ_in.nj();
639 const int nk = champ_in.nk();
640
641 for (int k = 0; k < nk; k++)
642 {
643 for (int j = 0; j < nj; j++)
644 {
645 for (int i = 0; i < ni; i++)
646 {
647 const double rho = champ_rho(i,j,k);
648 const double rho_im1 = champ_rho(i-1,j,k);
649 const double rhof_i = 0.5 * (rho + rho_im1);
650 if (flag_add)
651 {
652 champ_out(i,j,k) += rhof_i * champ_in(i,j,k) * constant;
653 }
654 else
655 {
656 champ_out(i,j,k) = rhof_i * champ_in(i,j,k) * constant;
657 }
658 }
659 }
660 }
661}
662
663void multiplier_champ_rho_face_j(const int flag_add,
664 const IJK_Field_double& champ_rho,
665 const double& constant,
666 const IJK_Field_double& champ_in,
667 IJK_Field_double& champ_out)
668{
669 const int ni = champ_in.ni();
670 const int nj = champ_in.nj();
671 const int nk = champ_in.nk();
672
673 for (int k = 0; k < nk; k++)
674 {
675 for (int j = 0; j < nj; j++)
676 {
677 for (int i = 0; i < ni; i++)
678 {
679 const double rho = champ_rho(i,j,k);
680 const double rho_jm1 = champ_rho(i,j-1,k);
681 const double rhof_j = 0.5 * (rho + rho_jm1);
682 if (flag_add)
683 {
684 champ_out(i,j,k) += rhof_j * champ_in(i,j,k) * constant;
685 }
686 else
687 {
688 champ_out(i,j,k) = rhof_j * champ_in(i,j,k) * constant;
689 }
690 }
691 }
692 }
693}
694
695void multiplier_champ_rho_face_k(const int flag_add,
696 const IJK_Field_double& champ_rho,
697 const double& constant,
698 double rho_kmin,
699 const IJK_Field_double& champ_in,
700 IJK_Field_double& champ_out)
701{
702 const int offset = champ_rho.get_domaine().get_offset_local(DIRECTION_K);
703
704 const int ni = champ_in.ni();
705 const int nj = champ_in.nj();
706 const int nk = champ_in.nk();
707
708 for (int k = 0; k < nk; k++)
709 {
710 for (int j = 0; j < nj; j++)
711 {
712 for (int i = 0; i < ni; i++)
713 {
714 const int kg = k + offset;
715 const double rho = champ_rho(i,j,k);
716 const double rhof_k = kg==0 ? rho_kmin : 0.5 * (rho + champ_rho(i,j,k-1));
717 if (flag_add)
718 {
719 champ_out(i,j,k) += rhof_k * champ_in(i,j,k) * constant;
720 }
721 else
722 {
723 champ_out(i,j,k) = rhof_k * champ_in(i,j,k) * constant;
724 }
725 }
726 }
727 }
728}
729
730inline void multiplier_champ_rho_face_i(const IJK_Field_double& champ_rho,
731 const double& constant,
732 IJK_Field_double& champ)
733{
734 multiplier_champ_rho_face_i(false, champ_rho, constant, champ, champ);
735}
736
737inline void multiplier_champ_rho_face_j(const IJK_Field_double& champ_rho,
738 const double& constant,
739 IJK_Field_double& champ)
740{
741 multiplier_champ_rho_face_j(false, champ_rho, constant, champ, champ);
742}
743
744inline void multiplier_champ_rho_face_k(const IJK_Field_double& champ_rho,
745 const double& constant,
746 double rho_kmin,
747 IJK_Field_double& champ)
748{
749 multiplier_champ_rho_face_k(false, champ_rho, constant, rho_kmin, champ, champ);
750}
751
752template<class T>
753void filtrer_champ_elem(const int flag_add,
754 const IJK_Field_double& champ,
755 const ArrOfDouble_with_ghost& delta_z,
756 const double facteur_delta_x,
757 const double facteur_delta_y,
758 const ArrOfDouble_with_ghost& delta_z_pour_delta,
759 T& kernel,
762 IJK_Field_double& champ_filtre)
763{
764 const double dx = champ.get_domaine().get_constant_delta(DIRECTION_I);
765 const double dy = champ.get_domaine().get_constant_delta(DIRECTION_J);
766 const double dx_pour_delta = facteur_delta_x*dx;
767 const double dy_pour_delta = facteur_delta_y*dy;
768
769 const int ni = champ.ni();
770 const int nj = champ.nj();
771 const int nk = champ.nk();
772
773 const int nktot = champ.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
774 const int offset = champ.get_domaine().get_offset_local(DIRECTION_K);
775
776 IJK_Field_local_double& b = tmp_b[0];
777 IJK_Field_local_double& a = tmp_a[0];
778
779 const int ghost_size_filter = kernel->ghost_size();
780 const int size_uniform = kernel->size_uniform();
781 const int shift_uniform = kernel->shift_uniform();
782 for (int k = 0; k < nk; k++)
783 {
784 const int kg = k + offset;
785
786 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
787 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
788
789 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
790 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
791 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
792 const int size_k_elem = kernel->size_k_elem(kg, nktot);
793 const int shift_k_elem = kernel->shift_k_elem(kg);
794 const bool ponderation_filter_kernel = kernel->ponderation();
795 const bool normalisation_filter_kernel = kernel->normalisation();
796
797 double facteur_elem = 0.;
798 if (ponderation_filter_kernel)
799 {
800 if (normalisation_filter_kernel)
801 {
802 double longueur_elem = 0.;
803 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
804 {
805 const int kpg = kg + kp;
806 if (kpg<-1 || kpg>nktot)
807 {
808 Cerr << "This should not happen." << finl;
810 }
811 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
812 const double filter_coef_z = filter_kernel_z[kp+10];
813 longueur_elem += filter_coef_z * dz;
814 }
815 facteur_elem = 1./longueur_elem;
816 }
817 else
818 {
819 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
820 }
821 }
822
823 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
824 {
825 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
826 {
827 b(i, j, 0) = 0.;
828 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
829 {
830 const int kpg = kg + kp;
831 if (!(kernel->is_at_wall_elem(kpg, nktot)))
832 {
833 const double filter_coef_z = filter_kernel_z[kp+10];
834 if (ponderation_filter_kernel)
835 {
836 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
837 b(i, j, 0) += champ(i,j,k+kp) * filter_coef_z * dz * facteur_elem;
838 }
839 else
840 {
841 b(i, j, 0) += champ(i,j,k+kp) * filter_coef_z;
842 }
843 }
844 }
845 }
846 }
847 for (int j = 0; j < nj; j++)
848 {
849 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
850 {
851 a(i, 0, 0) = 0.;
852 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
853 {
854 const double filter_coef_y = filter_kernel_y[jp+10];
855 a(i, 0, 0) += b(i, j+jp, 0) * filter_coef_y;
856 }
857 }
858
859 for (int i = 0; i < ni; i++)
860 {
861 double r = 0.;
862 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
863 {
864 const double filter_coef_x = filter_kernel_x[ip+10];
865 r += a(i+ip, 0, 0) * filter_coef_x;
866 }
867
868 if (flag_add)
869 {
870 champ_filtre(i,j,k) += r;
871 }
872 else
873 {
874 champ_filtre(i,j,k) = r;
875 }
876 }
877 }
878 }
879}
880
881template<class T>
882void filtrer_champ_face(const int flag_add,
883 const IJK_Field_double& champ,
884 const ArrOfDouble_with_ghost& delta_z,
885 const double facteur_delta_x,
886 const double facteur_delta_y,
887 const ArrOfDouble_with_ghost& delta_z_pour_delta,
888 T& kernel,
891 IJK_Field_double& champ_filtre)
892{
893 const double dx = champ.get_domaine().get_constant_delta(DIRECTION_I);
894 const double dy = champ.get_domaine().get_constant_delta(DIRECTION_J);
895 const double dx_pour_delta = facteur_delta_x*dx;
896 const double dy_pour_delta = facteur_delta_y*dy;
897
898 const int ni = champ.ni();
899 const int nj = champ.nj();
900 const int nk = champ.nk();
901
902 const int nktot = champ.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
903 const int offset = champ.get_domaine().get_offset_local(DIRECTION_K);
904
905 IJK_Field_local_double& b = tmp_b[0];
906 IJK_Field_local_double& a = tmp_a[0];
907
908 const int ghost_size_filter = kernel->ghost_size();
909 const int size_uniform = kernel->size_uniform();
910 const int shift_uniform = kernel->shift_uniform();
911 for (int k = 0; k < nk; k++)
912 {
913 const int kg = k + offset;
914
915 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
916 const double dz_m1_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z[k-1];
917 const double delta_m_glo = kg==0 ? 0.5*dz_glo : 0.5*(dz_glo + dz_m1_glo);
918 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
919 const double dz_m1_pour_delta_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1];
920 const double delta_m_pour_delta_glo = (kg-1<0 || kg>(nktot-1)) ? 0. : 0.5*(dz_pour_delta_glo + dz_m1_pour_delta_glo);
921
922 const FixedVector<double, 21> filter_kernel_z_face = kernel->inhomogeneous(false, k, kg, nktot, delta_m_pour_delta_glo, delta_z);
923 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
924 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
925 const int size_k_face = kernel->size_k_face(kg, nktot);
926 const int shift_k_face = kernel->shift_k_face(kg);
927 const bool ponderation_filter_kernel = kernel->ponderation();
928 const bool normalisation_filter_kernel = kernel->normalisation();
929
930 double facteur_face = 0.;
931 if (ponderation_filter_kernel)
932 {
933 if (normalisation_filter_kernel)
934 {
935 double longueur_face = 0.;
936 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
937 {
938 const int kpg = kg + kp;
939 if (kpg<0 || kpg>nktot)
940 {
941 Cerr << "This should not happen." << finl;
943 }
944 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
945 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
946 const double dzf = 0.5*(dz + dz_m1);
947 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
948 longueur_face += filter_coef_z_face * dzf;
949 }
950 facteur_face = 1./longueur_face;
951 }
952 else
953 {
954 facteur_face = delta_m_glo==0. ? 0. : 1./delta_m_glo;
955 }
956 }
957
958 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
959 {
960 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
961 {
962 b(i, j, 0) = 0.;
963 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
964 {
965 const int kpg = kg + kp;
966 if (!(kernel->is_at_wall_face(kpg, nktot)))
967 {
968 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
969 if (ponderation_filter_kernel)
970 {
971 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
972 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
973 const double dzf = 0.5*(dz + dz_m1);
974 b(i, j, 0) += champ(i,j,k+kp) * filter_coef_z_face * dzf * facteur_face;
975 }
976 else
977 {
978 b(i, j, 0) += champ(i,j,k+kp) * filter_coef_z_face;
979 }
980 }
981 }
982 }
983 }
984 for (int j = 0; j < nj; j++)
985 {
986 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
987 {
988 a(i, 0, 0) = 0.;
989 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
990 {
991 const double filter_coef_y = filter_kernel_y[jp+10];
992 a(i, 0, 0) += b(i, j+jp, 0) * filter_coef_y;
993 }
994 }
995
996 for (int i = 0; i < ni; i++)
997 {
998 double r = 0.;
999 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
1000 {
1001 const double filter_coef_x = filter_kernel_x[ip+10];
1002 r += a(i+ip, 0, 0) * filter_coef_x;
1003 }
1004
1005 if (flag_add)
1006 {
1007 champ_filtre(i,j,k) += r;
1008 }
1009 else
1010 {
1011 champ_filtre(i,j,k) = r;
1012 }
1013 }
1014 }
1015 }
1016}
1017
1018static inline void calculer_g(int i, int j, int k,
1019 const IJK_Field_vector3_double& velocity,
1020 const ArrOfDouble_with_ghost& delta_z_maillage,
1021 const double dx_delta,
1022 const double dy_delta,
1023 const double dz_delta,
1024 const double delta_m_delta,
1025 const double delta_p_delta,
1027{
1028 const IJK_Field_double& vitesse_i = velocity[0];
1029 const IJK_Field_double& vitesse_j = velocity[1];
1030 const IJK_Field_double& vitesse_k = velocity[2];
1031
1032 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
1033 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
1034 const double deltaunsurdx = dx_delta * 1./dx;
1035 const double deltaunsurdy = dy_delta * 1./dy;
1036
1037 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
1038 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
1039
1040 const int kg = k + offset;
1041 const double dz = delta_z_maillage[k];
1042 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
1043 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
1044
1045 const double deltaunsurdz = dz_delta * 1./dz;
1046 const double deltaunsurdelta_m = delta_m_delta * 1./delta_m;
1047 const double deltaunsurdelta_p = delta_p_delta * 1./delta_p;
1048
1049 const double uf_i = vitesse_i(i,j,k);
1050 const double uf_ip1 = vitesse_i(i+1,j,k);
1051 const double uf_i_jm1 = vitesse_i(i,j-1,k);
1052 const double uf_i_jp1 = vitesse_i(i,j+1,k);
1053 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
1054 const double uf_i_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i,j,k+1);
1055 const double uf_ip1_jp1 = vitesse_i(i+1,j+1,k);
1056 const double uf_ip1_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i+1,j,k+1);
1057 const double uf_ip1_jm1 = vitesse_i(i+1,j-1,k);
1058 const double uf_ip1_km1 = kg==0 ? 0. : vitesse_i(i+1,j,k-1);
1059
1060 const double vf_j = vitesse_j(i,j,k);
1061 const double vf_j_im1 = vitesse_j(i-1,j,k);
1062 const double vf_j_ip1 = vitesse_j(i+1,j,k);
1063 const double vf_jp1 = vitesse_j(i,j+1,k);
1064 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
1065 const double vf_j_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j,k+1);
1066 const double vf_jp1_ip1 = vitesse_j(i+1,j+1,k);
1067 const double vf_jp1_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j+1,k+1);
1068 const double vf_jp1_im1 = vitesse_j(i-1,j+1,k);
1069 const double vf_jp1_km1 = kg==0 ? 0. : vitesse_j(i,j+1,k-1);
1070
1071 const double wf_k = vitesse_k(i,j,k);
1072 const double wf_k_im1 = vitesse_k(i-1,j,k);
1073 const double wf_k_ip1 = vitesse_k(i+1,j,k);
1074 const double wf_k_jm1 = vitesse_k(i,j-1,k);
1075 const double wf_k_jp1 = vitesse_k(i,j+1,k);
1076 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
1077 const double wf_kp1_ip1 = kg==(nktot-1) ? 0. : vitesse_k(i+1,j,k+1);
1078 const double wf_kp1_jp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j+1,k+1);
1079 const double wf_kp1_im1 = kg==(nktot-1) ? 0. : vitesse_k(i-1,j,k+1);
1080 const double wf_kp1_jm1 = kg==(nktot-1) ? 0. : vitesse_k(i,j-1,k+1);
1081
1082 const double duidx = deltaunsurdx * (uf_ip1 - uf_i);
1083 const double dujdy = deltaunsurdy * (vf_jp1 - vf_j);
1084 const double dukdz = deltaunsurdz * (wf_kp1 - wf_k);
1085
1086 const double duidy_ij = deltaunsurdy * (uf_i - uf_i_jm1);
1087 const double duidy_ip1j = deltaunsurdy * (uf_ip1 - uf_ip1_jm1);
1088 const double duidy_ijp1 = deltaunsurdy * (uf_i_jp1 - uf_i);
1089 const double duidy_ip1jp1 = deltaunsurdy * (uf_ip1_jp1 - uf_ip1);
1090
1091 const double duidz_ik = deltaunsurdelta_m * (uf_i - uf_i_km1);
1092 const double duidz_ip1k = deltaunsurdelta_m * (uf_ip1 - uf_ip1_km1);
1093 const double duidz_ikp1 = deltaunsurdelta_p * (uf_i_kp1 - uf_i);
1094 const double duidz_ip1kp1 = deltaunsurdelta_p * (uf_ip1_kp1 - uf_ip1);
1095
1096 const double dujdx_ij = deltaunsurdx * (vf_j - vf_j_im1);
1097 const double dujdx_ip1j = deltaunsurdx * (vf_j_ip1 - vf_j);
1098 const double dujdx_ijp1 = deltaunsurdx * (vf_jp1 - vf_jp1_im1);
1099 const double dujdx_ip1jp1 = deltaunsurdx * (vf_jp1_ip1 - vf_jp1);
1100
1101 const double dujdz_jk = deltaunsurdelta_m * (vf_j - vf_j_km1);
1102 const double dujdz_jp1k = deltaunsurdelta_m * (vf_jp1 - vf_jp1_km1);
1103 const double dujdz_jkp1 = deltaunsurdelta_p * (vf_j_kp1 - vf_j);
1104 const double dujdz_jp1kp1 = deltaunsurdelta_p * (vf_jp1_kp1 - vf_jp1);
1105
1106 const double dukdx_ik = deltaunsurdx * (wf_k - wf_k_im1);
1107 const double dukdx_ip1k = deltaunsurdx * (wf_k_ip1 - wf_k);
1108 const double dukdx_ikp1 = deltaunsurdx * (wf_kp1 - wf_kp1_im1);
1109 const double dukdx_ip1kp1 = deltaunsurdx * (wf_kp1_ip1 - wf_kp1);
1110
1111 const double dukdy_jk = deltaunsurdy * (wf_k - wf_k_jm1);
1112 const double dukdy_jp1k = deltaunsurdy * (wf_k_jp1 - wf_k);
1113 const double dukdy_jkp1 = deltaunsurdy * (wf_kp1 - wf_kp1_jm1);
1114 const double dukdy_jp1kp1 = deltaunsurdy * (wf_kp1_jp1 - wf_kp1);
1115
1116 g[0][0] = duidx;
1117 g[0][1] = 0.25 * (duidy_ip1jp1 + duidy_ijp1 + duidy_ip1j + duidy_ij);
1118 g[0][2] = 0.25 * (duidz_ip1kp1 + duidz_ikp1 + duidz_ip1k + duidz_ik);
1119 g[1][0] = 0.25 * (dujdx_ip1jp1 + dujdx_ip1j + dujdx_ijp1 + dujdx_ij);
1120 g[1][1] = dujdy;
1121 g[1][2] = 0.25 * (dujdz_jp1kp1 + dujdz_jkp1 + dujdz_jp1k + dujdz_jk);
1122 g[2][0] = 0.25 * (dukdx_ip1kp1 + dukdx_ip1k + dukdx_ikp1 + dukdx_ik);
1123 g[2][1] = 0.25 * (dukdy_jp1kp1 + dukdy_jp1k + dukdy_jkp1 + dukdy_jk);
1124 g[2][2] = dukdz;
1125}
1126
1127static inline void calculer_tau(int i, int j, int k,
1128 const IJK_Field_vector3_double& velocity,
1129 const IJK_Field_double& turbulent_mu_xx,
1130 const IJK_Field_double& turbulent_mu_xy,
1131 const IJK_Field_double& turbulent_mu_xz,
1132 const IJK_Field_double& turbulent_mu_yy,
1133 const IJK_Field_double& turbulent_mu_yz,
1134 const IJK_Field_double& turbulent_mu_zz,
1135 const ArrOfDouble_with_ghost& delta_z_maillage,
1136 const double dx_delta,
1137 const double dy_delta,
1138 const double dz_delta,
1139 const double delta_m_delta,
1140 const double delta_p_delta,
1142{
1143 const IJK_Field_double& vitesse_i = velocity[0];
1144 const IJK_Field_double& vitesse_j = velocity[1];
1145 const IJK_Field_double& vitesse_k = velocity[2];
1146
1147 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
1148 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
1149 const double deltaunsurdx = dx_delta * 1./dx;
1150 const double deltaunsurdy = dy_delta * 1./dy;
1151
1152 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
1153 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
1154
1155 const int kg = k + offset;
1156 const double dz = delta_z_maillage[k];
1157 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
1158 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
1159
1160 const double deltaunsurdz = dz_delta * 1./dz;
1161 const double deltaunsurdelta_m = delta_m_delta * 1./delta_m;
1162 const double deltaunsurdelta_p = delta_p_delta * 1./delta_p;
1163
1164 const double nu_xx = turbulent_mu_xx(i,j,k);
1165
1166 const double nu_xy = turbulent_mu_xy(i,j,k);
1167 const double nu_xy_im1 = turbulent_mu_xy(i-1,j,k);
1168 const double nu_xy_jm1 = turbulent_mu_xy(i,j-1,k);
1169 const double nu_xy_im1_jm1 = turbulent_mu_xy(i-1,j-1,k);
1170 const double nu_xy_ip1 = turbulent_mu_xy(i+1,j,k);
1171 const double nu_xy_jp1 = turbulent_mu_xy(i,j+1,k);
1172 const double nu_xy_ip1_jp1 = turbulent_mu_xy(i+1,j+1,k);
1173 const double nu_xy_im1_jp1 = turbulent_mu_xy(i-1,j+1,k);
1174 const double nu_xy_ip1_jm1 = turbulent_mu_xy(i+1,j-1,k);
1175
1176 const double nu_xz = turbulent_mu_xz(i,j,k);
1177 const double nu_xz_im1 = turbulent_mu_xz(i-1,j,k);
1178 const double nu_xz_km1 = kg==0 ? 0. : turbulent_mu_xz(i,j,k-1);
1179 const double nu_xz_im1_km1 = kg==0 ? 0. : turbulent_mu_xz(i-1,j,k-1);
1180 const double nu_xz_ip1 = turbulent_mu_xz(i+1,j,k);
1181 const double nu_xz_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_xz(i,j,k+1);
1182 const double nu_xz_ip1_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_xz(i+1,j,k+1);
1183 const double nu_xz_im1_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_xz(i-1,j,k+1);
1184 const double nu_xz_ip1_km1 = kg==0 ? 0. : turbulent_mu_xz(i+1,j,k-1);
1185
1186 const double nu_yy = turbulent_mu_yy(i,j,k);
1187
1188 const double nu_yz = turbulent_mu_yz(i,j,k);
1189 const double nu_yz_jm1 = turbulent_mu_yz(i,j-1,k);
1190 const double nu_yz_km1 = kg==0 ? 0. : turbulent_mu_yz(i,j,k-1);
1191 const double nu_yz_jm1_km1 = kg==0 ? 0. : turbulent_mu_yz(i,j-1,k-1);
1192 const double nu_yz_jp1 = turbulent_mu_yz(i,j+1,k);
1193 const double nu_yz_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_yz(i,j,k+1);
1194 const double nu_yz_jp1_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_yz(i,j+1,k+1);
1195 const double nu_yz_jm1_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_yz(i,j-1,k+1);
1196 const double nu_yz_jp1_km1 = kg==0 ? 0. : turbulent_mu_yz(i,j+1,k-1);
1197
1198 const double nu_xy_ij = 0.25 * (nu_xy + nu_xy_im1 + nu_xy_jm1 + nu_xy_im1_jm1);
1199 const double nu_xy_ip1j = 0.25 * (nu_xy_ip1 + nu_xy + nu_xy_ip1_jm1 + nu_xy_jm1);
1200 const double nu_xy_ijp1 = 0.25 * (nu_xy_jp1 + nu_xy_im1_jp1 + nu_xy + nu_xy_im1);
1201 const double nu_xy_ip1jp1 = 0.25 * (nu_xy_ip1_jp1 + nu_xy_jp1 + nu_xy_ip1 + nu_xy);
1202 const double nu_xz_ik = 0.25 * (nu_xz + nu_xz_im1 + nu_xz_km1 + nu_xz_im1_km1);
1203 const double nu_xz_ip1k = 0.25 * (nu_xz_ip1 + nu_xz + nu_xz_ip1_km1 + nu_xz_km1);
1204 const double nu_xz_ikp1 = 0.25 * (nu_xz_kp1 + nu_xz_im1_kp1 + nu_xz + nu_xz_im1);
1205 const double nu_xz_ip1kp1 = 0.25 * (nu_xz_ip1_kp1 + nu_xz_kp1 + nu_xz_ip1 + nu_xz);
1206 const double nu_yz_jk = 0.25 * (nu_yz + nu_yz_jm1 + nu_yz_km1 + nu_yz_jm1_km1);
1207 const double nu_yz_jp1k = 0.25 * (nu_yz_jp1 + nu_yz + nu_yz_jp1_km1 + nu_yz_km1);
1208 const double nu_yz_jkp1 = 0.25 * (nu_yz_kp1 + nu_yz_jm1_kp1 + nu_yz + nu_yz_jm1);
1209 const double nu_yz_jp1kp1 = 0.25 * (nu_yz_jp1_kp1 + nu_yz_kp1 + nu_yz_jp1 + nu_yz);
1210
1211 const double nu_zz = turbulent_mu_zz(i,j,k);
1212
1213 const double uf_i = vitesse_i(i,j,k);
1214 const double uf_i_jm1 = vitesse_i(i,j-1,k);
1215 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
1216
1217 const double vf_j = vitesse_j(i,j,k);
1218 const double vf_j_im1 = vitesse_j(i-1,j,k);
1219 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
1220
1221 const double wf_k = vitesse_k(i,j,k);
1222 const double wf_k_im1 = vitesse_k(i-1,j,k);
1223 const double wf_k_jm1 = vitesse_k(i,j-1,k);
1224
1225 const double uf_ip1 = vitesse_i(i+1,j,k);
1226 const double uf_i_jp1 = vitesse_i(i,j+1,k);
1227 const double uf_i_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i,j,k+1);
1228 const double uf_ip1_jp1 = vitesse_i(i+1,j+1,k);
1229 const double uf_ip1_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i+1,j,k+1);
1230 const double uf_ip1_jm1 = vitesse_i(i+1,j-1,k);
1231 const double uf_ip1_km1 = kg==0 ? 0. : vitesse_i(i+1,j,k-1);
1232
1233 const double vf_j_ip1 = vitesse_j(i+1,j,k);
1234 const double vf_jp1 = vitesse_j(i,j+1,k);
1235 const double vf_j_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j,k+1);
1236 const double vf_jp1_ip1 = vitesse_j(i+1,j+1,k);
1237 const double vf_jp1_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j+1,k+1);
1238 const double vf_jp1_im1 = vitesse_j(i-1,j+1,k);
1239 const double vf_jp1_km1 = kg==0 ? 0. : vitesse_j(i,j+1,k-1);
1240
1241 const double wf_k_ip1 = vitesse_k(i+1,j,k);
1242 const double wf_k_jp1 = vitesse_k(i,j+1,k);
1243 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
1244 const double wf_kp1_ip1 = kg==(nktot-1) ? 0. : vitesse_k(i+1,j,k+1);
1245 const double wf_kp1_jp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j+1,k+1);
1246 const double wf_kp1_im1 = kg==(nktot-1) ? 0. : vitesse_k(i-1,j,k+1);
1247 const double wf_kp1_jm1 = kg==(nktot-1) ? 0. : vitesse_k(i,j-1,k+1);
1248
1249 const double duidx = deltaunsurdx * (uf_ip1 - uf_i);
1250 const double dujdy = deltaunsurdy * (vf_jp1 - vf_j);
1251 const double dukdz = deltaunsurdz * (wf_kp1 - wf_k);
1252
1253 const double duidy_ij = deltaunsurdy * (uf_i - uf_i_jm1);
1254 const double duidy_ip1j = deltaunsurdy * (uf_ip1 - uf_ip1_jm1);
1255 const double duidy_ijp1 = deltaunsurdy * (uf_i_jp1 - uf_i);
1256 const double duidy_ip1jp1 = deltaunsurdy * (uf_ip1_jp1 - uf_ip1);
1257
1258 const double duidz_ik = deltaunsurdelta_m * (uf_i - uf_i_km1);
1259 const double duidz_ip1k = deltaunsurdelta_m * (uf_ip1 - uf_ip1_km1);
1260 const double duidz_ikp1 = deltaunsurdelta_p * (uf_i_kp1 - uf_i);
1261 const double duidz_ip1kp1 = deltaunsurdelta_p * (uf_ip1_kp1 - uf_ip1);
1262
1263 const double dujdx_ij = deltaunsurdx * (vf_j - vf_j_im1);
1264 const double dujdx_ip1j = deltaunsurdx * (vf_j_ip1 - vf_j);
1265 const double dujdx_ijp1 = deltaunsurdx * (vf_jp1 - vf_jp1_im1);
1266 const double dujdx_ip1jp1 = deltaunsurdx * (vf_jp1_ip1 - vf_jp1);
1267
1268 const double dujdz_jk = deltaunsurdelta_m * (vf_j - vf_j_km1);
1269 const double dujdz_jp1k = deltaunsurdelta_m * (vf_jp1 - vf_jp1_km1);
1270 const double dujdz_jkp1 = deltaunsurdelta_p * (vf_j_kp1 - vf_j);
1271 const double dujdz_jp1kp1 = deltaunsurdelta_p * (vf_jp1_kp1 - vf_jp1);
1272
1273 const double dukdx_ik = deltaunsurdx * (wf_k - wf_k_im1);
1274 const double dukdx_ip1k = deltaunsurdx * (wf_k_ip1 - wf_k);
1275 const double dukdx_ikp1 = deltaunsurdx * (wf_kp1 - wf_kp1_im1);
1276 const double dukdx_ip1kp1 = deltaunsurdx * (wf_kp1_ip1 - wf_kp1);
1277
1278 const double dukdy_jk = deltaunsurdy * (wf_k - wf_k_jm1);
1279 const double dukdy_jp1k = deltaunsurdy * (wf_k_jp1 - wf_k);
1280 const double dukdy_jkp1 = deltaunsurdy * (wf_kp1 - wf_kp1_jm1);
1281 const double dukdy_jp1kp1 = deltaunsurdy * (wf_kp1_jp1 - wf_kp1);
1282
1283 const double s_ii = 0.5 * (duidx + duidx);
1284 const double s_jj = 0.5 * (dujdy + dujdy);
1285 const double s_kk = 0.5 * (dukdz + dukdz);
1286
1287 const double s_ij = 0.5 * (duidy_ij + dujdx_ij);
1288 const double s_ik = 0.5 * (duidz_ik + dukdx_ik);
1289 const double s_jk = 0.5 * (dujdz_jk + dukdy_jk);
1290
1291 const double s_ip1j = 0.5 * (duidy_ip1j + dujdx_ip1j);
1292 const double s_ip1k = 0.5 * (duidz_ip1k + dukdx_ip1k);
1293 const double s_jp1k = 0.5 * (dujdz_jp1k + dukdy_jp1k);
1294
1295 const double s_ijp1 = 0.5 * (duidy_ijp1 + dujdx_ijp1);
1296 const double s_ikp1 = 0.5 * (duidz_ikp1 + dukdx_ikp1);
1297 const double s_jkp1 = 0.5 * (dujdz_jkp1 + dukdy_jkp1);
1298
1299 const double s_ip1jp1 = 0.5 * (duidy_ip1jp1 + dujdx_ip1jp1);
1300 const double s_ip1kp1 = 0.5 * (duidz_ip1kp1 + dukdx_ip1kp1);
1301 const double s_jp1kp1 = 0.5 * (dujdz_jp1kp1 + dukdy_jp1kp1);
1302
1303 f[0][0] = - 2. * nu_xx * s_ii;
1304 f[0][1] = - 2. * 0.25 * (nu_xy_ip1jp1*s_ip1jp1 + nu_xy_ijp1*s_ijp1 + nu_xy_ip1j*s_ip1j + nu_xy_ij*s_ij);
1305 f[0][2] = - 2. * 0.25 * (nu_xz_ip1kp1*s_ip1kp1 + nu_xz_ikp1*s_ikp1 + nu_xz_ip1k*s_ip1k + nu_xz_ik*s_ik);
1306 f[1][0] = - 2. * 0.25 * (nu_xy_ip1jp1*s_ip1jp1 + nu_xy_ijp1*s_ijp1 + nu_xy_ip1j*s_ip1j + nu_xy_ij*s_ij);
1307 f[1][1] = - 2. * nu_yy * s_jj;
1308 f[1][2] = - 2. * 0.25 * (nu_yz_jp1kp1*s_jp1kp1 + nu_yz_jkp1*s_jkp1 + nu_yz_jp1k*s_jp1k + nu_yz_jk*s_jk);
1309 f[2][0] = - 2. * 0.25 * (nu_xz_ip1kp1*s_ip1kp1 + nu_xz_ikp1*s_ikp1 + nu_xz_ip1k*s_ip1k + nu_xz_ik*s_ik);
1310 f[2][1] = - 2. * 0.25 * (nu_yz_jp1kp1*s_jp1kp1 + nu_yz_jkp1*s_jkp1 + nu_yz_jp1k*s_jp1k + nu_yz_jk*s_jk);
1311 f[2][2] = - 2. * nu_zz * s_kk;
1312}
1313
1314static inline void calculer_q(int i, int j, int k,
1315 const IJK_Field_vector3_double& velocity,
1316 const IJK_Field_double& champ_scalar,
1317 double scalar_kmin, double scalar_kmax,
1318 const ArrOfDouble_with_ghost& delta_z_maillage,
1319 const double dx_delta,
1320 const double dy_delta,
1321 const double dz_delta,
1322 const double delta_m_delta,
1323 const double delta_p_delta,
1325{
1326 const IJK_Field_double& vitesse_k = velocity[2];
1327
1328 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
1329 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
1330 const double deltaunsurdx = dx_delta * 1./dx;
1331 const double deltaunsurdy = dy_delta * 1./dy;
1332
1333 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
1334 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
1335
1336 const int kg = k + offset;
1337 const double dz = delta_z_maillage[k];
1338 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
1339 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
1340
1341 const double deltaunsurdelta_m = delta_m_delta * 1./delta_m;
1342 const double deltaunsurdelta_p = delta_p_delta * 1./delta_p;
1343
1344 const double scalar = champ_scalar(i,j,k);
1345
1346 const double scalar_im1 = champ_scalar(i-1,j,k);
1347 const double scalar_ip1 = champ_scalar(i+1,j,k);
1348
1349 const double scalar_jm1 = champ_scalar(i,j-1,k);
1350 const double scalar_jp1 = champ_scalar(i,j+1,k);
1351
1352 const double scalar_km1 = kg==0 ? scalar_kmin : champ_scalar(i,j,k-1);
1353 const double scalar_kp1 = kg==(nktot-1) ? scalar_kmax : champ_scalar(i,j,k+1);
1354
1355 const double dscalardxf_i = deltaunsurdx * (scalar - scalar_im1);
1356 const double dscalardxf_ip1 = deltaunsurdx * (scalar_ip1 - scalar);
1357
1358 const double dscalardyf_j = deltaunsurdy * (scalar - scalar_jm1);
1359 const double dscalardyf_jp1 = deltaunsurdy * (scalar_jp1 - scalar);
1360
1361 const double dscalardzf_k = deltaunsurdelta_m * (scalar - scalar_km1);
1362 const double dscalardzf_kp1 = deltaunsurdelta_p * (scalar_kp1 - scalar);
1363
1364 q[0] = 0.5 * (dscalardxf_i + dscalardxf_ip1);
1365 q[1] = 0.5 * (dscalardyf_j + dscalardyf_jp1);
1366 q[2] = 0.5 * (dscalardzf_k + dscalardzf_kp1);
1367}
1368
1369static inline void calculer_pi(int i, int j, int k,
1370 const IJK_Field_vector3_double& velocity,
1371 const IJK_Field_double& champ_scalar,
1372 double scalar_kmin, double scalar_kmax,
1373 const IJK_Field_double& turbulent_mu_x,
1374 const IJK_Field_double& turbulent_mu_y,
1375 const IJK_Field_double& turbulent_mu_z,
1376 const ArrOfDouble_with_ghost& delta_z_maillage,
1377 const double dx_delta,
1378 const double dy_delta,
1379 const double dz_delta,
1380 const double delta_m_delta,
1381 const double delta_p_delta,
1383{
1384 const IJK_Field_double& vitesse_k = velocity[2];
1385
1386 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
1387 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
1388 const double deltaunsurdx = dx_delta * 1./dx;
1389 const double deltaunsurdy = dy_delta * 1./dy;
1390
1391 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
1392 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
1393
1394 const int kg = k + offset;
1395 const double dz = delta_z_maillage[k];
1396 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
1397 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
1398
1399 const double deltaunsurdelta_m = delta_m_delta * 1./delta_m;
1400 const double deltaunsurdelta_p = delta_p_delta * 1./delta_p;
1401
1402 const double nu_x = turbulent_mu_x(i,j,k);
1403 const double nu_x_im1 = turbulent_mu_x(i-1,j,k);
1404 const double nu_x_ip1 = turbulent_mu_x(i+1,j,k);
1405
1406 const double nu_y = turbulent_mu_y(i,j,k);
1407 const double nu_y_jm1 = turbulent_mu_y(i,j-1,k);
1408 const double nu_y_jp1 = turbulent_mu_y(i,j+1,k);
1409
1410 const double nu_z = turbulent_mu_z(i,j,k);
1411 const double nu_z_km1 = kg==0 ? 0. : turbulent_mu_z(i,j,k-1);
1412 const double nu_z_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_z(i,j,k+1);
1413
1414 const double nu_xf_i = 0.5 * (nu_x + nu_x_im1);
1415 const double nu_yf_j = 0.5 * (nu_y + nu_y_jm1);
1416 const double nu_zf_k = 0.5 * (nu_z + nu_z_km1);
1417 const double nu_xf_ip1 = 0.5 * (nu_x + nu_x_ip1);
1418 const double nu_yf_jp1 = 0.5 * (nu_y + nu_y_jp1);
1419 const double nu_zf_kp1 = 0.5 * (nu_z + nu_z_kp1);
1420
1421 const double scalar = champ_scalar(i,j,k);
1422
1423 const double scalar_im1 = champ_scalar(i-1,j,k);
1424 const double scalar_ip1 = champ_scalar(i+1,j,k);
1425
1426 const double scalar_jm1 = champ_scalar(i,j-1,k);
1427 const double scalar_jp1 = champ_scalar(i,j+1,k);
1428
1429 const double scalar_km1 = kg==0 ? scalar_kmin : champ_scalar(i,j,k-1);
1430 const double scalar_kp1 = kg==(nktot-1) ? scalar_kmax : champ_scalar(i,j,k+1);
1431
1432 const double dscalardxf_i = deltaunsurdx * (scalar - scalar_im1);
1433 const double dscalardxf_ip1 = deltaunsurdx * (scalar_ip1 - scalar);
1434
1435 const double dscalardyf_j = deltaunsurdy * (scalar - scalar_jm1);
1436 const double dscalardyf_jp1 = deltaunsurdy * (scalar_jp1 - scalar);
1437
1438 const double dscalardzf_k = deltaunsurdelta_m * (scalar - scalar_km1);
1439 const double dscalardzf_kp1 = deltaunsurdelta_p * (scalar_kp1 - scalar);
1440
1441 f[0] = - 0.5 * (nu_xf_i*dscalardxf_i + nu_xf_ip1*dscalardxf_ip1);
1442 f[1] = - 0.5 * (nu_yf_j*dscalardyf_j + nu_yf_jp1*dscalardyf_jp1);
1443 f[2] = - 0.5 * (nu_zf_k*dscalardzf_k + nu_zf_kp1*dscalardzf_kp1);
1444}
1445
1446template<class T>
1447void calculer_turbulent_mu(const bool anisotropic,
1448 T& model,
1449 const double turbulent_viscosity_model_constant,
1450 const double variation_cste_modele_fonctionnel_,
1451 const double smoothing_center_fr_,
1452 const double smoothing_factor_fr_,
1453 const double Re_tau_fr_,
1454 const double Re_tau_ch_,
1455 const double pond_fr_,
1456 const double pond_ch_,
1457 const double center_constant_,
1458 const double Lz_tot_,
1459 const IJK_Field_vector3_double& velocity,
1460 const IJK_Field_double& champ_rho,
1461 const IJK_Field_double& champ_scalar,
1462 double scalar_kmin, double scalar_kmax,
1463 const ArrOfDouble_with_ghost& delta_z_maillage,
1464 const double facteur_x_pour_delta,
1465 const double facteur_y_pour_delta,
1466 const ArrOfDouble_with_ghost& delta_z_pour_delta,
1467 IJK_Field_double& turbulent_mu,
1468 const Domaine_IJK& splitting)
1469{
1470 const IJK_Field_double& vitesse_k = velocity[2];
1471
1472 const double dx_pour_delta = facteur_x_pour_delta * vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
1473 const double dy_pour_delta = facteur_y_pour_delta * vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
1474
1475 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
1476 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
1477
1478 const int ni = vitesse_k.ni();
1479 const int nj = vitesse_k.nj();
1480 const int nk = vitesse_k.nk();
1481
1482 const ArrOfDouble& coord_z = splitting.get_node_coordinates(DIRECTION_K);
1483 ArrOfDouble elem_coord(nk);
1484 for (int i = 0; i < nktot; i++)
1485 {
1486 elem_coord[i] = 0.5 * (coord_z[i] + coord_z[i+1]);
1487 }
1488 elem_coord[nktot]=Lz_tot_;
1489
1492// Modif Martin
1493// const int nktot_elem = splitting.get_nb_elem_tot(DIRECTION_K);
1494 // Quick fix using the C++ std::vector
1495 // double turbulent_viscosity_model_constant_tab[nk];
1496 std::vector<double> turbulent_viscosity_model_constant_tab(nk);
1497 if ( !variation_cste_modele_fonctionnel_ )
1498 {
1499 if ( ( smoothing_factor_fr_ != 0. ) || ( smoothing_center_fr_ != 0. ) || pond_ch_ != 0. || pond_fr_ != 0. )
1500 {
1501 Cerr << "Error: (Inconsistent parameters) "
1502 << "A non null smoothing_factor_fr or smoothing_center_fr_ or pond_ch_ or pond_fr_ has been specified while the variation_constante_modele_fonctionnel flag has not been activated."
1503 << "" << finl;
1504 Process::exit();
1505 }
1506 for (int k = 0; k <= nktot; k++)
1507 {
1508 turbulent_viscosity_model_constant_tab[k]=turbulent_viscosity_model_constant;
1509 }
1510 }
1511 else
1512 {
1513 if ( smoothing_factor_fr_ == 0. )
1514 {
1515 Cerr << "Error: (Inconsistent parameters) "
1516 << "A null smoothing factor has been specified while the variation_constante_modele_fonctionnel flag has been activated. Check the 5 parameters used with this flag : smoothing_factor_fr_ smoothing_center_fr_, center_constant_, pond_fr_, pond_ch_."
1517 << "" << finl;
1518 Process::exit();
1519 }
1520 else if ((pond_fr_ == 0.) || (pond_ch_ == 0.))
1521 {
1522 Cerr << "Warning: pond_fr_ and/or pond_ch_ are equal to 0. The functional model constant is then not varying in the wall normal direction. Set pond_fr_ = 1. and pond_ch_ = 1. to obtain a symmetric variation of the model constant." ;
1523 }
1524 for (int k = 0; k < nktot/2; k++)
1525 {
1526 turbulent_viscosity_model_constant_tab[k]=turbulent_viscosity_model_constant*pond_fr_+(0.5+0.5*tanh((elem_coord[k]-smoothing_center_fr_)/(smoothing_factor_fr_)))*(center_constant_-turbulent_viscosity_model_constant*pond_fr_);
1527 }
1528 for (int k = nktot; k > nktot/2-1; --k)
1529 {
1530 turbulent_viscosity_model_constant_tab[k]=turbulent_viscosity_model_constant*pond_ch_+(0.5+0.5*tanh((Lz_tot_-elem_coord[k]-smoothing_center_fr_ * Re_tau_fr_/Re_tau_ch_)/(smoothing_factor_fr_ * Re_tau_fr_/Re_tau_ch_)))*(center_constant_-turbulent_viscosity_model_constant*pond_ch_);
1531 }
1532 }
1533// Fin modif Martin
1534
1535 for (int k = 0; k < nk; k++)
1536 {
1537 for (int j = 0; j < nj; j++)
1538 {
1539 for (int i = 0; i < ni; i++)
1540 {
1541 const int kg = k + offset;
1542 const double dz_pour_delta = delta_z_pour_delta[k];
1543
1544 const double rho = champ_rho(i,j,k);
1545
1546 if (!anisotropic)
1547 {
1548 calculer_g(i, j, k, velocity, delta_z_maillage, 1., 1., 1., 1., 1., g);
1549 calculer_q(i, j, k, velocity, champ_scalar, scalar_kmin, scalar_kmax, delta_z_maillage, 1., 1., 1., 1., 1., q);
1550// Modif Martin
1551 turbulent_mu(i,j,k) = model(turbulent_viscosity_model_constant_tab[k], dx_pour_delta, dy_pour_delta, dz_pour_delta, rho, g, q);
1552// Fin modif Martin
1553 }
1554 else
1555 {
1556 const double delta_m_pour_delta = kg==0 ? 0. : 0.5*(dz_pour_delta + delta_z_pour_delta[k-1]);
1557 const double delta_p_pour_delta = kg==(nktot-1) ? 0. : 0.5*(dz_pour_delta + delta_z_pour_delta[k+1]);
1558 calculer_g(i, j, k, velocity, delta_z_maillage, dx_pour_delta, dy_pour_delta, dz_pour_delta, delta_m_pour_delta, delta_p_pour_delta, g);
1559 calculer_q(i, j, k, velocity, champ_scalar, scalar_kmin, scalar_kmax, delta_z_maillage, dx_pour_delta, dy_pour_delta, dz_pour_delta, delta_m_pour_delta, delta_p_pour_delta, q);
1560// Modif Martin
1561 turbulent_mu(i,j,k) = model(turbulent_viscosity_model_constant_tab[k], 1., 1., 1., rho, g, q);
1562// Fin modif Martin
1563 }
1564 }
1565 }
1566 }
1567}
1568
1569template<class T>
1570void calculer_ml_dynamic_uu_tensor(const bool anisotropic,
1571 const bool tensorial,
1572 const IJK_Field_vector3_double& velocity,
1573 const IJK_Field_vector3_double& velocity_filtre,
1574 const int turbulent_viscosity,
1575 const IJK_Field_double& turbulent_mu_xx,
1576 const IJK_Field_double& turbulent_mu_xy,
1577 const IJK_Field_double& turbulent_mu_xz,
1578 const IJK_Field_double& turbulent_mu_yy,
1579 const IJK_Field_double& turbulent_mu_yz,
1580 const IJK_Field_double& turbulent_mu_zz,
1581 const IJK_Field_double& turbulent_mu_filtre_xx,
1582 const IJK_Field_double& turbulent_mu_filtre_xy,
1583 const IJK_Field_double& turbulent_mu_filtre_xz,
1584 const IJK_Field_double& turbulent_mu_filtre_yy,
1585 const IJK_Field_double& turbulent_mu_filtre_yz,
1586 const IJK_Field_double& turbulent_mu_filtre_zz,
1587 const int structural_uu,
1588 const FixedVector<IJK_Field_double, 6>& structural_uu_tensor,
1589 const FixedVector<IJK_Field_double, 6>& structural_uu_filtre_tensor,
1590 const ArrOfDouble_with_ghost& delta_z,
1591 const double facteur_delta_x,
1592 const double facteur_delta_y,
1593 const ArrOfDouble_with_ghost& delta_z_pour_delta,
1594 const double facteur_delta_filtre_x,
1595 const double facteur_delta_filtre_y,
1596 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
1597 T& kernel,
1601{
1602 const IJK_Field_double& vitesse_i = velocity[0];
1603 const IJK_Field_double& vitesse_j = velocity[1];
1604 const IJK_Field_double& vitesse_k = velocity[2];
1605
1606 const IJK_Field_double& vitesse_i_filtre = velocity_filtre[0];
1607 const IJK_Field_double& vitesse_j_filtre = velocity_filtre[1];
1608 const IJK_Field_double& vitesse_k_filtre = velocity_filtre[2];
1609
1610 const IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
1611 const IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
1612 const IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
1613 const IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
1614 const IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
1615 const IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
1616
1617 const IJK_Field_double& structural_uu_filtre_xx = structural_uu_filtre_tensor[0];
1618 const IJK_Field_double& structural_uu_filtre_xy = structural_uu_filtre_tensor[1];
1619 const IJK_Field_double& structural_uu_filtre_xz = structural_uu_filtre_tensor[2];
1620 const IJK_Field_double& structural_uu_filtre_yy = structural_uu_filtre_tensor[3];
1621 const IJK_Field_double& structural_uu_filtre_yz = structural_uu_filtre_tensor[4];
1622 const IJK_Field_double& structural_uu_filtre_zz = structural_uu_filtre_tensor[5];
1623
1624 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
1625 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
1626 const double dx_pour_delta = facteur_delta_x*dx;
1627 const double dy_pour_delta = facteur_delta_y*dy;
1628
1629 const int ni = vitesse_k.ni();
1630 const int nj = vitesse_k.nj();
1631 const int nk = vitesse_k.nk();
1632
1633 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
1634 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
1635
1636 IJK_Field_local_double& bf_ii = tmp_b[0];
1637 IJK_Field_local_double& bf_ij = tmp_b[1];
1638 IJK_Field_local_double& bf_ik = tmp_b[2];
1639 IJK_Field_local_double& bf_jj = tmp_b[3];
1640 IJK_Field_local_double& bf_jk = tmp_b[4];
1641 IJK_Field_local_double& bf_kk = tmp_b[5];
1642 IJK_Field_local_double& buu_ii = tmp_b[6];
1643 IJK_Field_local_double& buu_ij = tmp_b[7];
1644 IJK_Field_local_double& buu_ik = tmp_b[8];
1645 IJK_Field_local_double& buu_jj = tmp_b[9];
1646 IJK_Field_local_double& buu_jk = tmp_b[10];
1647 IJK_Field_local_double& buu_kk = tmp_b[11];
1648 IJK_Field_local_double& bg_ii = tmp_b[12];
1649 IJK_Field_local_double& bg_ij = tmp_b[13];
1650 IJK_Field_local_double& bg_ik = tmp_b[14];
1651 IJK_Field_local_double& bg_jj = tmp_b[15];
1652 IJK_Field_local_double& bg_jk = tmp_b[16];
1653 IJK_Field_local_double& bg_kk = tmp_b[17];
1654
1655 IJK_Field_local_double& af_ii = tmp_a[0];
1656 IJK_Field_local_double& af_ij = tmp_a[1];
1657 IJK_Field_local_double& af_ik = tmp_a[2];
1658 IJK_Field_local_double& af_jj = tmp_a[3];
1659 IJK_Field_local_double& af_jk = tmp_a[4];
1660 IJK_Field_local_double& af_kk = tmp_a[5];
1661 IJK_Field_local_double& auu_ii = tmp_a[6];
1662 IJK_Field_local_double& auu_ij = tmp_a[7];
1663 IJK_Field_local_double& auu_ik = tmp_a[8];
1664 IJK_Field_local_double& auu_jj = tmp_a[9];
1665 IJK_Field_local_double& auu_jk = tmp_a[10];
1666 IJK_Field_local_double& auu_kk = tmp_a[11];
1667 IJK_Field_local_double& ag_ii = tmp_a[12];
1668 IJK_Field_local_double& ag_ij = tmp_a[13];
1669 IJK_Field_local_double& ag_ik = tmp_a[14];
1670 IJK_Field_local_double& ag_jj = tmp_a[15];
1671 IJK_Field_local_double& ag_jk = tmp_a[16];
1672 IJK_Field_local_double& ag_kk = tmp_a[17];
1673
1674 ArrOfDouble& moy_lij_xx = ml[0][0];
1675 ArrOfDouble& moy_lij_xy = ml[0][1];
1676 ArrOfDouble& moy_lij_xz = ml[0][2];
1677 ArrOfDouble& moy_lij_yy = ml[0][3];
1678 ArrOfDouble& moy_lij_yz = ml[0][4];
1679 ArrOfDouble& moy_lij_zz = ml[0][5];
1680
1681 ArrOfDouble& moy_mij_xx = ml[1][0];
1682 ArrOfDouble& moy_mij_xy = ml[1][1];
1683 ArrOfDouble& moy_mij_xz = ml[1][2];
1684 ArrOfDouble& moy_mij_yy = ml[1][3];
1685 ArrOfDouble& moy_mij_yz = ml[1][4];
1686 ArrOfDouble& moy_mij_zz = ml[1][5];
1687
1688 ArrOfDouble& moy_hij_xx = ml[2][0];
1689 ArrOfDouble& moy_hij_xy = ml[2][1];
1690 ArrOfDouble& moy_hij_xz = ml[2][2];
1691 ArrOfDouble& moy_hij_yy = ml[2][3];
1692 ArrOfDouble& moy_hij_yz = ml[2][4];
1693 ArrOfDouble& moy_hij_zz = ml[2][5];
1694
1695 ArrOfDouble& moy_mijmij_xx = ml[3][0];
1696 ArrOfDouble& moy_mijmij_xy = ml[3][1];
1697 ArrOfDouble& moy_mijmij_xz = ml[3][2];
1698 ArrOfDouble& moy_mijmij_yy = ml[3][3];
1699 ArrOfDouble& moy_mijmij_yz = ml[3][4];
1700 ArrOfDouble& moy_mijmij_zz = ml[3][5];
1701 ArrOfDouble& moy_mijmij = ml[3][6];
1702
1703 ArrOfDouble& moy_hijhij_xx = ml[4][0];
1704 ArrOfDouble& moy_hijhij_xy = ml[4][1];
1705 ArrOfDouble& moy_hijhij_xz = ml[4][2];
1706 ArrOfDouble& moy_hijhij_yy = ml[4][3];
1707 ArrOfDouble& moy_hijhij_yz = ml[4][4];
1708 ArrOfDouble& moy_hijhij_zz = ml[4][5];
1709 ArrOfDouble& moy_hijhij = ml[4][6];
1710
1711 ArrOfDouble& moy_mijlij_xx = ml[5][0];
1712 ArrOfDouble& moy_mijlij_xy = ml[5][1];
1713 ArrOfDouble& moy_mijlij_xz = ml[5][2];
1714 ArrOfDouble& moy_mijlij_yy = ml[5][3];
1715 ArrOfDouble& moy_mijlij_yz = ml[5][4];
1716 ArrOfDouble& moy_mijlij_zz = ml[5][5];
1717 ArrOfDouble& moy_mijlij = ml[5][6];
1718
1719 ArrOfDouble& moy_hijlij_xx = ml[6][0];
1720 ArrOfDouble& moy_hijlij_xy = ml[6][1];
1721 ArrOfDouble& moy_hijlij_xz = ml[6][2];
1722 ArrOfDouble& moy_hijlij_yy = ml[6][3];
1723 ArrOfDouble& moy_hijlij_yz = ml[6][4];
1724 ArrOfDouble& moy_hijlij_zz = ml[6][5];
1725 ArrOfDouble& moy_hijlij = ml[6][6];
1726
1727 ArrOfDouble& moy_mijhij_xx = ml[7][0];
1728 ArrOfDouble& moy_mijhij_xy = ml[7][1];
1729 ArrOfDouble& moy_mijhij_xz = ml[7][2];
1730 ArrOfDouble& moy_mijhij_yy = ml[7][3];
1731 ArrOfDouble& moy_mijhij_yz = ml[7][4];
1732 ArrOfDouble& moy_mijhij_zz = ml[7][5];
1733 ArrOfDouble& moy_mijhij = ml[7][6];
1734
1735 double m_ii = 0.;
1736 double m_ij = 0.;
1737 double m_ik = 0.;
1738 double m_jj = 0.;
1739 double m_jk = 0.;
1740 double m_kk = 0.;
1741
1742 double h_ii = 0.;
1743 double h_ij = 0.;
1744 double h_ik = 0.;
1745 double h_jj = 0.;
1746 double h_jk = 0.;
1747 double h_kk = 0.;
1748
1751
1752 const int ghost_size_filter = kernel->ghost_size();
1753 const int size_uniform = kernel->size_uniform();
1754 const int shift_uniform = kernel->shift_uniform();
1755 for (int k = 0; k < nk; k++)
1756 {
1757 const int kg = k + offset;
1758
1759 if (tensorial)
1760 {
1761 moy_lij_xx[kg] = 0;
1762 moy_lij_xy[kg] = 0;
1763 moy_lij_xz[kg] = 0;
1764 moy_lij_yy[kg] = 0;
1765 moy_lij_yz[kg] = 0;
1766 moy_lij_zz[kg] = 0;
1767
1768 moy_mij_xx[kg] = 0;
1769 moy_mij_xy[kg] = 0;
1770 moy_mij_xz[kg] = 0;
1771 moy_mij_yy[kg] = 0;
1772 moy_mij_yz[kg] = 0;
1773 moy_mij_zz[kg] = 0;
1774
1775 moy_hij_xx[kg] = 0;
1776 moy_hij_xy[kg] = 0;
1777 moy_hij_xz[kg] = 0;
1778 moy_hij_yy[kg] = 0;
1779 moy_hij_yz[kg] = 0;
1780 moy_hij_zz[kg] = 0;
1781
1782 moy_mijmij_xx[kg] = 0;
1783 moy_mijmij_xy[kg] = 0;
1784 moy_mijmij_xz[kg] = 0;
1785 moy_mijmij_yy[kg] = 0;
1786 moy_mijmij_yz[kg] = 0;
1787 moy_mijmij_zz[kg] = 0;
1788
1789 moy_hijhij_xx[kg] = 0;
1790 moy_hijhij_xy[kg] = 0;
1791 moy_hijhij_xz[kg] = 0;
1792 moy_hijhij_yy[kg] = 0;
1793 moy_hijhij_yz[kg] = 0;
1794 moy_hijhij_zz[kg] = 0;
1795
1796 moy_mijlij_xx[kg] = 0;
1797 moy_mijlij_xy[kg] = 0;
1798 moy_mijlij_xz[kg] = 0;
1799 moy_mijlij_yy[kg] = 0;
1800 moy_mijlij_yz[kg] = 0;
1801 moy_mijlij_zz[kg] = 0;
1802
1803 moy_hijlij_xx[kg] = 0;
1804 moy_hijlij_xy[kg] = 0;
1805 moy_hijlij_xz[kg] = 0;
1806 moy_hijlij_yy[kg] = 0;
1807 moy_hijlij_yz[kg] = 0;
1808 moy_hijlij_zz[kg] = 0;
1809
1810 moy_mijhij_xx[kg] = 0;
1811 moy_mijhij_xy[kg] = 0;
1812 moy_mijhij_xz[kg] = 0;
1813 moy_mijhij_yy[kg] = 0;
1814 moy_mijhij_yz[kg] = 0;
1815 moy_mijhij_zz[kg] = 0;
1816 }
1817
1818 moy_mijmij[kg] = 0;
1819 moy_hijhij[kg] = 0;
1820 moy_mijlij[kg] = 0;
1821 moy_hijlij[kg] = 0;
1822 moy_mijhij[kg] = 0;
1823
1824 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
1825 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
1826
1827 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
1828 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
1829 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
1830 const int size_k_elem = kernel->size_k_elem(kg, nktot);
1831 const int shift_k_elem = kernel->shift_k_elem(kg);
1832 const bool ponderation_filter_kernel = kernel->ponderation();
1833 const bool normalisation_filter_kernel = kernel->normalisation();
1834
1835 double facteur_elem = 0.;
1836 if (ponderation_filter_kernel)
1837 {
1838 if (normalisation_filter_kernel)
1839 {
1840 double longueur_elem = 0.;
1841 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
1842 {
1843 const int kpg = kg + kp;
1844 if (kpg<-1 || kpg>nktot)
1845 {
1846 Cerr << "This should not happen." << finl;
1847 Process::exit();
1848 }
1849 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
1850 const double filter_coef_z = filter_kernel_z[kp+10];
1851 longueur_elem += filter_coef_z * dz;
1852 }
1853 facteur_elem = 1./longueur_elem;
1854 }
1855 else
1856 {
1857 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
1858 }
1859 }
1860
1861 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
1862 {
1863 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
1864 {
1865 buu_ii(i, j, 0) = 0.;
1866 buu_ij(i, j, 0) = 0.;
1867 buu_ik(i, j, 0) = 0.;
1868 buu_jj(i, j, 0) = 0.;
1869 buu_jk(i, j, 0) = 0.;
1870 buu_kk(i, j, 0) = 0.;
1871 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
1872 {
1873 const int kpg = kg + kp;
1874 if (!(kernel->is_at_wall_elem(kpg, nktot)))
1875 {
1876 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
1877 const double filter_coef_z = filter_kernel_z[kp+10];
1878 const double uf_i = vitesse_i(i,j,k+kp);
1879 const double vf_j = vitesse_j(i,j,k+kp);
1880 const double wf_k = vitesse_k(i,j,k+kp);
1881
1882 const double uf_ip1 = vitesse_i(i+1,j,k+kp);
1883 const double vf_jp1 = vitesse_j(i,j+1,k+kp);
1884 const double wf_kp1 = kpg==(nktot-1) ? 0. : vitesse_k(i,j,k+1+kp);
1885
1886 const double ue = 0.5 * (uf_i + uf_ip1);
1887 const double ve = 0.5 * (vf_j + vf_jp1);
1888 const double we = 0.5 * (wf_k + wf_kp1);
1889
1890 const double uu_e = ue * ue;
1891 const double uv_e = ue * ve;
1892 const double uw_e = ue * we;
1893 const double vv_e = ve * ve;
1894 const double vw_e = ve * we;
1895 const double ww_e = we * we;
1896
1897 if (ponderation_filter_kernel)
1898 {
1899 buu_ii(i, j, 0) += uu_e * filter_coef_z * dz * facteur_elem;
1900 buu_ij(i, j, 0) += uv_e * filter_coef_z * dz * facteur_elem;
1901 buu_ik(i, j, 0) += uw_e * filter_coef_z * dz * facteur_elem;
1902 buu_jj(i, j, 0) += vv_e * filter_coef_z * dz * facteur_elem;
1903 buu_jk(i, j, 0) += vw_e * filter_coef_z * dz * facteur_elem;
1904 buu_kk(i, j, 0) += ww_e * filter_coef_z * dz * facteur_elem;
1905 }
1906 else
1907 {
1908 buu_ii(i, j, 0) += uu_e * filter_coef_z;
1909 buu_ij(i, j, 0) += uv_e * filter_coef_z;
1910 buu_ik(i, j, 0) += uw_e * filter_coef_z;
1911 buu_jj(i, j, 0) += vv_e * filter_coef_z;
1912 buu_jk(i, j, 0) += vw_e * filter_coef_z;
1913 buu_kk(i, j, 0) += ww_e * filter_coef_z;
1914 }
1915 }
1916 }
1917
1918 if (turbulent_viscosity)
1919 {
1920 bf_ii(i, j, 0) = 0.;
1921 bf_ij(i, j, 0) = 0.;
1922 bf_ik(i, j, 0) = 0.;
1923 bf_jj(i, j, 0) = 0.;
1924 bf_jk(i, j, 0) = 0.;
1925 bf_kk(i, j, 0) = 0.;
1926 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
1927 {
1928 const int kpg = kg + kp;
1929 if (!(kernel->is_at_wall_elem(kpg, nktot)))
1930 {
1931 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
1932 const double filter_coef_z = filter_kernel_z[kp+10];
1933 if (!anisotropic)
1934 {
1935 calculer_tau(i, j, k+kp, velocity, turbulent_mu_xx, turbulent_mu_xy, turbulent_mu_xz, turbulent_mu_yy, turbulent_mu_yz, turbulent_mu_zz, delta_z, 1., 1., 1., 1., 1., f);
1936 }
1937 else
1938 {
1939 const double dz_pour_delta = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z_pour_delta[k+kp];
1940 const double dz_m1_pour_delta = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1+kp];
1941 const double dz_p1_pour_delta = (kpg+1<0 || kpg+1>(nktot-1)) ? 0. : delta_z_pour_delta[k+1+kp];
1942 const double delta_m_pour_delta = (kpg-1<0 || kpg>(nktot-1)) ? 0. : 0.5*(dz_pour_delta + dz_m1_pour_delta);
1943 const double delta_p_pour_delta = (kpg<0 || kpg+1>(nktot-1)) ? 0. : 0.5*(dz_pour_delta + dz_p1_pour_delta);
1944 calculer_tau(i, j, k+kp, velocity, turbulent_mu_xx, turbulent_mu_xy, turbulent_mu_xz, turbulent_mu_yy, turbulent_mu_yz, turbulent_mu_zz, delta_z, dx_pour_delta, dy_pour_delta, dz_pour_delta, delta_m_pour_delta, delta_p_pour_delta, f);
1945 }
1946
1947 if (ponderation_filter_kernel)
1948 {
1949 bf_ii(i, j, 0) += f[0][0] * filter_coef_z * dz * facteur_elem;
1950 bf_ij(i, j, 0) += f[0][1] * filter_coef_z * dz * facteur_elem;
1951 bf_ik(i, j, 0) += f[0][2] * filter_coef_z * dz * facteur_elem;
1952 bf_jj(i, j, 0) += f[1][1] * filter_coef_z * dz * facteur_elem;
1953 bf_jk(i, j, 0) += f[1][2] * filter_coef_z * dz * facteur_elem;
1954 bf_kk(i, j, 0) += f[2][2] * filter_coef_z * dz * facteur_elem;
1955 }
1956 else
1957 {
1958 bf_ii(i, j, 0) += f[0][0] * filter_coef_z;
1959 bf_ij(i, j, 0) += f[0][1] * filter_coef_z;
1960 bf_ik(i, j, 0) += f[0][2] * filter_coef_z;
1961 bf_jj(i, j, 0) += f[1][1] * filter_coef_z;
1962 bf_jk(i, j, 0) += f[1][2] * filter_coef_z;
1963 bf_kk(i, j, 0) += f[2][2] * filter_coef_z;
1964 }
1965 }
1966 }
1967 }
1968
1969 if (structural_uu)
1970 {
1971 bg_ii(i, j, 0) = 0.;
1972 bg_ij(i, j, 0) = 0.;
1973 bg_ik(i, j, 0) = 0.;
1974 bg_jj(i, j, 0) = 0.;
1975 bg_jk(i, j, 0) = 0.;
1976 bg_kk(i, j, 0) = 0.;
1977 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
1978 {
1979 const int kpg = kg + kp;
1980 if (!(kernel->is_at_wall_elem(kpg, nktot)))
1981 {
1982 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
1983 const double filter_coef_z = filter_kernel_z[kp+10];
1984 const double gxx_e = -structural_uu_xx(i,j,k+kp);
1985 const double gyy_e = -structural_uu_yy(i,j,k+kp);
1986 const double gzz_e = -structural_uu_zz(i,j,k+kp);
1987
1988 const double gxy_ij = -structural_uu_xy(i,j,k+kp);
1989 const double gxz_ik = -structural_uu_xz(i,j,k+kp);
1990 const double gyz_jk = -structural_uu_yz(i,j,k+kp);
1991
1992 const double gxy_ip1j = -structural_uu_xy(i+1,j,k+kp);
1993 const double gxz_ip1k = -structural_uu_xz(i+1,j,k+kp);
1994 const double gyz_jp1k = -structural_uu_yz(i,j+1,k+kp);
1995
1996 const double gxy_ijp1 = -structural_uu_xy(i,j+1,k+kp);
1997 const double gxz_ikp1 = kpg==(nktot-1) ? 0. : -structural_uu_xz(i,j,k+1+kp);
1998 const double gyz_jkp1 = kpg==(nktot-1) ? 0. : -structural_uu_yz(i,j,k+1+kp);
1999
2000 const double gxy_ip1jp1 = -structural_uu_xy(i+1,j+1,k+kp);
2001 const double gxz_ip1kp1 = kpg==(nktot-1) ? 0. : -structural_uu_xz(i+1,j,k+1+kp);
2002 const double gyz_jp1kp1 = kpg==(nktot-1) ? 0. : -structural_uu_yz(i,j+1,k+1+kp);
2003
2004 const double gxy_e = 0.25 * (gxy_ij + gxy_ip1j + gxy_ijp1 + gxy_ip1jp1);
2005 const double gxz_e = 0.25 * (gxz_ik + gxz_ip1k + gxz_ikp1 + gxz_ip1kp1);
2006 const double gyz_e = 0.25 * (gyz_jk + gyz_jp1k + gyz_jkp1 + gyz_jp1kp1);
2007
2008 if (ponderation_filter_kernel)
2009 {
2010 bg_ii(i, j, 0) += gxx_e * filter_coef_z * dz * facteur_elem;
2011 bg_ij(i, j, 0) += gxy_e * filter_coef_z * dz * facteur_elem;
2012 bg_ik(i, j, 0) += gxz_e * filter_coef_z * dz * facteur_elem;
2013 bg_jj(i, j, 0) += gyy_e * filter_coef_z * dz * facteur_elem;
2014 bg_jk(i, j, 0) += gyz_e * filter_coef_z * dz * facteur_elem;
2015 bg_kk(i, j, 0) += gzz_e * filter_coef_z * dz * facteur_elem;
2016 }
2017 else
2018 {
2019 bg_ii(i, j, 0) += gxx_e * filter_coef_z;
2020 bg_ij(i, j, 0) += gxy_e * filter_coef_z;
2021 bg_ik(i, j, 0) += gxz_e * filter_coef_z;
2022 bg_jj(i, j, 0) += gyy_e * filter_coef_z;
2023 bg_jk(i, j, 0) += gyz_e * filter_coef_z;
2024 bg_kk(i, j, 0) += gzz_e * filter_coef_z;
2025 }
2026 }
2027 }
2028 }
2029 }
2030 }
2031 for (int j = 0; j < nj; j++)
2032 {
2033 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
2034 {
2035 auu_ii(i, 0, 0) = 0.;
2036 auu_ij(i, 0, 0) = 0.;
2037 auu_ik(i, 0, 0) = 0.;
2038 auu_jj(i, 0, 0) = 0.;
2039 auu_jk(i, 0, 0) = 0.;
2040 auu_kk(i, 0, 0) = 0.;
2041 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
2042 {
2043 const double filter_coef_y = filter_kernel_y[jp+10];
2044 auu_ii(i, 0, 0) += buu_ii(i, j+jp, 0) * filter_coef_y;
2045 auu_ij(i, 0, 0) += buu_ij(i, j+jp, 0) * filter_coef_y;
2046 auu_ik(i, 0, 0) += buu_ik(i, j+jp, 0) * filter_coef_y;
2047 auu_jj(i, 0, 0) += buu_jj(i, j+jp, 0) * filter_coef_y;
2048 auu_jk(i, 0, 0) += buu_jk(i, j+jp, 0) * filter_coef_y;
2049 auu_kk(i, 0, 0) += buu_kk(i, j+jp, 0) * filter_coef_y;
2050 }
2051 if (turbulent_viscosity)
2052 {
2053 af_ii(i, 0, 0) = 0.;
2054 af_ij(i, 0, 0) = 0.;
2055 af_ik(i, 0, 0) = 0.;
2056 af_jj(i, 0, 0) = 0.;
2057 af_jk(i, 0, 0) = 0.;
2058 af_kk(i, 0, 0) = 0.;
2059 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
2060 {
2061 const double filter_coef_y = filter_kernel_y[jp+10];
2062 af_ii(i, 0, 0) += bf_ii(i, j+jp, 0) * filter_coef_y;
2063 af_ij(i, 0, 0) += bf_ij(i, j+jp, 0) * filter_coef_y;
2064 af_ik(i, 0, 0) += bf_ik(i, j+jp, 0) * filter_coef_y;
2065 af_jj(i, 0, 0) += bf_jj(i, j+jp, 0) * filter_coef_y;
2066 af_jk(i, 0, 0) += bf_jk(i, j+jp, 0) * filter_coef_y;
2067 af_kk(i, 0, 0) += bf_kk(i, j+jp, 0) * filter_coef_y;
2068 }
2069 }
2070 if (structural_uu)
2071 {
2072 ag_ii(i, 0, 0) = 0.;
2073 ag_ij(i, 0, 0) = 0.;
2074 ag_ik(i, 0, 0) = 0.;
2075 ag_jj(i, 0, 0) = 0.;
2076 ag_jk(i, 0, 0) = 0.;
2077 ag_kk(i, 0, 0) = 0.;
2078 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
2079 {
2080 const double filter_coef_y = filter_kernel_y[jp+10];
2081 ag_ii(i, 0, 0) += bg_ii(i, j+jp, 0) * filter_coef_y;
2082 ag_ij(i, 0, 0) += bg_ij(i, j+jp, 0) * filter_coef_y;
2083 ag_ik(i, 0, 0) += bg_ik(i, j+jp, 0) * filter_coef_y;
2084 ag_jj(i, 0, 0) += bg_jj(i, j+jp, 0) * filter_coef_y;
2085 ag_jk(i, 0, 0) += bg_jk(i, j+jp, 0) * filter_coef_y;
2086 ag_kk(i, 0, 0) += bg_kk(i, j+jp, 0) * filter_coef_y;
2087 }
2088 }
2089 }
2090
2091 for (int i = 0; i < ni; i++)
2092 {
2093 double ruu_ii = 0.;
2094 double ruu_ij = 0.;
2095 double ruu_ik = 0.;
2096 double ruu_jj = 0.;
2097 double ruu_jk = 0.;
2098 double ruu_kk = 0.;
2099 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
2100 {
2101 const double filter_coef_x = filter_kernel_x[ip+10];
2102 ruu_ii += auu_ii(i+ip, 0, 0) * filter_coef_x;
2103 ruu_ij += auu_ij(i+ip, 0, 0) * filter_coef_x;
2104 ruu_ik += auu_ik(i+ip, 0, 0) * filter_coef_x;
2105 ruu_jj += auu_jj(i+ip, 0, 0) * filter_coef_x;
2106 ruu_jk += auu_jk(i+ip, 0, 0) * filter_coef_x;
2107 ruu_kk += auu_kk(i+ip, 0, 0) * filter_coef_x;
2108 }
2109
2110 const double uf_i = vitesse_i_filtre(i,j,k);
2111 const double vf_j = vitesse_j_filtre(i,j,k);
2112 const double wf_k = vitesse_k_filtre(i,j,k);
2113
2114 const double uf_ip1 = vitesse_i_filtre(i+1,j,k);
2115 const double vf_jp1 = vitesse_j_filtre(i,j+1,k);
2116 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k_filtre(i,j,k+1);
2117
2118 const double ue = 0.5 * (uf_i + uf_ip1);
2119 const double ve = 0.5 * (vf_j + vf_jp1);
2120 const double we = 0.5 * (wf_k + wf_kp1);
2121
2122 const double l_ii = ruu_ii - ue*ue;
2123 const double l_ij = ruu_ij - ue*ve;
2124 const double l_ik = ruu_ik - ue*we;
2125 const double l_jj = ruu_jj - ve*ve;
2126 const double l_jk = ruu_jk - ve*we;
2127 const double l_kk = ruu_kk - we*we;
2128
2129 if (tensorial)
2130 {
2131 moy_lij_xx[kg] += l_ii;
2132 moy_lij_xy[kg] += l_ij;
2133 moy_lij_xz[kg] += l_ik;
2134 moy_lij_yy[kg] += l_jj;
2135 moy_lij_yz[kg] += l_jk;
2136 moy_lij_zz[kg] += l_kk;
2137 }
2138
2139 if (turbulent_viscosity)
2140 {
2141 double rf_ii = 0.;
2142 double rf_ij = 0.;
2143 double rf_ik = 0.;
2144 double rf_jj = 0.;
2145 double rf_jk = 0.;
2146 double rf_kk = 0.;
2147 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
2148 {
2149 const double filter_coef_x = filter_kernel_x[ip+10];
2150 rf_ii += af_ii(i+ip, 0, 0) * filter_coef_x;
2151 rf_ij += af_ij(i+ip, 0, 0) * filter_coef_x;
2152 rf_ik += af_ik(i+ip, 0, 0) * filter_coef_x;
2153 rf_jj += af_jj(i+ip, 0, 0) * filter_coef_x;
2154 rf_jk += af_jk(i+ip, 0, 0) * filter_coef_x;
2155 rf_kk += af_kk(i+ip, 0, 0) * filter_coef_x;
2156 }
2157
2158 if (!anisotropic)
2159 {
2160 calculer_tau(i, j, k, velocity_filtre, turbulent_mu_filtre_xx, turbulent_mu_filtre_xy, turbulent_mu_filtre_xz, turbulent_mu_filtre_yy, turbulent_mu_filtre_yz, turbulent_mu_filtre_zz, delta_z, 1., 1., 1., 1., 1., f_filtre);
2161 }
2162 else
2163 {
2164 const double dx_filtre = facteur_delta_filtre_x*dx;
2165 const double dy_filtre = facteur_delta_filtre_y*dy;
2166 const double dz_filtre = delta_z_pour_delta_filtre[k];
2167 const double delta_m_filtre = kg==0 ? 0. : 0.5*(dz_filtre + delta_z_pour_delta_filtre[k-1]);
2168 const double delta_p_filtre = kg==(nktot-1) ? 0. : 0.5*(dz_filtre + delta_z_pour_delta_filtre[k+1]);
2169 calculer_tau(i, j, k, velocity_filtre, turbulent_mu_filtre_xx, turbulent_mu_filtre_xy, turbulent_mu_filtre_xz, turbulent_mu_filtre_yy, turbulent_mu_filtre_yz, turbulent_mu_filtre_zz, delta_z, dx_filtre, dy_filtre, dz_filtre, delta_m_filtre, delta_p_filtre, f_filtre);
2170 }
2171
2172 m_ii = f_filtre[0][0] - rf_ii;
2173 m_ij = f_filtre[0][1] - rf_ij;
2174 m_ik = f_filtre[0][2] - rf_ik;
2175 m_jj = f_filtre[1][1] - rf_jj;
2176 m_jk = f_filtre[1][2] - rf_jk;
2177 m_kk = f_filtre[2][2] - rf_kk;
2178
2179 const double mijmij = m_ii * m_ii
2180 + m_ij * m_ij
2181 + m_ik * m_ik
2182 + m_ij * m_ij
2183 + m_jj * m_jj
2184 + m_jk * m_jk
2185 + m_ik * m_ik
2186 + m_jk * m_jk
2187 + m_kk * m_kk;
2188
2189 const double mijlij = m_ii * l_ii
2190 + m_ij * l_ij
2191 + m_ik * l_ik
2192 + m_ij * l_ij
2193 + m_jj * l_jj
2194 + m_jk * l_jk
2195 + m_ik * l_ik
2196 + m_jk * l_jk
2197 + m_kk * l_kk;
2198
2199 moy_mijmij[kg] += mijmij;
2200 moy_mijlij[kg] += mijlij;
2201
2202 if (tensorial)
2203 {
2204 moy_mij_xx[kg] += m_ii;
2205 moy_mij_xy[kg] += m_ij;
2206 moy_mij_xz[kg] += m_ik;
2207 moy_mij_yy[kg] += m_jj;
2208 moy_mij_yz[kg] += m_jk;
2209 moy_mij_zz[kg] += m_kk;
2210
2211 moy_mijmij_xx[kg] += m_ii * m_ii;
2212 moy_mijmij_xy[kg] += m_ij * m_ij;
2213 moy_mijmij_xz[kg] += m_ik * m_ik;
2214 moy_mijmij_yy[kg] += m_jj * m_jj;
2215 moy_mijmij_yz[kg] += m_jk * m_jk;
2216 moy_mijmij_zz[kg] += m_kk * m_kk;
2217
2218 moy_mijlij_xx[kg] += m_ii * l_ii;
2219 moy_mijlij_xy[kg] += m_ij * l_ij;
2220 moy_mijlij_xz[kg] += m_ik * l_ik;
2221 moy_mijlij_yy[kg] += m_jj * l_jj;
2222 moy_mijlij_yz[kg] += m_jk * l_jk;
2223 moy_mijlij_zz[kg] += m_kk * l_kk;
2224 }
2225 }
2226
2227 if (structural_uu)
2228 {
2229 double rg_ii = 0.;
2230 double rg_ij = 0.;
2231 double rg_ik = 0.;
2232 double rg_jj = 0.;
2233 double rg_jk = 0.;
2234 double rg_kk = 0.;
2235 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
2236 {
2237 const double filter_coef_x = filter_kernel_x[ip+10];
2238 rg_ii += ag_ii(i+ip, 0, 0) * filter_coef_x;
2239 rg_ij += ag_ij(i+ip, 0, 0) * filter_coef_x;
2240 rg_ik += ag_ik(i+ip, 0, 0) * filter_coef_x;
2241 rg_jj += ag_jj(i+ip, 0, 0) * filter_coef_x;
2242 rg_jk += ag_jk(i+ip, 0, 0) * filter_coef_x;
2243 rg_kk += ag_kk(i+ip, 0, 0) * filter_coef_x;
2244 }
2245
2246 const double gxx_e = -structural_uu_filtre_xx(i,j,k);
2247 const double gyy_e = -structural_uu_filtre_yy(i,j,k);
2248 const double gzz_e = -structural_uu_filtre_zz(i,j,k);
2249
2250 const double gxy_ij = -structural_uu_filtre_xy(i,j,k);
2251 const double gxz_ik = -structural_uu_filtre_xz(i,j,k);
2252 const double gyz_jk = -structural_uu_filtre_yz(i,j,k);
2253
2254 const double gxy_ip1j = -structural_uu_filtre_xy(i+1,j,k);
2255 const double gxz_ip1k = -structural_uu_filtre_xz(i+1,j,k);
2256 const double gyz_jp1k = -structural_uu_filtre_yz(i,j+1,k);
2257
2258 const double gxy_ijp1 = -structural_uu_filtre_xy(i,j+1,k);
2259 const double gxz_ikp1 = kg==(nktot-1) ? 0. : -structural_uu_filtre_xz(i,j,k+1);
2260 const double gyz_jkp1 = kg==(nktot-1) ? 0. : -structural_uu_filtre_yz(i,j,k+1);
2261
2262 const double gxy_ip1jp1 = -structural_uu_filtre_xy(i+1,j+1,k);
2263 const double gxz_ip1kp1 = kg==(nktot-1) ? 0. : -structural_uu_filtre_xz(i+1,j,k+1);
2264 const double gyz_jp1kp1 = kg==(nktot-1) ? 0. : -structural_uu_filtre_yz(i,j+1,k+1);
2265
2266 const double gxy_e = 0.25 * (gxy_ij + gxy_ip1j + gxy_ijp1 + gxy_ip1jp1);
2267 const double gxz_e = 0.25 * (gxz_ik + gxz_ip1k + gxz_ikp1 + gxz_ip1kp1);
2268 const double gyz_e = 0.25 * (gyz_jk + gyz_jp1k + gyz_jkp1 + gyz_jp1kp1);
2269
2270 h_ii = gxx_e - rg_ii;
2271 h_ij = gxy_e - rg_ij;
2272 h_ik = gxz_e - rg_ik;
2273 h_jj = gyy_e - rg_jj;
2274 h_jk = gyz_e - rg_jk;
2275 h_kk = gzz_e - rg_kk;
2276
2277 const double hijhij = h_ii * h_ii
2278 + h_ij * h_ij
2279 + h_ik * h_ik
2280 + h_ij * h_ij
2281 + h_jj * h_jj
2282 + h_jk * h_jk
2283 + h_ik * h_ik
2284 + h_jk * h_jk
2285 + h_kk * h_kk;
2286
2287 const double hijlij = h_ii * l_ii
2288 + h_ij * l_ij
2289 + h_ik * l_ik
2290 + h_ij * l_ij
2291 + h_jj * l_jj
2292 + h_jk * l_jk
2293 + h_ik * l_ik
2294 + h_jk * l_jk
2295 + h_kk * l_kk;
2296
2297 moy_hijhij[kg] += hijhij;
2298 moy_hijlij[kg] += hijlij;
2299
2300 if (tensorial)
2301 {
2302 moy_hij_xx[kg] += h_ii;
2303 moy_hij_xy[kg] += h_ij;
2304 moy_hij_xz[kg] += h_ik;
2305 moy_hij_yy[kg] += h_jj;
2306 moy_hij_yz[kg] += h_jk;
2307 moy_hij_zz[kg] += h_kk;
2308
2309 moy_hijhij_xx[kg] += h_ii * h_ii;
2310 moy_hijhij_xy[kg] += h_ij * h_ij;
2311 moy_hijhij_xz[kg] += h_ik * h_ik;
2312 moy_hijhij_yy[kg] += h_jj * h_jj;
2313 moy_hijhij_yz[kg] += h_jk * h_jk;
2314 moy_hijhij_zz[kg] += h_kk * h_kk;
2315
2316 moy_hijlij_xx[kg] += h_ii * l_ii;
2317 moy_hijlij_xy[kg] += h_ij * l_ij;
2318 moy_hijlij_xz[kg] += h_ik * l_ik;
2319 moy_hijlij_yy[kg] += h_jj * l_jj;
2320 moy_hijlij_yz[kg] += h_jk * l_jk;
2321 moy_hijlij_zz[kg] += h_kk * l_kk;
2322 }
2323
2324 if (turbulent_viscosity)
2325 {
2326 const double mijhij = m_ii * h_ii
2327 + m_ij * h_ij
2328 + m_ik * h_ik
2329 + m_ij * h_ij
2330 + m_jj * h_jj
2331 + m_jk * h_jk
2332 + m_ik * h_ik
2333 + m_jk * h_jk
2334 + m_kk * h_kk;
2335
2336 moy_mijhij[kg] += mijhij;
2337
2338 if (tensorial)
2339 {
2340 moy_mijhij_xx[kg] += m_ii * h_ii;
2341 moy_mijhij_xy[kg] += m_ij * h_ij;
2342 moy_mijhij_xz[kg] += m_ik * h_ik;
2343 moy_mijhij_yy[kg] += m_jj * h_jj;
2344 moy_mijhij_yz[kg] += m_jk * h_jk;
2345 moy_mijhij_zz[kg] += m_kk * h_kk;
2346 }
2347 }
2348 }
2349 }
2350 }
2351 }
2352}
2353
2354void calculer_constante_direct(const bool global,
2355 const bool clipping,
2356 const Nom& description,
2357 const ArrOfDouble& moy_mij_0,
2358 const ArrOfDouble& moy_lij_0,
2359 const bool flag_mixte,
2360 const ArrOfDouble& moy_hij_0,
2361 const IJK_Field_vector3_double& velocity,
2362 const ArrOfDouble_with_ghost& delta_z,
2363 ArrOfDouble_with_ghost& constante_modele)
2364{
2365 const IJK_Field_double& vitesse_k = velocity[2];
2366
2367 // Copie des tableaux
2368 ArrOfDouble moy_mij = moy_mij_0;
2369 ArrOfDouble moy_lij = moy_lij_0;
2370 ArrOfDouble moy_hij = moy_hij_0;
2371
2372 const int nk = vitesse_k.nk();
2373 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
2374
2375 Cout <<
2376 "Dynamic correction of constant [ " << description <<
2377 " ] type= direct global= " << (int)global <<
2378 " clipping= " << (int)clipping <<
2379 " mixte= " << (int)flag_mixte << " :"
2380 << finl;
2381
2382 if (global)
2383 {
2384 double moy_mij_global = 0;
2385 double moy_lij_global = 0;
2386 double moy_hij_global = 0;
2387 for (int k = 0; k < nk; k++)
2388 {
2389 const int kg = k + offset;
2390
2391 moy_mij_global += moy_mij[kg]*delta_z[k];
2392 moy_lij_global += moy_lij[kg]*delta_z[k];
2393 if (flag_mixte)
2394 {
2395 moy_hij_global += moy_hij[kg]*delta_z[k];
2396 }
2397 }
2398
2399 ArrOfDouble tmp(3);
2400 tmp[0] = moy_mij_global;
2401 tmp[1] = moy_lij_global;
2402 tmp[2] = moy_hij_global;
2404
2405 double c_global = (tmp[0]==0.) ? 1. : (tmp[1] - tmp[2])/tmp[0];
2406 if (clipping)
2407 {
2408 c_global = max(0., c_global);
2409 }
2410 Cout << "(global) constante_modele= " << c_global << finl;
2411
2412 for (int k = 0; k < nk; k++)
2413 {
2414 constante_modele[k] = c_global;
2415 }
2416 }
2417 else
2418 {
2421 if (flag_mixte)
2422 {
2424 }
2425
2426 for (int k = 0; k < nk; k++)
2427 {
2428 const int kg = k + offset;
2429
2430 if (flag_mixte)
2431 {
2432 constante_modele[k] = (moy_mij[kg]==0.) ? 1. : (moy_lij[kg] - moy_hij[kg])/moy_mij[kg];
2433 }
2434 else
2435 {
2436 constante_modele[k] = (moy_mij[kg]==0.) ? 1. : moy_lij[kg]/moy_mij[kg];
2437 }
2438 if (clipping)
2439 {
2440 constante_modele[k] = max(0., constante_modele[k]);
2441 }
2442 Cout << "k= " << kg << " constante_modele= " << constante_modele[k] << finl;
2443 }
2444 }
2445}
2446
2447void calculer_constante_lilly(const bool global,
2448 const bool clipping,
2449 const Nom& description,
2450 const ArrOfDouble& moy_mijmij_0,
2451 const ArrOfDouble& moy_mijlij_0,
2452 const bool flag_mixte,
2453 const ArrOfDouble& moy_mijhij_0,
2454 const IJK_Field_vector3_double& velocity,
2455 const ArrOfDouble_with_ghost& delta_z,
2456 ArrOfDouble_with_ghost& constante_modele)
2457{
2458 const IJK_Field_double& vitesse_k = velocity[2];
2459
2460 // Copie des tableaux
2461 ArrOfDouble moy_mijmij = moy_mijmij_0;
2462 ArrOfDouble moy_mijlij = moy_mijlij_0;
2463 ArrOfDouble moy_mijhij = moy_mijhij_0;
2464
2465 const int nk = vitesse_k.nk();
2466 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
2467
2468 Cout << "Dynamic correction of constant [ " << description << " ] type= lilly global= " << (int)global << " clipping= " << (int)clipping << " mixte= " << (int)flag_mixte << " :" << finl;
2469
2470 if (global)
2471 {
2472 double moy_mijmij_global = 0;
2473 double moy_mijlij_global = 0;
2474 double moy_mijhij_global = 0;
2475 for (int k = 0; k < nk; k++)
2476 {
2477 const int kg = k + offset;
2478
2479 moy_mijmij_global += moy_mijmij[kg]*delta_z[k];
2480 moy_mijlij_global += moy_mijlij[kg]*delta_z[k];
2481 if (flag_mixte)
2482 {
2483 moy_mijhij_global += moy_mijhij[kg]*delta_z[k];
2484 }
2485 }
2486
2487 ArrOfDouble tmp(3);
2488 tmp[0] = moy_mijmij_global;
2489 tmp[1] = moy_mijlij_global;
2490 tmp[2] = moy_mijhij_global;
2492
2493 double c_global = (tmp[0]==0.) ? 1. : (tmp[1] - tmp[2])/tmp[0];
2494 if (clipping)
2495 {
2496 c_global = max(0., c_global);
2497 }
2498 Cout << "(global) constante_modele= " << c_global << finl;
2499
2500 for (int k = 0; k < nk; k++)
2501 {
2502 constante_modele[k] = c_global;
2503 }
2504 }
2505 else
2506 {
2509 if (flag_mixte)
2510 {
2512 }
2513
2514 for (int k = 0; k < nk; k++)
2515 {
2516 const int kg = k + offset;
2517
2518 if (flag_mixte)
2519 {
2520 constante_modele[k] = (moy_mijmij[kg]==0.) ? 1. : (moy_mijlij[kg] - moy_mijhij[kg])/moy_mijmij[kg];
2521 }
2522 else
2523 {
2524 constante_modele[k] = (moy_mijmij[kg]==0.) ? 1. : moy_mijlij[kg]/moy_mijmij[kg];
2525 }
2526 if (clipping)
2527 {
2528 constante_modele[k] = max(0., constante_modele[k]);
2529 }
2530 Cout << "k= " << kg << " constante_modele= " << constante_modele[k] << finl;
2531 }
2532 }
2533}
2534
2535void calculer_constante_twoparameters(const bool global,
2536 const bool clipping,
2537 const Nom& description,
2538 const ArrOfDouble& moy_mijmij_0,
2539 const ArrOfDouble& moy_hijhij_0,
2540 const ArrOfDouble& moy_mijlij_0,
2541 const ArrOfDouble& moy_hijlij_0,
2542 const ArrOfDouble& moy_mijhij_0,
2543 const IJK_Field_vector3_double& velocity,
2544 const ArrOfDouble_with_ghost& delta_z,
2545 ArrOfDouble_with_ghost& constante_modele)
2546{
2547 const IJK_Field_double& vitesse_k = velocity[2];
2548
2549 // Copie des tableaux
2550 ArrOfDouble moy_mijmij = moy_mijmij_0;
2551 ArrOfDouble moy_hijhij = moy_hijhij_0;
2552 ArrOfDouble moy_mijlij = moy_mijlij_0;
2553 ArrOfDouble moy_hijlij = moy_hijlij_0;
2554 ArrOfDouble moy_mijhij = moy_mijhij_0;
2555
2556 const int nk = vitesse_k.nk();
2557 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
2558
2559 Cout << "Dynamic correction of constant [ " << description << " ] type= twoparameters global= " << (int)global << " clipping= " << (int)clipping << " :" << finl;
2560
2561 if (global)
2562 {
2563 double moy_mijmij_global = 0;
2564 double moy_hijhij_global = 0;
2565 double moy_mijlij_global = 0;
2566 double moy_hijlij_global = 0;
2567 double moy_mijhij_global = 0;
2568 for (int k = 0; k < nk; k++)
2569 {
2570 const int kg = k + offset;
2571
2572 moy_mijmij_global += moy_mijmij[kg]*delta_z[k];
2573 moy_hijhij_global += moy_hijhij[kg]*delta_z[k];
2574 moy_mijlij_global += moy_mijlij[kg]*delta_z[k];
2575 moy_hijlij_global += moy_hijlij[kg]*delta_z[k];
2576 moy_mijhij_global += moy_mijhij[kg]*delta_z[k];
2577 }
2578
2579 ArrOfDouble tmp(5);
2580 tmp[0] = moy_mijmij_global;
2581 tmp[1] = moy_hijhij_global;
2582 tmp[2] = moy_mijlij_global;
2583 tmp[3] = moy_hijlij_global;
2584 tmp[4] = moy_mijhij_global;
2586
2587 double c_global = ((tmp[0]*tmp[1] - tmp[4]*tmp[4])==0.) ? 1. :
2588 (tmp[2]*tmp[1] - tmp[3]*tmp[4])/(tmp[0]*tmp[1] - tmp[4]*tmp[4]);
2589 if (clipping)
2590 {
2591 c_global = max(0., c_global);
2592 }
2593 Cout << "(global) constante_modele= " << c_global << finl;
2594
2595 for (int k = 0; k < nk; k++)
2596 {
2597 constante_modele[k] = c_global;
2598 }
2599 }
2600 else
2601 {
2607
2608 for (int k = 0; k < nk; k++)
2609 {
2610 const int kg = k + offset;
2611
2612 constante_modele[k] = ((moy_mijmij[kg]*moy_hijhij[kg] - moy_mijhij[kg]*moy_mijhij[kg])==0.) ? 1. :
2613 (moy_mijlij[kg]*moy_hijhij[kg] - moy_hijlij[kg]*moy_mijhij[kg])/(moy_mijmij[kg]*moy_hijhij[kg] - moy_mijhij[kg]*moy_mijhij[kg]);
2614 if (clipping)
2615 {
2616 constante_modele[k] = max(0., constante_modele[k]);
2617 }
2618 Cout << "k= " << kg << " constante_modele= " << constante_modele[k] << finl;
2619 }
2620 }
2621}
2622
2623void calculer_constante_twonoerror(const bool global,
2624 const bool clipping,
2625 const Nom& description,
2626 const ArrOfDouble& moy_lij_0,
2627 const ArrOfDouble& moy_mij_0,
2628 const ArrOfDouble& moy_hij_0,
2629 const ArrOfDouble& moy_mijmij_0,
2630 const ArrOfDouble& moy_hijhij_0,
2631 const ArrOfDouble& moy_mijlij_0,
2632 const ArrOfDouble& moy_hijlij_0,
2633 const ArrOfDouble& moy_mijhij_0,
2634 const IJK_Field_vector3_double& velocity,
2635 const ArrOfDouble_with_ghost& delta_z,
2636 ArrOfDouble_with_ghost& constante_modele)
2637{
2638 const IJK_Field_double& vitesse_k = velocity[2];
2639
2640 // Copie des tableaux
2641 ArrOfDouble moy_lij = moy_lij_0;
2642 ArrOfDouble moy_mij = moy_mij_0;
2643 ArrOfDouble moy_hij = moy_hij_0;
2644 ArrOfDouble moy_mijmij = moy_mijmij_0;
2645 ArrOfDouble moy_hijhij = moy_hijhij_0;
2646 ArrOfDouble moy_mijlij = moy_mijlij_0;
2647 ArrOfDouble moy_hijlij = moy_hijlij_0;
2648 ArrOfDouble moy_mijhij = moy_mijhij_0;
2649
2650 const int nk = vitesse_k.nk();
2651 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
2652
2653 Cout << "Dynamic correction of constant [ " << description << " ] type= twonoerror global= " << (int)global << " clipping= " << (int)clipping << " :" << finl;
2654
2655 if (global)
2656 {
2657 double moy_lij_global = 0;
2658 double moy_mij_global = 0;
2659 double moy_hij_global = 0;
2660 double moy_mijmij_global = 0;
2661 double moy_hijhij_global = 0;
2662 double moy_mijlij_global = 0;
2663 double moy_hijlij_global = 0;
2664 double moy_mijhij_global = 0;
2665 for (int k = 0; k < nk; k++)
2666 {
2667 const int kg = k + offset;
2668
2669 moy_lij_global += moy_lij[kg]*delta_z[k];
2670 moy_mij_global += moy_mij[kg]*delta_z[k];
2671 moy_hij_global += moy_hij[kg]*delta_z[k];
2672 moy_mijmij_global += moy_mijmij[kg]*delta_z[k];
2673 moy_hijhij_global += moy_hijhij[kg]*delta_z[k];
2674 moy_mijlij_global += moy_mijlij[kg]*delta_z[k];
2675 moy_hijlij_global += moy_hijlij[kg]*delta_z[k];
2676 moy_mijhij_global += moy_mijhij[kg]*delta_z[k];
2677 }
2678
2679 ArrOfDouble tmp(8);
2680 tmp[0] = moy_lij_global;
2681 tmp[1] = moy_mij_global;
2682 tmp[2] = moy_hij_global;
2683 tmp[3] = moy_mijmij_global;
2684 tmp[4] = moy_hijhij_global;
2685 tmp[5] = moy_mijlij_global;
2686 tmp[6] = moy_hijlij_global;
2687 tmp[7] = moy_mijhij_global;
2689
2690 double c_global = ((tmp[2]*tmp[3] - tmp[1]*tmp[7] + tmp[2]*tmp[7] - tmp[1]*tmp[4])==0.) ? 1. :
2691 (tmp[3]*tmp[0] - tmp[1]*tmp[5] + tmp[7]*tmp[0] - tmp[1]*tmp[6])/(tmp[2]*tmp[3] - tmp[1]*tmp[7] + tmp[2]*tmp[7] - tmp[1]*tmp[4]);
2692 if (clipping)
2693 {
2694 c_global = max(0., c_global);
2695 }
2696 Cout << "(global) constante_modele= " << c_global << finl;
2697
2698 for (int k = 0; k < nk; k++)
2699 {
2700 constante_modele[k] = c_global;
2701 }
2702 }
2703 else
2704 {
2713
2714 for (int k = 0; k < nk; k++)
2715 {
2716 const int kg = k + offset;
2717
2718 constante_modele[k] = ((moy_hij[kg]*moy_mijmij[kg] - moy_mij[kg]*moy_mijhij[kg] + moy_hij[kg]*moy_mijhij[kg] - moy_mij[kg]*moy_hijhij[kg])==0.) ? 1. :
2719 (moy_mijmij[kg]*moy_lij[kg] - moy_mij[kg]*moy_mijlij[kg] + moy_mijhij[kg]*moy_lij[kg] - moy_mij[kg]*moy_hijlij[kg])/(moy_hij[kg]*moy_mijmij[kg] - moy_mij[kg]*moy_mijhij[kg] + moy_hij[kg]*moy_mijhij[kg] - moy_mij[kg]*moy_hijhij[kg]);
2720 if (clipping)
2721 {
2722 constante_modele[k] = max(0., constante_modele[k]);
2723 }
2724 Cout << "k= " << kg << " constante_modele= " << constante_modele[k] << finl;
2725 }
2726 }
2727}
2728
2729void multiplier_par_constante(const bool face,
2730 ArrOfDouble_with_ghost& constante_modele,
2731 const IJK_Field_vector3_double& velocity,
2732 IJK_Field_double& turbulent_mu)
2733{
2734 const IJK_Field_double& vitesse_k = velocity[2];
2735 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
2736
2737 const int ni = vitesse_k.ni();
2738 const int nj = vitesse_k.nj();
2739 const int nk = vitesse_k.nk();
2740
2741 if (face)
2742 {
2743 for (int k = 0; k < nk; k++)
2744 {
2745 for (int j = 0; j < nj; j++)
2746 {
2747 for (int i = 0; i < ni; i++)
2748 {
2749 const int kg = k + offset;
2750 const double constante_face = kg==0 ? 0. : 0.5*(constante_modele[k] + constante_modele[k-1]);
2751 turbulent_mu(i,j,k) = constante_face * turbulent_mu(i,j,k);
2752 }
2753 }
2754 }
2755 }
2756 else
2757 {
2758 for (int k = 0; k < nk; k++)
2759 {
2760 for (int j = 0; j < nj; j++)
2761 {
2762 for (int i = 0; i < ni; i++)
2763 {
2764 turbulent_mu(i,j,k) = constante_modele[k] * turbulent_mu(i,j,k);
2765 }
2766 }
2767 }
2768 }
2769}
2770
2771bool calculer_constante_modele(const Nom& turbulent_viscosity_dynamic_type,
2772 const Nom& description,
2773 const ArrOfDouble& moy_lij,
2774 const ArrOfDouble& moy_mij,
2775 const ArrOfDouble& moy_hij,
2776 const ArrOfDouble& moy_mijmij,
2777 const ArrOfDouble& moy_hijhij,
2778 const ArrOfDouble& moy_mijlij,
2779 const ArrOfDouble& moy_hijlij,
2780 const ArrOfDouble& moy_mijhij,
2781 const IJK_Field_vector3_double& velocity,
2782 const ArrOfDouble_with_ghost& delta_z,
2783 ArrOfDouble_with_ghost& constante_modele)
2784{
2785 bool mot_cle_reconnu = 0;
2786
2787 const bool clipping = turbulent_viscosity_dynamic_type.finit_par("clipping");
2788 Nom dynamic_type = clipping ? turbulent_viscosity_dynamic_type.getPrefix("clipping") : turbulent_viscosity_dynamic_type;
2789
2790 const bool global = dynamic_type.finit_par("global");
2791 dynamic_type = global ? dynamic_type.getPrefix("global") : dynamic_type;
2792
2793 if ( dynamic_type == Nom("direct")
2794 || dynamic_type == Nom("directmixte") )
2795 {
2796 mot_cle_reconnu = 1;
2797 const bool mixte = ( dynamic_type == Nom("directmixte") );
2798
2799 calculer_constante_direct(global, clipping,
2800 description,
2801 moy_mij, moy_lij,
2802 mixte, moy_hij,
2803 velocity, delta_z,
2804 constante_modele);
2805 }
2806 else if ( dynamic_type == Nom("lilly")
2807 || dynamic_type == Nom("lillymixte") )
2808 {
2809 mot_cle_reconnu = 1;
2810 const bool mixte = ( dynamic_type == Nom("lillymixte") );
2811
2812 calculer_constante_lilly(global, clipping,
2813 description,
2814 moy_mijmij, moy_mijlij,
2815 mixte, moy_mijhij,
2816 velocity, delta_z,
2817 constante_modele);
2818 }
2819 else if ( dynamic_type == Nom("twoparameters") )
2820 {
2821 mot_cle_reconnu = 1;
2822 calculer_constante_twoparameters(global, clipping,
2823 description,
2824 moy_mijmij, moy_hijhij,
2825 moy_mijlij, moy_hijlij,
2826 moy_mijhij,
2827 velocity, delta_z,
2828 constante_modele);
2829 }
2830 else if ( dynamic_type == Nom("twonoerror") )
2831 {
2832 mot_cle_reconnu = 1;
2833 calculer_constante_twonoerror(global, clipping,
2834 description,
2835 moy_lij, moy_mij, moy_hij,
2836 moy_mijmij, moy_hijhij,
2837 moy_mijlij, moy_hijlij,
2838 moy_mijhij,
2839 velocity, delta_z,
2840 constante_modele);
2841 }
2842 return mot_cle_reconnu;
2843}
2844
2845template<class T>
2846void calculer_ml_dynamic_uscalar_vector(const bool anisotropic,
2847 const bool vectorial,
2848 const IJK_Field_vector3_double& velocity,
2849 const IJK_Field_vector3_double& velocity_filtre,
2850 const IJK_Field_double& champ_scalar,
2851 const IJK_Field_double& champ_scalar_filtre,
2852 double scalar_kmin, double scalar_kmax,
2853 const int turbulent_viscosity,
2854 const IJK_Field_double& turbulent_mu_x,
2855 const IJK_Field_double& turbulent_mu_y,
2856 const IJK_Field_double& turbulent_mu_z,
2857 const IJK_Field_double& turbulent_mu_filtre_x,
2858 const IJK_Field_double& turbulent_mu_filtre_y,
2859 const IJK_Field_double& turbulent_mu_filtre_z,
2860 const int structural_uscalar,
2861 const IJK_Field_vector3_double& structural_uscalar_vector,
2862 const IJK_Field_vector3_double& structural_uscalar_filtre_vector,
2863 const ArrOfDouble_with_ghost& delta_z,
2864 const double facteur_delta_x,
2865 const double facteur_delta_y,
2866 const ArrOfDouble_with_ghost& delta_z_pour_delta,
2867 const double facteur_delta_filtre_x,
2868 const double facteur_delta_filtre_y,
2869 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
2870 T& kernel,
2874{
2875 const IJK_Field_double& vitesse_i = velocity[0];
2876 const IJK_Field_double& vitesse_j = velocity[1];
2877 const IJK_Field_double& vitesse_k = velocity[2];
2878
2879 const IJK_Field_double& vitesse_i_filtre = velocity_filtre[0];
2880 const IJK_Field_double& vitesse_j_filtre = velocity_filtre[1];
2881 const IJK_Field_double& vitesse_k_filtre = velocity_filtre[2];
2882
2883 const IJK_Field_double& structural_uscalar_x = structural_uscalar_vector[0];
2884 const IJK_Field_double& structural_uscalar_y = structural_uscalar_vector[1];
2885 const IJK_Field_double& structural_uscalar_z = structural_uscalar_vector[2];
2886
2887 const IJK_Field_double& structural_uscalar_filtre_x = structural_uscalar_filtre_vector[0];
2888 const IJK_Field_double& structural_uscalar_filtre_y = structural_uscalar_filtre_vector[1];
2889 const IJK_Field_double& structural_uscalar_filtre_z = structural_uscalar_filtre_vector[2];
2890
2891 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
2892 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
2893 const double dx_pour_delta = facteur_delta_x*dx;
2894 const double dy_pour_delta = facteur_delta_y*dy;
2895
2896 const int ni = vitesse_k.ni();
2897 const int nj = vitesse_k.nj();
2898 const int nk = vitesse_k.nk();
2899
2900 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
2901 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
2902
2903 IJK_Field_local_double& bf_i = tmp_b[0];
2904 IJK_Field_local_double& bf_j = tmp_b[1];
2905 IJK_Field_local_double& bf_k = tmp_b[2];
2906 IJK_Field_local_double& bus_i = tmp_b[3];
2907 IJK_Field_local_double& bus_j = tmp_b[4];
2908 IJK_Field_local_double& bus_k = tmp_b[5];
2909 IJK_Field_local_double& bg_i = tmp_b[6];
2910 IJK_Field_local_double& bg_j = tmp_b[7];
2911 IJK_Field_local_double& bg_k = tmp_b[8];
2912
2913 IJK_Field_local_double& af_i = tmp_a[0];
2914 IJK_Field_local_double& af_j = tmp_a[1];
2915 IJK_Field_local_double& af_k = tmp_a[2];
2916 IJK_Field_local_double& aus_i = tmp_a[3];
2917 IJK_Field_local_double& aus_j = tmp_a[4];
2918 IJK_Field_local_double& aus_k = tmp_a[5];
2919 IJK_Field_local_double& ag_i = tmp_a[6];
2920 IJK_Field_local_double& ag_j = tmp_a[7];
2921 IJK_Field_local_double& ag_k = tmp_a[8];
2922
2923 ArrOfDouble& moy_li_x = ml[0][0];
2924 ArrOfDouble& moy_li_y = ml[0][1];
2925 ArrOfDouble& moy_li_z = ml[0][2];
2926
2927 ArrOfDouble& moy_mi_x = ml[1][0];
2928 ArrOfDouble& moy_mi_y = ml[1][1];
2929 ArrOfDouble& moy_mi_z = ml[1][2];
2930
2931 ArrOfDouble& moy_hi_x = ml[2][0];
2932 ArrOfDouble& moy_hi_y = ml[2][1];
2933 ArrOfDouble& moy_hi_z = ml[2][2];
2934
2935 ArrOfDouble& moy_mimi_x = ml[3][0];
2936 ArrOfDouble& moy_mimi_y = ml[3][1];
2937 ArrOfDouble& moy_mimi_z = ml[3][2];
2938 ArrOfDouble& moy_mimi = ml[3][6];
2939
2940 ArrOfDouble& moy_hihi_x = ml[4][0];
2941 ArrOfDouble& moy_hihi_y = ml[4][1];
2942 ArrOfDouble& moy_hihi_z = ml[4][2];
2943 ArrOfDouble& moy_hihi = ml[4][6];
2944
2945 ArrOfDouble& moy_mili_x = ml[5][0];
2946 ArrOfDouble& moy_mili_y = ml[5][1];
2947 ArrOfDouble& moy_mili_z = ml[5][2];
2948 ArrOfDouble& moy_mili = ml[5][6];
2949
2950 ArrOfDouble& moy_hili_x = ml[6][0];
2951 ArrOfDouble& moy_hili_y = ml[6][1];
2952 ArrOfDouble& moy_hili_z = ml[6][2];
2953 ArrOfDouble& moy_hili = ml[6][6];
2954
2955 ArrOfDouble& moy_mihi_x = ml[7][0];
2956 ArrOfDouble& moy_mihi_y = ml[7][1];
2957 ArrOfDouble& moy_mihi_z = ml[7][2];
2958 ArrOfDouble& moy_mihi = ml[7][6];
2959
2960 double m_i = 0.;
2961 double m_j = 0.;
2962 double m_k = 0.;
2963
2964 double h_i = 0.;
2965 double h_j = 0.;
2966 double h_k = 0.;
2967
2969 FixedVector<double, 3> f_filtre;
2970
2971 const int ghost_size_filter = kernel->ghost_size();
2972 const int size_uniform = kernel->size_uniform();
2973 const int shift_uniform = kernel->shift_uniform();
2974 for (int k = 0; k < nk; k++)
2975 {
2976 const int kg = k + offset;
2977
2978 if (vectorial)
2979 {
2980 moy_li_x[kg] = 0;
2981 moy_li_y[kg] = 0;
2982 moy_li_z[kg] = 0;
2983
2984 moy_mi_x[kg] = 0;
2985 moy_mi_y[kg] = 0;
2986 moy_mi_z[kg] = 0;
2987
2988 moy_hi_x[kg] = 0;
2989 moy_hi_y[kg] = 0;
2990 moy_hi_z[kg] = 0;
2991
2992 moy_mimi_x[kg] = 0;
2993 moy_mimi_y[kg] = 0;
2994 moy_mimi_z[kg] = 0;
2995
2996 moy_hihi_x[kg] = 0;
2997 moy_hihi_y[kg] = 0;
2998 moy_hihi_z[kg] = 0;
2999
3000 moy_mili_x[kg] = 0;
3001 moy_mili_y[kg] = 0;
3002 moy_mili_z[kg] = 0;
3003
3004 moy_hili_x[kg] = 0;
3005 moy_hili_y[kg] = 0;
3006 moy_hili_z[kg] = 0;
3007
3008 moy_mihi_x[kg] = 0;
3009 moy_mihi_y[kg] = 0;
3010 moy_mihi_z[kg] = 0;
3011 }
3012
3013 moy_mimi[kg] = 0;
3014 moy_hihi[kg] = 0;
3015 moy_mili[kg] = 0;
3016 moy_hili[kg] = 0;
3017 moy_mihi[kg] = 0;
3018
3019 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
3020 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
3021
3022 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
3023 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
3024 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
3025 const int size_k_elem = kernel->size_k_elem(kg, nktot);
3026 const int shift_k_elem = kernel->shift_k_elem(kg);
3027 const bool ponderation_filter_kernel = kernel->ponderation();
3028 const bool normalisation_filter_kernel = kernel->normalisation();
3029
3030 double facteur_elem = 0.;
3031 if (ponderation_filter_kernel)
3032 {
3033 if (normalisation_filter_kernel)
3034 {
3035 double longueur_elem = 0.;
3036 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
3037 {
3038 const int kpg = kg + kp;
3039 if (kpg<-1 || kpg>nktot)
3040 {
3041 Cerr << "This should not happen." << finl;
3042 Process::exit();
3043 }
3044 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
3045 const double filter_coef_z = filter_kernel_z[kp+10];
3046 longueur_elem += filter_coef_z * dz;
3047 }
3048 facteur_elem = 1./longueur_elem;
3049 }
3050 else
3051 {
3052 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
3053 }
3054 }
3055
3056 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
3057 {
3058 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
3059 {
3060 bus_i(i, j, 0) = 0.;
3061 bus_j(i, j, 0) = 0.;
3062 bus_k(i, j, 0) = 0.;
3063 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
3064 {
3065 const int kpg = kg + kp;
3066 if (!(kernel->is_at_wall_elem(kpg, nktot)))
3067 {
3068 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
3069 const double filter_coef_z = filter_kernel_z[kp+10];
3070 const double scalar = champ_scalar(i,j,k+kp);
3071
3072 const double uf_i = vitesse_i(i,j,k+kp);
3073 const double vf_j = vitesse_j(i,j,k+kp);
3074 const double wf_k = vitesse_k(i,j,k+kp);
3075
3076 const double uf_ip1 = vitesse_i(i+1,j,k+kp);
3077 const double vf_jp1 = vitesse_j(i,j+1,k+kp);
3078 const double wf_kp1 = kpg==(nktot-1) ? 0. : vitesse_k(i,j,k+1+kp);
3079
3080 const double ue = 0.5 * (uf_i + uf_ip1);
3081 const double ve = 0.5 * (vf_j + vf_jp1);
3082 const double we = 0.5 * (wf_k + wf_kp1);
3083
3084 if (ponderation_filter_kernel)
3085 {
3086 bus_i(i, j, 0) += ue*scalar * filter_coef_z * dz * facteur_elem;
3087 bus_j(i, j, 0) += ve*scalar * filter_coef_z * dz * facteur_elem;
3088 bus_k(i, j, 0) += we*scalar * filter_coef_z * dz * facteur_elem;
3089 }
3090 else
3091 {
3092 bus_i(i, j, 0) += ue*scalar * filter_coef_z;
3093 bus_j(i, j, 0) += ve*scalar * filter_coef_z;
3094 bus_k(i, j, 0) += we*scalar * filter_coef_z;
3095 }
3096 }
3097 }
3098
3099 if (turbulent_viscosity)
3100 {
3101 bf_i(i, j, 0) = 0.;
3102 bf_j(i, j, 0) = 0.;
3103 bf_k(i, j, 0) = 0.;
3104 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
3105 {
3106 const int kpg = kg + kp;
3107 if (!(kernel->is_at_wall_elem(kpg, nktot)))
3108 {
3109 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
3110 const double filter_coef_z = filter_kernel_z[kp+10];
3111 if (!anisotropic)
3112 {
3113 calculer_pi(i, j, k+kp, velocity, champ_scalar, scalar_kmin, scalar_kmax, turbulent_mu_x, turbulent_mu_y, turbulent_mu_z, delta_z, 1., 1., 1., 1., 1., f);
3114 }
3115 else
3116 {
3117 const double dz_pour_delta = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z_pour_delta[k+kp];
3118 const double dz_m1_pour_delta = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1+kp];
3119 const double dz_p1_pour_delta = (kpg+1<0 || kpg+1>(nktot-1)) ? 0. : delta_z_pour_delta[k+1+kp];
3120 const double delta_m_pour_delta = (kpg-1<0 || kpg>(nktot-1)) ? 0. : 0.5*(dz_pour_delta + dz_m1_pour_delta);
3121 const double delta_p_pour_delta = (kpg<0 || kpg+1>(nktot-1)) ? 0. : 0.5*(dz_pour_delta + dz_p1_pour_delta);
3122 calculer_pi(i, j, k+kp, velocity, champ_scalar, scalar_kmin, scalar_kmax, turbulent_mu_x, turbulent_mu_y, turbulent_mu_z, delta_z, dx_pour_delta, dy_pour_delta, dz_pour_delta, delta_m_pour_delta, delta_p_pour_delta, f);
3123 }
3124
3125 if (ponderation_filter_kernel)
3126 {
3127 bf_i(i, j, 0) += f[0] * filter_coef_z * dz * facteur_elem;
3128 bf_j(i, j, 0) += f[1] * filter_coef_z * dz * facteur_elem;
3129 bf_k(i, j, 0) += f[2] * filter_coef_z * dz * facteur_elem;
3130 }
3131 else
3132 {
3133 bf_i(i, j, 0) += f[0] * filter_coef_z;
3134 bf_j(i, j, 0) += f[1] * filter_coef_z;
3135 bf_k(i, j, 0) += f[2] * filter_coef_z;
3136 }
3137 }
3138 }
3139 }
3140
3141 if (structural_uscalar)
3142 {
3143 bg_i(i, j, 0) = 0.;
3144 bg_j(i, j, 0) = 0.;
3145 bg_k(i, j, 0) = 0.;
3146 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
3147 {
3148 const int kpg = kg + kp;
3149 if (!(kernel->is_at_wall_elem(kpg, nktot)))
3150 {
3151 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
3152 const double filter_coef_z = filter_kernel_z[kp+10];
3153 const double gxf_i = -structural_uscalar_x(i,j,k+kp);
3154 const double gyf_j = -structural_uscalar_y(i,j,k+kp);
3155 const double gzf_k = -structural_uscalar_z(i,j,k+kp);
3156
3157 const double gxf_ip1 = -structural_uscalar_x(i+1,j,k+kp);
3158 const double gyf_jp1 = -structural_uscalar_y(i,j+1,k+kp);
3159 const double gzf_kp1 = kpg==(nktot-1) ? 0. : -structural_uscalar_z(i,j,k+1+kp);
3160
3161 const double gx_e = 0.5 * (gxf_i + gxf_ip1);
3162 const double gy_e = 0.5 * (gyf_j + gyf_jp1);
3163 const double gz_e = 0.5 * (gzf_k + gzf_kp1);
3164
3165 if (ponderation_filter_kernel)
3166 {
3167 bg_i(i, j, 0) += gx_e * filter_coef_z * dz * facteur_elem;
3168 bg_j(i, j, 0) += gy_e * filter_coef_z * dz * facteur_elem;
3169 bg_k(i, j, 0) += gz_e * filter_coef_z * dz * facteur_elem;
3170 }
3171 else
3172 {
3173 bg_i(i, j, 0) += gx_e * filter_coef_z;
3174 bg_j(i, j, 0) += gy_e * filter_coef_z;
3175 bg_k(i, j, 0) += gz_e * filter_coef_z;
3176 }
3177 }
3178 }
3179 }
3180 }
3181 }
3182 for (int j = 0; j < nj; j++)
3183 {
3184 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
3185 {
3186 aus_i(i, 0, 0) = 0.;
3187 aus_j(i, 0, 0) = 0.;
3188 aus_k(i, 0, 0) = 0.;
3189 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
3190 {
3191 const double filter_coef_y = filter_kernel_y[jp+10];
3192 aus_i(i, 0, 0) += bus_i(i, j+jp, 0) * filter_coef_y;
3193 aus_j(i, 0, 0) += bus_j(i, j+jp, 0) * filter_coef_y;
3194 aus_k(i, 0, 0) += bus_k(i, j+jp, 0) * filter_coef_y;
3195 }
3196 if (turbulent_viscosity)
3197 {
3198 af_i(i, 0, 0) = 0.;
3199 af_j(i, 0, 0) = 0.;
3200 af_k(i, 0, 0) = 0.;
3201 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
3202 {
3203 const double filter_coef_y = filter_kernel_y[jp+10];
3204 af_i(i, 0, 0) += bf_i(i, j+jp, 0) * filter_coef_y;
3205 af_j(i, 0, 0) += bf_j(i, j+jp, 0) * filter_coef_y;
3206 af_k(i, 0, 0) += bf_k(i, j+jp, 0) * filter_coef_y;
3207 }
3208 }
3209 if (structural_uscalar)
3210 {
3211 ag_i(i, 0, 0) = 0.;
3212 ag_j(i, 0, 0) = 0.;
3213 ag_k(i, 0, 0) = 0.;
3214 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
3215 {
3216 const double filter_coef_y = filter_kernel_y[jp+10];
3217 ag_i(i, 0, 0) += bg_i(i, j+jp, 0) * filter_coef_y;
3218 ag_j(i, 0, 0) += bg_j(i, j+jp, 0) * filter_coef_y;
3219 ag_k(i, 0, 0) += bg_k(i, j+jp, 0) * filter_coef_y;
3220 }
3221 }
3222 }
3223
3224 for (int i = 0; i < ni; i++)
3225 {
3226 double rus_i = 0.;
3227 double rus_j = 0.;
3228 double rus_k = 0.;
3229 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
3230 {
3231 const double filter_coef_x = filter_kernel_x[ip+10];
3232 rus_i += aus_i(i+ip, 0, 0) * filter_coef_x;
3233 rus_j += aus_j(i+ip, 0, 0) * filter_coef_x;
3234 rus_k += aus_k(i+ip, 0, 0) * filter_coef_x;
3235 }
3236
3237 const double scalar = champ_scalar_filtre(i,j,k);
3238
3239 const double uf_i = vitesse_i_filtre(i,j,k);
3240 const double vf_j = vitesse_j_filtre(i,j,k);
3241 const double wf_k = vitesse_k_filtre(i,j,k);
3242
3243 const double uf_ip1 = vitesse_i_filtre(i+1,j,k);
3244 const double vf_jp1 = vitesse_j_filtre(i,j+1,k);
3245 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k_filtre(i,j,k+1);
3246
3247 const double ue = 0.5 * (uf_i + uf_ip1);
3248 const double ve = 0.5 * (vf_j + vf_jp1);
3249 const double we = 0.5 * (wf_k + wf_kp1);
3250
3251 const double l_i = rus_i - ue*scalar;
3252 const double l_j = rus_j - ve*scalar;
3253 const double l_k = rus_k - we*scalar;
3254
3255 if (vectorial)
3256 {
3257 moy_li_x[kg] += l_i;
3258 moy_li_y[kg] += l_j;
3259 moy_li_z[kg] += l_k;
3260 }
3261
3262 if (turbulent_viscosity)
3263 {
3264 double rf_i = 0.;
3265 double rf_j = 0.;
3266 double rf_k = 0.;
3267 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
3268 {
3269 const double filter_coef_x = filter_kernel_x[ip+10];
3270 rf_i += af_i(i+ip, 0, 0) * filter_coef_x;
3271 rf_j += af_j(i+ip, 0, 0) * filter_coef_x;
3272 rf_k += af_k(i+ip, 0, 0) * filter_coef_x;
3273 }
3274
3275 if (!anisotropic)
3276 {
3277 calculer_pi(i, j, k, velocity_filtre, champ_scalar_filtre, scalar_kmin, scalar_kmax, turbulent_mu_filtre_x, turbulent_mu_filtre_y, turbulent_mu_filtre_z, delta_z, 1., 1., 1., 1., 1., f_filtre);
3278 }
3279 else
3280 {
3281 const double dx_filtre = facteur_delta_filtre_x*dx;
3282 const double dy_filtre = facteur_delta_filtre_y*dy;
3283 const double dz_filtre = delta_z_pour_delta_filtre[k];
3284 const double delta_m_filtre = kg==0 ? 0. : 0.5*(dz_filtre + delta_z_pour_delta_filtre[k-1]);
3285 const double delta_p_filtre = kg==(nktot-1) ? 0. : 0.5*(dz_filtre + delta_z_pour_delta_filtre[k+1]);
3286 calculer_pi(i, j, k, velocity_filtre, champ_scalar_filtre, scalar_kmin, scalar_kmax, turbulent_mu_filtre_x, turbulent_mu_filtre_y, turbulent_mu_filtre_z, delta_z, dx_filtre, dy_filtre, dz_filtre, delta_m_filtre, delta_p_filtre, f_filtre);
3287 }
3288
3289 m_i = f_filtre[0] - rf_i;
3290 m_j = f_filtre[1] - rf_j;
3291 m_k = f_filtre[2] - rf_k;
3292
3293 const double mimi = m_i * m_i
3294 + m_j * m_j
3295 + m_k * m_k;
3296
3297 const double mili = m_i * l_i
3298 + m_j * l_j
3299 + m_k * l_k;
3300
3301 moy_mimi[kg] += mimi;
3302 moy_mili[kg] += mili;
3303
3304 if (vectorial)
3305 {
3306 moy_mi_x[kg] += m_i;
3307 moy_mi_y[kg] += m_j;
3308 moy_mi_z[kg] += m_k;
3309
3310 moy_mimi_x[kg] += m_i * m_i;
3311 moy_mimi_y[kg] += m_j * m_j;
3312 moy_mimi_z[kg] += m_k * m_k;
3313
3314 moy_mili_x[kg] += m_i * l_i;
3315 moy_mili_y[kg] += m_j * l_j;
3316 moy_mili_z[kg] += m_k * l_k;
3317 }
3318 }
3319
3320 if (structural_uscalar)
3321 {
3322 double rg_i = 0.;
3323 double rg_j = 0.;
3324 double rg_k = 0.;
3325 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
3326 {
3327 const double filter_coef_x = filter_kernel_x[ip+10];
3328 rg_i += ag_i(i+ip, 0, 0) * filter_coef_x;
3329 rg_j += ag_j(i+ip, 0, 0) * filter_coef_x;
3330 rg_k += ag_k(i+ip, 0, 0) * filter_coef_x;
3331 }
3332
3333 const double gxf_i = -structural_uscalar_filtre_x(i,j,k);
3334 const double gyf_j = -structural_uscalar_filtre_y(i,j,k);
3335 const double gzf_k = -structural_uscalar_filtre_z(i,j,k);
3336
3337 const double gxf_ip1 = -structural_uscalar_filtre_x(i+1,j,k);
3338 const double gyf_jp1 = -structural_uscalar_filtre_y(i,j+1,k);
3339 const double gzf_kp1 = kg==(nktot-1) ? 0. : -structural_uscalar_filtre_z(i,j,k+1);
3340
3341 const double gx_e = 0.5 * (gxf_i + gxf_ip1);
3342 const double gy_e = 0.5 * (gyf_j + gyf_jp1);
3343 const double gz_e = 0.5 * (gzf_k + gzf_kp1);
3344
3345 h_i = gx_e - rg_i;
3346 h_j = gy_e - rg_j;
3347 h_k = gz_e - rg_k;
3348
3349 const double hihi = h_i * h_i
3350 + h_j * h_j
3351 + h_k * h_k;
3352
3353 const double hili = h_i * l_i
3354 + h_j * l_j
3355 + h_k * l_k;
3356
3357 moy_hihi[kg] += hihi;
3358 moy_hili[kg] += hili;
3359
3360 if (vectorial)
3361 {
3362 moy_hi_x[kg] += h_i;
3363 moy_hi_y[kg] += h_j;
3364 moy_hi_z[kg] += h_k;
3365
3366 moy_hihi_x[kg] += h_i * h_i;
3367 moy_hihi_y[kg] += h_j * h_j;
3368 moy_hihi_z[kg] += h_k * h_k;
3369
3370 moy_hili_x[kg] += h_i * l_i;
3371 moy_hili_y[kg] += h_j * l_j;
3372 moy_hili_z[kg] += h_k * l_k;
3373 }
3374
3375 if (turbulent_viscosity)
3376 {
3377 const double mihi = m_i * h_i
3378 + m_j * h_j
3379 + m_k * h_k;
3380
3381 moy_mihi[kg] += mihi;
3382
3383 if (vectorial)
3384 {
3385 moy_mihi_x[kg] += m_i * h_i;
3386 moy_mihi_y[kg] += m_j * h_j;
3387 moy_mihi_z[kg] += m_k * h_k;
3388 }
3389 }
3390 }
3391 }
3392 }
3393 }
3394}
3395
3396template<class T>
3397void calculer_turbulent_mu_scalar(const bool anisotropic,
3398 const Nom& turbulent_viscosity_model,
3399 const double turbulent_viscosity_model_constant,
3400 const double variation_cste_modele_fonctionnel_,
3401 const double smoothing_center_fr_,
3402 const double smoothing_factor_fr_,
3403 const double Re_tau_fr_,
3404 const double Re_tau_ch_,
3405 const double pond_fr_,
3406 const double pond_ch_,
3407 const double center_constant_,
3408 const double Lz_tot_,
3409 IJK_Field_vector3_double& velocity,
3410 IJK_Field_vector3_double& velocity_filtre,
3411 IJK_Field_double& rho,
3412 IJK_Field_double& rho_filtre,
3413 double rho_kmin, double rho_kmax,
3414 IJK_Field_double& scalar,
3415 IJK_Field_double& scalar_filtre,
3416 double scalar_kmin, double scalar_kmax,
3417 const ArrOfDouble_with_ghost& delta_z,
3418 const double facteur_delta_x,
3419 const double facteur_delta_y,
3420 const ArrOfDouble_with_ghost& delta_z_pour_delta,
3421 const double facteur_delta_filtre_x,
3422 const double facteur_delta_filtre_y,
3423 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
3424 T& kernel,
3427 const bool flag_turbulent_mu_filtre,
3428 IJK_Field_double& turbulent_mu_filtre,
3429 IJK_Field_double& turbulent_mu,
3430 const Domaine_IJK& splitting)
3431{
3432 Turbulent_viscosity_base* model = nullptr;
3433
3434 choix_modele(turbulent_viscosity_model, model);
3435
3436 calculer_turbulent_mu(anisotropic,
3437 *model, turbulent_viscosity_model_constant, variation_cste_modele_fonctionnel_, smoothing_center_fr_, smoothing_factor_fr_, Re_tau_fr_, Re_tau_ch_, pond_fr_, pond_ch_, center_constant_, Lz_tot_,
3438 velocity, rho, scalar, scalar_kmin, scalar_kmax,
3439 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
3440 turbulent_mu, splitting);
3441 int ghost_size_filter;
3442 int ghost_size_velocity;
3443 int ghost_size_scalar;
3444 if (flag_turbulent_mu_filtre)
3445 {
3446 ghost_size_filter = 1 + kernel->ghost_size();
3447 ghost_size_velocity = max((int) 2, ghost_size_filter);
3448 ghost_size_scalar = max((int) 2, ghost_size_filter);
3449 velocity[0].echange_espace_virtuel(ghost_size_velocity);
3450 velocity[1].echange_espace_virtuel(ghost_size_velocity);
3451 velocity[2].echange_espace_virtuel(ghost_size_velocity);
3452 rho.echange_espace_virtuel(ghost_size_scalar);
3453
3454 const int flag_add = 0;
3455 filtrer_champ_elem(flag_add, velocity[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[0]);
3456 filtrer_champ_elem(flag_add, velocity[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[1]);
3457 filtrer_champ_face(flag_add, velocity[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[2]);
3458 filtrer_champ_elem(flag_add, rho, delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, rho_filtre);
3459
3460 velocity_filtre[0].echange_espace_virtuel(2);
3461 velocity_filtre[1].echange_espace_virtuel(2);
3462 velocity_filtre[2].echange_espace_virtuel(2);
3463 rho_filtre.echange_espace_virtuel(2);
3464
3465 // si scalar et rho ne sont pas le meme objet
3466 if (&scalar != &rho)
3467 {
3468 scalar.echange_espace_virtuel(ghost_size_scalar);
3469 filtrer_champ_elem(flag_add, scalar, delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, scalar_filtre);
3470 scalar_filtre.echange_espace_virtuel(2);
3471 }
3472
3473 calculer_turbulent_mu(anisotropic,
3474 *model, turbulent_viscosity_model_constant, variation_cste_modele_fonctionnel_, smoothing_center_fr_, smoothing_factor_fr_, Re_tau_fr_, Re_tau_ch_, pond_fr_, pond_ch_, center_constant_, Lz_tot_,
3475 velocity_filtre, rho_filtre, scalar_filtre, scalar_kmin, scalar_kmax,
3476 delta_z, facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
3477 turbulent_mu_filtre, splitting);
3478 }
3479
3480 delete model;
3481}
3482
3483template<class T>
3484void calculer_turbulent_mu_tensor(const bool anisotropic,
3485 const Nom& turbulent_viscosity_model,
3486 const double turbulent_viscosity_model_constant,
3487 const ArrOfDouble& turbulent_viscosity_tensor_coefficients,
3488 const double variation_cste_modele_fonctionnel_,
3489 const double smoothing_center_fr_,
3490 const double smoothing_factor_fr_,
3491 const double Re_tau_fr_,
3492 const double Re_tau_ch_,
3493 const double pond_fr_,
3494 const double pond_ch_,
3495 const double center_constant_,
3496 const double Lz_tot_,
3497 IJK_Field_vector3_double& velocity,
3498 IJK_Field_vector3_double& velocity_filtre,
3499 IJK_Field_double& rho,
3500 IJK_Field_double& rho_filtre,
3501 double rho_kmin, double rho_kmax,
3502 IJK_Field_double& scalar,
3503 IJK_Field_double& scalar_filtre,
3504 double scalar_kmin, double scalar_kmax,
3505 const ArrOfDouble_with_ghost& delta_z,
3506 const double facteur_delta_x,
3507 const double facteur_delta_y,
3508 const ArrOfDouble_with_ghost& delta_z_pour_delta,
3509 const double facteur_delta_filtre_x,
3510 const double facteur_delta_filtre_y,
3511 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
3512 T& kernel,
3515 const bool flag_turbulent_mu_filtre,
3516 FixedVector<IJK_Field_double, 6>& turbulent_mu_filtre_tensor,
3517 FixedVector<IJK_Field_double, 6>& turbulent_mu_tensor,
3518 const Domaine_IJK& splitting)
3519{
3520 Turbulent_viscosity_base* model = nullptr;
3521
3522 const double& coefficient_xx = turbulent_viscosity_tensor_coefficients[0];
3523 const double& coefficient_xy = turbulent_viscosity_tensor_coefficients[1];
3524 const double& coefficient_xz = turbulent_viscosity_tensor_coefficients[2];
3525 const double& coefficient_yy = turbulent_viscosity_tensor_coefficients[3];
3526 const double& coefficient_yz = turbulent_viscosity_tensor_coefficients[4];
3527 const double& coefficient_zz = turbulent_viscosity_tensor_coefficients[5];
3528
3529 IJK_Field_double& turbulent_mu_xx = turbulent_mu_tensor[0];
3530 IJK_Field_double& turbulent_mu_xy = turbulent_mu_tensor[1];
3531 IJK_Field_double& turbulent_mu_xz = turbulent_mu_tensor[2];
3532 IJK_Field_double& turbulent_mu_yy = turbulent_mu_tensor[3];
3533 IJK_Field_double& turbulent_mu_yz = turbulent_mu_tensor[4];
3534 IJK_Field_double& turbulent_mu_zz = turbulent_mu_tensor[5];
3535
3536 IJK_Field_double& turbulent_mu_filtre_xx = turbulent_mu_filtre_tensor[0];
3537 IJK_Field_double& turbulent_mu_filtre_xy = turbulent_mu_filtre_tensor[1];
3538 IJK_Field_double& turbulent_mu_filtre_xz = turbulent_mu_filtre_tensor[2];
3539 IJK_Field_double& turbulent_mu_filtre_yy = turbulent_mu_filtre_tensor[3];
3540 IJK_Field_double& turbulent_mu_filtre_yz = turbulent_mu_filtre_tensor[4];
3541 IJK_Field_double& turbulent_mu_filtre_zz = turbulent_mu_filtre_tensor[5];
3542
3543 choix_modele(turbulent_viscosity_model, model);
3544
3545 if (0)
3546 {
3547 // do nothing
3548 }
3549 else
3550 {
3551 calculer_turbulent_mu_scalar(anisotropic,
3552 turbulent_viscosity_model, turbulent_viscosity_model_constant, variation_cste_modele_fonctionnel_, smoothing_center_fr_, smoothing_factor_fr_, Re_tau_fr_, Re_tau_ch_, pond_fr_, pond_ch_, center_constant_, Lz_tot_,
3553 velocity, velocity_filtre,
3554 rho, rho_filtre, rho_kmin, rho_kmax,
3555 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
3556 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
3557 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
3558 kernel, tmp_b, tmp_a,
3559 flag_turbulent_mu_filtre, turbulent_mu_filtre_xx,
3560 turbulent_mu_xx, splitting);
3561
3562 multiplier_champ(coefficient_xy, turbulent_mu_xx, turbulent_mu_xy);
3563 multiplier_champ(coefficient_xz, turbulent_mu_xx, turbulent_mu_xz);
3564 multiplier_champ(coefficient_yy, turbulent_mu_xx, turbulent_mu_yy);
3565 multiplier_champ(coefficient_yz, turbulent_mu_xx, turbulent_mu_yz);
3566 multiplier_champ(coefficient_zz, turbulent_mu_xx, turbulent_mu_zz);
3567 multiplier_champ(coefficient_xx, turbulent_mu_xx, turbulent_mu_xx);
3568
3569 if (flag_turbulent_mu_filtre)
3570 {
3571 multiplier_champ(coefficient_xy, turbulent_mu_filtre_xx, turbulent_mu_filtre_xy);
3572 multiplier_champ(coefficient_xz, turbulent_mu_filtre_xx, turbulent_mu_filtre_xz);
3573 multiplier_champ(coefficient_yy, turbulent_mu_filtre_xx, turbulent_mu_filtre_yy);
3574 multiplier_champ(coefficient_yz, turbulent_mu_filtre_xx, turbulent_mu_filtre_yz);
3575 multiplier_champ(coefficient_zz, turbulent_mu_filtre_xx, turbulent_mu_filtre_zz);
3576 multiplier_champ(coefficient_xx, turbulent_mu_filtre_xx, turbulent_mu_filtre_xx);
3577 }
3578 }
3579
3580 delete model;
3581}
3582
3583template<class T>
3584void calculer_turbulent_mu_vector(const bool anisotropic,
3585 const Nom& turbulent_viscosity_model,
3586 const double turbulent_viscosity_model_constant,
3587 const ArrOfDouble& turbulent_diffusivity_vector_coefficients,
3588 const double variation_cste_modele_fonctionnel_,
3589 const double smoothing_center_fr_,
3590 const double smoothing_factor_fr_,
3591 const double Re_tau_fr_,
3592 const double Re_tau_ch_,
3593 const double pond_fr_,
3594 const double pond_ch_,
3595 const double center_constant_,
3596 const double Lz_tot_,
3597 IJK_Field_vector3_double& velocity,
3598 IJK_Field_vector3_double& velocity_filtre,
3599 IJK_Field_double& rho,
3600 IJK_Field_double& rho_filtre,
3601 double rho_kmin, double rho_kmax,
3602 IJK_Field_double& scalar,
3603 IJK_Field_double& scalar_filtre,
3604 double scalar_kmin, double scalar_kmax,
3605 const ArrOfDouble_with_ghost& delta_z,
3606 const double facteur_delta_x,
3607 const double facteur_delta_y,
3608 const ArrOfDouble_with_ghost& delta_z_pour_delta,
3609 const double facteur_delta_filtre_x,
3610 const double facteur_delta_filtre_y,
3611 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
3612 T& kernel,
3615 const bool flag_turbulent_mu_filtre,
3616 IJK_Field_vector3_double& turbulent_mu_filtre_vector,
3617 IJK_Field_vector3_double& turbulent_mu_vector,
3618 const Domaine_IJK& splitting)
3619{
3620 Turbulent_viscosity_base* model = nullptr;
3621
3622 const double& coefficient_x = turbulent_diffusivity_vector_coefficients[0];
3623 const double& coefficient_y = turbulent_diffusivity_vector_coefficients[1];
3624 const double& coefficient_z = turbulent_diffusivity_vector_coefficients[2];
3625
3626 IJK_Field_double& turbulent_mu_x = turbulent_mu_vector[0];
3627 IJK_Field_double& turbulent_mu_y = turbulent_mu_vector[1];
3628 IJK_Field_double& turbulent_mu_z = turbulent_mu_vector[2];
3629
3630 IJK_Field_double& turbulent_mu_filtre_x = turbulent_mu_filtre_vector[0];
3631 IJK_Field_double& turbulent_mu_filtre_y = turbulent_mu_filtre_vector[1];
3632 IJK_Field_double& turbulent_mu_filtre_z = turbulent_mu_filtre_vector[2];
3633
3634 choix_modele(turbulent_viscosity_model, model);
3635
3636 if (0)
3637 {
3638 // do nothing
3639 }
3640 else
3641 {
3642 calculer_turbulent_mu_scalar(anisotropic,
3643 turbulent_viscosity_model, turbulent_viscosity_model_constant, variation_cste_modele_fonctionnel_, smoothing_center_fr_, smoothing_factor_fr_, Re_tau_fr_, Re_tau_ch_, pond_fr_, pond_ch_, center_constant_, Lz_tot_,
3644 velocity, velocity_filtre,
3645 rho, rho_filtre, rho_kmin, rho_kmax,
3646 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
3647 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
3648 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
3649 kernel, tmp_b, tmp_a,
3650 flag_turbulent_mu_filtre, turbulent_mu_filtre_x,
3651 turbulent_mu_x, splitting);
3652
3653 multiplier_champ(coefficient_y, turbulent_mu_x, turbulent_mu_y);
3654 multiplier_champ(coefficient_z, turbulent_mu_x, turbulent_mu_z);
3655 multiplier_champ(coefficient_x, turbulent_mu_x, turbulent_mu_x);
3656
3657 if (flag_turbulent_mu_filtre)
3658 {
3659 multiplier_champ(coefficient_y, turbulent_mu_filtre_x, turbulent_mu_filtre_y);
3660 multiplier_champ(coefficient_z, turbulent_mu_filtre_x, turbulent_mu_filtre_z);
3661 multiplier_champ(coefficient_x, turbulent_mu_filtre_x, turbulent_mu_filtre_x);
3662 }
3663 }
3664
3665 delete model;
3666}
3667
3668void calculer_structural_uu_gradient(const double structural_uu_model_constant,
3669 const ArrOfDouble& structural_uu_tensor_coefficients,
3670 const IJK_Field_vector3_double& velocity,
3671 const ArrOfDouble_with_ghost& delta_z_maillage,
3672 const double facteur_x_pour_delta,
3673 const double facteur_y_pour_delta,
3674 const ArrOfDouble_with_ghost& delta_z_pour_delta,
3675 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
3676{
3677 const IJK_Field_double& vitesse_i = velocity[0];
3678 const IJK_Field_double& vitesse_j = velocity[1];
3679 const IJK_Field_double& vitesse_k = velocity[2];
3680
3681 IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
3682 IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
3683 IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
3684 IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
3685 IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
3686 IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
3687
3688 const double& coefficient_xx = structural_uu_tensor_coefficients[0];
3689 const double& coefficient_xy = structural_uu_tensor_coefficients[1];
3690 const double& coefficient_xz = structural_uu_tensor_coefficients[2];
3691 const double& coefficient_yy = structural_uu_tensor_coefficients[3];
3692 const double& coefficient_yz = structural_uu_tensor_coefficients[4];
3693 const double& coefficient_zz = structural_uu_tensor_coefficients[5];
3694
3695 const double deltaunsurdx = facteur_x_pour_delta;
3696 const double deltaunsurdy = facteur_y_pour_delta;
3697
3698 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
3699 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
3700
3701 const int ni = vitesse_k.ni();
3702 const int nj = vitesse_k.nj();
3703 const int nk = vitesse_k.nk();
3704
3705 for (int k = 0; k < nk; k++)
3706 {
3707 for (int j = 0; j < nj; j++)
3708 {
3709 for (int i = 0; i < ni; i++)
3710 {
3711 const int kg = k + offset;
3712
3713 const double dz = delta_z_maillage[k];
3714 const double dz_m1 = kg==0 ? 0. : delta_z_maillage[k-1];
3715 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
3716 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
3717
3718 const double deltaunsurdz = delta_z_pour_delta[k] * 1./dz;
3719 const double deltaunsurdz_m1 = kg==0 ? 0. : delta_z_pour_delta[k-1] * 1./dz_m1;
3720 const double deltaunsurdelta_m = kg==0 ? 0. : 0.5*(delta_z_pour_delta[k] + delta_z_pour_delta[k-1]) * 1./delta_m;
3721 const double deltaunsurdelta_p = kg==(nktot-1) ? 0. : 0.5*(delta_z_pour_delta[k] + delta_z_pour_delta[k+1]) * 1./delta_p;
3722
3723 const double uf_i = vitesse_i(i,j,k);
3724 const double uf_ip1 = vitesse_i(i+1,j,k);
3725 const double uf_im1 = vitesse_i(i-1,j,k);
3726 const double uf_i_jm1 = vitesse_i(i,j-1,k);
3727 const double uf_i_jp1 = vitesse_i(i,j+1,k);
3728 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
3729 const double uf_i_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i,j,k+1);
3730 const double uf_i_jm1_km1 = kg==0 ? 0. : vitesse_i(i,j-1,k-1);
3731 const double uf_i_jp1_km1 = kg==0 ? 0. : vitesse_i(i,j+1,k-1);
3732 const double uf_i_jm1_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i,j-1,k+1);
3733 const double uf_ip1_jp1 = vitesse_i(i+1,j+1,k);
3734 const double uf_ip1_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i+1,j,k+1);
3735 const double uf_ip1_jm1 = vitesse_i(i+1,j-1,k);
3736 const double uf_ip1_km1 = kg==0 ? 0. : vitesse_i(i+1,j,k-1);
3737 const double uf_im1_jm1 = vitesse_i(i-1,j-1,k);
3738 const double uf_im1_km1 = kg==0 ? 0. : vitesse_i(i-1,j,k-1);
3739
3740 const double vf_j = vitesse_j(i,j,k);
3741 const double vf_j_im1 = vitesse_j(i-1,j,k);
3742 const double vf_j_ip1 = vitesse_j(i+1,j,k);
3743 const double vf_jp1 = vitesse_j(i,j+1,k);
3744 const double vf_jm1 = vitesse_j(i,j-1,k);
3745 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
3746 const double vf_j_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j,k+1);
3747 const double vf_j_im1_km1 = kg==0 ? 0. : vitesse_j(i-1,j,k-1);
3748 const double vf_j_ip1_km1 = kg==0 ? 0. : vitesse_j(i+1,j,k-1);
3749 const double vf_j_im1_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i-1,j,k+1);
3750 const double vf_jp1_ip1 = vitesse_j(i+1,j+1,k);
3751 const double vf_jp1_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j+1,k+1);
3752 const double vf_jp1_im1 = vitesse_j(i-1,j+1,k);
3753 const double vf_jp1_km1 = kg==0 ? 0. : vitesse_j(i,j+1,k-1);
3754 const double vf_jm1_im1 = vitesse_j(i-1,j-1,k);
3755 const double vf_jm1_km1 = kg==0 ? 0. : vitesse_j(i,j-1,k-1);
3756
3757 const double wf_k = vitesse_k(i,j,k);
3758 const double wf_k_im1 = vitesse_k(i-1,j,k);
3759 const double wf_k_ip1 = vitesse_k(i+1,j,k);
3760 const double wf_k_jm1 = vitesse_k(i,j-1,k);
3761 const double wf_k_jp1 = vitesse_k(i,j+1,k);
3762 const double wf_k_im1_jm1 = vitesse_k(i-1,j-1,k);
3763 const double wf_k_ip1_jm1 = vitesse_k(i+1,j-1,k);
3764 const double wf_k_im1_jp1 = vitesse_k(i-1,j+1,k);
3765 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
3766 const double wf_km1 = kg==0 ? 0. : vitesse_k(i,j,k-1);
3767 const double wf_kp1_ip1 = kg==(nktot-1) ? 0. : vitesse_k(i+1,j,k+1);
3768 const double wf_kp1_jp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j+1,k+1);
3769 const double wf_kp1_im1 = kg==(nktot-1) ? 0. : vitesse_k(i-1,j,k+1);
3770 const double wf_kp1_jm1 = kg==(nktot-1) ? 0. : vitesse_k(i,j-1,k+1);
3771 const double wf_km1_im1 = kg==0 ? 0. : vitesse_k(i-1,j,k-1);
3772 const double wf_km1_jm1 = kg==0 ? 0. : vitesse_k(i,j-1,k-1);
3773
3774 const double duidx = deltaunsurdx * (uf_ip1 - uf_i);
3775 const double dujdy = deltaunsurdy * (vf_jp1 - vf_j);
3776 const double dukdz = deltaunsurdz * (wf_kp1 - wf_k);
3777
3778 const double duidx_im1 = deltaunsurdx * (uf_i - uf_im1);
3779 const double dujdy_im1 = deltaunsurdy * (vf_jp1_im1 - vf_j_im1);
3780 const double dukdz_im1 = deltaunsurdz * (wf_kp1_im1 - wf_k_im1);
3781
3782 const double duidx_jm1 = deltaunsurdx * (uf_ip1_jm1 - uf_i_jm1);
3783 const double dujdy_jm1 = deltaunsurdy * (vf_j - vf_jm1);
3784 const double dukdz_jm1 = deltaunsurdz * (wf_kp1_jm1 - wf_k_jm1);
3785
3786 const double duidx_km1 = deltaunsurdx * (uf_ip1_km1 - uf_i_km1);
3787 const double dujdy_km1 = deltaunsurdy * (vf_jp1_km1 - vf_j_km1);
3788 const double dukdz_km1 = deltaunsurdz_m1 * (wf_k - wf_km1);
3789
3790 const double duidx_im1_jm1 = deltaunsurdx * (uf_i_jm1 - uf_im1_jm1);
3791 const double dujdy_im1_jm1 = deltaunsurdy * (vf_j_im1 - vf_jm1_im1);
3792
3793 const double dujdy_jm1_km1 = deltaunsurdy * (vf_j_km1 - vf_jm1_km1);
3794 const double dukdz_jm1_km1 = deltaunsurdz * (wf_k_jm1 - wf_km1_jm1);
3795
3796 const double duidx_im1_km1 = deltaunsurdx * (uf_i_km1 - uf_im1_km1);
3797 const double dukdz_im1_km1 = deltaunsurdz * (wf_k_im1 - wf_km1_im1);
3798
3799 const double duidy_ij = deltaunsurdy * (uf_i - uf_i_jm1);
3800 const double duidy_ip1j = deltaunsurdy * (uf_ip1 - uf_ip1_jm1);
3801 const double duidy_ijp1 = deltaunsurdy * (uf_i_jp1 - uf_i);
3802 const double duidy_ip1jp1 = deltaunsurdy * (uf_ip1_jp1 - uf_ip1);
3803 const double duidy_ij_km1 = deltaunsurdy * (uf_i_km1 - uf_i_jm1_km1);
3804 const double duidy_ijp1_km1 = deltaunsurdy * (uf_i_jp1_km1 - uf_i_km1);
3805
3806 const double duidz_ik = deltaunsurdelta_m * (uf_i - uf_i_km1);
3807 const double duidz_ip1k = deltaunsurdelta_m * (uf_ip1 - uf_ip1_km1);
3808 const double duidz_ikp1 = deltaunsurdelta_p * (uf_i_kp1 - uf_i);
3809 const double duidz_ip1kp1 = deltaunsurdelta_p * (uf_ip1_kp1 - uf_ip1);
3810 const double duidz_ik_jm1 = deltaunsurdelta_m * (uf_i_jm1 - uf_i_jm1_km1);
3811 const double duidz_ikp1_jm1 = deltaunsurdelta_p * (uf_i_jm1_kp1 - uf_i_jm1);
3812
3813 const double dujdx_ij = deltaunsurdx * (vf_j - vf_j_im1);
3814 const double dujdx_ip1j = deltaunsurdx * (vf_j_ip1 - vf_j);
3815 const double dujdx_ijp1 = deltaunsurdx * (vf_jp1 - vf_jp1_im1);
3816 const double dujdx_ip1jp1 = deltaunsurdx * (vf_jp1_ip1 - vf_jp1);
3817 const double dujdx_ij_km1 = deltaunsurdx * (vf_j_km1 - vf_j_im1_km1);
3818 const double dujdx_ip1j_km1 = deltaunsurdx * (vf_j_ip1_km1 - vf_j_km1);
3819
3820 const double dujdz_jk = deltaunsurdelta_m * (vf_j - vf_j_km1);
3821 const double dujdz_jp1k = deltaunsurdelta_m * (vf_jp1 - vf_jp1_km1);
3822 const double dujdz_jkp1 = deltaunsurdelta_p * (vf_j_kp1 - vf_j);
3823 const double dujdz_jp1kp1 = deltaunsurdelta_p * (vf_jp1_kp1 - vf_jp1);
3824 const double dujdz_jk_im1 = deltaunsurdelta_m * (vf_j_im1 - vf_j_im1_km1);
3825 const double dujdz_jkp1_im1 = deltaunsurdelta_p * (vf_j_im1_kp1 - vf_j_im1);
3826
3827 const double dukdx_ik = deltaunsurdx * (wf_k - wf_k_im1);
3828 const double dukdx_ip1k = deltaunsurdx * (wf_k_ip1 - wf_k);
3829 const double dukdx_ikp1 = deltaunsurdx * (wf_kp1 - wf_kp1_im1);
3830 const double dukdx_ip1kp1 = deltaunsurdx * (wf_kp1_ip1 - wf_kp1);
3831 const double dukdx_ik_jm1 = deltaunsurdx * (wf_k_jm1 - wf_k_im1_jm1);
3832 const double dukdx_ip1k_jm1 = deltaunsurdx * (wf_k_ip1_jm1 - wf_k_jm1);
3833
3834 const double dukdy_jk = deltaunsurdy * (wf_k - wf_k_jm1);
3835 const double dukdy_jp1k = deltaunsurdy * (wf_k_jp1 - wf_k);
3836 const double dukdy_jkp1 = deltaunsurdy * (wf_kp1 - wf_kp1_jm1);
3837 const double dukdy_jp1kp1 = deltaunsurdy * (wf_kp1_jp1 - wf_kp1);
3838 const double dukdy_jk_im1 = deltaunsurdy * (wf_k_im1 - wf_k_im1_jm1);
3839 const double dukdy_jp1k_im1 = deltaunsurdy * (wf_k_im1_jp1 - wf_k_im1);
3840
3841 const double g_e_ii = duidx;
3842 const double g_e_ij = 0.25 * (duidy_ip1jp1 + duidy_ijp1 + duidy_ip1j + duidy_ij);
3843 const double g_e_ik = 0.25 * (duidz_ip1kp1 + duidz_ikp1 + duidz_ip1k + duidz_ik);
3844 const double g_e_ji = 0.25 * (dujdx_ip1jp1 + dujdx_ip1j + dujdx_ijp1 + dujdx_ij);
3845 const double g_e_jj = dujdy;
3846 const double g_e_jk = 0.25 * (dujdz_jp1kp1 + dujdz_jkp1 + dujdz_jp1k + dujdz_jk);
3847 const double g_e_ki = 0.25 * (dukdx_ip1kp1 + dukdx_ip1k + dukdx_ikp1 + dukdx_ik);
3848 const double g_e_kj = 0.25 * (dukdy_jp1kp1 + dukdy_jp1k + dukdy_jkp1 + dukdy_jk);
3849 const double g_e_kk = dukdz;
3850
3851 const double g_aij_ii = 0.25 * (duidx_im1_jm1 + duidx_jm1 + duidx_im1 + duidx);
3852 const double g_aij_ij = duidy_ij;
3853 const double g_aij_ik = 0.25 * (duidz_ikp1_jm1 + duidz_ikp1 + duidz_ik_jm1 + duidz_ik);
3854 const double g_aij_ji = dujdx_ij;
3855 const double g_aij_jj = 0.25 * (dujdy_im1_jm1 + dujdy_jm1 + dujdy_im1 + dujdy);
3856 const double g_aij_jk = 0.25 * (dujdz_jkp1_im1 + dujdz_jkp1 + dujdz_jk_im1 + dujdz_jk);
3857
3858 const double g_aik_ii = 0.25 * (duidx_im1_km1 + duidx_km1 + duidx_im1 + duidx);
3859 const double g_aik_ij = 0.25 * (duidy_ijp1_km1 + duidy_ijp1 + duidy_ij_km1 + duidy_ij);
3860 const double g_aik_ik = duidz_ik;
3861 const double g_aik_ki = dukdx_ik;
3862 const double g_aik_kj = 0.25 * (dukdy_jp1k_im1 + dukdy_jp1k + dukdy_jk_im1 + dukdy_jk);
3863 const double g_aik_kk = 0.25 * (dukdz_im1_km1 + dukdz_km1 + dukdz_im1 + dukdz);
3864
3865 const double g_ajk_ji = 0.25 * (dujdx_ip1j_km1 + dujdx_ip1j + dujdx_ij_km1 + dujdx_ij);
3866 const double g_ajk_jj = 0.25 * (dujdy_jm1_km1 + dujdy_km1 + dujdy_jm1 + dujdy);
3867 const double g_ajk_jk = dujdz_jk;
3868 const double g_ajk_ki = 0.25 * (dukdx_ip1k_jm1 + dukdx_ip1k + dukdx_ik_jm1 + dukdx_ik);
3869 const double g_ajk_kj = dukdy_jk;
3870 const double g_ajk_kk = 0.25 * (dukdz_jm1_km1 + dukdz_km1 + dukdz_jm1 + dukdz);
3871
3872 const double c_ii = g_e_ii*g_e_ii + g_e_ij*g_e_ij + g_e_ik*g_e_ik;
3873 const double c_ij = g_aij_ii*g_aij_ji + g_aij_ij*g_aij_jj + g_aij_ik*g_aij_jk;
3874 const double c_ik = g_aik_ii*g_aik_ki + g_aik_ij*g_aik_kj + g_aik_ik*g_aik_kk;
3875 const double c_jj = g_e_ji*g_e_ji + g_e_jj*g_e_jj + g_e_jk*g_e_jk;
3876 const double c_jk = g_ajk_ji*g_ajk_ki + g_ajk_jj*g_ajk_kj + g_ajk_jk*g_ajk_kk;
3877 const double c_kk = g_e_ki*g_e_ki + g_e_kj*g_e_kj + g_e_kk*g_e_kk;
3878
3879 structural_uu_xx(i,j,k) = - coefficient_xx * structural_uu_model_constant * c_ii/12.;
3880 structural_uu_xy(i,j,k) = - coefficient_xy * structural_uu_model_constant * c_ij/12.;
3881 structural_uu_xz(i,j,k) = - coefficient_xz * structural_uu_model_constant * c_ik/12.;
3882 structural_uu_yy(i,j,k) = - coefficient_yy * structural_uu_model_constant * c_jj/12.;
3883 structural_uu_yz(i,j,k) = - coefficient_yz * structural_uu_model_constant * c_jk/12.;
3884 structural_uu_zz(i,j,k) = - coefficient_zz * structural_uu_model_constant * c_kk/12.;
3885 }
3886 }
3887 }
3888}
3889
3890void calculer_laplacien_u(const IJK_Field_vector3_double& velocity,
3891 const ArrOfDouble_with_ghost& delta_z_maillage,
3892 const double facteur_x_pour_delta,
3893 const double facteur_y_pour_delta,
3894 const ArrOfDouble_with_ghost& delta_z_pour_delta,
3895 IJK_Field_vector3_double& laplacien_velocity)
3896{
3897 const IJK_Field_double& vitesse_i = velocity[0];
3898 const IJK_Field_double& vitesse_j = velocity[1];
3899 const IJK_Field_double& vitesse_k = velocity[2];
3900
3901 IJK_Field_double& laplacien_i = laplacien_velocity[0];
3902 IJK_Field_double& laplacien_j = laplacien_velocity[1];
3903 IJK_Field_double& laplacien_k = laplacien_velocity[2];
3904
3905 const double deltaunsurdx = facteur_x_pour_delta;
3906 const double deltaunsurdy = facteur_y_pour_delta;
3907
3908 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
3909 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
3910
3911 const int ni = vitesse_k.ni();
3912 const int nj = vitesse_k.nj();
3913 const int nk = vitesse_k.nk();
3914
3915 for (int k = 0; k < nk; k++)
3916 {
3917 for (int j = 0; j < nj; j++)
3918 {
3919 for (int i = 0; i < ni; i++)
3920 {
3921 const int kg = k + offset;
3922
3923 const double dz = delta_z_maillage[k];
3924 const double dz_m1 = kg==0 ? 0. : delta_z_maillage[k-1];
3925 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
3926 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
3927
3928 const double deltaunsurdz = delta_z_pour_delta[k] * 1./dz;
3929 const double deltaunsurdz_m1 = kg==0 ? 0. : delta_z_pour_delta[k-1] * 1./dz_m1;
3930 const double deltaunsurdelta_m = kg==0 ? 0. : 0.5*(delta_z_pour_delta[k] + delta_z_pour_delta[k-1]) * 1./delta_m;
3931 const double deltaunsurdelta_p = kg==(nktot-1) ? 0. : 0.5*(delta_z_pour_delta[k] + delta_z_pour_delta[k+1]) * 1./delta_p;
3932
3933 const double uf_i = vitesse_i(i,j,k);
3934 const double uf_ip1 = vitesse_i(i+1,j,k);
3935 const double uf_im1 = vitesse_i(i-1,j,k);
3936 const double uf_i_jm1 = vitesse_i(i,j-1,k);
3937 const double uf_i_jp1 = vitesse_i(i,j+1,k);
3938 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
3939 const double uf_i_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i,j,k+1);
3940
3941 const double vf_j = vitesse_j(i,j,k);
3942 const double vf_j_im1 = vitesse_j(i-1,j,k);
3943 const double vf_j_ip1 = vitesse_j(i+1,j,k);
3944 const double vf_jp1 = vitesse_j(i,j+1,k);
3945 const double vf_jm1 = vitesse_j(i,j-1,k);
3946 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
3947 const double vf_j_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j,k+1);
3948
3949 const double wf_k = vitesse_k(i,j,k);
3950 const double wf_k_im1 = vitesse_k(i-1,j,k);
3951 const double wf_k_ip1 = vitesse_k(i+1,j,k);
3952 const double wf_k_jm1 = vitesse_k(i,j-1,k);
3953 const double wf_k_jp1 = vitesse_k(i,j+1,k);
3954 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
3955 const double wf_km1 = kg==0 ? 0. : vitesse_k(i,j,k-1);
3956
3957 const double duidx = deltaunsurdx * (uf_ip1 - uf_i);
3958 const double dujdy = deltaunsurdy * (vf_jp1 - vf_j);
3959 const double dukdz = deltaunsurdz * (wf_kp1 - wf_k);
3960
3961 const double duidx_im1 = deltaunsurdx * (uf_i - uf_im1);
3962 const double dujdy_jm1 = deltaunsurdy * (vf_j - vf_jm1);
3963 const double dukdz_km1 = deltaunsurdz_m1 * (wf_k - wf_km1);
3964
3965 const double duidy_ij = deltaunsurdy * (uf_i - uf_i_jm1);
3966 const double duidy_ijp1 = deltaunsurdy * (uf_i_jp1 - uf_i);
3967
3968 const double duidz_ik = deltaunsurdelta_m * (uf_i - uf_i_km1);
3969 const double duidz_ikp1 = deltaunsurdelta_p * (uf_i_kp1 - uf_i);
3970
3971 const double dujdx_ij = deltaunsurdx * (vf_j - vf_j_im1);
3972 const double dujdx_ip1j = deltaunsurdx * (vf_j_ip1 - vf_j);
3973
3974 const double dujdz_jk = deltaunsurdelta_m * (vf_j - vf_j_km1);
3975 const double dujdz_jkp1 = deltaunsurdelta_p * (vf_j_kp1 - vf_j);
3976
3977 const double dukdx_ik = deltaunsurdx * (wf_k - wf_k_im1);
3978 const double dukdx_ip1k = deltaunsurdx * (wf_k_ip1 - wf_k);
3979
3980 const double dukdy_jk = deltaunsurdy * (wf_k - wf_k_jm1);
3981 const double dukdy_jp1k = deltaunsurdy * (wf_k_jp1 - wf_k);
3982
3983 const double d2uidx2f_i = deltaunsurdx * (duidx - duidx_im1);
3984 const double d2ujdy2f_j = deltaunsurdy * (dujdy - dujdy_jm1);
3985 const double d2ukdz2f_k = deltaunsurdelta_m * (dukdz - dukdz_km1);
3986
3987 const double d2uidy2f_i = deltaunsurdy * (duidy_ijp1 - duidy_ij);
3988 const double d2uidz2f_i = deltaunsurdz * (duidz_ikp1 - duidz_ik);
3989
3990 const double d2ujdx2f_j = deltaunsurdx * (dujdx_ip1j - dujdx_ij);
3991 const double d2ujdz2f_j = deltaunsurdz * (dujdz_jkp1 - dujdz_jk);
3992
3993 const double d2ukdx2f_k = deltaunsurdx * (dukdx_ip1k - dukdx_ik);
3994 const double d2ukdy2f_k = deltaunsurdy * (dukdy_jp1k - dukdy_jk);
3995
3996 const double laplacien_uf_i = d2uidx2f_i + d2uidy2f_i + d2uidz2f_i;
3997 const double laplacien_vf_j = d2ujdx2f_j + d2ujdy2f_j + d2ujdz2f_j;
3998 const double laplacien_wf_k = d2ukdx2f_k + d2ukdy2f_k + d2ukdz2f_k;
3999
4000 laplacien_i(i,j,k) = laplacien_uf_i;
4001 laplacien_j(i,j,k) = laplacien_vf_j;
4002 laplacien_k(i,j,k) = laplacien_wf_k;
4003 }
4004 }
4005 }
4006}
4007
4008void calculer_structural_uu_su_laplacien_u(const double structural_uu_model_constant,
4009 const ArrOfDouble& structural_uu_tensor_coefficients,
4010 const IJK_Field_vector3_double& velocity,
4011 const IJK_Field_vector3_double& laplacien_velocity,
4012 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
4013{
4014 const IJK_Field_double& vitesse_i = velocity[0];
4015 const IJK_Field_double& vitesse_j = velocity[1];
4016 const IJK_Field_double& vitesse_k = velocity[2];
4017
4018 const IJK_Field_double& laplacien_i = laplacien_velocity[0];
4019 const IJK_Field_double& laplacien_j = laplacien_velocity[1];
4020 const IJK_Field_double& laplacien_k = laplacien_velocity[2];
4021
4022 IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
4023 IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
4024 IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
4025 IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
4026 IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
4027 IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
4028
4029 const double& coefficient_xx = structural_uu_tensor_coefficients[0];
4030 const double& coefficient_xy = structural_uu_tensor_coefficients[1];
4031 const double& coefficient_xz = structural_uu_tensor_coefficients[2];
4032 const double& coefficient_yy = structural_uu_tensor_coefficients[3];
4033 const double& coefficient_yz = structural_uu_tensor_coefficients[4];
4034 const double& coefficient_zz = structural_uu_tensor_coefficients[5];
4035
4036 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
4037 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
4038
4039 const int ni = vitesse_k.ni();
4040 const int nj = vitesse_k.nj();
4041 const int nk = vitesse_k.nk();
4042
4043 for (int k = 0; k < nk; k++)
4044 {
4045 for (int j = 0; j < nj; j++)
4046 {
4047 for (int i = 0; i < ni; i++)
4048 {
4049 const int kg = k + offset;
4050
4051 const double uf_i = vitesse_i(i,j,k);
4052 const double uf_ip1 = vitesse_i(i+1,j,k);
4053 const double uf_i_jm1 = vitesse_i(i,j-1,k);
4054 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
4055
4056 const double vf_j = vitesse_j(i,j,k);
4057 const double vf_j_im1 = vitesse_j(i-1,j,k);
4058 const double vf_jp1 = vitesse_j(i,j+1,k);
4059 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
4060
4061 const double wf_k = vitesse_k(i,j,k);
4062 const double wf_k_im1 = vitesse_k(i-1,j,k);
4063 const double wf_k_jm1 = vitesse_k(i,j-1,k);
4064 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
4065
4066 const double u_ij = 0.5*(uf_i + uf_i_jm1);
4067 const double u_ik = 0.5*(uf_i + uf_i_km1);
4068 const double v_ij = 0.5*(vf_j + vf_j_im1);
4069 const double v_jk = 0.5*(vf_j + vf_j_km1);
4070 const double w_ik = 0.5*(wf_k + wf_k_im1);
4071 const double w_jk = 0.5*(wf_k + wf_k_jm1);
4072
4073 const double ue = 0.5 * (uf_i + uf_ip1);
4074 const double ve = 0.5 * (vf_j + vf_jp1);
4075 const double we = 0.5 * (wf_k + wf_kp1);
4076
4077 const double laplacien_uf_i = laplacien_i(i,j,k);
4078 const double laplacien_vf_j = laplacien_j(i,j,k);
4079 const double laplacien_wf_k = laplacien_k(i,j,k);
4080
4081 const double laplacien_uf_ip1 = laplacien_i(i+1,j,k);
4082 const double laplacien_vf_jp1 = laplacien_j(i,j+1,k);
4083 const double laplacien_wf_kp1 = kg==(nktot-1) ? 0. : laplacien_k(i,j,k+1);
4084
4085 const double laplacien_uf_i_jm1 = laplacien_i(i,j-1,k);
4086 const double laplacien_uf_i_km1 = kg==0 ? 0. : laplacien_i(i,j,k-1);
4087 const double laplacien_vf_j_im1 = laplacien_j(i-1,j,k);
4088 const double laplacien_vf_j_km1 = kg==0 ? 0. : laplacien_j(i,j,k-1);
4089 const double laplacien_wf_k_im1 = laplacien_k(i-1,j,k);
4090 const double laplacien_wf_k_jm1 = laplacien_k(i,j-1,k);
4091
4092 const double laplacien_u_aij = 0.5*(laplacien_uf_i + laplacien_uf_i_jm1);
4093 const double laplacien_u_aik = 0.5*(laplacien_uf_i + laplacien_uf_i_km1);
4094 const double laplacien_v_aij = 0.5*(laplacien_vf_j + laplacien_vf_j_im1);
4095 const double laplacien_v_ajk = 0.5*(laplacien_vf_j + laplacien_vf_j_km1);
4096 const double laplacien_w_aik = 0.5*(laplacien_wf_k + laplacien_wf_k_im1);
4097 const double laplacien_w_ajk = 0.5*(laplacien_wf_k + laplacien_wf_k_jm1);
4098
4099 const double laplacien_u_e = 0.5 * (laplacien_uf_i + laplacien_uf_ip1);
4100 const double laplacien_v_e = 0.5 * (laplacien_vf_j + laplacien_vf_jp1);
4101 const double laplacien_w_e = 0.5 * (laplacien_wf_k + laplacien_wf_kp1);
4102
4103 const double udu_ii = ue*laplacien_u_e/24.;
4104 const double udu_ij = u_ij*laplacien_v_aij/24.;
4105 const double udu_ik = u_ik*laplacien_w_aik/24.;
4106 const double udu_ji = v_ij*laplacien_u_aij/24.;
4107 const double udu_jj = ve*laplacien_v_e/24.;
4108 const double udu_jk = v_jk*laplacien_w_ajk/24.;
4109 const double udu_ki = w_ik*laplacien_u_aik/24.;
4110 const double udu_kj = w_jk*laplacien_v_ajk/24.;
4111 const double udu_kk = we*laplacien_w_e/24.;
4112
4113 const double su_laplacien_u_ii = - udu_ii - udu_ii;
4114 const double su_laplacien_u_ij = - udu_ij - udu_ji;
4115 const double su_laplacien_u_ik = - udu_ik - udu_ki;
4116 const double su_laplacien_u_jj = - udu_jj - udu_jj;
4117 const double su_laplacien_u_jk = - udu_jk - udu_kj;
4118 const double su_laplacien_u_kk = - udu_kk - udu_kk;
4119
4120 structural_uu_xx(i,j,k) = - coefficient_xx * structural_uu_model_constant * su_laplacien_u_ii;
4121 structural_uu_xy(i,j,k) = - coefficient_xy * structural_uu_model_constant * su_laplacien_u_ij;
4122 structural_uu_xz(i,j,k) = - coefficient_xz * structural_uu_model_constant * su_laplacien_u_ik;
4123 structural_uu_yy(i,j,k) = - coefficient_yy * structural_uu_model_constant * su_laplacien_u_jj;
4124 structural_uu_yz(i,j,k) = - coefficient_yz * structural_uu_model_constant * su_laplacien_u_jk;
4125 structural_uu_zz(i,j,k) = - coefficient_zz * structural_uu_model_constant * su_laplacien_u_kk;
4126 }
4127 }
4128 }
4129}
4130
4131void calculer_structural_uu_convection(const double structural_uu_model_constant,
4132 const ArrOfDouble& structural_uu_tensor_coefficients,
4133 const IJK_Field_vector3_double& velocity,
4134 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
4135{
4136 const IJK_Field_double& vitesse_i = velocity[0];
4137 const IJK_Field_double& vitesse_j = velocity[1];
4138 const IJK_Field_double& vitesse_k = velocity[2];
4139
4140 IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
4141 IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
4142 IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
4143 IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
4144 IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
4145 IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
4146
4147 const double& coefficient_xx = structural_uu_tensor_coefficients[0];
4148 const double& coefficient_xy = structural_uu_tensor_coefficients[1];
4149 const double& coefficient_xz = structural_uu_tensor_coefficients[2];
4150 const double& coefficient_yy = structural_uu_tensor_coefficients[3];
4151 const double& coefficient_yz = structural_uu_tensor_coefficients[4];
4152 const double& coefficient_zz = structural_uu_tensor_coefficients[5];
4153
4154 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
4155 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
4156
4157 const int ni = vitesse_k.ni();
4158 const int nj = vitesse_k.nj();
4159 const int nk = vitesse_k.nk();
4160
4161 for (int k = 0; k < nk; k++)
4162 {
4163 for (int j = 0; j < nj; j++)
4164 {
4165 for (int i = 0; i < ni; i++)
4166 {
4167 const int kg = k + offset;
4168
4169 const double uf_i = vitesse_i(i,j,k);
4170 const double uf_ip1 = vitesse_i(i+1,j,k);
4171 const double uf_i_jm1 = vitesse_i(i,j-1,k);
4172 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
4173
4174 const double vf_j = vitesse_j(i,j,k);
4175 const double vf_j_im1 = vitesse_j(i-1,j,k);
4176 const double vf_jp1 = vitesse_j(i,j+1,k);
4177 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
4178
4179 const double wf_k = vitesse_k(i,j,k);
4180 const double wf_k_im1 = vitesse_k(i-1,j,k);
4181 const double wf_k_jm1 = vitesse_k(i,j-1,k);
4182 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
4183
4184 const double u_ij = 0.5*(uf_i + uf_i_jm1);
4185 const double u_ik = 0.5*(uf_i + uf_i_km1);
4186 const double v_ij = 0.5*(vf_j + vf_j_im1);
4187 const double v_jk = 0.5*(vf_j + vf_j_km1);
4188 const double w_ik = 0.5*(wf_k + wf_k_im1);
4189 const double w_jk = 0.5*(wf_k + wf_k_jm1);
4190
4191 const double ue = 0.5 * (uf_i + uf_ip1);
4192 const double ve = 0.5 * (vf_j + vf_jp1);
4193 const double we = 0.5 * (wf_k + wf_kp1);
4194
4195 const double uu_ii = ue*ue;
4196 const double uu_ij = u_ij*v_ij;
4197 const double uu_ik = u_ik*w_ik;
4198 const double uu_jj = ve*ve;
4199 const double uu_jk = v_jk*w_jk;
4200 const double uu_kk = we*we;
4201
4202 structural_uu_xx(i,j,k) = - coefficient_xx * structural_uu_model_constant * uu_ii;
4203 structural_uu_xy(i,j,k) = - coefficient_xy * structural_uu_model_constant * uu_ij;
4204 structural_uu_xz(i,j,k) = - coefficient_xz * structural_uu_model_constant * uu_ik;
4205 structural_uu_yy(i,j,k) = - coefficient_yy * structural_uu_model_constant * uu_jj;
4206 structural_uu_yz(i,j,k) = - coefficient_yz * structural_uu_model_constant * uu_jk;
4207 structural_uu_zz(i,j,k) = - coefficient_zz * structural_uu_model_constant * uu_kk;
4208 }
4209 }
4210 }
4211}
4212template<class T>
4213void calculer_structural_uu_similarity_comp(const double structural_uu_model_constant,
4214 const ArrOfDouble& structural_uu_tensor_coefficients,
4215 const IJK_Field_double& rho,
4216 const IJK_Field_vector3_double& velocity,
4217 const IJK_Field_vector3_double& velocity_filtre,
4218 const ArrOfDouble_with_ghost& delta_z,
4219 const double facteur_delta_x,
4220 const double facteur_delta_y,
4221 const ArrOfDouble_with_ghost& delta_z_pour_delta,
4222 T& kernel,
4225 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
4226{
4227 const IJK_Field_double& vitesse_i = velocity[0];
4228 const IJK_Field_double& vitesse_j = velocity[1];
4229 const IJK_Field_double& vitesse_k = velocity[2];
4230 const IJK_Field_double& masse_vol_ijk = rho;
4231 IJK_Field_local_double& masse_vol_ijk_filtre = tmp_b[15];
4232 IJK_Field_local_double& aa_rho_ijk_filtre = tmp_a[15];
4233
4234 // const IJK_Field_double& vitesse_i_filtre = velocity_filtre[0];
4235 // const IJK_Field_double& vitesse_j_filtre = velocity_filtre[1];
4236 // const IJK_Field_double& vitesse_k_filtre = velocity_filtre[2];
4237
4238 IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
4239 IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
4240 IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
4241 IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
4242 IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
4243 IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
4244
4245 const double& coefficient_xx = structural_uu_tensor_coefficients[0];
4246 const double& coefficient_xy = structural_uu_tensor_coefficients[1];
4247 const double& coefficient_xz = structural_uu_tensor_coefficients[2];
4248 const double& coefficient_yy = structural_uu_tensor_coefficients[3];
4249 const double& coefficient_yz = structural_uu_tensor_coefficients[4];
4250 const double& coefficient_zz = structural_uu_tensor_coefficients[5];
4251
4252 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
4253 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
4254 const double dx_pour_delta = facteur_delta_x*dx;
4255 const double dy_pour_delta = facteur_delta_y*dy;
4256
4257 const int ni = vitesse_k.ni();
4258 const int nj = vitesse_k.nj();
4259 const int nk = vitesse_k.nk();
4260 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
4261 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
4262
4263 IJK_Field_local_double& b_ii = tmp_b[0];
4264 IJK_Field_local_double& b_ij = tmp_b[1];
4265 IJK_Field_local_double& b_ik = tmp_b[2];
4266 IJK_Field_local_double& b_jj = tmp_b[3];
4267 IJK_Field_local_double& b_jk = tmp_b[4];
4268 IJK_Field_local_double& b_kk = tmp_b[5];
4269 IJK_Field_local_double& bb_uii = tmp_b[6];
4270 IJK_Field_local_double& bb_uij = tmp_b[7];
4271 IJK_Field_local_double& bb_vjj = tmp_b[8];
4272 IJK_Field_local_double& bb_vij = tmp_b[9];
4273 IJK_Field_local_double& bb_wkk = tmp_b[10];
4274 IJK_Field_local_double& bb_uik = tmp_b[11];
4275 IJK_Field_local_double& bb_vjk = tmp_b[12];
4276 IJK_Field_local_double& bb_wik = tmp_b[13];
4277 IJK_Field_local_double& bb_wjk = tmp_b[14];
4278
4279 IJK_Field_local_double& a_ii = tmp_a[0];
4280 IJK_Field_local_double& a_ij = tmp_a[1];
4281 IJK_Field_local_double& a_ik = tmp_a[2];
4282 IJK_Field_local_double& a_jj = tmp_a[3];
4283 IJK_Field_local_double& a_jk = tmp_a[4];
4284 IJK_Field_local_double& a_kk = tmp_a[5];
4285 IJK_Field_local_double& aa_uii = tmp_a[6];
4286 IJK_Field_local_double& aa_uij = tmp_a[7];
4287 IJK_Field_local_double& aa_vjj = tmp_a[8];
4288 IJK_Field_local_double& aa_vij = tmp_a[9];
4289 IJK_Field_local_double& aa_wkk = tmp_a[10];
4290 IJK_Field_local_double& aa_uik = tmp_a[11];
4291 IJK_Field_local_double& aa_vjk = tmp_a[12];
4292 IJK_Field_local_double& aa_wik = tmp_a[13];
4293 IJK_Field_local_double& aa_wjk = tmp_a[14];
4294
4295 const int ghost_size_filter = kernel->ghost_size();
4296 const int size_uniform = kernel->size_uniform();
4297 const int shift_uniform = kernel->shift_uniform();
4298 for (int k = 0; k < nk; k++)
4299 {
4300 const int kg = k + offset;
4301
4302 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
4303 const double dz_m1_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z[k-1];
4304 const double delta_m_glo = kg==0 ? 0.5*dz_glo : 0.5*(dz_glo + dz_m1_glo);
4305 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
4306 const double dz_m1_pour_delta_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1];
4307 const double delta_m_pour_delta_glo = (kg-1<0 || kg>(nktot-1)) ? 0. : 0.5*(dz_pour_delta_glo + dz_m1_pour_delta_glo);
4308
4309 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
4310 const FixedVector<double, 21> filter_kernel_z_face = kernel->inhomogeneous(false, k, kg, nktot, delta_m_pour_delta_glo, delta_z);
4311 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
4312 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
4313 const int size_k_elem = kernel->size_k_elem(kg, nktot);
4314 const int size_k_face = kernel->size_k_face(kg, nktot);
4315 const int shift_k_elem = kernel->shift_k_elem(kg);
4316 const int shift_k_face = kernel->shift_k_face(kg);
4317 const bool ponderation_filter_kernel = kernel->ponderation();
4318 const bool normalisation_filter_kernel = kernel->normalisation();
4319
4320 double facteur_elem = 0.;
4321 if (ponderation_filter_kernel)
4322 {
4323 if (normalisation_filter_kernel)
4324 {
4325 double longueur_elem = 0.;
4326 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
4327 {
4328 const int kpg = kg + kp;
4329 if (kpg<-1 || kpg>nktot)
4330 {
4331 Cerr << "This should not happen." << finl;
4332 Process::exit();
4333 }
4334 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4335 const double filter_coef_z = filter_kernel_z[kp+10];
4336 longueur_elem += filter_coef_z * dz;
4337 }
4338 facteur_elem = 1./longueur_elem;
4339 }
4340 else
4341 {
4342 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
4343 }
4344 }
4345 double facteur_face = 0.;
4346 if (ponderation_filter_kernel)
4347 {
4348 if (normalisation_filter_kernel)
4349 {
4350 double longueur_face = 0.;
4351 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
4352 {
4353 const int kpg = kg + kp;
4354 if (kpg<0 || kpg>nktot)
4355 {
4356 Cerr << "This should not happen." << finl;
4357 Process::exit();
4358 }
4359 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4360 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
4361 const double dzf = 0.5*(dz + dz_m1);
4362 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
4363 longueur_face += filter_coef_z_face * dzf;
4364 }
4365 facteur_face = 1./longueur_face;
4366 }
4367 else
4368 {
4369 facteur_face = delta_m_glo==0. ? 0. : 1./delta_m_glo;
4370 }
4371 }
4372
4373 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
4374 {
4375 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
4376 {
4377 b_ii(i, j, 0) = 0.;
4378 bb_uii(i, j, 0) = 0.;
4379 bb_uij(i, j, 0) = 0.;
4380 b_ij(i, j, 0) = 0.;
4381 b_ik(i, j, 0) = 0.;
4382 b_jj(i, j, 0) = 0.;
4383 bb_vjj(i, j, 0) = 0.;
4384 bb_vij(i, j, 0) = 0.;
4385 b_jk(i, j, 0) = 0.;
4386 b_kk(i, j, 0) = 0.;
4387 bb_wkk(i, j, 0) = 0.;
4388 bb_uik(i, j, 0) = 0.;
4389 bb_vjk(i, j, 0) = 0.;
4390 bb_wik(i, j, 0) = 0.;
4391 bb_wjk(i, j, 0) = 0.;
4392 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
4393 {
4394 const int kpg = kg + kp;
4395 if (!(kernel->is_at_wall_elem(kpg, nktot)))
4396 {
4397 const double filter_coef_z = filter_kernel_z[kp+10];
4398
4399 const double rho_ijk = masse_vol_ijk(i,j,k+kp);
4400 const double uf_i = vitesse_i(i,j,k+kp);
4401 const double vf_j = vitesse_j(i,j,k+kp);
4402 const double wf_k = vitesse_k(i,j,k+kp);
4403
4404 const double uf_ip1 = vitesse_i(i+1,j,k+kp);
4405 const double vf_jp1 = vitesse_j(i,j+1,k+kp);
4406 const double wf_kp1 = kpg==(nktot-1) ? 0. : vitesse_k(i,j,k+1+kp);
4407
4408 const double uf_i_jm1 = vitesse_i(i,j-1,k+kp);
4409 const double vf_j_im1 = vitesse_j(i-1,j,k+kp);
4410
4411 const double u_ij = 0.5*(uf_i + uf_i_jm1);
4412 const double v_ij = 0.5*(vf_j + vf_j_im1);
4413
4414 const double ue = 0.5 * (uf_i + uf_ip1);
4415 const double ve = 0.5 * (vf_j + vf_jp1);
4416 const double we = 0.5 * (wf_k + wf_kp1);
4417
4418 if (ponderation_filter_kernel)
4419 {
4420 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4421 b_ii(i, j, 0) += rho_ijk*ue*ue * filter_coef_z * dz * facteur_elem;
4422 b_ij(i, j, 0) += rho_ijk*u_ij*v_ij * filter_coef_z * dz * facteur_elem;
4423 b_jj(i, j, 0) += rho_ijk*ve*ve * filter_coef_z * dz * facteur_elem;
4424 b_kk(i, j, 0) += rho_ijk*we*we * filter_coef_z * dz * facteur_elem;
4425 bb_uii(i, j, 0) += rho_ijk*ue * filter_coef_z * dz * facteur_elem;
4426 bb_uij(i, j, 0) += rho_ijk*u_ij * filter_coef_z * dz * facteur_elem;
4427 bb_vij(i, j, 0) += rho_ijk*v_ij * filter_coef_z * dz * facteur_elem;
4428 bb_vjj(i, j, 0) += rho_ijk*ve * filter_coef_z * dz * facteur_elem;
4429 bb_wkk(i, j, 0) += rho_ijk*we * filter_coef_z * dz * facteur_elem;
4430 masse_vol_ijk_filtre(i, j, 0) += rho_ijk * filter_coef_z * dz * facteur_elem;
4431 }
4432 else
4433 {
4434 b_ii(i, j, 0) += rho_ijk*ue*ue * filter_coef_z;
4435 b_ij(i, j, 0) += rho_ijk*u_ij*v_ij * filter_coef_z;
4436 b_jj(i, j, 0) += rho_ijk*ve*ve * filter_coef_z;
4437 b_kk(i, j, 0) += rho_ijk*we*we * filter_coef_z;
4438 bb_uii(i, j, 0) += rho_ijk*ue * filter_coef_z;
4439 bb_uij(i, j, 0) += rho_ijk*u_ij * filter_coef_z;
4440 bb_vij(i, j, 0) += rho_ijk*v_ij * filter_coef_z;
4441 bb_vjj(i, j, 0) += rho_ijk*ve * filter_coef_z;
4442 bb_wkk(i, j, 0) += rho_ijk*we * filter_coef_z;
4443 masse_vol_ijk_filtre(i, j, 0) += rho_ijk * filter_coef_z;
4444 }
4445 }
4446 }
4447 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
4448 {
4449 const int kpg = kg + kp;
4450 if (!(kernel->is_at_wall_face(kpg, nktot)))
4451 {
4452 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
4453
4454 const double rho_ijk = masse_vol_ijk(i,j,k+kp);
4455 const double uf_i = vitesse_i(i,j,k+kp);
4456 const double vf_j = vitesse_j(i,j,k+kp);
4457 const double wf_k = vitesse_k(i,j,k+kp);
4458
4459 const double uf_i_km1 = kpg==0 ? 0. : vitesse_i(i,j,k-1+kp);
4460 const double vf_j_km1 = kpg==0 ? 0. : vitesse_j(i,j,k-1+kp);
4461 const double wf_k_im1 = vitesse_k(i-1,j,k+kp);
4462 const double wf_k_jm1 = vitesse_k(i,j-1,k+kp);
4463
4464 const double u_ik = 0.5*(uf_i + uf_i_km1);
4465 const double v_jk = 0.5*(vf_j + vf_j_km1);
4466 const double w_ik = 0.5*(wf_k + wf_k_im1);
4467 const double w_jk = 0.5*(wf_k + wf_k_jm1);
4468
4469 if (ponderation_filter_kernel)
4470 {
4471 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4472 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
4473 const double dzf = 0.5*(dz + dz_m1);
4474 b_ik(i, j, 0) += rho_ijk*u_ik*w_ik * filter_coef_z_face * dzf * facteur_face;
4475 b_jk(i, j, 0) += rho_ijk*v_jk*w_jk * filter_coef_z_face * dzf * facteur_face;
4476 bb_uik(i, j, 0) += rho_ijk*u_ik * filter_coef_z_face * dzf * facteur_face;
4477 bb_vjk(i, j, 0) += rho_ijk*v_jk * filter_coef_z_face * dzf * facteur_face;
4478 bb_wik(i, j, 0) += rho_ijk*w_ik * filter_coef_z_face * dzf * facteur_face;
4479 bb_wjk(i, j, 0) += rho_ijk*w_jk * filter_coef_z_face * dzf * facteur_face;
4480 }
4481 else
4482 {
4483 b_ik(i, j, 0) += rho_ijk*u_ik*w_ik * filter_coef_z_face;
4484 b_jk(i, j, 0) += rho_ijk*v_jk*w_jk * filter_coef_z_face;
4485 bb_uik(i, j, 0) += rho_ijk*u_ik * filter_coef_z_face;
4486 bb_vjk(i, j, 0) += rho_ijk*v_jk * filter_coef_z_face;
4487 bb_wik(i, j, 0) += rho_ijk*w_ik * filter_coef_z_face;
4488 bb_wjk(i, j, 0) += rho_ijk*w_jk * filter_coef_z_face;
4489 }
4490 }
4491 }
4492 }
4493 }
4494 for (int j = 0; j < nj; j++)
4495 {
4496 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
4497 {
4498 a_ii(i, 0, 0) = 0.;
4499 aa_uii(i, 0, 0) = 0.;
4500 aa_uij(i, 0, 0) = 0.;
4501 a_ij(i, 0, 0) = 0.;
4502 a_ik(i, 0, 0) = 0.;
4503 a_jj(i, 0, 0) = 0.;
4504 aa_vjj(i, 0, 0) = 0.;
4505 aa_vij(i, 0, 0) = 0.;
4506 a_jk(i, 0, 0) = 0.;
4507 a_kk(i, 0, 0) = 0.;
4508 aa_wkk(i, 0, 0) = 0.;
4509 aa_uik(i, 0, 0) = 0.;
4510 aa_vjk(i, 0, 0) = 0.;
4511 aa_wik(i, 0, 0) = 0.;
4512 aa_wjk(i, 0, 0) = 0.;
4513 aa_rho_ijk_filtre(i, 0, 0) = 0.;
4514 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
4515 {
4516 const double filter_coef_y = filter_kernel_y[jp+10];
4517 a_ii(i, 0, 0) += b_ii(i, j+jp, 0) * filter_coef_y;
4518 aa_uii(i, 0, 0) += bb_uii(i, j+jp, 0) * filter_coef_y;
4519 aa_uij(i, 0, 0) += bb_uij(i, j+jp, 0) * filter_coef_y;
4520 a_ij(i, 0, 0) += b_ij(i, j+jp, 0) * filter_coef_y;
4521 a_ik(i, 0, 0) += b_ik(i, j+jp, 0) * filter_coef_y;
4522 a_jj(i, 0, 0) += b_jj(i, j+jp, 0) * filter_coef_y;
4523 aa_vjj(i, 0, 0) += bb_vjj(i, j+jp, 0) * filter_coef_y;
4524 aa_vij(i, 0, 0) += bb_vij(i, j+jp, 0) * filter_coef_y;
4525 a_jk(i, 0, 0) += b_jk(i, j+jp, 0) * filter_coef_y;
4526 a_kk(i, 0, 0) += b_kk(i, j+jp, 0) * filter_coef_y;
4527 aa_wkk(i, 0, 0) += bb_wkk(i, j+jp, 0) * filter_coef_y;
4528 aa_uik(i, 0, 0) += bb_uik(i, j+jp, 0) * filter_coef_y;
4529 aa_vjk(i, 0, 0) += bb_vjk(i, j+jp, 0) * filter_coef_y;
4530 aa_wik(i, 0, 0) += bb_wik(i, j+jp, 0) * filter_coef_y;
4531 aa_wjk(i, 0, 0) += bb_wjk(i, j+jp, 0) * filter_coef_y;
4532 aa_rho_ijk_filtre(i, 0, 0) += masse_vol_ijk_filtre(i, j+jp, 0)* filter_coef_y;
4533 }
4534 }
4535
4536 for (int i = 0; i < ni; i++)
4537 {
4538 double r_ii = 0.;
4539 double r_ij = 0.;
4540 double r_ik = 0.;
4541 double r_jj = 0.;
4542 double r_jk = 0.;
4543 double r_kk = 0.;
4544 double rho_ue = 0.;
4545 double rho_ve = 0.;
4546 double rho_we = 0.;
4547 double rho_uij = 0.;
4548 double rho_uik = 0.;
4549 double rho_vij = 0.;
4550 double rho_vjk = 0.;
4551 double rho_wik = 0.;
4552 double rho_wjk = 0.;
4553 double rho_filtre = 0.;
4554 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
4555 {
4556 const double filter_coef_x = filter_kernel_x[ip+10];
4557 r_ii += a_ii(i+ip, 0, 0) * filter_coef_x;
4558 r_ij += a_ij(i+ip, 0, 0) * filter_coef_x;
4559 r_ik += a_ik(i+ip, 0, 0) * filter_coef_x;
4560 r_jj += a_jj(i+ip, 0, 0) * filter_coef_x;
4561 r_jk += a_jk(i+ip, 0, 0) * filter_coef_x;
4562 r_kk += a_kk(i+ip, 0, 0) * filter_coef_x;
4563 rho_ue += aa_uii(i+ip, 0, 0) * filter_coef_x;
4564 rho_ve += aa_vjj(i+ip, 0, 0) * filter_coef_x;
4565 rho_we += aa_wkk(i+ip, 0, 0) * filter_coef_x;
4566 rho_uij += aa_uij(i+ip, 0, 0) * filter_coef_x;
4567 rho_uik += aa_uik(i+ip, 0, 0) * filter_coef_x;
4568 rho_vij += aa_vij(i+ip, 0, 0) * filter_coef_x;
4569 rho_vjk += aa_vjk(i+ip, 0, 0) * filter_coef_x;
4570 rho_wik += aa_wik(i+ip, 0, 0) * filter_coef_x;
4571 rho_wjk += aa_wjk(i+ip, 0, 0) * filter_coef_x;
4572 rho_filtre += aa_rho_ijk_filtre(i+ip, 0, 0)* filter_coef_x;
4573 }
4574
4575 const double c_ii = (r_ii)/rho_filtre - (rho_ue*rho_ue)/(rho_filtre*rho_filtre);
4576 const double c_ij = (r_ij)/rho_filtre - (rho_uij*rho_vij)/(rho_filtre*rho_filtre);
4577 const double c_ik = (r_ik)/rho_filtre - (rho_uik*rho_wik)/(rho_filtre*rho_filtre);
4578 const double c_jj = (r_jj)/rho_filtre - (rho_ve*rho_ve)/(rho_filtre*rho_filtre);
4579 const double c_jk = (r_jk)/rho_filtre - (rho_vjk*rho_wjk)/(rho_filtre*rho_filtre);
4580 const double c_kk = (r_kk)/rho_filtre - (rho_we*rho_we)/(rho_filtre*rho_filtre);
4581
4582 structural_uu_xx(i,j,k) = - coefficient_xx * structural_uu_model_constant * c_ii;
4583 structural_uu_xy(i,j,k) = - coefficient_xy * structural_uu_model_constant * c_ij;
4584 structural_uu_xz(i,j,k) = - coefficient_xz * structural_uu_model_constant * c_ik;
4585 structural_uu_yy(i,j,k) = - coefficient_yy * structural_uu_model_constant * c_jj;
4586 structural_uu_yz(i,j,k) = - coefficient_yz * structural_uu_model_constant * c_jk;
4587 structural_uu_zz(i,j,k) = - coefficient_zz * structural_uu_model_constant * c_kk;
4588 }
4589 }
4590 }
4591}
4592
4593template<class T>
4594void calculer_structural_uu_similarity(const double structural_uu_model_constant,
4595 const ArrOfDouble& structural_uu_tensor_coefficients,
4596 const IJK_Field_vector3_double& velocity,
4597 const IJK_Field_vector3_double& velocity_filtre,
4598 const ArrOfDouble_with_ghost& delta_z,
4599 const double facteur_delta_x,
4600 const double facteur_delta_y,
4601 const ArrOfDouble_with_ghost& delta_z_pour_delta,
4602 T& kernel,
4605 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
4606{
4607 const IJK_Field_double& vitesse_i = velocity[0];
4608 const IJK_Field_double& vitesse_j = velocity[1];
4609 const IJK_Field_double& vitesse_k = velocity[2];
4610
4611 const IJK_Field_double& vitesse_i_filtre = velocity_filtre[0];
4612 const IJK_Field_double& vitesse_j_filtre = velocity_filtre[1];
4613 const IJK_Field_double& vitesse_k_filtre = velocity_filtre[2];
4614
4615 IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
4616 IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
4617 IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
4618 IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
4619 IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
4620 IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
4621
4622 const double& coefficient_xx = structural_uu_tensor_coefficients[0];
4623 const double& coefficient_xy = structural_uu_tensor_coefficients[1];
4624 const double& coefficient_xz = structural_uu_tensor_coefficients[2];
4625 const double& coefficient_yy = structural_uu_tensor_coefficients[3];
4626 const double& coefficient_yz = structural_uu_tensor_coefficients[4];
4627 const double& coefficient_zz = structural_uu_tensor_coefficients[5];
4628
4629 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
4630 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
4631 const double dx_pour_delta = facteur_delta_x*dx;
4632 const double dy_pour_delta = facteur_delta_y*dy;
4633
4634 const int ni = vitesse_k.ni();
4635 const int nj = vitesse_k.nj();
4636 const int nk = vitesse_k.nk();
4637
4638 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
4639 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
4640
4641 IJK_Field_local_double& b_ii = tmp_b[0];
4642 IJK_Field_local_double& b_ij = tmp_b[1];
4643 IJK_Field_local_double& b_ik = tmp_b[2];
4644 IJK_Field_local_double& b_jj = tmp_b[3];
4645 IJK_Field_local_double& b_jk = tmp_b[4];
4646 IJK_Field_local_double& b_kk = tmp_b[5];
4647
4648 IJK_Field_local_double& a_ii = tmp_a[0];
4649 IJK_Field_local_double& a_ij = tmp_a[1];
4650 IJK_Field_local_double& a_ik = tmp_a[2];
4651 IJK_Field_local_double& a_jj = tmp_a[3];
4652 IJK_Field_local_double& a_jk = tmp_a[4];
4653 IJK_Field_local_double& a_kk = tmp_a[5];
4654
4655 const int ghost_size_filter = kernel->ghost_size();
4656 const int size_uniform = kernel->size_uniform();
4657 const int shift_uniform = kernel->shift_uniform();
4658 for (int k = 0; k < nk; k++)
4659 {
4660 const int kg = k + offset;
4661
4662 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
4663 const double dz_m1_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z[k-1];
4664 const double delta_m_glo = kg==0 ? 0.5*dz_glo : 0.5*(dz_glo + dz_m1_glo);
4665 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
4666 const double dz_m1_pour_delta_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1];
4667 const double delta_m_pour_delta_glo = (kg-1<0 || kg>(nktot-1)) ? 0. : 0.5*(dz_pour_delta_glo + dz_m1_pour_delta_glo);
4668
4669 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
4670 const FixedVector<double, 21> filter_kernel_z_face = kernel->inhomogeneous(false, k, kg, nktot, delta_m_pour_delta_glo, delta_z);
4671 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
4672 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
4673 const int size_k_elem = kernel->size_k_elem(kg, nktot);
4674 const int size_k_face = kernel->size_k_face(kg, nktot);
4675 const int shift_k_elem = kernel->shift_k_elem(kg);
4676 const int shift_k_face = kernel->shift_k_face(kg);
4677 const bool ponderation_filter_kernel = kernel->ponderation();
4678 const bool normalisation_filter_kernel = kernel->normalisation();
4679
4680 double facteur_elem = 0.;
4681 if (ponderation_filter_kernel)
4682 {
4683 if (normalisation_filter_kernel)
4684 {
4685 double longueur_elem = 0.;
4686 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
4687 {
4688 const int kpg = kg + kp;
4689 if (kpg<-1 || kpg>nktot)
4690 {
4691 Cerr << "This should not happen." << finl;
4692 Process::exit();
4693 }
4694 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4695 const double filter_coef_z = filter_kernel_z[kp+10];
4696 longueur_elem += filter_coef_z * dz;
4697 }
4698 facteur_elem = 1./longueur_elem;
4699 }
4700 else
4701 {
4702 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
4703 }
4704 }
4705 double facteur_face = 0.;
4706 if (ponderation_filter_kernel)
4707 {
4708 if (normalisation_filter_kernel)
4709 {
4710 double longueur_face = 0.;
4711 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
4712 {
4713 const int kpg = kg + kp;
4714 if (kpg<0 || kpg>nktot)
4715 {
4716 Cerr << "This should not happen." << finl;
4717 Process::exit();
4718 }
4719 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4720 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
4721 const double dzf = 0.5*(dz + dz_m1);
4722 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
4723 longueur_face += filter_coef_z_face * dzf;
4724 }
4725 facteur_face = 1./longueur_face;
4726 }
4727 else
4728 {
4729 facteur_face = delta_m_glo==0. ? 0. : 1./delta_m_glo;
4730 }
4731 }
4732
4733 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
4734 {
4735 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
4736 {
4737 b_ii(i, j, 0) = 0.;
4738 b_ij(i, j, 0) = 0.;
4739 b_ik(i, j, 0) = 0.;
4740 b_jj(i, j, 0) = 0.;
4741 b_jk(i, j, 0) = 0.;
4742 b_kk(i, j, 0) = 0.;
4743 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
4744 {
4745 const int kpg = kg + kp;
4746 if (!(kernel->is_at_wall_elem(kpg, nktot)))
4747 {
4748 const double filter_coef_z = filter_kernel_z[kp+10];
4749
4750 const double uf_i = vitesse_i(i,j,k+kp);
4751 const double vf_j = vitesse_j(i,j,k+kp);
4752 const double wf_k = vitesse_k(i,j,k+kp);
4753
4754 const double uf_ip1 = vitesse_i(i+1,j,k+kp);
4755 const double vf_jp1 = vitesse_j(i,j+1,k+kp);
4756 const double wf_kp1 = kpg==(nktot-1) ? 0. : vitesse_k(i,j,k+1+kp);
4757
4758 const double uf_i_jm1 = vitesse_i(i,j-1,k+kp);
4759 const double vf_j_im1 = vitesse_j(i-1,j,k+kp);
4760
4761 const double u_ij = 0.5*(uf_i + uf_i_jm1);
4762 const double v_ij = 0.5*(vf_j + vf_j_im1);
4763
4764 const double ue = 0.5 * (uf_i + uf_ip1);
4765 const double ve = 0.5 * (vf_j + vf_jp1);
4766 const double we = 0.5 * (wf_k + wf_kp1);
4767
4768 if (ponderation_filter_kernel)
4769 {
4770 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4771 b_ii(i, j, 0) += ue*ue * filter_coef_z * dz * facteur_elem;
4772 b_ij(i, j, 0) += u_ij*v_ij * filter_coef_z * dz * facteur_elem;
4773 b_jj(i, j, 0) += ve*ve * filter_coef_z * dz * facteur_elem;
4774 b_kk(i, j, 0) += we*we * filter_coef_z * dz * facteur_elem;
4775 }
4776 else
4777 {
4778 b_ii(i, j, 0) += ue*ue * filter_coef_z;
4779 b_ij(i, j, 0) += u_ij*v_ij * filter_coef_z;
4780 b_jj(i, j, 0) += ve*ve * filter_coef_z;
4781 b_kk(i, j, 0) += we*we * filter_coef_z;
4782 }
4783 }
4784 }
4785 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
4786 {
4787 const int kpg = kg + kp;
4788 if (!(kernel->is_at_wall_face(kpg, nktot)))
4789 {
4790 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
4791
4792 const double uf_i = vitesse_i(i,j,k+kp);
4793 const double vf_j = vitesse_j(i,j,k+kp);
4794 const double wf_k = vitesse_k(i,j,k+kp);
4795
4796 const double uf_i_km1 = kpg==0 ? 0. : vitesse_i(i,j,k-1+kp);
4797 const double vf_j_km1 = kpg==0 ? 0. : vitesse_j(i,j,k-1+kp);
4798 const double wf_k_im1 = vitesse_k(i-1,j,k+kp);
4799 const double wf_k_jm1 = vitesse_k(i,j-1,k+kp);
4800
4801 const double u_ik = 0.5*(uf_i + uf_i_km1);
4802 const double v_jk = 0.5*(vf_j + vf_j_km1);
4803 const double w_ik = 0.5*(wf_k + wf_k_im1);
4804 const double w_jk = 0.5*(wf_k + wf_k_jm1);
4805
4806 if (ponderation_filter_kernel)
4807 {
4808 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4809 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
4810 const double dzf = 0.5*(dz + dz_m1);
4811 b_ik(i, j, 0) += u_ik*w_ik * filter_coef_z_face * dzf * facteur_face;
4812 b_jk(i, j, 0) += v_jk*w_jk * filter_coef_z_face * dzf * facteur_face;
4813 }
4814 else
4815 {
4816 b_ik(i, j, 0) += u_ik*w_ik * filter_coef_z_face;
4817 b_jk(i, j, 0) += v_jk*w_jk * filter_coef_z_face;
4818 }
4819 }
4820 }
4821 }
4822 }
4823 for (int j = 0; j < nj; j++)
4824 {
4825 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
4826 {
4827 a_ii(i, 0, 0) = 0.;
4828 a_ij(i, 0, 0) = 0.;
4829 a_ik(i, 0, 0) = 0.;
4830 a_jj(i, 0, 0) = 0.;
4831 a_jk(i, 0, 0) = 0.;
4832 a_kk(i, 0, 0) = 0.;
4833 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
4834 {
4835 const double filter_coef_y = filter_kernel_y[jp+10];
4836 a_ii(i, 0, 0) += b_ii(i, j+jp, 0) * filter_coef_y;
4837 a_ij(i, 0, 0) += b_ij(i, j+jp, 0) * filter_coef_y;
4838 a_ik(i, 0, 0) += b_ik(i, j+jp, 0) * filter_coef_y;
4839 a_jj(i, 0, 0) += b_jj(i, j+jp, 0) * filter_coef_y;
4840 a_jk(i, 0, 0) += b_jk(i, j+jp, 0) * filter_coef_y;
4841 a_kk(i, 0, 0) += b_kk(i, j+jp, 0) * filter_coef_y;
4842 }
4843 }
4844
4845 for (int i = 0; i < ni; i++)
4846 {
4847 double r_ii = 0.;
4848 double r_ij = 0.;
4849 double r_ik = 0.;
4850 double r_jj = 0.;
4851 double r_jk = 0.;
4852 double r_kk = 0.;
4853 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
4854 {
4855 const double filter_coef_x = filter_kernel_x[ip+10];
4856 r_ii += a_ii(i+ip, 0, 0) * filter_coef_x;
4857 r_ij += a_ij(i+ip, 0, 0) * filter_coef_x;
4858 r_ik += a_ik(i+ip, 0, 0) * filter_coef_x;
4859 r_jj += a_jj(i+ip, 0, 0) * filter_coef_x;
4860 r_jk += a_jk(i+ip, 0, 0) * filter_coef_x;
4861 r_kk += a_kk(i+ip, 0, 0) * filter_coef_x;
4862 }
4863
4864 const double uf_i = vitesse_i_filtre(i,j,k);
4865 const double vf_j = vitesse_j_filtre(i,j,k);
4866 const double wf_k = vitesse_k_filtre(i,j,k);
4867
4868 const double uf_ip1 = vitesse_i_filtre(i+1,j,k);
4869 const double vf_jp1 = vitesse_j_filtre(i,j+1,k);
4870 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k_filtre(i,j,k+1);
4871
4872 const double uf_i_jm1 = vitesse_i_filtre(i,j-1,k);
4873 const double uf_i_km1 = kg==0 ? 0. : vitesse_i_filtre(i,j,k-1);
4874 const double vf_j_im1 = vitesse_j_filtre(i-1,j,k);
4875 const double vf_j_km1 = kg==0 ? 0. : vitesse_j_filtre(i,j,k-1);
4876 const double wf_k_im1 = vitesse_k_filtre(i-1,j,k);
4877 const double wf_k_jm1 = vitesse_k_filtre(i,j-1,k);
4878
4879 const double u_ij = 0.5*(uf_i + uf_i_jm1);
4880 const double u_ik = 0.5*(uf_i + uf_i_km1);
4881 const double v_ij = 0.5*(vf_j + vf_j_im1);
4882 const double v_jk = 0.5*(vf_j + vf_j_km1);
4883 const double w_ik = 0.5*(wf_k + wf_k_im1);
4884 const double w_jk = 0.5*(wf_k + wf_k_jm1);
4885
4886 const double ue = 0.5 * (uf_i + uf_ip1);
4887 const double ve = 0.5 * (vf_j + vf_jp1);
4888 const double we = 0.5 * (wf_k + wf_kp1);
4889
4890 const double c_ii = r_ii - ue*ue;
4891 const double c_ij = r_ij - u_ij*v_ij;
4892 const double c_ik = r_ik - u_ik*w_ik;
4893 const double c_jj = r_jj - ve*ve;
4894 const double c_jk = r_jk - v_jk*w_jk;
4895 const double c_kk = r_kk - we*we;
4896
4897 structural_uu_xx(i,j,k) = - coefficient_xx * structural_uu_model_constant * c_ii;
4898 structural_uu_xy(i,j,k) = - coefficient_xy * structural_uu_model_constant * c_ij;
4899 structural_uu_xz(i,j,k) = - coefficient_xz * structural_uu_model_constant * c_ik;
4900 structural_uu_yy(i,j,k) = - coefficient_yy * structural_uu_model_constant * c_jj;
4901 structural_uu_yz(i,j,k) = - coefficient_yz * structural_uu_model_constant * c_jk;
4902 structural_uu_zz(i,j,k) = - coefficient_zz * structural_uu_model_constant * c_kk;
4903 }
4904 }
4905 }
4906}
4907
4908
4909//#####################
4910//#####Martin 092021###
4911//#####################
4912
4913template<class T>
4914void calculer_structural_uu_similarity_Streher(const double structural_uu_model_constant,
4915 const IJK_Field_vector3_double& velocity,
4916 T& kernel,
4917 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
4918{
4919 const IJK_Field_double& vitesse_i = velocity[0];
4920 const IJK_Field_double& vitesse_j = velocity[1];
4921 const IJK_Field_double& vitesse_k = velocity[2];
4922
4923 const int ni = vitesse_k.ni();
4924 const int nj = vitesse_k.nj();
4925 const int nk = vitesse_k.nk();
4926
4927 IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
4928 IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
4929 IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
4930 IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
4931 IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
4932 IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
4933
4934 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
4935 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
4936
4937 for (int k = 0; k < nk; k++)
4938 {
4939 const int kg = k + offset;
4940 for (int j = 0; j < nj; j++)
4941 {
4942 for (int i = 0; i < ni; i++)
4943 {
4944 const double uf_im1 = vitesse_i(i-1,j,k);
4945 const double uf_i = vitesse_i(i,j,k);
4946 const double uf_i_jm2 = vitesse_i(i,j-2,k);
4947 const double uf_i_jm1 = vitesse_i(i,j-1,k);
4948 const double uf_i_jp1 = vitesse_i(i,j+1,k);
4949 const double uf_i_km2 = kg<=1 ? 0. : vitesse_i(i,j,k-2);
4950 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
4951 const double uf_i_kp1 = kg>=(nktot-1) ? 0. : vitesse_i(i,j,k+1);
4952 const double uf_ip1 = vitesse_i(i+1,j,k);
4953 const double uf_ip2 = vitesse_i(i+2,j,k);
4954
4955 const double vf_jm1 = vitesse_j(i,j-1,k);
4956 const double vf_j = vitesse_j(i,j,k);
4957 const double vf_j_im2 = vitesse_j(i-2,j,k);
4958 const double vf_j_im1 = vitesse_j(i-1,j,k);
4959 const double vf_j_ip1 = vitesse_j(i+1,j,k);
4960 const double vf_j_km2 = kg<=1 ? 0. : vitesse_j(i,j,k-2);
4961 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
4962 const double vf_j_kp1 = kg>=(nktot-1) ? 0. : vitesse_j(i,j,k+1);
4963 const double vf_jp1 = vitesse_j(i,j+1,k);
4964 const double vf_jp2 = vitesse_j(i,j+2,k);
4965
4966 const double wf_km1 = kg<=1 ? 0. : vitesse_k(i,j,k-1);
4967 const double wf_k = vitesse_k(i,j,k);
4968 const double wf_k_im2 = vitesse_k(i-2,j,k);
4969 const double wf_k_im1 = vitesse_k(i-1,j,k);
4970 const double wf_k_ip1 = vitesse_k(i+1,j,k);
4971 const double wf_k_jm2 = vitesse_k(i,j-2,k);
4972 const double wf_k_jm1 = vitesse_k(i,j-1,k);
4973 const double wf_k_jp1 = vitesse_k(i,j+1,k);
4974 const double wf_kp1 = kg>=(nktot-1) ? 0. : vitesse_k(i,j,k+1);
4975 const double wf_kp2 = kg>=(nktot-2) ? 0. : vitesse_k(i,j,k+2);
4976
4977 const double c_ii = (uf_i+uf_ip1)*(uf_i+uf_ip1)/4.-(uf_im1+uf_i+uf_ip1+uf_ip2)*(uf_im1+uf_i+uf_ip1+uf_ip2)/16.;
4978 const double c_jj = (vf_j+vf_jp1)*(vf_j+vf_jp1)/4.-(vf_jm1+vf_j+vf_jp1+vf_jp2)*(vf_jm1+vf_j+vf_jp1+vf_jp2)/16.;
4979 const double c_kk = (wf_k+wf_kp1)*(wf_k+wf_kp1)/4.-(wf_km1+wf_k+wf_kp1+wf_kp2)*(wf_km1+wf_k+wf_kp1+wf_kp2)/16.;
4980 const double c_ij = (uf_i_jm1+uf_i)*(vf_j_im1+vf_j)/4.-(uf_i_jp1+uf_i+uf_i_jm1+uf_i_jm2)*(vf_j_ip1+vf_j+vf_j_im1+vf_j_im2)/16.;
4981 const double c_ik = (uf_i_km1+uf_i)*(wf_k_im1+wf_k)/4.-(uf_i_kp1+uf_i+uf_i_km1+uf_i_km2)*(wf_k_ip1+wf_k+wf_k_im1+wf_k_im2)/16.;
4982 const double c_jk = (vf_j_km1+vf_j)*(wf_k_jm1+wf_k)/4.-(vf_j_kp1+vf_j+vf_j_km1+vf_j_km2)*(wf_k_jp1+wf_k+wf_k_jm1+wf_k_jm2)/16.;
4983
4984 structural_uu_xx(i,j,k) = - c_ii * structural_uu_model_constant;
4985 structural_uu_xy(i,j,k) = - c_ij * structural_uu_model_constant;
4986 structural_uu_xz(i,j,k) = - c_ik * structural_uu_model_constant;
4987 structural_uu_yy(i,j,k) = - c_jj * structural_uu_model_constant;
4988 structural_uu_yz(i,j,k) = - c_jk * structural_uu_model_constant;
4989 structural_uu_zz(i,j,k) = - c_kk * structural_uu_model_constant;
4990 }
4991 }
4992 }
4993}
4994
4995template<class T>
4996void calculer_structural_uu(const Nom& structural_uu_model,
4997 const double structural_uu_model_constant,
4998 const ArrOfDouble& structural_uu_tensor_coefficients,
4999 IJK_Field_double& rho,
5000 IJK_Field_vector3_double& velocity,
5001 IJK_Field_vector3_double& velocity_filtre,
5002 const ArrOfDouble_with_ghost& delta_z,
5003 const double facteur_delta_x,
5004 const double facteur_delta_y,
5005 const ArrOfDouble_with_ghost& delta_z_pour_delta,
5006 const double facteur_delta_filtre_x,
5007 const double facteur_delta_filtre_y,
5008 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
5009 T& kernel,
5012 FixedVector<IJK_Field_double, 6>& structural_uu_tmp_tensor,
5013 const bool flag_structural_uu_filtre,
5014 FixedVector<IJK_Field_double, 6>& structural_uu_filtre_tensor,
5015 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
5016{
5017 int ghost_size_filter;
5018 int ghost_size_velocity;
5019 int ghost_size_structural_uu_tmp;
5020
5021 if ( structural_uu_model == Nom("gradient") )
5022 {
5023 calculer_structural_uu_gradient(structural_uu_model_constant,
5024 structural_uu_tensor_coefficients,
5025 velocity,
5026 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
5027 structural_uu_tensor);
5028 }
5029 else if ( structural_uu_model == Nom("gradient_filtre") )
5030 {
5031 calculer_structural_uu_gradient(structural_uu_model_constant,
5032 structural_uu_tensor_coefficients,
5033 velocity,
5034 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
5035 structural_uu_tmp_tensor);
5036
5037 ghost_size_filter = 1 + kernel->ghost_size();
5038 ghost_size_structural_uu_tmp = max((int) 2, ghost_size_filter);
5039 structural_uu_tmp_tensor[0].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5040 structural_uu_tmp_tensor[1].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5041 structural_uu_tmp_tensor[2].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5042 structural_uu_tmp_tensor[3].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5043 structural_uu_tmp_tensor[4].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5044 structural_uu_tmp_tensor[5].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5045
5046 const int flag_add = 0;
5047 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_tensor[0]);
5048 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_tensor[1]);
5049 filtrer_champ_face(flag_add, structural_uu_tmp_tensor[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_tensor[2]);
5050 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[3], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_tensor[3]);
5051 filtrer_champ_face(flag_add, structural_uu_tmp_tensor[4], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_tensor[4]);
5052 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[5], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_tensor[5]);
5053 }
5054 else if ( structural_uu_model == Nom("su_laplacien_u") )
5055 {
5056 velocity[0].echange_espace_virtuel(2);
5057 velocity[1].echange_espace_virtuel(2);
5058 velocity[2].echange_espace_virtuel(2);
5059
5060 calculer_laplacien_u(velocity,
5061 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
5062 velocity_filtre);
5063
5064 velocity_filtre[0].echange_espace_virtuel(2);
5065 velocity_filtre[1].echange_espace_virtuel(2);
5066 velocity_filtre[2].echange_espace_virtuel(2);
5067
5068 calculer_structural_uu_su_laplacien_u(structural_uu_model_constant,
5069 structural_uu_tensor_coefficients,
5070 velocity,
5071 velocity_filtre,
5072 structural_uu_tensor);
5073 }
5074 else if ( structural_uu_model == Nom("convection") )
5075 {
5076 calculer_structural_uu_convection(structural_uu_model_constant,
5077 structural_uu_tensor_coefficients,
5078 velocity,
5079 structural_uu_tensor);
5080 }
5081 else if ( structural_uu_model == Nom("convection_filtre") )
5082 {
5083 calculer_structural_uu_convection(structural_uu_model_constant,
5084 structural_uu_tensor_coefficients,
5085 velocity,
5086 structural_uu_tmp_tensor);
5087
5088 ghost_size_filter = 1 + kernel->ghost_size();
5089 ghost_size_structural_uu_tmp = max((int) 2, ghost_size_filter);
5090 structural_uu_tmp_tensor[0].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5091 structural_uu_tmp_tensor[1].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5092 structural_uu_tmp_tensor[2].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5093 structural_uu_tmp_tensor[3].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5094 structural_uu_tmp_tensor[4].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5095 structural_uu_tmp_tensor[5].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5096
5097 const int flag_add = 0;
5098 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_tensor[0]);
5099 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_tensor[1]);
5100 filtrer_champ_face(flag_add, structural_uu_tmp_tensor[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_tensor[2]);
5101 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[3], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_tensor[3]);
5102 filtrer_champ_face(flag_add, structural_uu_tmp_tensor[4], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_tensor[4]);
5103 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[5], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_tensor[5]);
5104 }
5105 else if ( structural_uu_model == Nom("similarity") )
5106 {
5107 ghost_size_filter = 1 + kernel->ghost_size();
5108 ghost_size_velocity = max((int) 2, ghost_size_filter);
5109 velocity[0].echange_espace_virtuel(ghost_size_velocity);
5110 velocity[1].echange_espace_virtuel(ghost_size_velocity);
5111 velocity[2].echange_espace_virtuel(ghost_size_velocity);
5112
5113 const int flag_add = 0;
5114 filtrer_champ_elem(flag_add, velocity[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[0]);
5115 filtrer_champ_elem(flag_add, velocity[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[1]);
5116 filtrer_champ_face(flag_add, velocity[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[2]);
5117
5118 velocity_filtre[0].echange_espace_virtuel(2);
5119 velocity_filtre[1].echange_espace_virtuel(2);
5120 velocity_filtre[2].echange_espace_virtuel(2);
5121
5122 calculer_structural_uu_similarity(structural_uu_model_constant,
5123 structural_uu_tensor_coefficients,
5124 velocity, velocity_filtre,
5125 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
5126 kernel, tmp_b, tmp_a,
5127 structural_uu_tensor);
5128 }
5129 else if ( structural_uu_model == Nom("similarity_comp") )
5130 {
5131 ghost_size_filter = 1 + kernel->ghost_size();
5132 ghost_size_velocity = max((int) 2, ghost_size_filter);
5133 velocity[0].echange_espace_virtuel(ghost_size_velocity);
5134 velocity[1].echange_espace_virtuel(ghost_size_velocity);
5135 velocity[2].echange_espace_virtuel(ghost_size_velocity);
5136
5137 const int flag_add = 0;
5138 filtrer_champ_elem(flag_add, velocity[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[0]);
5139 filtrer_champ_elem(flag_add, velocity[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[1]);
5140 filtrer_champ_face(flag_add, velocity[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[2]);
5141
5142 velocity_filtre[0].echange_espace_virtuel(2);
5143 velocity_filtre[1].echange_espace_virtuel(2);
5144 velocity_filtre[2].echange_espace_virtuel(2);
5145
5146 calculer_structural_uu_similarity_comp(structural_uu_model_constant,
5147 structural_uu_tensor_coefficients,
5148 rho,
5149 velocity, velocity_filtre,
5150 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
5151 kernel, tmp_b, tmp_a,
5152 structural_uu_tensor);
5153 }
5154 else if ( structural_uu_model == Nom("similarity_streher") )
5155 {
5156 ghost_size_filter = 1 + kernel->ghost_size();
5157 ghost_size_velocity = max((int) 2, ghost_size_filter);
5158 velocity[0].echange_espace_virtuel(ghost_size_velocity);
5159 velocity[1].echange_espace_virtuel(ghost_size_velocity);
5160 velocity[2].echange_espace_virtuel(ghost_size_velocity);
5161
5162 const int flag_add = 0;
5163 filtrer_champ_elem(flag_add, velocity[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[0]);
5164 filtrer_champ_elem(flag_add, velocity[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[1]);
5165 filtrer_champ_face(flag_add, velocity[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[2]);
5166
5167 velocity_filtre[0].echange_espace_virtuel(2);
5168 velocity_filtre[1].echange_espace_virtuel(2);
5169 velocity_filtre[2].echange_espace_virtuel(2);
5170
5171 calculer_structural_uu_similarity_Streher(structural_uu_model_constant,
5172 velocity,
5173 kernel,
5174 structural_uu_tensor);
5175 }
5176 else
5177 {
5178 Cerr << "The name of the structural model for uu is unknown." << finl;
5179 Process::exit();
5180 }
5181
5182 if (flag_structural_uu_filtre)
5183 {
5184 ghost_size_filter = 1 + kernel->ghost_size();
5185 ghost_size_velocity = max((int) 2, ghost_size_filter);
5186 velocity[0].echange_espace_virtuel(ghost_size_velocity);
5187 velocity[1].echange_espace_virtuel(ghost_size_velocity);
5188 velocity[2].echange_espace_virtuel(ghost_size_velocity);
5189
5190 const int flag_add = 0;
5191 filtrer_champ_elem(flag_add, velocity[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[0]);
5192 filtrer_champ_elem(flag_add, velocity[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[1]);
5193 filtrer_champ_face(flag_add, velocity[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[2]);
5194
5195 velocity_filtre[0].echange_espace_virtuel(2);
5196 velocity_filtre[1].echange_espace_virtuel(2);
5197 velocity_filtre[2].echange_espace_virtuel(2);
5198
5199
5200 if ( structural_uu_model == Nom("gradient") )
5201 {
5202 calculer_structural_uu_gradient(structural_uu_model_constant,
5203 structural_uu_tensor_coefficients,
5204 velocity_filtre,
5205 delta_z, facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
5206 structural_uu_filtre_tensor);
5207 }
5208 else if ( structural_uu_model == Nom("gradient_filtre") )
5209 {
5210 calculer_structural_uu_gradient(structural_uu_model_constant,
5211 structural_uu_tensor_coefficients,
5212 velocity_filtre,
5213 delta_z, facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
5214 structural_uu_tmp_tensor);
5215
5216 ghost_size_filter = 1 + kernel->ghost_size();
5217 ghost_size_structural_uu_tmp = max((int) 2, ghost_size_filter);
5218 structural_uu_tmp_tensor[0].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5219 structural_uu_tmp_tensor[1].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5220 structural_uu_tmp_tensor[2].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5221 structural_uu_tmp_tensor[3].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5222 structural_uu_tmp_tensor[4].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5223 structural_uu_tmp_tensor[5].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5224
5225 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_filtre_tensor[0]);
5226 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_filtre_tensor[1]);
5227 filtrer_champ_face(flag_add, structural_uu_tmp_tensor[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_filtre_tensor[2]);
5228 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[3], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_filtre_tensor[3]);
5229 filtrer_champ_face(flag_add, structural_uu_tmp_tensor[4], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_filtre_tensor[4]);
5230 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[5], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_filtre_tensor[5]);
5231 }
5232 else if ( structural_uu_model == Nom("su_laplacien_u") )
5233 {
5234 calculer_laplacien_u(velocity_filtre,
5235 delta_z, facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
5236 velocity_filtre);
5237
5238 velocity_filtre[0].echange_espace_virtuel(2);
5239 velocity_filtre[1].echange_espace_virtuel(2);
5240 velocity_filtre[2].echange_espace_virtuel(2);
5241
5242 calculer_structural_uu_su_laplacien_u(structural_uu_model_constant,
5243 structural_uu_tensor_coefficients,
5244 velocity_filtre,
5245 velocity_filtre,
5246 structural_uu_filtre_tensor);
5247 }
5248 else if ( structural_uu_model == Nom("convection") )
5249 {
5250 calculer_structural_uu_convection(structural_uu_model_constant,
5251 structural_uu_tensor_coefficients,
5252 velocity_filtre,
5253 structural_uu_filtre_tensor);
5254 }
5255 else if ( structural_uu_model == Nom("convection_filtre") )
5256 {
5257 calculer_structural_uu_convection(structural_uu_model_constant,
5258 structural_uu_tensor_coefficients,
5259 velocity_filtre,
5260 structural_uu_tmp_tensor);
5261
5262 ghost_size_filter = 1 + kernel->ghost_size();
5263 ghost_size_structural_uu_tmp = max((int) 2, ghost_size_filter);
5264 structural_uu_tmp_tensor[0].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5265 structural_uu_tmp_tensor[1].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5266 structural_uu_tmp_tensor[2].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5267 structural_uu_tmp_tensor[3].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5268 structural_uu_tmp_tensor[4].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5269 structural_uu_tmp_tensor[5].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5270
5271 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_filtre_tensor[0]);
5272 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_filtre_tensor[1]);
5273 filtrer_champ_face(flag_add, structural_uu_tmp_tensor[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_filtre_tensor[2]);
5274 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[3], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_filtre_tensor[3]);
5275 filtrer_champ_face(flag_add, structural_uu_tmp_tensor[4], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_filtre_tensor[4]);
5276 filtrer_champ_elem(flag_add, structural_uu_tmp_tensor[5], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uu_filtre_tensor[5]);
5277 }
5278 else if ( structural_uu_model == Nom("similarity") )
5279 {
5280 Cerr << "The use of a dynamic constant with the SIMILARITY structural model is not allowed." << finl;
5281 Process::exit();
5282 }
5283 }
5284}
5285
5286void calculer_structural_uscalar_gradient(const double structural_uscalar_model_constant,
5287 const ArrOfDouble& structural_uscalar_vector_coefficients,
5288 const IJK_Field_vector3_double& velocity,
5289 const IJK_Field_double& champ_scalar,
5290 double scalar_kmin, double scalar_kmax,
5291 const ArrOfDouble_with_ghost& delta_z_maillage,
5292 const double facteur_x_pour_delta,
5293 const double facteur_y_pour_delta,
5294 const ArrOfDouble_with_ghost& delta_z_pour_delta,
5295 IJK_Field_vector3_double& structural_uscalar_vector)
5296{
5297 const IJK_Field_double& vitesse_i = velocity[0];
5298 const IJK_Field_double& vitesse_j = velocity[1];
5299 const IJK_Field_double& vitesse_k = velocity[2];
5300
5301 IJK_Field_double& structural_uscalar_x = structural_uscalar_vector[0];
5302 IJK_Field_double& structural_uscalar_y = structural_uscalar_vector[1];
5303 IJK_Field_double& structural_uscalar_z = structural_uscalar_vector[2];
5304
5305 const double& coefficient_x = structural_uscalar_vector_coefficients[0];
5306 const double& coefficient_y = structural_uscalar_vector_coefficients[1];
5307 const double& coefficient_z = structural_uscalar_vector_coefficients[2];
5308
5309 const double deltaunsurdx = facteur_x_pour_delta;
5310 const double deltaunsurdy = facteur_y_pour_delta;
5311
5312 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
5313 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
5314
5315 const int ni = vitesse_k.ni();
5316 const int nj = vitesse_k.nj();
5317 const int nk = vitesse_k.nk();
5318
5319 for (int k = 0; k < nk; k++)
5320 {
5321 for (int j = 0; j < nj; j++)
5322 {
5323 for (int i = 0; i < ni; i++)
5324 {
5325 const int kg = k + offset;
5326
5327 const double dz = delta_z_maillage[k];
5328 const double dz_m1 = kg==0 ? 0. : delta_z_maillage[k-1];
5329 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
5330 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
5331
5332 const double deltaunsurdz = delta_z_pour_delta[k] * 1./dz;
5333 const double deltaunsurdz_m1 = kg==0 ? 0. : delta_z_pour_delta[k-1] * 1./dz_m1;
5334 const double deltaunsurdelta_m = kg==0 ? 0. : 0.5*(delta_z_pour_delta[k] + delta_z_pour_delta[k-1]) * 1./delta_m;
5335 const double deltaunsurdelta_p = kg==(nktot-1) ? 0. : 0.5*(delta_z_pour_delta[k] + delta_z_pour_delta[k+1]) * 1./delta_p;
5336
5337 const double uf_i = vitesse_i(i,j,k);
5338 const double uf_ip1 = vitesse_i(i+1,j,k);
5339 const double uf_im1 = vitesse_i(i-1,j,k);
5340 const double uf_i_jm1 = vitesse_i(i,j-1,k);
5341 const double uf_i_jp1 = vitesse_i(i,j+1,k);
5342 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
5343 const double uf_i_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i,j,k+1);
5344
5345 const double vf_j = vitesse_j(i,j,k);
5346 const double vf_j_im1 = vitesse_j(i-1,j,k);
5347 const double vf_j_ip1 = vitesse_j(i+1,j,k);
5348 const double vf_jp1 = vitesse_j(i,j+1,k);
5349 const double vf_jm1 = vitesse_j(i,j-1,k);
5350 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
5351 const double vf_j_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j,k+1);
5352
5353 const double wf_k = vitesse_k(i,j,k);
5354 const double wf_k_im1 = vitesse_k(i-1,j,k);
5355 const double wf_k_ip1 = vitesse_k(i+1,j,k);
5356 const double wf_k_jm1 = vitesse_k(i,j-1,k);
5357 const double wf_k_jp1 = vitesse_k(i,j+1,k);
5358 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
5359 const double wf_km1 = kg==0 ? 0. : vitesse_k(i,j,k-1);
5360
5361 const double duidx = deltaunsurdx * (uf_ip1 - uf_i);
5362 const double dujdy = deltaunsurdy * (vf_jp1 - vf_j);
5363 const double dukdz = deltaunsurdz * (wf_kp1 - wf_k);
5364
5365 const double duidx_im1 = deltaunsurdx * (uf_i - uf_im1);
5366 const double dujdy_jm1 = deltaunsurdy * (vf_j - vf_jm1);
5367 const double dukdz_km1 = deltaunsurdz_m1 * (wf_k - wf_km1);
5368
5369 const double duidy_ij = deltaunsurdy * (uf_i - uf_i_jm1);
5370 const double duidy_ijp1 = deltaunsurdy * (uf_i_jp1 - uf_i);
5371
5372 const double duidz_ik = deltaunsurdelta_m * (uf_i - uf_i_km1);
5373 const double duidz_ikp1 = deltaunsurdelta_p * (uf_i_kp1 - uf_i);
5374
5375 const double dujdx_ij = deltaunsurdx * (vf_j - vf_j_im1);
5376 const double dujdx_ip1j = deltaunsurdx * (vf_j_ip1 - vf_j);
5377
5378 const double dujdz_jk = deltaunsurdelta_m * (vf_j - vf_j_km1);
5379 const double dujdz_jkp1 = deltaunsurdelta_p * (vf_j_kp1 - vf_j);
5380
5381 const double dukdx_ik = deltaunsurdx * (wf_k - wf_k_im1);
5382 const double dukdx_ip1k = deltaunsurdx * (wf_k_ip1 - wf_k);
5383
5384 const double dukdy_jk = deltaunsurdy * (wf_k - wf_k_jm1);
5385 const double dukdy_jp1k = deltaunsurdy * (wf_k_jp1 - wf_k);
5386
5387 const double g_fi_ii = 0.5 * (duidx_im1 + duidx);
5388 const double g_fi_ij = 0.5 * (duidy_ijp1 + duidy_ij);
5389 const double g_fi_ik = 0.5 * (duidz_ikp1 + duidz_ik);
5390 const double g_fj_ji = 0.5 * (dujdx_ip1j + dujdx_ij);
5391 const double g_fj_jj = 0.5 * (dujdy_jm1 + dujdy);
5392 const double g_fj_jk = 0.5 * (dujdz_jkp1 + dujdz_jk);
5393 const double g_fk_ki = 0.5 * (dukdx_ip1k + dukdx_ik);
5394 const double g_fk_kj = 0.5 * (dukdy_jp1k + dukdy_jk);
5395 const double g_fk_kk = 0.5 * (dukdz_km1 + dukdz);
5396
5397 const double scalar = champ_scalar(i,j,k);
5398
5399 const double scalar_im1 = champ_scalar(i-1,j,k);
5400 const double scalar_ip1 = champ_scalar(i+1,j,k);
5401 const double scalar_im1_jm1 = champ_scalar(i-1,j-1,k);
5402 const double scalar_ip1_jm1 = champ_scalar(i+1,j-1,k);
5403 const double scalar_im1_km1 = kg==0 ? scalar_kmin : champ_scalar(i-1,j,k-1);
5404 const double scalar_ip1_km1 = kg==0 ? scalar_kmin : champ_scalar(i+1,j,k-1);
5405
5406 const double scalar_jm1 = champ_scalar(i,j-1,k);
5407 const double scalar_jp1 = champ_scalar(i,j+1,k);
5408 const double scalar_jm1_km1 = kg==0 ? scalar_kmin : champ_scalar(i,j-1,k-1);
5409 const double scalar_jp1_km1 = kg==0 ? scalar_kmin : champ_scalar(i,j+1,k-1);
5410
5411 const double scalar_km1 = kg==0 ? scalar_kmin : champ_scalar(i,j,k-1);
5412 const double scalar_kp1 = kg==(nktot-1) ? scalar_kmax : champ_scalar(i,j,k+1);
5413
5414 const double scalar_im1_jp1 = champ_scalar(i-1,j+1,k);
5415 const double scalar_im1_kp1 = kg==(nktot-1) ? scalar_kmax : champ_scalar(i-1,j,k+1);
5416 const double scalar_jm1_kp1 = kg==(nktot-1) ? scalar_kmax : champ_scalar(i,j-1,k+1);
5417
5418 const double dscalardxf_i = deltaunsurdx * (scalar - scalar_im1);
5419 const double dscalardxf_ip1 = deltaunsurdx * (scalar_ip1 - scalar);
5420 const double dscalardxf_i_jm1 = deltaunsurdx * (scalar_jm1 - scalar_im1_jm1);
5421 const double dscalardxf_ip1_jm1 = deltaunsurdx * (scalar_ip1_jm1 - scalar_jm1);
5422 const double dscalardxf_i_km1 = deltaunsurdx * (scalar_km1 - scalar_im1_km1);
5423 const double dscalardxf_ip1_km1 = deltaunsurdx * (scalar_ip1_km1 - scalar_km1);
5424
5425 const double dscalardyf_j = deltaunsurdy * (scalar - scalar_jm1);
5426 const double dscalardyf_jp1 = deltaunsurdy * (scalar_jp1 - scalar);
5427 const double dscalardyf_j_im1 = deltaunsurdy * (scalar_im1 - scalar_im1_jm1);
5428 const double dscalardyf_jp1_im1 = deltaunsurdy * (scalar_im1_jp1 - scalar_im1);
5429 const double dscalardyf_j_km1 = deltaunsurdy * (scalar_km1 - scalar_jm1_km1);
5430 const double dscalardyf_jp1_km1 = deltaunsurdy * (scalar_jp1_km1 - scalar_km1);
5431
5432 const double dscalardzf_k = deltaunsurdelta_m * (scalar - scalar_km1);
5433 const double dscalardzf_kp1 = deltaunsurdelta_p * (scalar_kp1 - scalar);
5434 const double dscalardzf_k_im1 = deltaunsurdelta_m * (scalar_im1 - scalar_im1_km1);
5435 const double dscalardzf_kp1_im1 = deltaunsurdelta_p * (scalar_im1_kp1 - scalar_im1);
5436 const double dscalardzf_k_jm1 = deltaunsurdelta_m * (scalar_jm1 - scalar_jm1_km1);
5437 const double dscalardzf_kp1_jm1 = deltaunsurdelta_p * (scalar_jm1_kp1 - scalar_jm1);
5438
5439 const double q_fi_i = dscalardxf_i;
5440 const double q_fi_j = 0.25 * (dscalardyf_jp1_im1 + dscalardyf_jp1 + dscalardyf_j_im1 + dscalardyf_j);
5441 const double q_fi_k = 0.25 * (dscalardzf_kp1_im1 + dscalardzf_kp1 + dscalardzf_k_im1 + dscalardzf_k);
5442
5443 const double q_fj_i = 0.25 * (dscalardxf_ip1_jm1 + dscalardxf_ip1 + dscalardxf_i_jm1 + dscalardxf_i);
5444 const double q_fj_j = dscalardyf_j;
5445 const double q_fj_k = 0.25 * (dscalardzf_kp1_jm1 + dscalardzf_kp1 + dscalardzf_k_jm1 + dscalardzf_k);
5446
5447 const double q_fk_i = 0.25 * (dscalardxf_ip1_km1 + dscalardxf_ip1 + dscalardxf_i_km1 + dscalardxf_i);
5448 const double q_fk_j = 0.25 * (dscalardyf_jp1_km1 + dscalardyf_jp1 + dscalardyf_j_km1 + dscalardyf_j);
5449 const double q_fk_k = dscalardzf_k;
5450
5451 const double c_i = g_fi_ii*q_fi_i + g_fi_ij*q_fi_j + g_fi_ik*q_fi_k;
5452 const double c_j = g_fj_ji*q_fj_i + g_fj_jj*q_fj_j + g_fj_jk*q_fj_k;
5453 const double c_k = g_fk_ki*q_fk_i + g_fk_kj*q_fk_j + g_fk_kk*q_fk_k;
5454
5455 structural_uscalar_x(i,j,k) = - coefficient_x * structural_uscalar_model_constant * c_i/12.;
5456 structural_uscalar_y(i,j,k) = - coefficient_y * structural_uscalar_model_constant * c_j/12.;
5457 structural_uscalar_z(i,j,k) = - coefficient_z * structural_uscalar_model_constant * c_k/12.;
5458 }
5459 }
5460 }
5461}
5462
5463
5464template<class T>
5465void calculer_structural_uscalar_similarity_comp(const double structural_uscalar_model_constant,
5466 const ArrOfDouble& structural_uscalar_vector_coefficients,
5467 const IJK_Field_double& rho,
5468 const IJK_Field_vector3_double& velocity,
5469 const IJK_Field_vector3_double& velocity_filtre,
5470 const IJK_Field_double& champ_scalar,
5471 const IJK_Field_double& champ_scalar_filtre,
5472 double scalar_kmin, double scalar_kmax,
5473 const ArrOfDouble_with_ghost& delta_z,
5474 const double facteur_delta_x,
5475 const double facteur_delta_y,
5476 const ArrOfDouble_with_ghost& delta_z_pour_delta,
5477 T& kernel,
5480 IJK_Field_vector3_double& structural_uscalar_vector)
5481{
5482 const IJK_Field_double& vitesse_i = velocity[0];
5483 const IJK_Field_double& vitesse_j = velocity[1];
5484 const IJK_Field_double& vitesse_k = velocity[2];
5485 const IJK_Field_double& masse_vol_ijk = rho;
5486 IJK_Field_local_double& masse_vol_ijk_filtre = tmp_b[9];
5487 IJK_Field_local_double& aa_rho_ijk_filtre = tmp_a[9];
5488
5489 // const IJK_Field_double& vitesse_i_filtre = velocity_filtre[0];
5490 // const IJK_Field_double& vitesse_j_filtre = velocity_filtre[1];
5491 // const IJK_Field_double& vitesse_k_filtre = velocity_filtre[2];
5492
5493 IJK_Field_double& structural_uscalar_x = structural_uscalar_vector[0];
5494 IJK_Field_double& structural_uscalar_y = structural_uscalar_vector[1];
5495 IJK_Field_double& structural_uscalar_z = structural_uscalar_vector[2];
5496
5497 const double& coefficient_x = structural_uscalar_vector_coefficients[0];
5498 const double& coefficient_y = structural_uscalar_vector_coefficients[1];
5499 const double& coefficient_z = structural_uscalar_vector_coefficients[2];
5500
5501 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
5502 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
5503 const double dx_pour_delta = facteur_delta_x*dx;
5504 const double dy_pour_delta = facteur_delta_y*dy;
5505
5506 const int ni = vitesse_k.ni();
5507 const int nj = vitesse_k.nj();
5508 const int nk = vitesse_k.nk();
5509
5510 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
5511 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
5512
5513 IJK_Field_local_double& b_is = tmp_b[0];
5514 IJK_Field_local_double& b_js = tmp_b[1];
5515 IJK_Field_local_double& b_ks = tmp_b[2];
5516 IJK_Field_local_double& bb_is = tmp_b[3];
5517 IJK_Field_local_double& bb_js = tmp_b[4];
5518 IJK_Field_local_double& bb_ks = tmp_b[5];
5519 IJK_Field_local_double& bbT_i = tmp_b[6];
5520 IJK_Field_local_double& bbT_j = tmp_b[7];
5521 IJK_Field_local_double& bbT_k = tmp_b[8];
5522
5523 IJK_Field_local_double& a_is = tmp_a[0];
5524 IJK_Field_local_double& a_js = tmp_a[1];
5525 IJK_Field_local_double& a_ks = tmp_a[2];
5526 IJK_Field_local_double& aa_is = tmp_a[3];
5527 IJK_Field_local_double& aa_js = tmp_a[4];
5528 IJK_Field_local_double& aa_ks = tmp_a[5];
5529 IJK_Field_local_double& aaT_i = tmp_a[6];
5530 IJK_Field_local_double& aaT_j = tmp_a[7];
5531 IJK_Field_local_double& aaT_k = tmp_a[8];
5532
5533 const int ghost_size_filter = kernel->ghost_size();
5534 const int size_uniform = kernel->size_uniform();
5535 const int shift_uniform = kernel->shift_uniform();
5536 for (int k = 0; k < nk; k++)
5537 {
5538 const int kg = k + offset;
5539
5540 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
5541 const double dz_m1_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z[k-1];
5542 const double delta_m_glo = kg==0 ? 0.5*dz_glo : 0.5*(dz_glo + dz_m1_glo);
5543
5544 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
5545 const double dz_m1_pour_delta_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1];
5546 const double delta_m_pour_delta_glo = (kg-1<0 || kg>(nktot-1)) ? 0. : 0.5*(dz_pour_delta_glo + dz_m1_pour_delta_glo);
5547
5548 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
5549 const FixedVector<double, 21> filter_kernel_z_face = kernel->inhomogeneous(false, k, kg, nktot, delta_m_pour_delta_glo, delta_z);
5550 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
5551 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
5552 const int size_k_elem = kernel->size_k_elem(kg, nktot);
5553 const int size_k_face = kernel->size_k_face(kg, nktot);
5554 const int shift_k_elem = kernel->shift_k_elem(kg);
5555 const int shift_k_face = kernel->shift_k_face(kg);
5556 const bool ponderation_filter_kernel = kernel->ponderation();
5557 const bool normalisation_filter_kernel = kernel->normalisation();
5558
5559 double facteur_elem = 0.;
5560 if (ponderation_filter_kernel)
5561 {
5562 if (normalisation_filter_kernel)
5563 {
5564 double longueur_elem = 0.;
5565 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
5566 {
5567 const int kpg = kg + kp;
5568 if (kpg<-1 || kpg>nktot)
5569 {
5570 Cerr << "This should not happen." << finl;
5571 Process::exit();
5572 }
5573 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5574 const double filter_coef_z = filter_kernel_z[kp+10];
5575 longueur_elem += filter_coef_z * dz;
5576 }
5577 facteur_elem = 1./longueur_elem;
5578 }
5579 else
5580 {
5581 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
5582 }
5583 }
5584 double facteur_face = 0.;
5585 if (ponderation_filter_kernel)
5586 {
5587 if (normalisation_filter_kernel)
5588 {
5589 double longueur_face = 0.;
5590 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
5591 {
5592 const int kpg = kg + kp;
5593 if (kpg<0 || kpg>nktot)
5594 {
5595 Cerr << "This should not happen." << finl;
5596 Process::exit();
5597 }
5598 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5599 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
5600 const double dzf = 0.5*(dz + dz_m1);
5601 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
5602 longueur_face += filter_coef_z_face * dzf;
5603 }
5604 facteur_face = 1./longueur_face;
5605 }
5606 else
5607 {
5608 facteur_face = delta_m_glo==0. ? 0. : 1./delta_m_glo;
5609 }
5610 }
5611
5612 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
5613 {
5614 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
5615 {
5616 b_is(i, j, 0) = 0.;
5617 b_js(i, j, 0) = 0.;
5618 b_ks(i, j, 0) = 0.;
5619 bb_is(i, j, 0) = 0.;
5620 bb_js(i, j, 0) = 0.;
5621 bb_ks(i, j, 0) = 0.;
5622 bbT_i(i, j, 0) = 0.;
5623 bbT_j(i, j, 0) = 0.;
5624 bbT_k(i, j, 0) = 0.;
5625 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
5626 {
5627 const int kpg = kg + kp;
5628 if (!(kernel->is_at_wall_elem(kpg, nktot)))
5629 {
5630 const double filter_coef_z = filter_kernel_z[kp+10];
5631
5632 const double rho_ijk = masse_vol_ijk(i,j,k+kp);
5633 const double scalar = champ_scalar(i,j,k+kp);
5634 // const double scalar_im1 = champ_scalar(i-1,j,k+kp);
5635 // const double scalar_jm1 = champ_scalar(i,j-1,k+kp);
5636 const double scalarf_i = (scalar);
5637 const double scalarf_j = (scalar);
5638
5639 const double uf_i = 0.5*(vitesse_i(i,j,k+kp)+vitesse_i(i+1,j,k+kp));
5640 const double vf_j = 0.5*(vitesse_j(i,j,k+kp)+vitesse_j(i,j+1,k+kp));
5641
5642 if (ponderation_filter_kernel)
5643 {
5644 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5645 b_is(i, j, 0) += rho_ijk*uf_i*scalarf_i * filter_coef_z * dz * facteur_elem;
5646 b_js(i, j, 0) += rho_ijk*vf_j*scalarf_j * filter_coef_z * dz * facteur_elem;
5647 bb_is(i, j, 0) += rho_ijk*uf_i * filter_coef_z * dz * facteur_elem;
5648 bb_js(i, j, 0) += rho_ijk*vf_j * filter_coef_z * dz * facteur_elem;
5649 bbT_i(i, j, 0) += rho_ijk*scalarf_i * filter_coef_z * dz * facteur_elem;
5650 bbT_j(i, j, 0) += rho_ijk*scalarf_j * filter_coef_z * dz * facteur_elem;
5651 masse_vol_ijk_filtre(i, j, 0) += rho_ijk * filter_coef_z * dz * facteur_elem;
5652 }
5653 else
5654 {
5655 b_is(i, j, 0) += rho_ijk*uf_i*scalarf_i * filter_coef_z;
5656 b_js(i, j, 0) += rho_ijk*vf_j*scalarf_j * filter_coef_z;
5657 bb_is(i, j, 0) += rho_ijk*uf_i * filter_coef_z;
5658 bb_js(i, j, 0) += rho_ijk*vf_j * filter_coef_z;
5659 bbT_i(i, j, 0) += rho_ijk*scalarf_i * filter_coef_z;
5660 bbT_j(i, j, 0) += rho_ijk*scalarf_j * filter_coef_z;
5661 masse_vol_ijk_filtre(i, j, 0) += rho_ijk * filter_coef_z;
5662 }
5663 }
5664 }
5665 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
5666 {
5667 const int kpg = kg + kp;
5668 if (!(kernel->is_at_wall_face(kpg, nktot)))
5669 {
5670 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
5671
5672 const double rho_ijk = masse_vol_ijk(i,j,k+kp);
5673 const double scalar = champ_scalar(i,j,k+kp);
5674 // const double scalar_km1 = kpg==0 ? scalar_kmin : champ_scalar(i,j,k-1+kp);
5675 const double scalarf_k = (scalar);
5676
5677 const double wf_k = kpg==(nktot-1) ? 0. : 0.5*(vitesse_k(i,j,k+kp)+vitesse_k(i,j,k+kp+1));
5678
5679 if (ponderation_filter_kernel)
5680 {
5681 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5682 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
5683 const double dzf = 0.5*(dz + dz_m1);
5684 b_ks(i, j, 0) += rho_ijk*wf_k*scalarf_k * filter_coef_z_face * dzf * facteur_face;
5685 bb_ks(i, j, 0) += rho_ijk*wf_k*scalarf_k * filter_coef_z_face * dzf * facteur_face;
5686 bbT_k(i, j, 0) += rho_ijk*scalarf_k * filter_coef_z_face * dzf * facteur_face;
5687 }
5688 else
5689 {
5690 b_ks(i, j, 0) += rho_ijk*wf_k*scalarf_k * filter_coef_z_face;
5691 bb_ks(i, j, 0) += rho_ijk*wf_k*scalarf_k * filter_coef_z_face;
5692 bbT_k(i, j, 0) += rho_ijk*scalarf_k * filter_coef_z_face;
5693 }
5694 }
5695 }
5696 }
5697 }
5698 for (int j = 0; j < nj; j++)
5699 {
5700 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
5701 {
5702 a_is(i, 0, 0) = 0.;
5703 a_js(i, 0, 0) = 0.;
5704 a_ks(i, 0, 0) = 0.;
5705 aa_is(i, 0, 0) = 0.;
5706 aa_js(i, 0, 0) = 0.;
5707 aa_ks(i, 0, 0) = 0.;
5708 aaT_i(i, 0, 0) = 0.;
5709 aaT_j(i, 0, 0) = 0.;
5710 aaT_k(i, 0, 0) = 0.;
5711 aa_rho_ijk_filtre(i, 0, 0) = 0.;
5712 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
5713 {
5714 const double filter_coef_y = filter_kernel_y[jp+10];
5715 a_is(i, 0, 0) += b_is(i, j+jp, 0) * filter_coef_y;
5716 a_js(i, 0, 0) += b_js(i, j+jp, 0) * filter_coef_y;
5717 a_ks(i, 0, 0) += b_ks(i, j+jp, 0) * filter_coef_y;
5718 aa_is(i, 0, 0) += bb_is(i, j+jp, 0) * filter_coef_y;
5719 aa_js(i, 0, 0) += bb_js(i, j+jp, 0) * filter_coef_y;
5720 aa_ks(i, 0, 0) += bb_ks(i, j+jp, 0) * filter_coef_y;
5721 aaT_i(i, 0, 0) += bbT_i(i, j+jp, 0) * filter_coef_y;
5722 aaT_j(i, 0, 0) += bbT_j(i, j+jp, 0) * filter_coef_y;
5723 aaT_k(i, 0, 0) += bbT_k(i, j+jp, 0) * filter_coef_y;
5724 aa_rho_ijk_filtre(i, 0, 0) += masse_vol_ijk_filtre(i, j+jp, 0)* filter_coef_y;
5725 }
5726 }
5727
5728 for (int i = 0; i < ni; i++)
5729 {
5730 double r_is = 0.;
5731 double r_js = 0.;
5732 double r_ks = 0.;
5733 double rho_uf_i = 0.;
5734 double rho_vf_j = 0.;
5735 double rho_wf_k = 0.;
5736 double rho_scalarf_i = 0.;
5737 double rho_scalarf_j = 0.;
5738 double rho_scalarf_k = 0.;
5739 double rho_filtre = 0.;
5740 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
5741 {
5742 const double filter_coef_x = filter_kernel_x[ip+10];
5743 r_is += a_is(i+ip, 0, 0) * filter_coef_x;
5744 r_js += a_js(i+ip, 0, 0) * filter_coef_x;
5745 r_ks += a_ks(i+ip, 0, 0) * filter_coef_x;
5746 rho_uf_i += aa_is(i+ip, 0, 0) * filter_coef_x;
5747 rho_vf_j += aa_js(i+ip, 0, 0) * filter_coef_x;
5748 rho_wf_k += aa_ks(i+ip, 0, 0) * filter_coef_x;
5749 rho_scalarf_i += aaT_i(i+ip, 0, 0) * filter_coef_x;
5750 rho_scalarf_j += aaT_j(i+ip, 0, 0) * filter_coef_x;
5751 rho_scalarf_k += aaT_k(i+ip, 0, 0) * filter_coef_x;
5752 rho_filtre += aa_rho_ijk_filtre(i+ip, 0, 0)* filter_coef_x;
5753 }
5754
5755 Cerr << "i=" << i << finl;
5756 Cerr << "j=" << j << finl;
5757 Cerr << "k=" << k << finl;
5758 Cerr << "rho_filtre=" << rho_filtre << finl;
5759 Cerr << "r_is=" << r_is << finl;
5760 Cerr << "rho_uf_i=" << rho_uf_i << finl;
5761 Cerr << "rho_scalarf_i=" << rho_scalarf_i << finl;
5762 Cerr << "-----------------------" << finl;
5763
5764 const double c_is = (r_is)/rho_filtre - (rho_uf_i*rho_scalarf_i)/(rho_filtre*rho_filtre);
5765 const double c_js = (r_js)/rho_filtre - (rho_vf_j*rho_scalarf_j)/(rho_filtre*rho_filtre);
5766 const double c_ks = (r_ks)/rho_filtre - (rho_wf_k*rho_scalarf_k)/(rho_filtre*rho_filtre);
5767
5768 structural_uscalar_x(i,j,k) = - coefficient_x * structural_uscalar_model_constant * c_is;
5769 structural_uscalar_y(i,j,k) = - coefficient_y * structural_uscalar_model_constant * c_js;
5770 structural_uscalar_z(i,j,k) = - coefficient_z * structural_uscalar_model_constant * c_ks;
5771 }
5772 }
5773 }
5774}
5775
5776template<class T>
5777void calculer_structural_uscalar_similarity(const double structural_uscalar_model_constant,
5778 const ArrOfDouble& structural_uscalar_vector_coefficients,
5779 const IJK_Field_vector3_double& velocity,
5780 const IJK_Field_vector3_double& velocity_filtre,
5781 const IJK_Field_double& champ_scalar,
5782 const IJK_Field_double& champ_scalar_filtre,
5783 double scalar_kmin, double scalar_kmax,
5784 const ArrOfDouble_with_ghost& delta_z,
5785 const double facteur_delta_x,
5786 const double facteur_delta_y,
5787 const ArrOfDouble_with_ghost& delta_z_pour_delta,
5788 T& kernel,
5791 IJK_Field_vector3_double& structural_uscalar_vector)
5792{
5793 const IJK_Field_double& vitesse_i = velocity[0];
5794 const IJK_Field_double& vitesse_j = velocity[1];
5795 const IJK_Field_double& vitesse_k = velocity[2];
5796
5797 const IJK_Field_double& vitesse_i_filtre = velocity_filtre[0];
5798 const IJK_Field_double& vitesse_j_filtre = velocity_filtre[1];
5799 const IJK_Field_double& vitesse_k_filtre = velocity_filtre[2];
5800
5801 IJK_Field_double& structural_uscalar_x = structural_uscalar_vector[0];
5802 IJK_Field_double& structural_uscalar_y = structural_uscalar_vector[1];
5803 IJK_Field_double& structural_uscalar_z = structural_uscalar_vector[2];
5804
5805 const double& coefficient_x = structural_uscalar_vector_coefficients[0];
5806 const double& coefficient_y = structural_uscalar_vector_coefficients[1];
5807 const double& coefficient_z = structural_uscalar_vector_coefficients[2];
5808
5809 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
5810 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
5811 const double dx_pour_delta = facteur_delta_x*dx;
5812 const double dy_pour_delta = facteur_delta_y*dy;
5813
5814 const int ni = vitesse_k.ni();
5815 const int nj = vitesse_k.nj();
5816 const int nk = vitesse_k.nk();
5817
5818 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
5819 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
5820
5821 IJK_Field_local_double& b_is = tmp_b[0];
5822 IJK_Field_local_double& b_js = tmp_b[1];
5823 IJK_Field_local_double& b_ks = tmp_b[2];
5824
5825 IJK_Field_local_double& a_is = tmp_a[0];
5826 IJK_Field_local_double& a_js = tmp_a[1];
5827 IJK_Field_local_double& a_ks = tmp_a[2];
5828
5829 const int ghost_size_filter = kernel->ghost_size();
5830 const int size_uniform = kernel->size_uniform();
5831 const int shift_uniform = kernel->shift_uniform();
5832 for (int k = 0; k < nk; k++)
5833 {
5834 const int kg = k + offset;
5835
5836 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
5837 const double dz_m1_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z[k-1];
5838 const double delta_m_glo = kg==0 ? 0.5*dz_glo : 0.5*(dz_glo + dz_m1_glo);
5839
5840 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
5841 const double dz_m1_pour_delta_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1];
5842 const double delta_m_pour_delta_glo = (kg-1<0 || kg>(nktot-1)) ? 0. : 0.5*(dz_pour_delta_glo + dz_m1_pour_delta_glo);
5843
5844 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
5845 const FixedVector<double, 21> filter_kernel_z_face = kernel->inhomogeneous(false, k, kg, nktot, delta_m_pour_delta_glo, delta_z);
5846 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
5847 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
5848 const int size_k_elem = kernel->size_k_elem(kg, nktot);
5849 const int size_k_face = kernel->size_k_face(kg, nktot);
5850 const int shift_k_elem = kernel->shift_k_elem(kg);
5851 const int shift_k_face = kernel->shift_k_face(kg);
5852 const bool ponderation_filter_kernel = kernel->ponderation();
5853 const bool normalisation_filter_kernel = kernel->normalisation();
5854
5855 double facteur_elem = 0.;
5856 if (ponderation_filter_kernel)
5857 {
5858 if (normalisation_filter_kernel)
5859 {
5860 double longueur_elem = 0.;
5861 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
5862 {
5863 const int kpg = kg + kp;
5864 if (kpg<-1 || kpg>nktot)
5865 {
5866 Cerr << "This should not happen." << finl;
5867 Process::exit();
5868 }
5869 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5870 const double filter_coef_z = filter_kernel_z[kp+10];
5871 longueur_elem += filter_coef_z * dz;
5872 }
5873 facteur_elem = 1./longueur_elem;
5874 }
5875 else
5876 {
5877 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
5878 }
5879 }
5880 double facteur_face = 0.;
5881 if (ponderation_filter_kernel)
5882 {
5883 if (normalisation_filter_kernel)
5884 {
5885 double longueur_face = 0.;
5886 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
5887 {
5888 const int kpg = kg + kp;
5889 if (kpg<0 || kpg>nktot)
5890 {
5891 Cerr << "This should not happen." << finl;
5892 Process::exit();
5893 }
5894 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5895 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
5896 const double dzf = 0.5*(dz + dz_m1);
5897 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
5898 longueur_face += filter_coef_z_face * dzf;
5899 }
5900 facteur_face = 1./longueur_face;
5901 }
5902 else
5903 {
5904 facteur_face = delta_m_glo==0. ? 0. : 1./delta_m_glo;
5905 }
5906 }
5907
5908 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
5909 {
5910 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
5911 {
5912 b_is(i, j, 0) = 0.;
5913 b_js(i, j, 0) = 0.;
5914 b_ks(i, j, 0) = 0.;
5915 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
5916 {
5917 const int kpg = kg + kp;
5918 if (!(kernel->is_at_wall_elem(kpg, nktot)))
5919 {
5920 const double filter_coef_z = filter_kernel_z[kp+10];
5921
5922 const double scalar = champ_scalar(i,j,k+kp);
5923 const double scalar_im1 = champ_scalar(i-1,j,k+kp);
5924 const double scalar_jm1 = champ_scalar(i,j-1,k+kp);
5925 const double scalarf_i = 0.5*(scalar + scalar_im1);
5926 const double scalarf_j = 0.5*(scalar + scalar_jm1);
5927
5928 const double uf_i = vitesse_i(i,j,k+kp);
5929 const double vf_j = vitesse_j(i,j,k+kp);
5930
5931 if (ponderation_filter_kernel)
5932 {
5933 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5934 b_is(i, j, 0) += uf_i*scalarf_i * filter_coef_z * dz * facteur_elem;
5935 b_js(i, j, 0) += vf_j*scalarf_j * filter_coef_z * dz * facteur_elem;
5936 }
5937 else
5938 {
5939 b_is(i, j, 0) += uf_i*scalarf_i * filter_coef_z;
5940 b_js(i, j, 0) += vf_j*scalarf_j * filter_coef_z;
5941 }
5942 }
5943 }
5944 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
5945 {
5946 const int kpg = kg + kp;
5947 if (!(kernel->is_at_wall_face(kpg, nktot)))
5948 {
5949 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
5950
5951 const double scalar = champ_scalar(i,j,k+kp);
5952 const double scalar_km1 = kpg==0 ? scalar_kmin : champ_scalar(i,j,k-1+kp);
5953 const double scalarf_k = 0.5*(scalar + scalar_km1);
5954
5955 const double wf_k = vitesse_k(i,j,k+kp);
5956
5957 if (ponderation_filter_kernel)
5958 {
5959 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5960 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
5961 const double dzf = 0.5*(dz + dz_m1);
5962 b_ks(i, j, 0) += wf_k*scalarf_k * filter_coef_z_face * dzf * facteur_face;
5963 }
5964 else
5965 {
5966 b_ks(i, j, 0) += wf_k*scalarf_k * filter_coef_z_face;
5967 }
5968 }
5969 }
5970 }
5971 }
5972 for (int j = 0; j < nj; j++)
5973 {
5974 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
5975 {
5976 a_is(i, 0, 0) = 0.;
5977 a_js(i, 0, 0) = 0.;
5978 a_ks(i, 0, 0) = 0.;
5979 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
5980 {
5981 const double filter_coef_y = filter_kernel_y[jp+10];
5982 a_is(i, 0, 0) += b_is(i, j+jp, 0) * filter_coef_y;
5983 a_js(i, 0, 0) += b_js(i, j+jp, 0) * filter_coef_y;
5984 a_ks(i, 0, 0) += b_ks(i, j+jp, 0) * filter_coef_y;
5985 }
5986 }
5987
5988 for (int i = 0; i < ni; i++)
5989 {
5990 double r_is = 0.;
5991 double r_js = 0.;
5992 double r_ks = 0.;
5993 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
5994 {
5995 const double filter_coef_x = filter_kernel_x[ip+10];
5996 r_is += a_is(i+ip, 0, 0) * filter_coef_x;
5997 r_js += a_js(i+ip, 0, 0) * filter_coef_x;
5998 r_ks += a_ks(i+ip, 0, 0) * filter_coef_x;
5999 }
6000
6001 const double scalar = champ_scalar_filtre(i,j,k);
6002 const double scalar_im1 = champ_scalar_filtre(i-1,j,k);
6003 const double scalar_jm1 = champ_scalar_filtre(i,j-1,k);
6004 const double scalar_km1 = kg==0 ? scalar_kmin : champ_scalar_filtre(i,j,k-1);
6005 const double scalarf_i = 0.5*(scalar + scalar_im1);
6006 const double scalarf_j = 0.5*(scalar + scalar_jm1);
6007 const double scalarf_k = 0.5*(scalar + scalar_km1);
6008
6009 const double uf_i = vitesse_i_filtre(i,j,k);
6010 const double vf_j = vitesse_j_filtre(i,j,k);
6011 const double wf_k = vitesse_k_filtre(i,j,k);
6012
6013 const double c_is = r_is - uf_i*scalarf_i;
6014 const double c_js = r_js - vf_j*scalarf_j;
6015 const double c_ks = r_ks - wf_k*scalarf_k;
6016
6017 structural_uscalar_x(i,j,k) = - coefficient_x * structural_uscalar_model_constant * c_is;
6018 structural_uscalar_y(i,j,k) = - coefficient_y * structural_uscalar_model_constant * c_js;
6019 structural_uscalar_z(i,j,k) = - coefficient_z * structural_uscalar_model_constant * c_ks;
6020 }
6021 }
6022 }
6023}
6024
6025void calculer_structural_uscalar_similarity_Streher(const double structural_uscalar_model_constant,
6026 const ArrOfDouble& structural_uscalar_vector_coefficients,
6027 const IJK_Field_vector3_double& velocity,
6028 const IJK_Field_double& champ_scalar,
6029 double scalar_kmin, double scalar_kmax,
6030 IJK_Field_vector3_double& structural_uscalar_vector)
6031{
6032 const IJK_Field_double& vitesse_i = velocity[0];
6033 const IJK_Field_double& vitesse_j = velocity[1];
6034 const IJK_Field_double& vitesse_k = velocity[2];
6035
6036 const int ni = vitesse_k.ni();
6037 const int nj = vitesse_k.nj();
6038 const int nk = vitesse_k.nk();
6039
6040 IJK_Field_double& structural_uscalar_x = structural_uscalar_vector[0];
6041 IJK_Field_double& structural_uscalar_y = structural_uscalar_vector[1];
6042 IJK_Field_double& structural_uscalar_z = structural_uscalar_vector[2];
6043
6044 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
6045 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
6046
6047 for (int k = 0; k < nk; k++)
6048 {
6049 const int kg = k + offset;
6050 for (int j = 0; j < nj; j++)
6051 {
6052 for (int i = 0; i < ni; i++)
6053 {
6054
6055 // const double uf_im1 = vitesse_i(i-1,j,k);
6056 const double uf_i = vitesse_i(i,j,k);
6057 // const double uf_ip1 = vitesse_i(i+1,j,k);
6058 // const double uf_ip2 = vitesse_i(i+2,j,k);
6059
6060 // const double vf_jm1 = vitesse_j(i,j-1,k);
6061 const double vf_j = vitesse_j(i,j,k);
6062 // const double vf_jp1 = vitesse_j(i,j+1,k);
6063 // const double vf_jp2 = vitesse_j(i,j+2,k);
6064
6065 // const double wf_km1 = kg<=1 ? 0. : vitesse_k(i,j,k-1);
6066 const double wf_k = vitesse_k(i,j,k);
6067 // const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
6068 // const double wf_kp2 = kg>=(nktot-2) ? 0. : vitesse_k(i,j,k+2);
6069
6070 const double sf_im2 = champ_scalar(i-2,j,k);
6071 const double sf_im1 = champ_scalar(i-1,j,k);
6072 const double sf_i = champ_scalar(i,j,k);
6073 const double sf_ip1 = champ_scalar(i+1,j,k);
6074 // const double sf_ip2 = champ_scalar(i+2,j,k);
6075
6076 const double sf_jm2 = champ_scalar(i,j-2,k);
6077 const double sf_jm1 = champ_scalar(i,j-1,k);
6078 const double sf_j = champ_scalar(i,j,k);
6079 const double sf_jp1 = champ_scalar(i,j+1,k);
6080 // const double sf_jp2 = champ_scalar(i,j+2,k);
6081
6082 const double sf_km2 = kg<=1 ? scalar_kmin : champ_scalar(i,j,k-2);
6083 const double sf_km1 = kg==0 ? scalar_kmin : champ_scalar(i,j,k-1);
6084 const double sf_k = kg >=(nktot-1) ? scalar_kmax : champ_scalar(i,j,k);
6085 const double sf_kp1 = kg >=(nktot-2) ? scalar_kmax : champ_scalar(i,j,k+1);
6086 // const double sf_kp2 = kg >=(nktot-3) ? scalar_kmax : champ_scalar(i,j,k+2);
6087
6088
6089 const double c_is = uf_i*(sf_i+sf_im1)/2. - (uf_i)*(sf_im2+sf_im1+sf_i+sf_ip1)/4.;
6090 const double c_js = vf_j*(sf_j+sf_jm1)/2. - (vf_j)*(sf_jm2+sf_jm1+sf_j+sf_jp1)/4.;
6091 const double c_ks = wf_k*(sf_k+sf_km1)/2. - (wf_k)*(sf_km2+sf_km1+sf_k+sf_kp1)/4.;
6092
6093 structural_uscalar_x(i,j,k) = - structural_uscalar_model_constant * c_is;
6094 structural_uscalar_y(i,j,k) = - structural_uscalar_model_constant * c_js;
6095 structural_uscalar_z(i,j,k) = - structural_uscalar_model_constant * c_ks;
6096
6097 }
6098 }
6099 }
6100}
6101
6102template<class T>
6103void calculer_structural_uscalar(const Nom& structural_uscalar_model,
6104 const double structural_uscalar_model_constant,
6105 const ArrOfDouble& structural_uscalar_vector_coefficients,
6106 IJK_Field_double& rho,
6107 IJK_Field_vector3_double& velocity,
6108 IJK_Field_vector3_double& velocity_filtre,
6109 IJK_Field_double& scalar,
6110 IJK_Field_double& scalar_filtre,
6111 double scalar_kmin, double scalar_kmax,
6112 const ArrOfDouble_with_ghost& delta_z,
6113 const double facteur_delta_x,
6114 const double facteur_delta_y,
6115 const ArrOfDouble_with_ghost& delta_z_pour_delta,
6116 const double facteur_delta_filtre_x,
6117 const double facteur_delta_filtre_y,
6118 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
6119 T& kernel,
6122 IJK_Field_vector3_double& structural_uscalar_tmp_vector,
6123 const bool flag_structural_uscalar_filtre,
6124 IJK_Field_vector3_double& structural_uscalar_filtre_vector,
6125 IJK_Field_vector3_double& structural_uscalar_vector)
6126{
6127 int ghost_size_filter;
6128 int ghost_size_velocity;
6129 int ghost_size_scalar;
6130 int ghost_size_structural_uscalar_tmp;
6131
6132
6133 if ( structural_uscalar_model == Nom("gradient") )
6134 {
6135 calculer_structural_uscalar_gradient(structural_uscalar_model_constant,
6136 structural_uscalar_vector_coefficients,
6137 velocity, scalar, scalar_kmin, scalar_kmax,
6138 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6139 structural_uscalar_vector);
6140 }
6141 else if ( structural_uscalar_model == Nom("gradient_filtre") )
6142 {
6143 calculer_structural_uscalar_gradient(structural_uscalar_model_constant,
6144 structural_uscalar_vector_coefficients,
6145 velocity, scalar, scalar_kmin, scalar_kmax,
6146 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6147 structural_uscalar_tmp_vector);
6148
6149 ghost_size_filter = 1 + kernel->ghost_size();
6150 ghost_size_structural_uscalar_tmp = max((int) 2, ghost_size_filter);
6151 structural_uscalar_tmp_vector[0].echange_espace_virtuel(ghost_size_structural_uscalar_tmp);
6152 structural_uscalar_tmp_vector[1].echange_espace_virtuel(ghost_size_structural_uscalar_tmp);
6153 structural_uscalar_tmp_vector[2].echange_espace_virtuel(ghost_size_structural_uscalar_tmp);
6154
6155 const int flag_add = 0;
6156 filtrer_champ_elem(flag_add, structural_uscalar_tmp_vector[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uscalar_vector[0]);
6157 filtrer_champ_elem(flag_add, structural_uscalar_tmp_vector[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uscalar_vector[1]);
6158 filtrer_champ_face(flag_add, structural_uscalar_tmp_vector[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uscalar_vector[2]);
6159 }
6160 else if ( structural_uscalar_model == Nom("similarity") )
6161 {
6162 ghost_size_filter = 1 + kernel->ghost_size();
6163 ghost_size_velocity = max((int) 2, ghost_size_filter);
6164 ghost_size_scalar = max((int) 2, ghost_size_filter);
6165 velocity[0].echange_espace_virtuel(ghost_size_velocity);
6166 velocity[1].echange_espace_virtuel(ghost_size_velocity);
6167 velocity[2].echange_espace_virtuel(ghost_size_velocity);
6168 scalar.echange_espace_virtuel(ghost_size_scalar);
6169
6170 const int flag_add = 0;
6171 filtrer_champ_elem(flag_add, velocity[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[0]);
6172 filtrer_champ_elem(flag_add, velocity[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[1]);
6173 filtrer_champ_face(flag_add, velocity[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[2]);
6174 filtrer_champ_elem(flag_add, scalar, delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, scalar_filtre);
6175
6176 velocity_filtre[0].echange_espace_virtuel(2);
6177 velocity_filtre[1].echange_espace_virtuel(2);
6178 velocity_filtre[2].echange_espace_virtuel(2);
6179 scalar_filtre.echange_espace_virtuel(2);
6180
6181 calculer_structural_uscalar_similarity(structural_uscalar_model_constant,
6182 structural_uscalar_vector_coefficients,
6183 velocity, velocity_filtre,
6184 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
6185 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6186 kernel, tmp_b, tmp_a,
6187 structural_uscalar_vector);
6188 }
6189 else if ( structural_uscalar_model == Nom("similarity_comp") )
6190 {
6191 ghost_size_filter = 1 + kernel->ghost_size();
6192 ghost_size_velocity = max((int) 2, ghost_size_filter);
6193 ghost_size_scalar = max((int) 2, ghost_size_filter);
6194 velocity[0].echange_espace_virtuel(ghost_size_velocity);
6195 velocity[1].echange_espace_virtuel(ghost_size_velocity);
6196 velocity[2].echange_espace_virtuel(ghost_size_velocity);
6197 scalar.echange_espace_virtuel(ghost_size_scalar);
6198
6199 const int flag_add = 0;
6200 filtrer_champ_elem(flag_add, velocity[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[0]);
6201 filtrer_champ_elem(flag_add, velocity[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[1]);
6202 filtrer_champ_face(flag_add, velocity[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[2]);
6203 filtrer_champ_elem(flag_add, scalar, delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, scalar_filtre);
6204
6205 velocity_filtre[0].echange_espace_virtuel(2);
6206 velocity_filtre[1].echange_espace_virtuel(2);
6207 velocity_filtre[2].echange_espace_virtuel(2);
6208 scalar_filtre.echange_espace_virtuel(2);
6209
6210 calculer_structural_uscalar_similarity_comp(structural_uscalar_model_constant,
6211 structural_uscalar_vector_coefficients,
6212 rho,
6213 velocity, velocity_filtre,
6214 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
6215 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6216 kernel, tmp_b, tmp_a,
6217 structural_uscalar_vector);
6218 }
6219 else if ( structural_uscalar_model == Nom("similarity_streher") )
6220 {
6221 ghost_size_filter = 1 + kernel->ghost_size();
6222 ghost_size_velocity = max((int) 2, ghost_size_filter);
6223 ghost_size_scalar = max((int) 2, ghost_size_filter);
6224 velocity[0].echange_espace_virtuel(ghost_size_velocity);
6225 velocity[1].echange_espace_virtuel(ghost_size_velocity);
6226 velocity[2].echange_espace_virtuel(ghost_size_velocity);
6227 scalar.echange_espace_virtuel(ghost_size_scalar);
6228
6229 const int flag_add = 0;
6230 filtrer_champ_elem(flag_add, velocity[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[0]);
6231 filtrer_champ_elem(flag_add, velocity[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[1]);
6232 filtrer_champ_face(flag_add, velocity[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[2]);
6233 filtrer_champ_elem(flag_add, scalar, delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, scalar_filtre);
6234
6235 velocity_filtre[0].echange_espace_virtuel(2);
6236 velocity_filtre[1].echange_espace_virtuel(2);
6237 velocity_filtre[2].echange_espace_virtuel(2);
6238 scalar_filtre.echange_espace_virtuel(2);
6239
6240 calculer_structural_uscalar_similarity_Streher(structural_uscalar_model_constant,
6241 structural_uscalar_vector_coefficients,
6242 velocity,
6243 scalar, scalar_kmin, scalar_kmax,
6244 structural_uscalar_vector);
6245 }
6246 else
6247 {
6248 Cerr << "The name of the structural model for uscalar is unknown." << finl;
6249 Process::exit();
6250 }
6251
6252 if (flag_structural_uscalar_filtre)
6253 {
6254 ghost_size_filter = 1 + kernel->ghost_size();
6255 ghost_size_velocity = max((int) 2, ghost_size_filter);
6256 ghost_size_scalar = max((int) 2, ghost_size_filter);
6257 velocity[0].echange_espace_virtuel(ghost_size_velocity);
6258 velocity[1].echange_espace_virtuel(ghost_size_velocity);
6259 velocity[2].echange_espace_virtuel(ghost_size_velocity);
6260 scalar.echange_espace_virtuel(ghost_size_scalar);
6261
6262 const int flag_add = 0;
6263 filtrer_champ_elem(flag_add, velocity[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[0]);
6264 filtrer_champ_elem(flag_add, velocity[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[1]);
6265 filtrer_champ_face(flag_add, velocity[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, velocity_filtre[2]);
6266 filtrer_champ_elem(flag_add, scalar, delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, scalar_filtre);
6267
6268 velocity_filtre[0].echange_espace_virtuel(2);
6269 velocity_filtre[1].echange_espace_virtuel(2);
6270 velocity_filtre[2].echange_espace_virtuel(2);
6271 scalar_filtre.echange_espace_virtuel(2);
6272
6273 if ( structural_uscalar_model == Nom("gradient") )
6274 {
6275 calculer_structural_uscalar_gradient(structural_uscalar_model_constant,
6276 structural_uscalar_vector_coefficients,
6277 velocity_filtre, scalar_filtre, scalar_kmin, scalar_kmax,
6278 delta_z, facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6279 structural_uscalar_filtre_vector);
6280 }
6281 else if ( structural_uscalar_model == Nom("gradient_filtre") )
6282 {
6283 calculer_structural_uscalar_gradient(structural_uscalar_model_constant,
6284 structural_uscalar_vector_coefficients,
6285 velocity_filtre, scalar_filtre, scalar_kmin, scalar_kmax,
6286 delta_z, facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6287 structural_uscalar_tmp_vector);
6288
6289 ghost_size_filter = 1 + kernel->ghost_size();
6290 ghost_size_structural_uscalar_tmp = max((int) 2, ghost_size_filter);
6291 structural_uscalar_tmp_vector[0].echange_espace_virtuel(ghost_size_structural_uscalar_tmp);
6292 structural_uscalar_tmp_vector[1].echange_espace_virtuel(ghost_size_structural_uscalar_tmp);
6293 structural_uscalar_tmp_vector[2].echange_espace_virtuel(ghost_size_structural_uscalar_tmp);
6294
6295 filtrer_champ_elem(flag_add, structural_uscalar_tmp_vector[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uscalar_filtre_vector[0]);
6296 filtrer_champ_elem(flag_add, structural_uscalar_tmp_vector[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uscalar_filtre_vector[1]);
6297 filtrer_champ_face(flag_add, structural_uscalar_tmp_vector[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, structural_uscalar_filtre_vector[2]);
6298 }
6299 else if ( structural_uscalar_model == Nom("similarity") )
6300 {
6301 Cerr << "The use of a dynamic constant with the SIMILARITY structural model is not allowed." << finl;
6302 Process::exit();
6303 }
6304 }
6305}
6306
6307template<class T>
6308void modification_modele_dynamic_uu_scalar(const bool anisotropic,
6309 const Nom& turbulent_viscosity_dynamic_type,
6310 const Nom& structural_uu_dynamic_type,
6311 const IJK_Field_vector3_double& velocity,
6312 const IJK_Field_vector3_double& velocity_filtre,
6313 const IJK_Field_double& scalar,
6314 const IJK_Field_double& scalar_filtre,
6315 double scalar_kmin, double scalar_kmax,
6316 const ArrOfDouble_with_ghost& delta_z,
6317 const double facteur_delta_x,
6318 const double facteur_delta_y,
6319 const ArrOfDouble_with_ghost& delta_z_pour_delta,
6320 const double facteur_delta_filtre_x,
6321 const double facteur_delta_filtre_y,
6322 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
6323 T& kernel,
6326 ArrOfDouble_with_ghost& constante_modele,
6328 const int turbulent_viscosity,
6329 IJK_Field_double& turbulent_mu,
6330 IJK_Field_double& turbulent_mu_filtre,
6331 const int structural_uu,
6332 FixedVector<IJK_Field_double, 6>& structural_uu_tensor,
6333 FixedVector<IJK_Field_double, 6>& structural_uu_filtre_tensor)
6334{
6335 int ghost_size_filter;
6336 int ghost_size_turbulent_mu;
6337 int ghost_size_structural_uu;
6338 if ( turbulent_viscosity_dynamic_type == Nom("not_dynamic")
6339 && structural_uu_dynamic_type == Nom("not_dynamic") )
6340 {
6341 // do nothing
6342 }
6343 else
6344 {
6345 if (turbulent_viscosity)
6346 {
6347 ghost_size_filter = 1 + kernel->ghost_size();
6348 ghost_size_turbulent_mu = max((int) 2, ghost_size_filter);
6349 turbulent_mu.echange_espace_virtuel(ghost_size_turbulent_mu);
6350 turbulent_mu_filtre.echange_espace_virtuel(2);
6351 }
6352
6353 if (structural_uu)
6354 {
6355 for (int j=0 ; j<6 ; j++)
6356 {
6357 ghost_size_filter = 1 + kernel->ghost_size();
6358 ghost_size_structural_uu = max((int) 2, ghost_size_filter);
6359 structural_uu_tensor[j].echange_espace_virtuel(ghost_size_structural_uu);
6360 structural_uu_filtre_tensor[j].echange_espace_virtuel(2);
6361 }
6362 }
6363
6364 const bool tensorial_struct = structural_uu_dynamic_type.finit_par("tensorial");
6365
6366 calculer_ml_dynamic_uu_tensor(anisotropic, tensorial_struct,
6367 velocity, velocity_filtre,
6368 turbulent_viscosity,
6369 turbulent_mu,
6370 turbulent_mu,
6371 turbulent_mu,
6372 turbulent_mu,
6373 turbulent_mu,
6374 turbulent_mu,
6375 turbulent_mu_filtre,
6376 turbulent_mu_filtre,
6377 turbulent_mu_filtre,
6378 turbulent_mu_filtre,
6379 turbulent_mu_filtre,
6380 turbulent_mu_filtre,
6381 structural_uu,
6382 structural_uu_tensor,
6383 structural_uu_filtre_tensor,
6384 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6385 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6386 kernel, tmp_b, tmp_a,
6387 ml);
6388
6389 FixedVector<ArrOfDouble, 7>& lij = ml[0];
6390 FixedVector<ArrOfDouble, 7>& mij = ml[1];
6391 FixedVector<ArrOfDouble, 7>& hij = ml[2];
6392 FixedVector<ArrOfDouble, 7>& mijmij = ml[3];
6393 FixedVector<ArrOfDouble, 7>& hijhij = ml[4];
6394 FixedVector<ArrOfDouble, 7>& mijlij = ml[5];
6395 FixedVector<ArrOfDouble, 7>& hijlij = ml[6];
6396 FixedVector<ArrOfDouble, 7>& mijhij = ml[7];
6397
6398 ArrOfDouble& moy_lij = ml[0][6];
6399 ArrOfDouble& moy_mij = ml[1][6];
6400 ArrOfDouble& moy_hij = ml[2][6];
6401 ArrOfDouble& moy_mijmij = ml[3][6];
6402 ArrOfDouble& moy_hijhij = ml[4][6];
6403 ArrOfDouble& moy_mijlij = ml[5][6];
6404 ArrOfDouble& moy_hijlij = ml[6][6];
6405 ArrOfDouble& moy_mijhij = ml[7][6];
6406
6407 const bool visc_reconnu = calculer_constante_modele(turbulent_viscosity_dynamic_type,
6408 Nom("uu, viscosity"),
6409 moy_lij, moy_mij, moy_hij,
6410 moy_mijmij, moy_hijhij,
6411 moy_mijlij, moy_hijlij,
6412 moy_mijhij,
6413 velocity, delta_z,
6414 constante_modele);
6415 if (visc_reconnu)
6416 {
6417 const bool flag_face = false;
6418 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu);
6419 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_filtre);
6420 }
6421
6422 const bool struct_reconnu = calculer_constante_modele(structural_uu_dynamic_type,
6423 Nom("uu, structural"),
6424 moy_lij, moy_hij, moy_mij,
6425 moy_hijhij, moy_mijmij,
6426 moy_hijlij, moy_mijlij,
6427 moy_mijhij,
6428 velocity, delta_z,
6429 constante_modele);
6430 if (struct_reconnu)
6431 {
6432 for (int j=0 ; j<6 ; j++)
6433 {
6434 const bool flag_face = (j==2||j==4);
6435 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_tensor[j]);
6436 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_filtre_tensor[j]);
6437 }
6438 }
6439
6440 if (tensorial_struct)
6441 {
6442 Nom struct_dynamic_type = structural_uu_dynamic_type.getPrefix("tensorial");
6443 for (int j=0 ; j<6 ; j++)
6444 {
6445 const bool reconnu = calculer_constante_modele(struct_dynamic_type,
6446 Nom("uu, structural, tensorial, j= ") + Nom(j),
6447 lij[j], hij[j], mij[j],
6448 hijhij[j], mijmij[j],
6449 hijlij[j], mijlij[j],
6450 mijhij[j],
6451 velocity, delta_z,
6452 constante_modele);
6453 if (reconnu)
6454 {
6455 const bool flag_face = (j==2||j==4);
6456 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_tensor[j]);
6457 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_filtre_tensor[j]);
6458 }
6459 else
6460 {
6461 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6462 Process::exit();
6463 }
6464 }
6465 }
6466
6467 const bool twopass_visc = turbulent_viscosity_dynamic_type.finit_par("_twopass");
6468 const bool twopass_struct = structural_uu_dynamic_type.finit_par("_twopass");
6469 if (twopass_visc || twopass_struct)
6470 {
6471 if (!turbulent_viscosity)
6472 {
6473 Cerr << "Erreur : On ne devrait pas pouvoir rentrer dans une evaluation dynamique de la constante de type 'twopass' en ayant pas de viscosite turbulente" << finl;
6474 Process::exit();
6475 }
6476 if (!structural_uu)
6477 {
6478 Cerr << "Erreur : On ne devrait pas pouvoir rentrer dans une evaluation dynamique de la constante de type 'twopass' en ayant pas de modele structurel" << finl;
6479 Process::exit();
6480 }
6481
6482 Nom visc_dynamic_type;
6483 Nom struct_dynamic_type;
6484 if (twopass_visc)
6485 {
6486 Cout << "Second pass, dynamic correction of constant: uu, viscosity" << finl;
6487 visc_dynamic_type = turbulent_viscosity_dynamic_type.getPrefix("_twopass");
6488 struct_dynamic_type = Nom("not_dynamic");
6489 }
6490 else
6491 {
6492 Cout << "Second pass, dynamic correction of constant: uu, structural" << finl;
6493 visc_dynamic_type = Nom("not_dynamic");
6494 struct_dynamic_type = structural_uu_dynamic_type.getPrefix("_twopass");
6495 }
6496
6497 modification_modele_dynamic_uu_scalar(anisotropic,
6498 visc_dynamic_type,
6499 struct_dynamic_type,
6500 velocity, velocity_filtre,
6501 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
6502 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6503 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6504 kernel, tmp_b, tmp_a,
6505 constante_modele, ml,
6506 turbulent_viscosity, turbulent_mu, turbulent_mu_filtre,
6507 structural_uu, structural_uu_tensor, structural_uu_filtre_tensor);
6508 }
6509
6510 if ((!visc_reconnu) && (!struct_reconnu) && (!twopass_visc) && (!tensorial_struct) && (!twopass_struct))
6511 {
6512 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6513 Process::exit();
6514 }
6515 }
6516}
6517
6518template<class T>
6519void modification_modele_dynamic_uu_tensor(const bool anisotropic,
6520 const Nom& turbulent_viscosity_dynamic_type,
6521 const Nom& structural_uu_dynamic_type,
6522 const IJK_Field_vector3_double& velocity,
6523 const IJK_Field_vector3_double& velocity_filtre,
6524 const IJK_Field_double& scalar,
6525 const IJK_Field_double& scalar_filtre,
6526 double scalar_kmin, double scalar_kmax,
6527 const ArrOfDouble_with_ghost& delta_z,
6528 const double facteur_delta_x,
6529 const double facteur_delta_y,
6530 const ArrOfDouble_with_ghost& delta_z_pour_delta,
6531 const double facteur_delta_filtre_x,
6532 const double facteur_delta_filtre_y,
6533 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
6534 T& kernel,
6537 ArrOfDouble_with_ghost& constante_modele,
6539 const int turbulent_viscosity,
6540 FixedVector<IJK_Field_double, 6>& turbulent_mu_tensor,
6541 FixedVector<IJK_Field_double, 6>& turbulent_mu_filtre_tensor,
6542 const int structural_uu,
6543 FixedVector<IJK_Field_double, 6>& structural_uu_tensor,
6544 FixedVector<IJK_Field_double, 6>& structural_uu_filtre_tensor)
6545{
6546 IJK_Field_double& turbulent_mu_xx = turbulent_mu_tensor[0];
6547 IJK_Field_double& turbulent_mu_xy = turbulent_mu_tensor[1];
6548 IJK_Field_double& turbulent_mu_xz = turbulent_mu_tensor[2];
6549 IJK_Field_double& turbulent_mu_yy = turbulent_mu_tensor[3];
6550 IJK_Field_double& turbulent_mu_yz = turbulent_mu_tensor[4];
6551 IJK_Field_double& turbulent_mu_zz = turbulent_mu_tensor[5];
6552
6553 IJK_Field_double& turbulent_mu_filtre_xx = turbulent_mu_filtre_tensor[0];
6554 IJK_Field_double& turbulent_mu_filtre_xy = turbulent_mu_filtre_tensor[1];
6555 IJK_Field_double& turbulent_mu_filtre_xz = turbulent_mu_filtre_tensor[2];
6556 IJK_Field_double& turbulent_mu_filtre_yy = turbulent_mu_filtre_tensor[3];
6557 IJK_Field_double& turbulent_mu_filtre_yz = turbulent_mu_filtre_tensor[4];
6558 IJK_Field_double& turbulent_mu_filtre_zz = turbulent_mu_filtre_tensor[5];
6559
6560 int ghost_size_filter, ghost_size_turbulent_mu, ghost_size_structural_uu;
6561
6562 if ( turbulent_viscosity_dynamic_type == Nom("not_dynamic")
6563 && structural_uu_dynamic_type == Nom("not_dynamic") )
6564 {
6565 // do nothing
6566 }
6567 else
6568 {
6569 if (turbulent_viscosity)
6570 {
6571 for (int j=0 ; j<6 ; j++)
6572 {
6573 ghost_size_filter = 1 + kernel->ghost_size();
6574 ghost_size_turbulent_mu = max((int) 2, ghost_size_filter);
6575 turbulent_mu_tensor[j].echange_espace_virtuel(ghost_size_turbulent_mu);
6576 turbulent_mu_filtre_tensor[j].echange_espace_virtuel(2);
6577 }
6578 }
6579
6580 if (structural_uu)
6581 {
6582 for (int j=0 ; j<6 ; j++)
6583 {
6584 ghost_size_filter = 1 + kernel->ghost_size();
6585 ghost_size_structural_uu = max((int) 2, ghost_size_filter);
6586 structural_uu_tensor[j].echange_espace_virtuel(ghost_size_structural_uu);
6587 structural_uu_filtre_tensor[j].echange_espace_virtuel(2);
6588 }
6589 }
6590
6591 const bool tensorial_visc = turbulent_viscosity_dynamic_type.finit_par("tensorial");
6592 const bool tensorial_struct = structural_uu_dynamic_type.finit_par("tensorial");
6593 const bool tensorial = tensorial_visc || tensorial_struct;
6594
6595 calculer_ml_dynamic_uu_tensor(anisotropic, tensorial,
6596 velocity, velocity_filtre,
6597 turbulent_viscosity,
6598 turbulent_mu_xx,
6599 turbulent_mu_xy,
6600 turbulent_mu_xz,
6601 turbulent_mu_yy,
6602 turbulent_mu_yz,
6603 turbulent_mu_zz,
6604 turbulent_mu_filtre_xx,
6605 turbulent_mu_filtre_xy,
6606 turbulent_mu_filtre_xz,
6607 turbulent_mu_filtre_yy,
6608 turbulent_mu_filtre_yz,
6609 turbulent_mu_filtre_zz,
6610 structural_uu,
6611 structural_uu_tensor,
6612 structural_uu_filtre_tensor,
6613 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6614 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6615 kernel, tmp_b, tmp_a,
6616 ml);
6617
6618 FixedVector<ArrOfDouble, 7>& lij = ml[0];
6619 FixedVector<ArrOfDouble, 7>& mij = ml[1];
6620 FixedVector<ArrOfDouble, 7>& hij = ml[2];
6621 FixedVector<ArrOfDouble, 7>& mijmij = ml[3];
6622 FixedVector<ArrOfDouble, 7>& hijhij = ml[4];
6623 FixedVector<ArrOfDouble, 7>& mijlij = ml[5];
6624 FixedVector<ArrOfDouble, 7>& hijlij = ml[6];
6625 FixedVector<ArrOfDouble, 7>& mijhij = ml[7];
6626
6627 ArrOfDouble& moy_lij = ml[0][6];
6628 ArrOfDouble& moy_mij = ml[1][6];
6629 ArrOfDouble& moy_hij = ml[2][6];
6630 ArrOfDouble& moy_mijmij = ml[3][6];
6631 ArrOfDouble& moy_hijhij = ml[4][6];
6632 ArrOfDouble& moy_mijlij = ml[5][6];
6633 ArrOfDouble& moy_hijlij = ml[6][6];
6634 ArrOfDouble& moy_mijhij = ml[7][6];
6635
6636 const bool visc_reconnu = calculer_constante_modele(turbulent_viscosity_dynamic_type,
6637 Nom("uu, viscosity"),
6638 moy_lij, moy_mij, moy_hij,
6639 moy_mijmij, moy_hijhij,
6640 moy_mijlij, moy_hijlij,
6641 moy_mijhij,
6642 velocity, delta_z,
6643 constante_modele);
6644 if (visc_reconnu)
6645 {
6646 for (int j=0 ; j<6 ; j++)
6647 {
6648 const bool flag_face = false;
6649 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_tensor[j]);
6650 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_filtre_tensor[j]);
6651 }
6652 }
6653
6654 const bool struct_reconnu = calculer_constante_modele(structural_uu_dynamic_type,
6655 Nom("uu, structural"),
6656 moy_lij, moy_hij, moy_mij,
6657 moy_hijhij, moy_mijmij,
6658 moy_hijlij, moy_mijlij,
6659 moy_mijhij,
6660 velocity, delta_z,
6661 constante_modele);
6662 if (struct_reconnu)
6663 {
6664 for (int j=0 ; j<6 ; j++)
6665 {
6666 const bool flag_face = (j==2||j==4);
6667 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_tensor[j]);
6668 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_filtre_tensor[j]);
6669 }
6670 }
6671
6672 if (tensorial_visc)
6673 {
6674 Nom visc_dynamic_type = turbulent_viscosity_dynamic_type.getPrefix("tensorial");
6675 for (int j=0 ; j<6 ; j++)
6676 {
6677 const bool reconnu = calculer_constante_modele(visc_dynamic_type,
6678 Nom("uu, viscosity, tensorial, j= ") + Nom(j),
6679 lij[j], mij[j], hij[j],
6680 mijmij[j], hijhij[j],
6681 mijlij[j], hijlij[j],
6682 mijhij[j],
6683 velocity, delta_z,
6684 constante_modele);
6685 if (reconnu)
6686 {
6687 const bool flag_face = false;
6688 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_tensor[j]);
6689 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_filtre_tensor[j]);
6690 }
6691 else
6692 {
6693 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6694 Process::exit();
6695 }
6696 }
6697 }
6698
6699 if (tensorial_struct)
6700 {
6701 Nom struct_dynamic_type = structural_uu_dynamic_type.getPrefix("tensorial");
6702 for (int j=0 ; j<6 ; j++)
6703 {
6704 const bool reconnu = calculer_constante_modele(struct_dynamic_type,
6705 Nom("uu, structural, tensorial, j= ") + Nom(j),
6706 lij[j], hij[j], mij[j],
6707 hijhij[j], mijmij[j],
6708 hijlij[j], mijlij[j],
6709 mijhij[j],
6710 velocity, delta_z,
6711 constante_modele);
6712 if (reconnu)
6713 {
6714 const bool flag_face = (j==2||j==4);
6715 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_tensor[j]);
6716 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_filtre_tensor[j]);
6717 }
6718 else
6719 {
6720 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6721 Process::exit();
6722 }
6723 }
6724 }
6725
6726 const bool twopass_visc = turbulent_viscosity_dynamic_type.finit_par("_twopass");
6727 const bool twopass_struct = structural_uu_dynamic_type.finit_par("_twopass");
6728 if (twopass_visc || twopass_struct)
6729 {
6730 if (!turbulent_viscosity)
6731 {
6732 Cerr << "Erreur : On ne devrait pas pouvoir rentrer dans une evaluation dynamique de la constante de type 'twopass' en ayant pas de viscosite turbulente" << finl;
6733 Process::exit();
6734 }
6735 if (!structural_uu)
6736 {
6737 Cerr << "Erreur : On ne devrait pas pouvoir rentrer dans une evaluation dynamique de la constante de type 'twopass' en ayant pas de modele structurel" << finl;
6738 Process::exit();
6739 }
6740
6741 Nom visc_dynamic_type;
6742 Nom struct_dynamic_type;
6743 if (twopass_visc)
6744 {
6745 Cout << "Second pass, dynamic correction of constant: uu, viscosity" << finl;
6746 visc_dynamic_type = turbulent_viscosity_dynamic_type.getPrefix("_twopass");
6747 struct_dynamic_type = Nom("not_dynamic");
6748 }
6749 else
6750 {
6751 Cout << "Second pass, dynamic correction of constant: uu, structural" << finl;
6752 visc_dynamic_type = Nom("not_dynamic");
6753 struct_dynamic_type = structural_uu_dynamic_type.getPrefix("_twopass");
6754 }
6755
6756 modification_modele_dynamic_uu_tensor(anisotropic,
6757 visc_dynamic_type,
6758 struct_dynamic_type,
6759 velocity, velocity_filtre,
6760 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
6761 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6762 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6763 kernel, tmp_b, tmp_a,
6764 constante_modele, ml,
6765 turbulent_viscosity, turbulent_mu_tensor, turbulent_mu_filtre_tensor,
6766 structural_uu, structural_uu_tensor, structural_uu_filtre_tensor);
6767 }
6768
6769 if ((!visc_reconnu) && (!struct_reconnu) && (!tensorial_visc) && (!tensorial_struct) && (!twopass_visc) && (!twopass_struct))
6770 {
6771 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6772 Process::exit();
6773 }
6774 }
6775}
6776
6777template<class T>
6778void modification_modele_dynamic_uscalar_scalar(const bool anisotropic,
6779 const Nom& turbulent_viscosity_dynamic_type,
6780 const Nom& structural_uscalar_dynamic_type,
6781 const IJK_Field_vector3_double& velocity,
6782 const IJK_Field_vector3_double& velocity_filtre,
6783 const IJK_Field_double& scalar,
6784 const IJK_Field_double& scalar_filtre,
6785 double scalar_kmin, double scalar_kmax,
6786 const ArrOfDouble_with_ghost& delta_z,
6787 const double facteur_delta_x,
6788 const double facteur_delta_y,
6789 const ArrOfDouble_with_ghost& delta_z_pour_delta,
6790 const double facteur_delta_filtre_x,
6791 const double facteur_delta_filtre_y,
6792 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
6793 T& kernel,
6796 ArrOfDouble_with_ghost& constante_modele,
6798 const int turbulent_viscosity,
6799 IJK_Field_double& turbulent_mu,
6800 IJK_Field_double& turbulent_mu_filtre,
6801 const int structural_uscalar,
6802 IJK_Field_vector3_double& structural_uscalar_vector,
6803 IJK_Field_vector3_double& structural_uscalar_filtre_vector)
6804{
6805 int ghost_size_filter, ghost_size_turbulent_mu, ghost_size_structural_uu;
6806 if ( turbulent_viscosity_dynamic_type == Nom("not_dynamic")
6807 && structural_uscalar_dynamic_type == Nom("not_dynamic") )
6808 {
6809 // do nothing
6810 }
6811 else
6812 {
6813 if (turbulent_viscosity)
6814 {
6815 ghost_size_filter = 1 + kernel->ghost_size();
6816 ghost_size_turbulent_mu = max((int) 2, ghost_size_filter);
6817 turbulent_mu.echange_espace_virtuel(ghost_size_turbulent_mu);
6818 turbulent_mu_filtre.echange_espace_virtuel(2);
6819 }
6820
6821 if (structural_uscalar)
6822 {
6823 for (int j=0 ; j<3 ; j++)
6824 {
6825 ghost_size_filter = 1 + kernel->ghost_size();
6826 ghost_size_structural_uu = max((int) 2, ghost_size_filter);
6827 structural_uscalar_vector[j].echange_espace_virtuel(ghost_size_structural_uu);
6828 structural_uscalar_filtre_vector[j].echange_espace_virtuel(2);
6829 }
6830 }
6831
6832 const bool vectorial_struct = structural_uscalar_dynamic_type.finit_par("vectorial");
6833
6834 calculer_ml_dynamic_uscalar_vector(anisotropic, vectorial_struct,
6835 velocity, velocity_filtre,
6836 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
6837 turbulent_viscosity,
6838 turbulent_mu,
6839 turbulent_mu,
6840 turbulent_mu,
6841 turbulent_mu_filtre,
6842 turbulent_mu_filtre,
6843 turbulent_mu_filtre,
6844 structural_uscalar,
6845 structural_uscalar_vector,
6846 structural_uscalar_filtre_vector,
6847 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6848 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6849 kernel, tmp_b, tmp_a,
6850 ml);
6851
6852 FixedVector<ArrOfDouble, 7>& li = ml[0];
6853 FixedVector<ArrOfDouble, 7>& mi = ml[1];
6854 FixedVector<ArrOfDouble, 7>& hi = ml[2];
6855 FixedVector<ArrOfDouble, 7>& mimi = ml[3];
6856 FixedVector<ArrOfDouble, 7>& hihi = ml[4];
6857 FixedVector<ArrOfDouble, 7>& mili = ml[5];
6858 FixedVector<ArrOfDouble, 7>& hili = ml[6];
6859 FixedVector<ArrOfDouble, 7>& mihi = ml[7];
6860
6861 ArrOfDouble& moy_li = ml[0][6];
6862 ArrOfDouble& moy_mi = ml[1][6];
6863 ArrOfDouble& moy_hi = ml[2][6];
6864 ArrOfDouble& moy_mimi = ml[3][6];
6865 ArrOfDouble& moy_hihi = ml[4][6];
6866 ArrOfDouble& moy_mili = ml[5][6];
6867 ArrOfDouble& moy_hili = ml[6][6];
6868 ArrOfDouble& moy_mihi = ml[7][6];
6869
6870 const bool visc_reconnu = calculer_constante_modele(turbulent_viscosity_dynamic_type,
6871 Nom("uscalar, viscosity"),
6872 moy_li, moy_mi, moy_hi,
6873 moy_mimi, moy_hihi,
6874 moy_mili, moy_hili,
6875 moy_mihi,
6876 velocity, delta_z,
6877 constante_modele);
6878 if (visc_reconnu)
6879 {
6880 const bool flag_face = false;
6881 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu);
6882 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_filtre);
6883 }
6884
6885 const bool struct_reconnu = calculer_constante_modele(structural_uscalar_dynamic_type,
6886 Nom("uscalar, structural"),
6887 moy_li, moy_hi, moy_mi,
6888 moy_hihi, moy_mimi,
6889 moy_hili, moy_mili,
6890 moy_mihi,
6891 velocity, delta_z,
6892 constante_modele);
6893 if (struct_reconnu)
6894 {
6895 for (int j=0 ; j<3 ; j++)
6896 {
6897 const bool flag_face = (j==2);
6898 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_vector[j]);
6899 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_filtre_vector[j]);
6900 }
6901 }
6902
6903 if (vectorial_struct)
6904 {
6905 Nom struct_dynamic_type = structural_uscalar_dynamic_type.getPrefix("vectorial");
6906 for (int j=0 ; j<3 ; j++)
6907 {
6908 const bool reconnu = calculer_constante_modele(struct_dynamic_type,
6909 Nom("uscalar, structural, vectorial, j= ") + Nom(j),
6910 li[j], hi[j], mi[j],
6911 hihi[j], mimi[j],
6912 hili[j], mili[j],
6913 mihi[j],
6914 velocity, delta_z,
6915 constante_modele);
6916 if (reconnu)
6917 {
6918 const bool flag_face = (j==2);
6919 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_vector[j]);
6920 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_filtre_vector[j]);
6921 }
6922 else
6923 {
6924 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6925 Process::exit();
6926 }
6927 }
6928 }
6929
6930 const bool twopass_visc = turbulent_viscosity_dynamic_type.finit_par("_twopass");
6931 const bool twopass_struct = structural_uscalar_dynamic_type.finit_par("_twopass");
6932 if (twopass_visc || twopass_struct)
6933 {
6934 if (!turbulent_viscosity)
6935 {
6936 Cerr << "Erreur : On ne devrait pas pouvoir rentrer dans une evaluation dynamique de la constante de type 'lillymixtedynamic' en ayant pas de viscosite turbulente" << finl;
6937 Process::exit();
6938 }
6939 if (!structural_uscalar)
6940 {
6941 Cerr << "Erreur : On ne devrait pas pouvoir rentrer dans une evaluation dynamique de la constante de type 'lillymixtedynamic' en ayant pas de modele structurel" << finl;
6942 Process::exit();
6943 }
6944
6945 Nom visc_dynamic_type;
6946 Nom struct_dynamic_type;
6947 if (twopass_visc)
6948 {
6949 Cout << "Second pass, dynamic correction of constant: uscalar, viscosity" << finl;
6950 visc_dynamic_type = turbulent_viscosity_dynamic_type.getPrefix("_twopass");
6951 struct_dynamic_type = Nom("not_dynamic");
6952 }
6953 else
6954 {
6955 Cout << "Second pass, dynamic correction of constant: uscalar, structural" << finl;
6956 visc_dynamic_type = Nom("not_dynamic");
6957 struct_dynamic_type = structural_uscalar_dynamic_type.getPrefix("_twopass");
6958 }
6959
6960 modification_modele_dynamic_uscalar_scalar(anisotropic,
6961 visc_dynamic_type,
6962 struct_dynamic_type,
6963 velocity, velocity_filtre,
6964 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
6965 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6966 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6967 kernel, tmp_b, tmp_a,
6968 constante_modele, ml,
6969 turbulent_viscosity, turbulent_mu, turbulent_mu_filtre,
6970 structural_uscalar, structural_uscalar_vector, structural_uscalar_filtre_vector);
6971 }
6972
6973 if ((!visc_reconnu) && (!struct_reconnu) && (!vectorial_struct) && (!twopass_visc) && (!twopass_struct))
6974 {
6975 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6976 Process::exit();
6977 }
6978 }
6979}
6980
6981template<class T>
6982void modification_modele_dynamic_uscalar_vector(const bool anisotropic,
6983 const Nom& turbulent_viscosity_dynamic_type,
6984 const Nom& structural_uscalar_dynamic_type,
6985 const IJK_Field_vector3_double& velocity,
6986 const IJK_Field_vector3_double& velocity_filtre,
6987 const IJK_Field_double& scalar,
6988 const IJK_Field_double& scalar_filtre,
6989 double scalar_kmin, double scalar_kmax,
6990 const ArrOfDouble_with_ghost& delta_z,
6991 const double facteur_delta_x,
6992 const double facteur_delta_y,
6993 const ArrOfDouble_with_ghost& delta_z_pour_delta,
6994 const double facteur_delta_filtre_x,
6995 const double facteur_delta_filtre_y,
6996 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
6997 T& kernel,
7000 ArrOfDouble_with_ghost& constante_modele,
7002 const int turbulent_viscosity,
7003 IJK_Field_vector3_double& turbulent_mu_vector,
7004 IJK_Field_vector3_double& turbulent_mu_filtre_vector,
7005 const int structural_uscalar,
7006 IJK_Field_vector3_double& structural_uscalar_vector,
7007 IJK_Field_vector3_double& structural_uscalar_filtre_vector)
7008{
7009 IJK_Field_double& turbulent_mu_x = turbulent_mu_vector[0];
7010 IJK_Field_double& turbulent_mu_y = turbulent_mu_vector[1];
7011 IJK_Field_double& turbulent_mu_z = turbulent_mu_vector[2];
7012
7013 IJK_Field_double& turbulent_mu_filtre_x = turbulent_mu_filtre_vector[0];
7014 IJK_Field_double& turbulent_mu_filtre_y = turbulent_mu_filtre_vector[1];
7015 IJK_Field_double& turbulent_mu_filtre_z = turbulent_mu_filtre_vector[2];
7016
7017 if ( turbulent_viscosity_dynamic_type == Nom("not_dynamic")
7018 && structural_uscalar_dynamic_type == Nom("not_dynamic") )
7019 {
7020 // do nothing
7021 }
7022 else
7023 {
7024 int ghost_size_filter, ghost_size_turbulent_mu, ghost_size_structural_uu;
7025 if (turbulent_viscosity)
7026 {
7027 for (int j=0 ; j<3 ; j++)
7028 {
7029 ghost_size_filter = 1 + kernel->ghost_size();
7030 ghost_size_turbulent_mu = max((int) 2, ghost_size_filter);
7031 turbulent_mu_vector[j].echange_espace_virtuel(ghost_size_turbulent_mu);
7032 turbulent_mu_filtre_vector[j].echange_espace_virtuel(2);
7033 }
7034 }
7035
7036 if (structural_uscalar)
7037 {
7038 for (int j=0 ; j<3 ; j++)
7039 {
7040 ghost_size_filter = 1 + kernel->ghost_size();
7041 ghost_size_structural_uu = max((int) 2, ghost_size_filter);
7042 structural_uscalar_vector[j].echange_espace_virtuel(ghost_size_structural_uu);
7043 structural_uscalar_filtre_vector[j].echange_espace_virtuel(2);
7044 }
7045 }
7046
7047 const bool vectorial_visc = turbulent_viscosity_dynamic_type.finit_par("vectorial");
7048 const bool vectorial_struct = structural_uscalar_dynamic_type.finit_par("vectorial");
7049 const bool vectorial = vectorial_visc || vectorial_struct;
7050
7051 calculer_ml_dynamic_uscalar_vector(anisotropic, vectorial,
7052 velocity, velocity_filtre,
7053 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
7054 turbulent_viscosity,
7055 turbulent_mu_x,
7056 turbulent_mu_y,
7057 turbulent_mu_z,
7058 turbulent_mu_filtre_x,
7059 turbulent_mu_filtre_y,
7060 turbulent_mu_filtre_z,
7061 structural_uscalar,
7062 structural_uscalar_vector,
7063 structural_uscalar_filtre_vector,
7064 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
7065 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
7066 kernel, tmp_b, tmp_a,
7067 ml);
7068
7069 FixedVector<ArrOfDouble, 7>& li = ml[0];
7070 FixedVector<ArrOfDouble, 7>& mi = ml[1];
7071 FixedVector<ArrOfDouble, 7>& hi = ml[2];
7072 FixedVector<ArrOfDouble, 7>& mimi = ml[3];
7073 FixedVector<ArrOfDouble, 7>& hihi = ml[4];
7074 FixedVector<ArrOfDouble, 7>& mili = ml[5];
7075 FixedVector<ArrOfDouble, 7>& hili = ml[6];
7076 FixedVector<ArrOfDouble, 7>& mihi = ml[7];
7077
7078 ArrOfDouble& moy_li = ml[0][6];
7079 ArrOfDouble& moy_mi = ml[1][6];
7080 ArrOfDouble& moy_hi = ml[2][6];
7081 ArrOfDouble& moy_mimi = ml[3][6];
7082 ArrOfDouble& moy_hihi = ml[4][6];
7083 ArrOfDouble& moy_mili = ml[5][6];
7084 ArrOfDouble& moy_hili = ml[6][6];
7085 ArrOfDouble& moy_mihi = ml[7][6];
7086
7087 const bool visc_reconnu = calculer_constante_modele(turbulent_viscosity_dynamic_type,
7088 Nom("uscalar, viscosity"),
7089 moy_li, moy_mi, moy_hi,
7090 moy_mimi, moy_hihi,
7091 moy_mili, moy_hili,
7092 moy_mihi,
7093 velocity, delta_z,
7094 constante_modele);
7095 if (visc_reconnu)
7096 {
7097 for (int j=0 ; j<3 ; j++)
7098 {
7099 const bool flag_face = false;
7100 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_vector[j]);
7101 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_filtre_vector[j]);
7102 }
7103 }
7104
7105 const bool struct_reconnu = calculer_constante_modele(structural_uscalar_dynamic_type,
7106 Nom("uscalar, structural"),
7107 moy_li, moy_hi, moy_mi,
7108 moy_hihi, moy_mimi,
7109 moy_hili, moy_mili,
7110 moy_mihi,
7111 velocity, delta_z,
7112 constante_modele);
7113 if (struct_reconnu)
7114 {
7115 for (int j=0 ; j<3 ; j++)
7116 {
7117 const bool flag_face = (j==2);
7118 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_vector[j]);
7119 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_filtre_vector[j]);
7120 }
7121 }
7122
7123 if (vectorial_visc)
7124 {
7125 Nom visc_dynamic_type = turbulent_viscosity_dynamic_type.getPrefix("vectorial");
7126 for (int j=0 ; j<3 ; j++)
7127 {
7128 const bool reconnu = calculer_constante_modele(visc_dynamic_type,
7129 Nom("uscalar, viscosity, vectorial, j= ") + Nom(j),
7130 li[j], mi[j], hi[j],
7131 mimi[j], hihi[j],
7132 mili[j], hili[j],
7133 mihi[j],
7134 velocity, delta_z,
7135 constante_modele);
7136 if (reconnu)
7137 {
7138 const bool flag_face = false;
7139 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_vector[j]);
7140 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_filtre_vector[j]);
7141 }
7142 else
7143 {
7144 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
7145 Process::exit();
7146 }
7147 }
7148 }
7149
7150 if (vectorial_struct)
7151 {
7152 Nom struct_dynamic_type = structural_uscalar_dynamic_type.getPrefix("vectorial");
7153 for (int j=0 ; j<3 ; j++)
7154 {
7155 const bool reconnu = calculer_constante_modele(struct_dynamic_type,
7156 Nom("uscalar, structural, vectorial, j= ") + Nom(j),
7157 li[j], hi[j], mi[j],
7158 hihi[j], mimi[j],
7159 hili[j], mili[j],
7160 mihi[j],
7161 velocity, delta_z,
7162 constante_modele);
7163 if (reconnu)
7164 {
7165 const bool flag_face = (j==2);
7166 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_vector[j]);
7167 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_filtre_vector[j]);
7168 }
7169 else
7170 {
7171 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
7172 Process::exit();
7173 }
7174 }
7175 }
7176
7177 const bool twopass_visc = turbulent_viscosity_dynamic_type.finit_par("_twopass");
7178 const bool twopass_struct = structural_uscalar_dynamic_type.finit_par("_twopass");
7179 if (twopass_visc || twopass_struct)
7180 {
7181 if (!turbulent_viscosity)
7182 {
7183 Cerr << "Erreur : On ne devrait pas pouvoir rentrer dans une evaluation dynamique de la constante de type 'lillymixtedynamic' en ayant pas de viscosite turbulente" << finl;
7184 Process::exit();
7185 }
7186 if (!structural_uscalar)
7187 {
7188 Cerr << "Erreur : On ne devrait pas pouvoir rentrer dans une evaluation dynamique de la constante de type 'lillymixtedynamic' en ayant pas de modele structurel" << finl;
7189 Process::exit();
7190 }
7191
7192 Nom visc_dynamic_type;
7193 Nom struct_dynamic_type;
7194 if (twopass_visc)
7195 {
7196 Cout << "Second pass, dynamic correction of constant: uscalar, viscosity" << finl;
7197 visc_dynamic_type = turbulent_viscosity_dynamic_type.getPrefix("_twopass");
7198 struct_dynamic_type = Nom("not_dynamic");
7199 }
7200 else
7201 {
7202 Cout << "Second pass, dynamic correction of constant: uscalar, structural" << finl;
7203 visc_dynamic_type = Nom("not_dynamic");
7204 struct_dynamic_type = structural_uscalar_dynamic_type.getPrefix("_twopass");
7205 }
7206
7207 modification_modele_dynamic_uscalar_vector(anisotropic,
7208 visc_dynamic_type,
7209 struct_dynamic_type,
7210 velocity, velocity_filtre,
7211 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
7212 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
7213 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
7214 kernel, tmp_b, tmp_a,
7215 constante_modele, ml,
7216 turbulent_viscosity, turbulent_mu_vector, turbulent_mu_filtre_vector,
7217 structural_uscalar, structural_uscalar_vector, structural_uscalar_filtre_vector);
7218 }
7219
7220 if ((!visc_reconnu) && (!struct_reconnu) && (!vectorial_visc) && (!vectorial_struct) && (!twopass_visc) && (!twopass_struct))
7221 {
7222 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
7223 Process::exit();
7224 }
7225 }
7226}
7227
7228
7230{
7231 //M.D. 12-02-2019 ajout possibilite puit
7232 puit_ = 0.;
7233 fichier_reprise_rho_ = "??";
7237 expression_vitesse_initiale_.dimensionner(3);
7239 check_divergence_ = false;
7240 Param param(que_suis_je());
7241 Nom ijk_splitting_name;
7242 reprise_spectrale_ = false;
7243 dt_post_ = 2000000000; // jamais de post-traitement
7244 timestep_facsec_ = 1.;
7245 timestep_max_ = 1.;
7246 timestep_ = 1.e28;
7247 old_timestep_= 1.e28; // Evite la division par zero
7248 current_time_ = 0.;
7249 dt_sauvegarde_ = 2000000000; // jamais
7250 dt_raw_data_ = 2000000000; // jamais
7251 dt_stats_ = 2000000000; // jamais
7253 nom_sauvegarde_ = nom_du_cas() + ".sauv";
7254 nom_reprise_ = "??"; // pas de reprise
7257 calcul_2d_ = 0;
7259 // F.A 3/03/14 modification source
7260 dump_factor_ = 10./3.;
7261 // F.A 17/03/14 ajout diffs et convections negligeables
7266 // DD,2016-10-14: ajout disable_solveur_poisson_
7268 // F.A dt_start ajout possibilite de dt_start
7269 dt_start_ = 1.e28; // tres grand
7270
7271 //oscillating boundary condition
7274
7275 /* amplitude_oscillating_boundary_2_=0; */
7276 /* frequency_oscillating_boundary_2_=0; */
7277 /* flag_oscillating_boundary_2_=false; */
7278 /* statistiques spectrales */
7279 dt_post_spectral_ = -1;
7280 Nom post_splitting_name = "??";
7281
7282 /* sauvegarde des lata par plan */
7284
7285 // DD,2016-28-01: statistiques a partir de fichiers lata uniquement
7292
7293 // DD,2016-06-15: changement des pas de temps de stabilite,
7294 old_dtstab_ = false;
7295
7296 debit_cible_=0;
7297 aim_t_bulk_=-1;
7298 dump_factor_2_=3./100.;
7299
7300 convection_rho_amont_ = false;
7303
7307
7312
7316 Re_tau_fr_=1.;
7317 Re_tau_ch_=1.;
7318 pond_fr_=0.;
7319 pond_ch_=0.;
7321
7322 // DD,2017-04-27: diffusion modifie en vue de l'ajout de modeles
7323 type_velocity_diffusion_ = Nom("full");
7324
7327 turbulent_viscosity_dynamic_type_ = Nom("not_dynamic");
7331 turbulent_viscosity_ = false;
7332
7339 turbulent_diffusivity_ = false;
7340
7341 structural_uu_model_ = Nom("none");
7342 structural_uu_dynamic_type_ = Nom("not_dynamic");
7344 structural_uu_tensor_coefficients_.resize_array(6);
7346 structural_uu_ = false;
7347
7349 structural_uscalar_dynamic_type_ = Nom("not_dynamic");
7353 structural_uscalar_ = false;
7354
7355 filter_kernel_name_ = Nom("none");
7361
7363 Nom geom_name_pour_delta = Nom("__identique_au_maillage__");
7364 formulation_velocity_ = false;
7365 formulation_favre_ = false;
7366
7367 param.ajouter("ijk_splitting", &ijk_splitting_name, Param::REQUIRED);
7368 param.ajouter("tinit", &current_time_);
7369 param.ajouter("timestep", &timestep_max_, Param::REQUIRED);
7370 param.ajouter("timestep_facsec", &timestep_facsec_);
7371 param.ajouter("dt_start", &dt_start_);
7372 param.ajouter("nb_pas_dt_max", &nb_timesteps_, Param::REQUIRED);
7373 param.ajouter("multigrid_solver", &poisson_solver_, Param::REQUIRED);
7374 param.ajouter_flag("check_divergence", &check_divergence_);
7375
7376 param.ajouter("t_paroi_impose_kmin", &T_paroi_impose_kmin_, Param::REQUIRED);
7377 param.ajouter("t_paroi_impose_kmax", &T_paroi_impose_kmax_, Param::REQUIRED);
7378
7379 param.ajouter("p_thermo_init", &P_thermodynamique_, Param::REQUIRED);
7380 param.ajouter("puit", &puit_);
7381 param.ajouter("smoothing_center_fr", &smoothing_center_fr_);
7382 param.ajouter("smoothing_factor_fr", &smoothing_factor_fr_);
7383 param.ajouter("Re_tau_fr", &Re_tau_fr_);
7384 param.ajouter("Re_tau_ch", &Re_tau_ch_);
7385 param.ajouter("ponderation_fr", &pond_fr_);
7386 param.ajouter("ponderation_ch", &pond_ch_);
7387 param.ajouter("center_constant", &center_constant_);
7388 param.ajouter("cp", &Cp_gaz_, Param::REQUIRED);
7389 param.ajouter("gamma", &gamma_, Param::REQUIRED);
7390
7391
7392 param.ajouter("expression_vx_init", &expression_vitesse_initiale_[0]);
7393 param.ajouter("expression_vy_init", &expression_vitesse_initiale_[1]);
7394 param.ajouter("expression_vz_init", &expression_vitesse_initiale_[2]);
7395 param.ajouter("expression_t_init", &expression_temperature_initiale_);
7396 param.ajouter("fichier_reprise_vitesse", &fichier_reprise_vitesse_);
7397 param.ajouter("fichier_reprise_rho", &fichier_reprise_rho_);
7398 param.ajouter("timestep_reprise_vitesse", &timestep_reprise_vitesse_);
7399 param.ajouter("timestep_reprise_rho", &timestep_reprise_rho_);
7400
7401 // F.A on change la source utilisee
7402 param.ajouter("debit_massique", &debit_cible_);
7403 // Y.Z. forcing T^b by changing H_s (heat sink)
7404 param.ajouter("t_bulk", &aim_t_bulk_);
7405 param.ajouter("dump_factor_2", &dump_factor_2_);
7406
7407 param.ajouter_flag("convection_rho_amont", &convection_rho_amont_);
7408 param.ajouter_flag("convection_rho_centre2", &convection_rho_centre2_);
7409 param.ajouter_flag("convection_rho_centre4", &convection_rho_centre4_);
7410
7411 param.ajouter_flag("convection_velocity_amont", &convection_velocity_amont_);
7412 param.ajouter_flag("convection_velocity_quicksharp", &convection_velocity_quicksharp_);
7413 param.ajouter_flag("convection_velocity_centre2", &convection_velocity_centre2_);
7414
7415 param.ajouter_flag("variation_cste_modele_fonctionnel", &variation_cste_modele_fonctionnel_);
7416
7417 param.ajouter("dumping_factor", &dump_factor_);
7418
7419 // param.ajouter("terme_force_init", &terme_source_acceleration_, Param::REQUIRED);
7420 // param.ajouter("expression_derivee_force", &expression_derivee_acceleration_, Param::REQUIRED);
7421 param.ajouter("terme_source_acceleration_constant", &terme_source_acceleration_constant_);
7422
7423 param.ajouter("dt_post", &dt_post_);
7424 param.ajouter("champs_a_postraiter", &liste_post_instantanes_);
7425
7426 param.ajouter("dt_sauvegarde", &dt_sauvegarde_);
7427 param.ajouter("dt_raw_data", &dt_raw_data_); /* Number of timesteps to save raw data */
7428 param.ajouter("dt_stats", &dt_stats_); /* Number of timesteps to save statistics */
7429 param.ajouter("dt_save_oscillating_cycle_raw_data", &dt_save_oscillating_cycle_raw_data_); /* Timestep at each to save the raw data */
7430
7431 param.ajouter_flag("postraiter_sous_pas_de_temps", &postraiter_sous_pas_de_temps_);
7432 param.ajouter("nom_sauvegarde", &nom_sauvegarde_);
7433 param.ajouter("nom_reprise", &nom_reprise_);
7434
7435 param.ajouter("t_debut_statistiques", &t_debut_statistiques_);
7436
7437 /* stats spectrales */
7438 param.ajouter("dt_post_spectral", &dt_post_spectral_);
7439 param.ajouter("spectral_splitting", &post_splitting_name);
7440 param.ajouter_flag("reprise_spectrale", &reprise_spectrale_);
7441 /* -------------------- */
7442
7443 /* sauvegarde des lata par plan */
7444 param.ajouter("sauvegarde_splitting", &sauvegarde_splitting_name_);
7445
7446 param.ajouter_flag("calcul_2d", &calcul_2d_);
7447 param.ajouter("check_stop_file", &check_stop_file_);
7448 param.ajouter_flag("projection_initiale", &projection_initiale_demandee_);
7449
7450 // Ajout possibilite diffusion ou convection negligeable pour chaque equa (sauf celle de la chaleur !! ) !!
7451 param.ajouter_flag("convection_rho_negligeable", &conv_rho_negligeable_);
7452 param.ajouter_flag("convection_qdm_negligeable", &conv_qdm_negligeable_);
7453 param.ajouter_flag("diffusion_qdm_negligeable", &diff_qdm_negligeable_);
7454 param.ajouter_flag("diffusion_temp_negligeable", &diff_temp_negligeable_);
7455 // DD,2016-10-14: ajout disable_solveur_poisson_
7456 param.ajouter_flag("disable_solveur_poisson", &disable_solveur_poisson_);
7457
7458 // DD,2017-04-27: diffusion modifie en vue de l'ajout de modeles
7459 param.ajouter("type_velocity_diffusion", &type_velocity_diffusion_);
7460
7461 param.ajouter("large_eddy_simulation_formulation", &large_eddy_simulation_formulation_);
7462 param.ajouter("ijk_grid_geometry_pour_delta", &geom_name_pour_delta);
7463
7464 param.ajouter("type_velocity_turbulent_diffusion", &type_velocity_turbulent_diffusion_);
7465 param.ajouter("turbulent_viscosity_model", &turbulent_viscosity_model_);
7466 param.ajouter("turbulent_viscosity_dynamic_type", &turbulent_viscosity_dynamic_type_);
7467 param.ajouter("turbulent_viscosity_model_constant", &turbulent_viscosity_model_constant_);
7468 param.ajouter("turbulent_viscosity_tensor_coefficients", &turbulent_viscosity_tensor_coefficients_);
7469 param.ajouter_flag("turbulent_viscosity", &turbulent_viscosity_);
7470
7471 param.ajouter("type_scalar_turbulent_diffusion", &type_scalar_turbulent_diffusion_);
7472 param.ajouter("turbulent_diffusivity_model", &turbulent_diffusivity_model_);
7473 param.ajouter("turbulent_diffusivity_dynamic_type", &turbulent_diffusivity_dynamic_type_);
7474 param.ajouter("turbulent_diffusivity_model_constant", &turbulent_diffusivity_model_constant_);
7475 param.ajouter("turbulent_diffusivity_vector_coefficients", &turbulent_diffusivity_vector_coefficients_);
7476 param.ajouter_flag("turbulent_diffusivity", &turbulent_diffusivity_);
7477
7478 param.ajouter("structural_uu_model", &structural_uu_model_);
7479 param.ajouter("structural_uu_dynamic_type", &structural_uu_dynamic_type_);
7480 param.ajouter("structural_uu_model_constant", &structural_uu_model_constant_);
7481 param.ajouter("structural_uu_tensor_coefficients", &structural_uu_tensor_coefficients_);
7482 param.ajouter_flag("structural_uu", &structural_uu_);
7483
7484 param.ajouter("structural_uscalar_model", &structural_uscalar_model_);
7485 param.ajouter("structural_uscalar_dynamic_type", &structural_uscalar_dynamic_type_);
7486 param.ajouter("structural_uscalar_model_constant", &structural_uscalar_model_constant_);
7487 param.ajouter("structural_uscalar_vector_coefficients", &structural_uscalar_vector_coefficients_);
7488 param.ajouter_flag("structural_uscalar", &structural_uscalar_);
7489
7490 param.ajouter("filter_kernel_name", &filter_kernel_name_);
7491 param.ajouter_flag("filtrage_convection_qdm", &flag_filtrage_convection_qdm_);
7492 param.ajouter_flag("filtrage_turbulent_diffusion_qdm", &flag_filtrage_turbulent_diffusion_qdm_);
7493 param.ajouter_flag("filtrage_structural_diffusion_qdm", &flag_filtrage_structural_diffusion_qdm_);
7494 param.ajouter_flag("convection_qdm_sans_rho", &flag_convection_qdm_sans_rho_);
7495 param.ajouter_flag("convection_qdm_sans_divergence", &flag_convection_qdm_sans_divergence_);
7496
7497 // DD,2016-28-01: statistiques a partir de fichiers lata uniquement
7498 param.ajouter("statlata_namelist", &statlata_namelist_);
7499 param.ajouter_flag("sauvegarde_post_instantanes", &sauvegarde_post_instantanes_);
7500 param.ajouter_flag("lecture_post_instantanes", &lecture_post_instantanes_);
7501 param.ajouter_flag("lecture_post_instantanes_filtrer_u", &lecture_post_instantanes_filtrer_u_);
7502 param.ajouter_flag("lecture_post_instantanes_filtrer_rho", &lecture_post_instantanes_filtrer_rho_);
7503 param.ajouter_flag("lecture_post_instantanes_filtrer_p", &lecture_post_instantanes_filtrer_p_);
7504 param.ajouter_flag("lecture_post_instantanes_filtrer_tous", &lecture_post_instantanes_filtrer_tous_);
7505 param.ajouter("compteur_post_instantanes", &compteur_post_instantanes_);
7506
7507 // DD,2016-06-15: changement des pas de temps de stabilite,
7508 param.ajouter_flag("old_dtstab", &old_dtstab_);
7509
7510 // Oscillating boundary condition expression
7511 // param.ajouter("expression_oscillating_boundary", &expression_oscillating_boundary);
7512 param.ajouter("amplitude_oscillating_boundary", &amplitude_oscillating_boundary_);
7513 param.ajouter("frequency_oscillating_boundary", &frequency_oscillating_boundary_);
7514
7515 /* param.ajouter("amplitude_oscillating_boundary_2", &amplitude_oscillating_boundary_2_); */
7516 /* param.ajouter("frequency_oscillating_boundary_2", &frequency_oscillating_boundary_2_); */
7517
7518
7519 param.lire_avec_accolades(is);
7520
7521 // Recuperation des donnees de maillage
7522 domaine_ = ref_cast(Domaine_IJK, Interprete_bloc::objet_global(ijk_splitting_name));
7523 // Initialisation de delta_z_local_
7524 domaine_.get_local_mesh_delta(DIRECTION_K, 2 /* ghost cells */, delta_z_local_);
7525
7526 if (geom_name_pour_delta == Nom("__identique_au_maillage__"))
7527 {
7528 facteur_delta_x_ = 1.;
7529 facteur_delta_y_ = 1.;
7531 }
7532 else
7533 {
7534 Cerr << "Lecture de la taille du filtre depuis le Domaine_IJK " << geom_name_pour_delta << "." << finl;
7535 Domaine_IJK geom_pour_delta = ref_cast(Domaine_IJK, Interprete_bloc::objet_global(geom_name_pour_delta));
7536 const double dx_maillage = domaine_.get_constant_delta(DIRECTION_I);
7537 const double dy_maillage = domaine_.get_constant_delta(DIRECTION_J);
7538 const double dx_pour_delta = geom_pour_delta.get_constant_delta(DIRECTION_I);
7539 const double dy_pour_delta = geom_pour_delta.get_constant_delta(DIRECTION_J);
7540 facteur_delta_x_ = dx_pour_delta/dx_maillage;
7541 facteur_delta_y_ = dy_pour_delta/dy_maillage;
7542
7543 calculer_delta_z_pour_delta(domaine_, geom_pour_delta, 2, delta_z_local_pour_delta_);
7544 for (int i=-2 ; i<domaine_.get_nb_elem_local(DIRECTION_K)+2 ; i++)
7545 {
7546 Cerr << i << " " << delta_z_local_[i] << " " << delta_z_local_pour_delta_[i] << finl;
7547 }
7548 }
7549
7552 {
7553 Cerr << " Error: (Inconsistent parameters) The keyword DEBIT_MASSIQUE cannot be used with TERME_SOURCE_ACCELERATION_CONdoubleANT." << finl;
7554 Process::exit();
7555 }
7557 {
7558 Cerr << "Simulation en mode : TERME SOURCE IMPOSE." << finl;
7559 }
7560 else
7561 {
7562 Cerr << "Simulation en mode : DEBIT IMPOSE." << finl;
7563 }
7564
7565 if ( (post_splitting_name != "??") || ( dt_post_spectral_ != -1 ) )
7566 {
7567 if ( dt_post_spectral_ <= 0 )
7568 {
7569 Cerr << " You need to specify an dt_post_spectral X," <<
7570 " were X is the number of step between 2 post" << finl;
7571 Process::exit();
7572 }
7573 else if ( (post_splitting_name == "??") )
7574 {
7575 Cerr << " You need to specify an other splitting like : spectral_splitting post_splitting " << finl;
7576 Cerr << "in order to compute FFT on planes you must only split in z direction" << finl;
7577 Process::exit();
7578 }
7579 else
7580 {
7581#if defined(WITH_FFTW)
7582 post_splitting_ =ref_cast(Domaine_IJK, Interprete_bloc::objet_global(post_splitting_name));
7583
7584 const int decoupage_selon_x_ou_y = post_splitting_.get_nprocessor_per_direction(0)*post_splitting_.get_nprocessor_per_direction(1);
7585 if (decoupage_selon_x_ou_y > 1 )
7586 {
7587 Cerr << "In order to compute FFT on planes you must only split in z direction the spectral_splitting" << finl;
7588 Process::exit();
7589 }
7590#else
7591 Cerr << " Module FFTW desactive impossible de faire la FFT " << finl;
7592 Process::exit();
7593#endif
7594 }
7595 }
7596
7597 if (sauvegarde_splitting_name_ != "??")
7598 {
7600 const int decoupage_selon_x_ou_y = sauvegarde_splitting_.get_nprocessor_per_direction(0)*sauvegarde_splitting_.get_nprocessor_per_direction(1);
7601 // Modif Martin
7602 if (decoupage_selon_x_ou_y > 1 )
7603 {
7604 Cerr << "In order to save lata on planes you must only split in z direction the sauvegarde_splitting" << finl;
7605 Process::exit();
7606 }
7607 // Fin modif Martin
7608
7609 Cerr << "Initialisation de la sauvegarde des lata par plan" << finl;
7614 }
7615
7620 {
7621 Cerr << " Error: (Inconsistent parameters) The keyword LECTURE_POdouble_INdoubleANTANES_FILTRER_U, LECTURE_POdouble_INdoubleANTANES_FILTRER_RHO, LECTURE_POdouble_INdoubleANTANES_FILTRER_P and LECTURE_POdouble_INdoubleANTANES_FILTRER_TOUS cannot be used without the keyword LECTURE_POdouble_INdoubleANTANES." << finl;
7622 Process::exit();
7623 }
7624
7625 if (turbulent_viscosity_tensor_coefficients_.size_array() != 6)
7626 {
7627 Cerr << "Erreur: TURBULENT_VISCOSITY_TENSOR_COEFFICIENTS doit etre un vecteur de 6 composantes (xx, xy, xz, yy, yz, zz)." << finl;
7628 Process::exit();
7629 }
7630 if (turbulent_diffusivity_vector_coefficients_.size_array() != 3)
7631 {
7632 Cerr << "Erreur: TURBULENT_VISCOSITY_TENSOR_COEFFICIENTS doit etre un vecteur de 3 composantes (x, y, z)." << finl;
7633 Process::exit();
7634 }
7635 if (structural_uu_tensor_coefficients_.size_array() != 6)
7636 {
7637 Cerr << "Erreur: sTRUCTURAL_UU_TENSOR_COEFFICIENTS doit etre un vecteur de 6 composantes (xx, xy, xz, yy, yz, zz)." << finl;
7638 Process::exit();
7639 }
7640 if (structural_uscalar_vector_coefficients_.size_array() != 3)
7641 {
7642 Cerr << "Erreur: sTRUCTURAL_USCALAR_VECTOR_COEFFICIENTS doit etre un vecteur de 3 composantes (x, y, z)." << finl;
7643 Process::exit();
7644 }
7645
7646 if ( large_eddy_simulation_formulation_ == Nom("favre") )
7647 {
7648 formulation_favre_ = true;
7649 }
7650 else if ( large_eddy_simulation_formulation_ == Nom("velocity") )
7651 {
7652 formulation_velocity_ = true;
7653 }
7654
7655 // DD,2017-04-27: diffusion modifie en vue de l'ajout de modeles
7656 if ( large_eddy_simulation_formulation_ == Nom("none") )
7657 {
7659 {
7660 Cerr << "Error: (Inconsistent parameters) "
7661 << "The TURBULENT_VISCOSITY flag was activated but no large eddy simulation formulation was specified. "
7662 << "To specify a large eddy simulation formulation, you may use the keyword LARGE_EDDY_SIMULATION_FORMULATION with the parameters FAVRE, VELOCITY or NONE." << finl;
7663 Process::exit();
7664 }
7665 else if (turbulent_diffusivity_)
7666 {
7667 Cerr << "Error: (Inconsistent parameters) "
7668 << "The TURBULENT_DIFFUSIVITY flag was activated but no large eddy simulation formulation was specified. "
7669 << "To specify a large eddy simulation formulation, you may use the keyword LARGE_EDDY_SIMULATION_FORMULATION with the parameters FAVRE, VELOCITY or NONE." << finl;
7670 Process::exit();
7671 }
7672 else if (structural_uu_)
7673 {
7674 Cerr << "Error: (Inconsistent parameters) "
7675 << "The sTRUCTURAL_UU flag was activated but no large eddy simulation formulation was specified. "
7676 << "To specify a large eddy simulation formulation, you may use the keyword LARGE_EDDY_SIMULATION_FORMULATION with the parameters FAVRE, VELOCITY or NONE." << finl;
7677 Process::exit();
7678 }
7679 else if (structural_uscalar_)
7680 {
7681 Cerr << "Error: (Inconsistent parameters) "
7682 << "The sTRUCTURAL_USCALAR flag was activated but no large eddy simulation formulation was specified. "
7683 << "To specify a large eddy simulation formulation, you may use the keyword LARGE_EDDY_SIMULATION_FORMULATION with the parameters FAVRE, VELOCITY or NONE." << finl;
7684 Process::exit();
7685 }
7686 }
7687 else
7688 {
7690 {
7691 Cerr << "Error: (Inconsistent parameters) "
7692 << "A LARGE_EDDY_SIMULATION_FORMULATION was specified but neither the TURBULENT_VISCOSITY flag, the TURBULENT_DIFFUSIVITY flag, the sTRUCTURAL_UU flag nor the sTRUCTURAL_USCALAR flag have been activated. "
7693 << "" << finl;
7694 Process::exit();
7695 }
7696 }
7697
7699 {
7700 if ( type_velocity_turbulent_diffusion_ != Nom("none") )
7701 {
7702 Cerr << "Error: (Inconsistent parameters) "
7703 << "A velocity turbulent diffusion type was specified but the TURBULENT_VISCOSITY flag has not been activated. "
7704 << "" << finl;
7705 Process::exit();
7706 }
7707 else if ( turbulent_viscosity_model_ != Nom("none") )
7708 {
7709 Cerr << "Error: (Inconsistent parameters) "
7710 << "A subgrid viscosity model was specified but the TURBULENT_VISCOSITY flag has not been activated. "
7711 << "" << finl;
7712 Process::exit();
7713 }
7714 else if ( turbulent_viscosity_model_constant_ != -1 )
7715 {
7716 Cerr << "Error: (Inconsistent parameters) "
7717 << "A subgrid viscosity model constant was specified but the TURBULENT_VISCOSITY flag has not been activated. "
7718 << "" << finl;
7719 Process::exit();
7720 }
7721 }
7722 else
7723 {
7724 if ( type_velocity_turbulent_diffusion_ == Nom("none") )
7725 {
7726 Cerr << "Error: (Inconsistent parameters) "
7727 << "The TURBULENT_VISCOSITY flag expect a velocity turbulent diffusion type but no velocity turbulent diffusion type was specified. "
7728 << "To specify a velocity turbulent diffusion type, you may use the keyword TYPE_VELOCITY_TURBULENT_DIFFUSION with the parameters SIMPLE, SIMPLE_WITH_TRANSPOSE, FULL or NONE" << finl;
7729 Process::exit();
7730 }
7731 else if ( turbulent_viscosity_model_ == Nom("none") )
7732 {
7733 Cerr << "Error: (Inconsistent parameters) "
7734 << "The TURBULENT_VISCOSITY flag expect a subgrid viscosity model but no model was specified. "
7735 << "To specify a model, you may use the keyword TURBULENT_VISCOSITY_MODEL with the parameters CONdoubleANT, UNSRHO, SMAGORINSKY, VREMAN, SIGMA, WALE, AMD, AMD_COMP, AMDNOCLIP, AMDSCALAR, AMDSCALARNOCLIP, RDS, VSS, KOBAYASHI or NONE." << finl;
7736 Process::exit();
7737 }
7738 else if ( turbulent_viscosity_model_constant_ == -1 )
7739 {
7740 Cerr << "Error: (Inconsistent parameters) "
7741 << "The TURBULENT_VISCOSITY flag expect a subgrid viscosity model constant but no constant was specified. "
7742 << "To specify a constant, you may use the keyword TURBULENT_VISCOSITY_MODEL_CONdoubleANT." << finl;
7743 Process::exit();
7744 }
7745 }
7746
7748 {
7749 if ( type_scalar_turbulent_diffusion_ != Nom("none") )
7750 {
7751 Cerr << "Error: (Inconsistent parameters) "
7752 << "A scalar turbulent diffusion type was specified but the TURBULENT_DIFFUSIVITY flag has not been activated. "
7753 << "" << finl;
7754 Process::exit();
7755 }
7756 if ( turbulent_diffusivity_model_ != Nom("none") )
7757 {
7758 Cerr << "Error: (Inconsistent parameters) "
7759 << "A subgrid diffusivity model was specified but the TURBULENT_DIFFUSIVITY flag has not been activated. "
7760 << "" << finl;
7761 Process::exit();
7762 }
7764 {
7765 Cerr << "Error: (Inconsistent parameters) "
7766 << "A subgrid diffusivity model constant was specified but the TURBULENT_DIFFUSIVITY flag has not been activated. "
7767 << "" << finl;
7768 Process::exit();
7769 }
7770 }
7771 else
7772 {
7773 if ( type_scalar_turbulent_diffusion_ == Nom("none") )
7774 {
7775 Cerr << "Error: (Inconsistent parameters) "
7776 << "The TURBULENT_DIFFUSIVITY flag expect a scalar turbulent diffusion type but no scalar turbulent diffusion type was specified. "
7777 << "To specify a scalar turbulent diffusion type, you may use the keyword TYPE_SCALAR_TURBULENT_DIFFUSION with the parameters NORMAL, ANISOTROPIC or NONE" << finl;
7778 Process::exit();
7779 }
7780 if ( turbulent_diffusivity_model_ == Nom("none") )
7781 {
7782 Cerr << "Error: (Inconsistent parameters) "
7783 << "The TURBULENT_DIFFUSIVITY flag expect a subgrid diffusivity model but no model was specified. "
7784 << "To specify a model, you may use the keyword TURBULENT_DIFFUSIVITY_MODEL with the parameters CONdoubleANT, UNSRHO, SMAGORINSKY, VREMAN, SIGMA, WALE, AMD, AMD_COMP, AMDNOCLIP, AMDSCALAR, AMDSCALARNOCLIP, RDS, VSS, KOBAYASHI or NONE." << finl;
7785 Process::exit();
7786 }
7788 {
7789 Cerr << "Error: (Inconsistent parameters) "
7790 << "The TURBULENT_DIFFUSIVITY flag expect a subgrid diffusivity model constant but no constant was specified. "
7791 << "To specify a constant, you may use the keyword TURBULENT_DIFFUSIVITY_MODEL_CONdoubleANT." << finl;
7792 Process::exit();
7793 }
7794 }
7795
7796 if (!structural_uu_)
7797 {
7798 if ( structural_uu_model_ != Nom("none") )
7799 {
7800 Cerr << "Error: (Inconsistent parameters) "
7801 << "A structural model for uu was specified but the sTRUCTURAL_UU flag has not been activated. "
7802 << "" << finl;
7803 Process::exit();
7804 }
7805 else if ( structural_uu_model_constant_ != -1 )
7806 {
7807 Cerr << "Error: (Inconsistent parameters) "
7808 << "A structural model for uu constant was specified but the sTRUCTURAL_UU flag has not been activated. "
7809 << "" << finl;
7810 Process::exit();
7811 }
7812 }
7813 else
7814 {
7815 if ( structural_uu_model_ == Nom("none") )
7816 {
7817 Cerr << "Error: (Inconsistent parameters) "
7818 << "The sTRUCTURAL_UU flag expect a structural model but no model was specified. "
7819 << "To specify a model, you may use the keyword sTRUCTURAL_UU_MODEL with the parameters GRADIENT, GRADIENT_FILTRE, SU_LAPLACIEN_U, SIMILARITY or NONE." << finl;
7820 Process::exit();
7821 }
7822 else if ( structural_uu_model_constant_ == -1 )
7823 {
7824 Cerr << "Error: (Inconsistent parameters) "
7825 << "The sTRUCTURAL_UU flag expect a structural model constant but no constant was specified. "
7826 << "To specify a constant, you may use the keyword sTRUCTURAL_UU_MODEL_CONdoubleANT." << finl;
7827 Process::exit();
7828 }
7829 }
7830
7832 {
7833 if ( structural_uscalar_model_ != Nom("none") )
7834 {
7835 Cerr << "Error: (Inconsistent parameters) "
7836 << "A structural model for uscalar was specified but the sTRUCTURAL_USCALAR flag has not been activated. "
7837 << "" << finl;
7838 Process::exit();
7839 }
7841 {
7842 Cerr << "Error: (Inconsistent parameters) "
7843 << "A structural model for uscalar constant was specified but the sTRUCTURAL_USCALAR flag has not been activated. "
7844 << "" << finl;
7845 Process::exit();
7846 }
7847 }
7848 else
7849 {
7850 if ( structural_uscalar_model_ == Nom("none") )
7851 {
7852 Cerr << "Error: (Inconsistent parameters) "
7853 << "The sTRUCTURAL_USCALAR flag expect a subgrid diffusivity model but no model was specified. "
7854 << "To specify a model, you may use the keyword sTRUCTURAL_USCALAR_MODEL with the parameters GRADIENT, GRADIENT_FILTRE, SIMILARITY or NONE." << finl;
7855 Process::exit();
7856 }
7857 else if ( structural_uscalar_model_constant_ == -1 )
7858 {
7859 Cerr << "Error: (Inconsistent parameters) "
7860 << "The sTRUCTURAL_USCALAR flag expect a subgrid diffusivity model constant but no constant was specified. "
7861 << "To specify a constant, you may use the keyword sTRUCTURAL_USCALAR_MODEL_CONdoubleANT." << finl;
7862 Process::exit();
7863 }
7864 }
7865
7866 // Note :
7867 // 'dynamic_uu', 'dynamicglobal_uu', 'dynamic_urho', 'dynamicglobal_urho',
7868 // 'dynamic_ut' et 'dynamicglobal_ut' sont des options obsoletes
7869 // equivalentes a 'lilly' et 'lillyglobal'.
7870
7871 if (turbulent_viscosity_dynamic_type_ == Nom("dynamic_uu"))
7872 {
7874 }
7875 if (turbulent_viscosity_dynamic_type_ == Nom("dynamicglobal_uu"))
7876 {
7877 turbulent_viscosity_dynamic_type_ = Nom("lillyglobal");
7878 }
7879 if ( turbulent_diffusivity_dynamic_type_ == Nom("dynamic_urho")
7880 || turbulent_diffusivity_dynamic_type_ == Nom("dynamic_ut") )
7881 {
7883 }
7884 if ( turbulent_diffusivity_dynamic_type_ == Nom("dynamicglobal_urho")
7885 || turbulent_diffusivity_dynamic_type_ == Nom("dynamicglobal_ut") )
7886 {
7888 }
7889
7891 || (structural_uu_ && (structural_uu_model_ != Nom("gradient")) )
7892 || (structural_uscalar_ && (structural_uscalar_model_ != Nom("gradient")) )
7893 || (turbulent_viscosity_dynamic_type_ != Nom("not_dynamic"))
7894 || (turbulent_diffusivity_dynamic_type_ != Nom("not_dynamic"))
7895 || (structural_uu_dynamic_type_ != Nom("not_dynamic"))
7896 || (structural_uscalar_dynamic_type_ != Nom("not_dynamic"));
7899 || (turbulent_diffusivity_dynamic_type_ != Nom("not_dynamic"))
7900 || (turbulent_viscosity_dynamic_type_ != Nom("not_dynamic"))
7901 || (structural_uu_dynamic_type_ != Nom("not_dynamic"))
7902 || (structural_uscalar_dynamic_type_ != Nom("not_dynamic"));
7905 || (turbulent_viscosity_dynamic_type_ != Nom("not_dynamic"))
7906 || (turbulent_diffusivity_dynamic_type_ != Nom("not_dynamic"))
7907 || (structural_uu_dynamic_type_ != Nom("not_dynamic"))
7908 || (structural_uscalar_dynamic_type_ != Nom("not_dynamic"))
7909 );
7914
7915 flag_structural_uu_tmp_ = structural_uu_ && (structural_uu_model_ == Nom("gradient_filtre") || structural_uu_model_ == Nom("convection_filtre"));
7918
7919 flag_nu_anisotropic_ = ( (type_velocity_turbulent_diffusion_ == Nom("simple_anisotropic"))
7920 || (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose_anisotropic"))
7921 || (type_velocity_turbulent_diffusion_ == Nom("full_anisotropic")) );
7922 flag_nu_tensorial_ = ( turbulent_viscosity_dynamic_type_.finit_par("tensorial")
7923 || turbulent_viscosity_dynamic_type_.finit_par("tensorial_twopass")
7932 || turbulent_diffusivity_dynamic_type_.finit_par("vectorial_twopass")
7936
7937 // //3/03/14 changement de la source
7938 // // Preparation de l'expression derivee de l'acceleration
7939 // String2 tmpstring(expression_derivee_acceleration_);
7940 // parser_derivee_acceleration_.setString(tmpstring);
7941 // parser_derivee_acceleration_.setNbVar(3);
7942 // parser_derivee_acceleration_.addVar("force");
7943 // parser_derivee_acceleration_.addVar("v_moyen");
7944 // parser_derivee_acceleration_.addVar("rho_v_moyen");
7945 // parser_derivee_acceleration_.parseString();
7946 //
7947
7950 {
7951 Cerr <<
7952 "The boundary is oscillating at amplitude "
7954 << " and frequency "
7956 << finl;
7958 }
7959
7960
7961 flag_t_bulk_forced_=false;
7962 if(aim_t_bulk_ != -1)
7963 {
7964 Cerr <<
7965 "Simulation in forced T bulk mode with value "
7966 << aim_t_bulk_
7967 << " K"
7968 << finl;
7969 flag_t_bulk_forced_ = true;
7970 }
7971
7972 if (dt_post_ == 2000000000 && dt_raw_data_ == 2000000000 && dt_stats_ == 2000000000 && dt_save_oscillating_cycle_raw_data_== 0)
7973 dt_post_ = 100;
7974
7975 if (nom_reprise_ != "??")
7977
7978 dt_save_cycle_ = 2000000000;
7980 {
7982 dt_save_cycle_ = 0;
7985 Cerr << "Dt save cycle: " << dt_save_cycle_ << "dt_save_oscillating_cycle_raw_data_: " << dt_save_oscillating_cycle_raw_data_;
7986 }
7987
7988 run();
7989 return is;
7990}
7991
7992// Attention, il faut 1 epaisseur de joint valide sur rho
7993static void calculer_debit(const IJK_Field_double& vx, const IJK_Field_double& rho, const ArrOfDouble_with_ghost& delta_z, const double longeur_Lx_tot, double& debit)
7994{
7995 const int ni = vx.ni();
7996 const int nj = vx.nj();
7997 const int nk = vx.nk();
7998 const double dx = vx.get_domaine().get_constant_delta(DIRECTION_I);
7999 const double dy = vx.get_domaine().get_constant_delta(DIRECTION_J);
8000
8001 debit = 0.;
8002 // Ponderation par le volume des mailles pour traiter le cas ou le maillage est irregulier en k
8003 for (int k = 0; k < nk; k++)
8004 {
8005 double somme_rhov = 0;
8006 for (int j = 0; j < nj; j++)
8007 {
8008 for (int i = 0; i < ni; i++)
8009 {
8010 double rhov = vx(i,j,k) * (rho(i-1,j,k) + rho(i,j,k)) * 0.5; // rho moyen sur la face
8011 somme_rhov += rhov;
8012 //Cerr << "somme " << somme_rhov << " i " << i << " j " << j << " k " << k << " vx " << vx(i,j,k) << " rho -1 " << rho(i-1,j,k) << " rho " << rho(i,j,k) << finl;
8013 }
8014 }
8015 // volume d'une maille de ce plan
8016 double volume = dx * dy * delta_z[k];
8017 debit += volume * somme_rhov;
8018 }
8019 // somme sur tous les processeurs. On regroupe toutes les communications en un seul appel:
8020 ArrOfDouble tmp(1);
8021 tmp[0] = debit;
8023
8024 // ici on calcule la valeur moyenne sur le volume V = Lx * Ly * Lz et on multiplie par la surface debitante S = Ly * Lz
8025// on doit donc juste diviser par Lx
8026 debit = tmp[0] / longeur_Lx_tot;
8027}
8028
8029// Methode appelee dans run().
8030// Intialise toutes les variables et champs pour le demarrage du calcul
8031// (soit avec des valeurs du jdd, soit avec des valeurs lues dans le fichier de reprise)
8033{
8034 Cout << "DNS_QC_double::initialise()" << finl;
8035
8036 // precision de sortie du Cerr !!!
8037 Cerr.setf(ios::scientific);
8038 Cerr.precision(20);
8039 Cout.setf(ios::scientific);
8040 Cout.precision(20);
8041
8042 Cout << "precision de sortie du out et du err modifier" << finl;
8043
8044 // calcul de la constante specifique du gaz
8046 Cout << " Cp_gaz = " << Cp_gaz_
8047 << "\n constante_specifique_gaz = " << constante_specifique_gaz_ << finl;
8048
8049 // calcule les valeurs aux parois
8050 const double Pth_sur_R = P_thermodynamique_ / constante_specifique_gaz_;
8053 lambda_de_t_paroi_kmin_ = calculer_lambda_air(T_paroi_impose_kmin_);
8054 lambda_de_t_paroi_kmax_ = calculer_lambda_air(T_paroi_impose_kmax_);
8055 Cout << " T_paroi_impose_kmin_ = " << T_paroi_impose_kmin_
8056 << "\n T_paroi_impose_kmax_ = " << T_paroi_impose_kmax_
8057 << "\n lambda_de_t_paroi_kmin = " << lambda_de_t_paroi_kmin_
8058 << "\n lambda_de_t_paroi_kmax = " << lambda_de_t_paroi_kmax_ << finl;
8059
8060 // calcul du volume total du domaine
8061 const Nom& geom_name = domaine_.le_nom();
8062
8063 int Nx_tot = domaine_.get_nb_elem_tot(0) + 1;
8064 int Ny_tot = domaine_.get_nb_elem_tot(1) + 1;
8065 int Nz_tot = domaine_.get_nb_elem_tot(2) + 1;
8066 Lx_tot_ = domaine_.get_node_coordinates(0)[Nx_tot - 1] - domaine_.get_origin(0);
8067 Ly_tot_ = domaine_.get_node_coordinates(1)[Ny_tot - 1] - domaine_.get_origin(1);
8068 Lz_tot_ = domaine_.get_node_coordinates(2)[Nz_tot - 1] - domaine_.get_origin(2);
8070 Cout << " Volume total domaine = " << volume_total_domaine_ << finl;
8071
8072 if ( fichier_reprise_rho_ == "??" ) // si on ne fait pas une reprise on initialise T et rho suivant une methode
8073 {
8074 Cout << "Initialisation temperature, expression = " << expression_temperature_initiale_ << finl;
8076 // Calcul de rho_ fonction de la temperature:
8077 const int nk = temperature_.nk();
8078 const int nj = temperature_.nj();
8079 const int ni = temperature_.ni();
8080 for (int k = 0; k < nk; k++ )
8081 {
8082 for (int j = 0; j < nj; j++)
8083 {
8084 for (int i = 0; i < ni; i++)
8085 {
8086 double t = temperature_(i,j,k);
8087 rho_(i,j,k) = Pth_sur_R / t;
8088 }
8089 }
8090 }
8091 }
8092 else
8093 {
8094 Cout << "Lecture rho initial dans fichier " << fichier_reprise_rho_ << " timestep= " << timestep_reprise_rho_ << finl;
8095 lire_dans_lata(fichier_reprise_rho_, timestep_reprise_rho_, geom_name, "RHO", rho_);
8096 }
8097
8098 if (fichier_reprise_vitesse_ == "??") // si on ne fait pas une reprise on initialise V
8099 {
8100 if (expression_vitesse_initiale_.size() != 3)
8101 {
8102 Cerr << "Erreur dans l'initialisation: la vitesse initiale doit etre fournie avec trois expressions" << finl;
8103 Process::exit();
8104 }
8105 Cout << "Initialisation vitesse \nvx = " << expression_vitesse_initiale_[0]
8106 << "\nvy = " << expression_vitesse_initiale_[1]
8107 << "\nvz = " << expression_vitesse_initiale_[2] << finl;
8108 for (int i = 0; i < 3; i++)
8109 set_field_data(velocity_[i], expression_vitesse_initiale_[i]);
8110 }
8111 else
8112 {
8113 Cout << "Lecture vitesse initiale dans fichier " << fichier_reprise_vitesse_ << " timestep= " << timestep_reprise_vitesse_ << finl;
8114 lire_dans_lata(fichier_reprise_vitesse_, timestep_reprise_vitesse_, geom_name, "VELOCITY",
8115 velocity_[0], velocity_[1], velocity_[2]); // fonction qui lit un champ a partir d'un lata .
8116 }
8117
8118 // initialise temperature, lambda et mu
8119 // (on a besoin de mu(rho) initial pour l'operateur diffusion, voir rk3_sub_step()
8120 rho_.echange_espace_virtuel(1); // Nous avons besoin d'avoir rho a jour aux bord pour calculer le joints de mu et lambda !!
8122
8123 // statistiques...
8124 Cout << "Initialisation des statistiques. T_debut_statistiques=" << t_debut_statistiques_ << finl;
8126
8127 if ( dt_post_spectral_ > 0 ) // si on a un post traitement spectral
8128 {
8129 if (!statistiques_.is_converge())
8130 {
8131 Cerr << " les stats ne sont pas converger pas de productions spectrale allowed." << finl;
8132 Process::exit();
8133 }
8134
8135 partie_fourier_.initialize(domaine_ /* maillage de simu */
8136 ,post_splitting_ /* maillage de post traitement */
8137 ,statistiques_.vitesse_moyenne() /* vitesse moyenne utilisee dans les stats standart */
8138 ,statistiques_.masse_volumique_moyenne() /* masse volumique moyenne utilisee dans les stats standart */
8139 ,statistiques_.viscosite_cinematique_moyenne() /* viscosite cinematique moyenne utilisee dans les stats standart */
8143 }
8144
8145// pour source :
8147 if (debit_actuel_<0)
8148 {
8149 calculer_debit(velocity_[0], rho_, delta_z_local_, Lx_tot_, debit_actuel_);
8151 Cerr<< "debit "<<debit_actuel_<<finl;
8152 }
8153
8156}
8157
8158static void force_zero_normal_velocity_on_walls(IJK_Field_double& vz)
8159{
8160 const int nj = vz.nj();
8161 const int ni = vz.ni();
8162 const int kmin = vz.get_domaine().get_offset_local(DIRECTION_K);
8163 const int nktot = vz.get_domaine().get_nb_items_global(Domaine_IJK::FACES_K, DIRECTION_K);
8164 if (kmin == 0)
8165 {
8166 for (int j = 0; j < nj; j++)
8167 {
8168 for (int i = 0; i < ni; i++)
8169 {
8170 vz(i,j,0) = 0.;
8171 }
8172 }
8173 }
8174 if (kmin + vz.nk() == nktot)
8175 {
8176 const int k = vz.nk()-1;
8177 for (int j = 0; j < nj; j++)
8178 {
8179 for (int i = 0; i < ni; i++)
8180 {
8181 vz(i,j,k) = 0.;
8182 }
8183 }
8184 }
8185}
8186
8187static double calculer_dtstab_diffusion_temperature_local(const IJK_Field_double& lambda,
8188 const IJK_Field_double& rho,
8189 const double cp_gaz)
8190{
8191 const Domaine_IJK& geom = lambda.get_domaine();
8192 const int ni = geom.get_nb_elem_local(DIRECTION_I);
8193 const int nj = geom.get_nb_elem_local(DIRECTION_J);
8194 const int nk = geom.get_nb_elem_local(DIRECTION_K);
8195 const double dx = geom.get_constant_delta(DIRECTION_I);
8196 const double dy = geom.get_constant_delta(DIRECTION_J);
8197 const ArrOfDouble& delta_z = geom.get_delta(DIRECTION_K);
8198 const int k_offset = geom.get_offset_local(DIRECTION_K);
8199
8200 double inv_dtstab = 1e-20;
8201 for (int k = 0; k < nk; k++)
8202 {
8203 const double dz = delta_z[k + k_offset];
8204 const double coeff = 2. * (1./(dx*dx) + 1./(dy*dy) + 1./(dz*dz)) / cp_gaz;
8205 for (int j = 0; j < nj; j++)
8206 {
8207 for (int i = 0; i < ni; i++)
8208 {
8209 double dt = lambda(i,j,k) / rho(i,j,k) * coeff;
8210 inv_dtstab = max(dt, inv_dtstab);
8211 }
8212 }
8213 }
8214 return 1. / inv_dtstab;
8215}
8216
8217static double calculer_dtstab_diffusion_temperature_local_sans_rho(const bool anisotropic,
8218 const IJK_Field_double& lambda_x,
8219 const IJK_Field_double& lambda_y,
8220 const IJK_Field_double& lambda_z,
8221 const double cp_gaz)
8222{
8223 const Domaine_IJK& geom = lambda_x.get_domaine();
8224 const int ni = geom.get_nb_elem_local(DIRECTION_I);
8225 const int nj = geom.get_nb_elem_local(DIRECTION_J);
8226 const int nk = geom.get_nb_elem_local(DIRECTION_K);
8227 const double dx = geom.get_constant_delta(DIRECTION_I);
8228 const double dy = geom.get_constant_delta(DIRECTION_J);
8229 const ArrOfDouble& delta_z = geom.get_delta(DIRECTION_K);
8230 const int k_offset = geom.get_offset_local(DIRECTION_K);
8231
8232 double inv_dtstab = 1e-20;
8233 for (int k = 0; k < nk; k++)
8234 {
8235 const double dz = delta_z[k + k_offset];
8236 double coeff_x;
8237 double coeff_y;
8238 double coeff_z;
8239 if (anisotropic)
8240 {
8241 coeff_x = 2. * (1./(dx)) / cp_gaz;
8242 coeff_y = 2. * (1./(dy)) / cp_gaz;
8243 coeff_z = 2. * (1./(dz)) / cp_gaz;
8244 }
8245 else
8246 {
8247 coeff_x = 2. * (1./(dx*dx)) / cp_gaz;
8248 coeff_y = 2. * (1./(dy*dy)) / cp_gaz;
8249 coeff_z = 2. * (1./(dz*dz)) / cp_gaz;
8250 }
8251 for (int j = 0; j < nj; j++)
8252 {
8253 for (int i = 0; i < ni; i++)
8254 {
8255 double dt_x = lambda_x(i,j,k) * coeff_x;
8256 double dt_y = lambda_y(i,j,k) * coeff_y;
8257 double dt_z = lambda_z(i,j,k) * coeff_z;
8258 double dt = dt_x + dt_y + dt_z;
8259 inv_dtstab = max(dt, inv_dtstab);
8260 }
8261 }
8262 }
8263 return 1. / inv_dtstab;
8264}
8265
8266static double calculer_dtstab_diffusion_temperature_local_avec_turbulent_favre(const bool anisotropic,
8267 const IJK_Field_double& lambda,
8268 const IJK_Field_double& lambda_turbulent_xx,
8269 const IJK_Field_double& lambda_turbulent_xy,
8270 const IJK_Field_double& lambda_turbulent_xz,
8271 const IJK_Field_double& lambda_turbulent_yy,
8272 const IJK_Field_double& lambda_turbulent_yz,
8273 const IJK_Field_double& lambda_turbulent_zz,
8274 const IJK_Field_double& rho,
8275 const double cp_gaz)
8276{
8277 const IJK_Field_double& lambda_turbulent_yx = lambda_turbulent_xy;
8278 const IJK_Field_double& lambda_turbulent_zx = lambda_turbulent_xz;
8279 const IJK_Field_double& lambda_turbulent_zy = lambda_turbulent_yz;
8280
8281 const Domaine_IJK& geom = lambda.get_domaine();
8282 const int ni = geom.get_nb_elem_local(DIRECTION_I);
8283 const int nj = geom.get_nb_elem_local(DIRECTION_J);
8284 const int nk = geom.get_nb_elem_local(DIRECTION_K);
8285 const double dx = geom.get_constant_delta(DIRECTION_I);
8286 const double dy = geom.get_constant_delta(DIRECTION_J);
8287 const ArrOfDouble& delta_z = geom.get_delta(DIRECTION_K);
8288 const int k_offset = geom.get_offset_local(DIRECTION_K);
8289
8290 double inv_dtstab = 1e-20;
8291 for (int k = 0; k < nk; k++)
8292 {
8293 const double dz = delta_z[k + k_offset];
8294 const double coeff_x = 2. * (1./(dx*dx)) / cp_gaz;
8295 const double coeff_y = 2. * (1./(dy*dy)) / cp_gaz;
8296 const double coeff_z = 2. * (1./(dz*dz)) / cp_gaz;
8297 double fac_x;
8298 double fac_y;
8299 double fac_z;
8300 if (anisotropic)
8301 {
8302 fac_x = dx;
8303 fac_y = dy;
8304 fac_z = dz;
8305 }
8306 else
8307 {
8308 fac_x = 1.;
8309 fac_y = 1.;
8310 fac_z = 1.;
8311 }
8312 for (int j = 0; j < nj; j++)
8313 {
8314 for (int i = 0; i < ni; i++)
8315 {
8316 double dt_xx = ( lambda(i,j,k) + lambda_turbulent_xx(i,j,k)*fac_x ) / rho(i,j,k) * coeff_x;
8317 double dt_xy = ( lambda(i,j,k) + lambda_turbulent_xy(i,j,k)*fac_y ) / rho(i,j,k) * coeff_y;
8318 double dt_xz = ( lambda(i,j,k) + lambda_turbulent_xz(i,j,k)*fac_z ) / rho(i,j,k) * coeff_z;
8319 double dt_yx = ( lambda(i,j,k) + lambda_turbulent_yx(i,j,k)*fac_x ) / rho(i,j,k) * coeff_x;
8320 double dt_yy = ( lambda(i,j,k) + lambda_turbulent_yy(i,j,k)*fac_y ) / rho(i,j,k) * coeff_y;
8321 double dt_yz = ( lambda(i,j,k) + lambda_turbulent_yz(i,j,k)*fac_z ) / rho(i,j,k) * coeff_z;
8322 double dt_zx = ( lambda(i,j,k) + lambda_turbulent_zx(i,j,k)*fac_x ) / rho(i,j,k) * coeff_x;
8323 double dt_zy = ( lambda(i,j,k) + lambda_turbulent_zy(i,j,k)*fac_y ) / rho(i,j,k) * coeff_y;
8324 double dt_zz = ( lambda(i,j,k) + lambda_turbulent_zz(i,j,k)*fac_z ) / rho(i,j,k) * coeff_z;
8325 double dt_x = dt_xx + dt_xy + dt_xz;
8326 double dt_y = dt_yx + dt_yy + dt_yz;
8327 double dt_z = dt_zx + dt_zy + dt_zz;
8328 double dt = max(dt_x , max(dt_y, dt_z));
8329 inv_dtstab = max(dt, inv_dtstab);
8330 }
8331 }
8332 }
8333 return 1. / inv_dtstab;
8334}
8335
8336static double calculer_dtstab_diffusion_temperature_local_avec_turbulent_velocity(const bool anisotropic,
8337 const IJK_Field_double& lambda,
8338 const IJK_Field_double& lambda_turbulent_xx,
8339 const IJK_Field_double& lambda_turbulent_xy,
8340 const IJK_Field_double& lambda_turbulent_xz,
8341 const IJK_Field_double& lambda_turbulent_yy,
8342 const IJK_Field_double& lambda_turbulent_yz,
8343 const IJK_Field_double& lambda_turbulent_zz,
8344 const IJK_Field_double& rho,
8345 const double cp_gaz)
8346{
8347 const IJK_Field_double& lambda_turbulent_yx = lambda_turbulent_xy;
8348 const IJK_Field_double& lambda_turbulent_zx = lambda_turbulent_xz;
8349 const IJK_Field_double& lambda_turbulent_zy = lambda_turbulent_yz;
8350
8351 const Domaine_IJK& geom = lambda.get_domaine();
8352 const int ni = geom.get_nb_elem_local(DIRECTION_I);
8353 const int nj = geom.get_nb_elem_local(DIRECTION_J);
8354 const int nk = geom.get_nb_elem_local(DIRECTION_K);
8355 const double dx = geom.get_constant_delta(DIRECTION_I);
8356 const double dy = geom.get_constant_delta(DIRECTION_J);
8357 const ArrOfDouble& delta_z = geom.get_delta(DIRECTION_K);
8358 const int k_offset = geom.get_offset_local(DIRECTION_K);
8359
8360 double inv_dtstab = 1e-20;
8361 for (int k = 0; k < nk; k++)
8362 {
8363 const double dz = delta_z[k + k_offset];
8364 const double coeff_x = 2. * (1./(dx*dx)) / cp_gaz;
8365 const double coeff_y = 2. * (1./(dy*dy)) / cp_gaz;
8366 const double coeff_z = 2. * (1./(dz*dz)) / cp_gaz;
8367 double fac_x;
8368 double fac_y;
8369 double fac_z;
8370 if (anisotropic)
8371 {
8372 fac_x = dx;
8373 fac_y = dy;
8374 fac_z = dz;
8375 }
8376 else
8377 {
8378 fac_x = 1.;
8379 fac_y = 1.;
8380 fac_z = 1.;
8381 }
8382 for (int j = 0; j < nj; j++)
8383 {
8384 for (int i = 0; i < ni; i++)
8385 {
8386 double dt_xx = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_xx(i,j,k)*fac_x ) * coeff_x;
8387 double dt_xy = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_xy(i,j,k)*fac_y ) * coeff_y;
8388 double dt_xz = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_xz(i,j,k)*fac_z ) * coeff_z;
8389 double dt_yx = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_yx(i,j,k)*fac_x ) * coeff_x;
8390 double dt_yy = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_yy(i,j,k)*fac_y ) * coeff_y;
8391 double dt_yz = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_yz(i,j,k)*fac_z ) * coeff_z;
8392 double dt_zx = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_zx(i,j,k)*fac_x ) * coeff_x;
8393 double dt_zy = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_zy(i,j,k)*fac_y ) * coeff_y;
8394 double dt_zz = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_zz(i,j,k)*fac_z ) * coeff_z;
8395 double dt_x = dt_xx + dt_xy + dt_xz;
8396 double dt_y = dt_yx + dt_yy + dt_yz;
8397 double dt_z = dt_zx + dt_zy + dt_zz;
8398 double dt = max(dt_x , max(dt_y, dt_z));
8399 inv_dtstab = max(dt, inv_dtstab);
8400 }
8401 }
8402 }
8403 return 1. / inv_dtstab;
8404}
8405
8406// Impression dans cerr du flux vertical (direction K) conductif et
8408{
8409 const int ni = velocity_[2].ni();
8410 const int nj = velocity_[2].nj();
8411 const int nk = velocity_[2].nk();
8412
8413 const double dx = velocity_[2].get_domaine().get_constant_delta(DIRECTION_I);
8414 const double dy = velocity_[2].get_domaine().get_constant_delta(DIRECTION_J);
8415
8416 const double facteur = Cp_gaz_ * P_thermodynamique_ / constante_specifique_gaz_;
8417 const double surface = 1. / (ni*nj); // calcule directement la surface et la moyenne.
8418 const int offset = temperature_.get_domaine().get_offset_local(DIRECTION_K);
8419 const int nktot = velocity_[2].get_domaine().get_nb_items_global(Domaine_IJK::FACES_K, DIRECTION_K);
8420
8421 // tableau globaux plus facile pour faire un mp_sum.
8422 ArrOfDouble flux_cv(nktot);
8423 ArrOfDouble flux_cd(nktot);
8424
8425 flux_cv =0;
8426 flux_cd =0;
8427
8428 for (int k = 0; k < nk; k++)
8429 {
8430 double partiel_flux_cv = 0.;
8431 double partiel_flux_cd = 0.;
8432
8433 if ( (k + offset) == (nktot-1) )
8434 {
8435 partiel_flux_cv =0; // vitesse nulle a la paroi
8436 for (int j = 0; j < nj; j++)
8437 {
8438 for (int i = 0; i < ni; i++)
8439 {
8440 partiel_flux_cd += boundary_flux_kmax_(i,j,0)/ (dx* dy); // somme des flux de bord
8441 }
8442 }
8443 }
8444 else if ( (k + offset) == 0 )
8445 {
8446 partiel_flux_cv =0; // vitesse nulle a la paroi
8447 for (int j = 0; j < nj; j++)
8448 {
8449 for (int i = 0; i < ni; i++)
8450 {
8451 partiel_flux_cd += boundary_flux_kmin_(i,j,0) / (dx* dy); // somme des flux de bord
8452 }
8453 }
8454 }
8455 else
8456 {
8457 const double d0 = delta_z_local_[k-1] * 0.5;
8458 const double d1 = delta_z_local_[k] * 0.5;
8459 for (int j = 0; j < nj; j++)
8460 {
8461 for (int i = 0; i < ni; i++)
8462 {
8463 const double v = velocity_[2](i,j,k);
8464 const double L0 = molecular_lambda_(i,j,k-1);
8465 const double L1 = molecular_lambda_(i,j,k);
8466
8467 const double lambda_face = (L0 * L1) / ( d0 * L0 + d1 *L1);
8468 // mauvaise methode ici il faut utiliser la CL de flux bord.
8469 const double T_inf = temperature_(i,j,k-1);
8470 const double T_sup = temperature_(i,j,k);
8471
8472 double flux = lambda_face * ( T_inf - T_sup); // on calcule -L dT/dy
8473
8474 partiel_flux_cv += v * facteur;
8475 partiel_flux_cd += flux;
8476 }
8477 }
8478 }
8479 flux_cv[k+offset] = partiel_flux_cv;
8480 flux_cd[k+offset] = partiel_flux_cd;
8481 }
8482 flux_cv *= surface;
8483 flux_cd *= surface;
8484
8485 // communication
8486 // je veux ton recevoir sur le 0 pour ecrire.
8487 // pas besoin d'un envoi general.
8488 // bon pour le moment je m'en contente.
8489 mp_sum_for_each_item(flux_cv);
8490 mp_sum_for_each_item(flux_cd);
8491}
8492
8493
8494void DNS_QC_double::ecrire_fichier_sauv(const char *fichier_sauvegarde, const char *lata_name)
8495{
8497 {
8498 Cerr << "T= " << current_time_ << " Checkpointing dans le fichier " << fichier_sauvegarde << finl;
8499 SFichier fichier(fichier_sauvegarde);
8500 fichier.precision(17);
8501 fichier.setf(std::ios_base::scientific);
8502 fichier << "{\n"
8503 << " tinit " << current_time_ << "\n"
8504 << " terme_acceleration_init " << terme_source_acceleration_ << "\n"
8505 << " terme_acceleration_init_z " << terme_source_acceleration_z_ << "\n"
8506 << " p_thermo_init " << P_thermodynamique_ << "\n"
8507 << " fichier_reprise_vitesse " << lata_name << "\n";
8508 fichier << " fichier_reprise_rho " << lata_name << "\n"
8509 << " timestep_reprise_vitesse " << (int) 1 << "\n"
8510 << " timestep_reprise_rho " << (int) 1 << "\n";
8511 if (statistiques_.t_integration() > 0.)
8512 fichier << " statistiques " << statistiques_;
8513 fichier << "}\n";
8514 }
8515}
8516
8517void DNS_QC_double::sauvegarder_qc(const char *fichier_sauvegarde)
8518{
8519 Nom lata_name(fichier_sauvegarde);
8520 lata_name += ".lata";
8521
8522 ecrire_fichier_sauv(fichier_sauvegarde, lata_name);
8523 if (sauvegarde_splitting_name_ != "??")
8524 {
8525 for (int i = 0; i < 3; i++)
8526 {
8528 velocity_sauvegarde_[i].echange_espace_virtuel(velocity_sauvegarde_[i].ghost());
8529 }
8531 rho_sauvegarde_.echange_espace_virtuel(rho_sauvegarde_.ghost());
8532
8533 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8534 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8535 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8536
8537 if (ni > 0 || nj > 0 || nk > 0)
8538 {
8539 dumplata_header(lata_name, rho_sauvegarde_ /* on passe un champ pour ecrire la geometrie */);
8540 dumplata_newtime(lata_name, current_time_);
8541 dumplata_vector_parallele_plan(lata_name, "VELOCITY", velocity_sauvegarde_[0], velocity_sauvegarde_[1], velocity_sauvegarde_[2], 0);
8542 dumplata_scalar_parallele_plan(lata_name, "RHO", rho_sauvegarde_, 0);
8543 }
8544 }
8545 else
8546 {
8547 dumplata_header(lata_name, rho_ /* on passe un champ pour ecrire la geometrie */);
8548 dumplata_newtime(lata_name,current_time_);
8549 dumplata_vector(lata_name,"VELOCITY", velocity_[0], velocity_[1], velocity_[2], 0);
8550 dumplata_scalar(lata_name,"RHO", rho_, 0);
8551 }
8552
8553 if (dt_post_spectral_ > 0 )
8554 partie_fourier_.sauvegarde();
8555
8556}
8557
8558void DNS_QC_double::reprendre_qc(const char *fichier_reprise)
8559{
8560 Cerr << "Reprise du calcul dans le fichier " << fichier_reprise << finl;
8561 // Lecture par tous les processeurs, on retire les commentaires etc...
8562 LecFicDiffuse_JDD fichier(fichier_reprise);
8563 Param param(que_suis_je());
8564 param.ajouter("tinit", &current_time_);
8565 param.ajouter("terme_acceleration_init", &terme_source_acceleration_, Param::REQUIRED);
8566 param.ajouter("terme_acceleration_init_z", &terme_source_acceleration_z_, Param::REQUIRED);
8567 param.ajouter("p_thermo_init", &P_thermodynamique_, Param::REQUIRED);
8568 param.ajouter("fichier_reprise_vitesse", &fichier_reprise_vitesse_);
8569 param.ajouter("fichier_reprise_rho", &fichier_reprise_rho_);
8570 param.ajouter("timestep_reprise_vitesse", &timestep_reprise_vitesse_);
8571 param.ajouter("timestep_reprise_rho", &timestep_reprise_rho_);
8572 Cerr << "Avant ajout statistiques" << finl;
8573 param.ajouter("statistiques", &statistiques_);
8574 Cerr << "Apres ajout statistiques" << finl;
8575 param.lire_avec_accolades(fichier);
8576 // Appeler ensuite initialize() pour lire les fichiers lata etc...
8577 Cerr << "Reprise des donnees a t=" << current_time_ << "\n P_thermo=" << P_thermodynamique_ << finl;
8578}
8579
8580// MD 31/07/2019
8581// Calcul de la vitesse aux elements
8583{
8584 const int ni = velocity_elem_X_.ni();
8585 const int nj = velocity_elem_Y_.nj();
8586 const int nk = velocity_elem_Z_.nk();
8587
8588 for (int k = 0 ; k < nk ; k++)
8589 {
8590 for (int j = 0 ; j < nj ; j++)
8591 {
8592 for (int i = 0 ; i < ni ; i++)
8593 {
8594 velocity_elem_X_(i,j,k) = 0.5*(velocity_[0](i,j,k)+velocity_[0](i+1,j,k));
8595 velocity_elem_Y_(i,j,k) = 0.5*(velocity_[1](i,j,k)+velocity_[1](i,j+1,k));
8596 //if (kg == (nktot-1)) {
8597 // velocity_elem_Z_(i,j,k) = 0.5*(velocity_[2](i,j,k) + 0.);
8598 //} else {
8599 velocity_elem_Z_(i,j,k) = 0.5*(velocity_[2](i,j,k) + velocity_[2](i,j,k+1));
8600 //}
8601 }
8602 }
8603 }
8604 velocity_elem_X_.echange_espace_virtuel(1);
8605 velocity_elem_Y_.echange_espace_virtuel(1);
8606 velocity_elem_Z_.echange_espace_virtuel(1);
8607}
8608
8609void DNS_QC_double::posttraiter_champs_instantanes(const char *lata_name, double current_time)
8610{
8611 // DD,2016-28-01: statistiques a partir de fichiers lata uniquement
8613 {
8614 Nom nom_fichier_sauvegarde(lata_name);
8615 nom_fichier_sauvegarde += Nom(compteur_post_instantanes_);
8616 nom_fichier_sauvegarde += Nom(".sauv");
8617
8618 Nom lata_name_lata(nom_fichier_sauvegarde);
8619 lata_name_lata += ".lata";
8620
8621 ecrire_fichier_sauv(nom_fichier_sauvegarde, lata_name_lata);
8622
8623 dumplata_header(lata_name_lata, rho_ /* on passe un champ pour ecrire la geometrie */);
8624 dumplata_newtime(lata_name_lata, current_time_);
8625
8626 if (liste_post_instantanes_.contient_("TOUS"))
8627 {
8628 liste_post_instantanes_.dimensionner_force(0);
8629 liste_post_instantanes_.add("VELOCITY");
8630 liste_post_instantanes_.add("VELOCITY_ELEM_X");
8631 liste_post_instantanes_.add("VELOCITY_ELEM_Y");
8632 liste_post_instantanes_.add("VELOCITY_ELEM_Z");
8633 liste_post_instantanes_.add("D_VELOCITY");
8634 liste_post_instantanes_.add("PRESSURE");
8635 liste_post_instantanes_.add("TEMPERATURE");
8636 liste_post_instantanes_.add("RHO");
8637 liste_post_instantanes_.add("LAMBDA");
8638 liste_post_instantanes_.add("MU");
8639 liste_post_instantanes_.add("PRESSURE_RHS");
8640 liste_post_instantanes_.add("DIV_LAMBDA_GRAD_T_VOLUME");
8641 liste_post_instantanes_.add("U_DIV_RHO_U");
8642 liste_post_instantanes_.add("DRHO_DT");
8654 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_XX");
8655 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_XY");
8656 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_XZ");
8657 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_YY");
8658 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_YZ");
8659 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_ZZ");
8660 if (structural_uscalar_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_X");
8661 if (structural_uscalar_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_Y");
8662 if (structural_uscalar_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_Z");
8663 if (flag_u_filtre_) liste_post_instantanes_.add("VELOCITY_FILTRE");
8664 if (flag_rho_filtre_) liste_post_instantanes_.add("RHO_FILTRE");
8665 if (flag_temperature_filtre_) liste_post_instantanes_.add("TEMPERATURE_FILTRE");
8666 if (flag_turbulent_mu_filtre_ && (!flag_nu_tensorial_)) liste_post_instantanes_.add("TURBULENT_MU_FILTRE");
8668 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_XY");
8669 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_XZ");
8670 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_YY");
8671 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_YZ");
8672 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_ZZ");
8673 if (flag_turbulent_kappa_filtre_ && (!flag_kappa_vectorial_)) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE");
8674 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE_X");
8675 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE_Y");
8676 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE_Z");
8677 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_XX");
8678 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_XY");
8679 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_XZ");
8680 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_YY");
8681 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_YZ");
8682 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_ZZ");
8683 if (flag_structural_uscalar_filtre_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_FILTRE_X");
8684 if (flag_structural_uscalar_filtre_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_FILTRE_Y");
8685 if (flag_structural_uscalar_filtre_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_FILTRE_Z");
8686 }
8687 int n = liste_post_instantanes_.size();
8688 Cerr << " Martinn n= " << n << finl;
8689
8690 if (liste_post_instantanes_.contient_("VELOCITY"))
8691 {
8692 n=n-1;
8693 dumplata_vector(lata_name_lata,"VELOCITY", velocity_[0], velocity_[1], velocity_[2], 0);
8694 }
8695 if (liste_post_instantanes_.contient_("VELOCITY_ELEM_X"))
8696 {
8697 n=n-1;
8699 if (sauvegarde_splitting_name_ != "??")
8700 {
8702 velocity_elem_X_sauvegarde_.echange_espace_virtuel(velocity_elem_X_sauvegarde_.ghost());
8703
8704 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8705 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8706 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8707
8708 if (ni > 0 || nj > 0 || nk > 0)
8709 {
8710 dumplata_scalar_parallele_plan(lata_name_lata, "VELOCITY_ELEM_X", velocity_elem_X_sauvegarde_, 0);
8711 }
8712 }
8713 else
8714 {
8715 dumplata_scalar(lata_name_lata,"VELOCITY_ELEM_X", velocity_elem_X_, 0);
8716 }
8717 }
8718
8719 if (liste_post_instantanes_.contient_("VELOCITY_ELEM_Y"))
8720 {
8721 n=n-1;
8722 if (sauvegarde_splitting_name_ != "??")
8723 {
8725 velocity_elem_Y_sauvegarde_.echange_espace_virtuel(velocity_elem_Y_sauvegarde_.ghost());
8726
8727 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8728 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8729 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8730
8731 if (ni > 0 || nj > 0 || nk > 0)
8732 {
8733 dumplata_scalar_parallele_plan(lata_name_lata, "VELOCITY_ELEM_Y", velocity_elem_Y_sauvegarde_, 0);
8734 }
8735 }
8736 else
8737 {
8738 dumplata_scalar(lata_name_lata,"VELOCITY_ELEM_Y", velocity_elem_Y_, 0);
8739 }
8740 }
8741
8742 if (liste_post_instantanes_.contient_("VELOCITY_ELEM_Z"))
8743 {
8744 n=n-1;
8745 if (sauvegarde_splitting_name_ != "??")
8746 {
8748 velocity_elem_Z_sauvegarde_.echange_espace_virtuel(velocity_elem_Z_sauvegarde_.ghost());
8749
8750 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8751 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8752 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8753
8754 if (ni > 0 || nj > 0 || nk > 0)
8755 {
8756 dumplata_scalar_parallele_plan(lata_name_lata, "VELOCITY_ELEM_Z", velocity_elem_Z_sauvegarde_, 0);
8757 }
8758 }
8759 else
8760 {
8761 dumplata_scalar(lata_name_lata,"VELOCITY_ELEM_Z", velocity_elem_Z_, 0);
8762 }
8763 }
8764 if (liste_post_instantanes_.contient_("D_VELOCITY"))
8765 n--, dumplata_vector(lata_name_lata,"D_VELOCITY", d_velocity_[0], d_velocity_[1], d_velocity_[2], 0);
8766 if (liste_post_instantanes_.contient_("PRESSURE"))
8767 {
8768 n=n-1;
8769 if (sauvegarde_splitting_name_ != "??")
8770 {
8772 pressure_sauvegarde_.echange_espace_virtuel(pressure_sauvegarde_.ghost());
8773
8774 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8775 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8776 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8777
8778 if (ni > 0 || nj > 0 || nk > 0)
8779 {
8780 dumplata_scalar_parallele_plan(lata_name_lata, "PRESSURE", pressure_sauvegarde_, 0);
8781 }
8782 }
8783 else
8784 {
8785 dumplata_scalar(lata_name_lata,"PRESSURE", pressure_, 0);
8786 }
8787 }
8788 if (liste_post_instantanes_.contient_("TEMPERATURE"))
8789 {
8790 n=n-1;
8791 if (sauvegarde_splitting_name_ != "??")
8792 {
8794 temperature_sauvegarde_.echange_espace_virtuel(temperature_sauvegarde_.ghost());
8795
8796 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8797 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8798 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8799
8800 if (ni > 0 || nj > 0 || nk > 0)
8801 {
8802 dumplata_scalar_parallele_plan(lata_name_lata, "TEMPERATURE", temperature_sauvegarde_, 0);
8803 }
8804 }
8805 else
8806 {
8807 dumplata_scalar(lata_name_lata,"TEMPERATURE", temperature_, 0);
8808 }
8809 }
8810 if (liste_post_instantanes_.contient_("RHO"))
8811 {
8812 n=n-1;
8813 if (sauvegarde_splitting_name_ != "??")
8814 {
8816 rho_sauvegarde_.echange_espace_virtuel(rho_sauvegarde_.ghost());
8817
8818 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8819 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8820 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8821
8822 if (ni > 0 || nj > 0 || nk > 0)
8823 {
8824 dumplata_scalar_parallele_plan(lata_name_lata, "RHO", rho_sauvegarde_, 0);
8825 }
8826 }
8827 else
8828 {
8829 dumplata_scalar(lata_name_lata,"RHO", rho_, 0);
8830 }
8831 }
8832 if (liste_post_instantanes_.contient_("LAMBDA"))
8833 {
8834 n=n-1;
8835 if (sauvegarde_splitting_name_ != "??")
8836 {
8838 molecular_lambda_sauvegarde_.echange_espace_virtuel(molecular_lambda_sauvegarde_.ghost());
8839
8840 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8841 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8842 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8843
8844 if (ni > 0 || nj > 0 || nk > 0)
8845 {
8846 dumplata_scalar_parallele_plan(lata_name_lata, "LAMBDA", molecular_lambda_sauvegarde_, 0);
8847 }
8848 }
8849 else
8850 {
8851 dumplata_scalar(lata_name_lata,"LAMBDA", molecular_lambda_, 0);
8852 }
8853 }
8854 if (liste_post_instantanes_.contient_("MU"))
8855 {
8856 n=n-1;
8857 if (sauvegarde_splitting_name_ != "??")
8858 {
8860 molecular_mu_sauvegarde_.echange_espace_virtuel(molecular_mu_sauvegarde_.ghost());
8861
8862 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8863 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8864 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8865
8866 if (ni > 0 || nj > 0 || nk > 0)
8867 {
8868 dumplata_scalar_parallele_plan(lata_name_lata, "MU", molecular_mu_sauvegarde_, 0);
8869 }
8870 }
8871 else
8872 {
8873 dumplata_scalar(lata_name_lata,"MU", molecular_mu_, 0);
8874 }
8875 }
8876 if (liste_post_instantanes_.contient_("PRESSURE_RHS"))
8877 n--,dumplata_scalar(lata_name_lata,"PRESSURE_RHS", pressure_rhs_, 0);
8878 if (liste_post_instantanes_.contient_("DIV_LAMBDA_GRAD_T_VOLUME"))
8879 n--,dumplata_scalar(lata_name_lata,"DIV_LAMBDA_GRAD_T_VOLUME", div_lambda_grad_T_volume_, 0);
8880 if (liste_post_instantanes_.contient_("U_DIV_RHO_U"))
8881 n--,dumplata_scalar(lata_name_lata,"U_DIV_RHO_U", u_div_rho_u_, 0);
8882 if (liste_post_instantanes_.contient_("DRHO_DT"))
8883 n--,dumplata_scalar(lata_name_lata,"DRHO_DT", d_rho_, 0);
8884 if (turbulent_viscosity_ && (!flag_nu_tensorial_) && liste_post_instantanes_.contient_("TURBULENT_MU"))
8885 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU", turbulent_mu_, 0);
8886 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_XX"))
8887 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_XX", turbulent_mu_tensor_[0], 0);
8888 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_XY"))
8889 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_XY", turbulent_mu_tensor_[1], 0);
8890 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_XZ"))
8891 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_XZ", turbulent_mu_tensor_[2], 0);
8892 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_YY"))
8893 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_YY", turbulent_mu_tensor_[3], 0);
8894 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_YZ"))
8895 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_YZ", turbulent_mu_tensor_[4], 0);
8896 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_ZZ"))
8897 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_ZZ", turbulent_mu_tensor_[5], 0);
8898 if (turbulent_diffusivity_ && (!flag_kappa_vectorial_) && liste_post_instantanes_.contient_("TURBULENT_KAPPA"))
8899 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA", turbulent_kappa_, 0);
8900 if (turbulent_diffusivity_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_X"))
8901 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_X", turbulent_kappa_vector_[0], 0);
8902 if (turbulent_diffusivity_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_Y"))
8903 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_Y", turbulent_kappa_vector_[1], 0);
8904 if (turbulent_diffusivity_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_Z"))
8905 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_Z", turbulent_kappa_vector_[2], 0);
8906 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_XX"))
8907 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_XX", structural_uu_tensor_[0], 0);
8908 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_XY"))
8909 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_XY", structural_uu_tensor_[1], 0);
8910 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_XZ"))
8911 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_XZ", structural_uu_tensor_[2], 0);
8912 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_YY"))
8913 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_YY", structural_uu_tensor_[3], 0);
8914 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_YZ"))
8915 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_YZ", structural_uu_tensor_[4], 0);
8916 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_ZZ"))
8917 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_ZZ", structural_uu_tensor_[5], 0);
8918 if (structural_uscalar_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_X"))
8919 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_X", structural_uscalar_vector_[0], 0);
8920 if (structural_uscalar_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_Y"))
8921 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_Y", structural_uscalar_vector_[1], 0);
8922 if (structural_uscalar_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_Z"))
8923 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_Z", structural_uscalar_vector_[2], 0);
8924 if (flag_u_filtre_ && liste_post_instantanes_.contient_("VELOCITY_FILTRE"))
8925 n--,dumplata_vector(lata_name_lata,"VELOCITY_FILTRE", velocity_filtre_[0], velocity_filtre_[1], velocity_filtre_[2], 0);
8926 if (flag_rho_filtre_ && liste_post_instantanes_.contient_("RHO_FILTRE"))
8927 n--,dumplata_scalar(lata_name_lata,"RHO_FILTRE", rho_filtre_, 0);
8928 if (flag_temperature_filtre_ && liste_post_instantanes_.contient_("TEMPERATURE_FILTRE"))
8929 n--,dumplata_scalar(lata_name_lata,"TEMPERATURE_FILTRE", temperature_filtre_, 0);
8930 if (flag_turbulent_mu_filtre_ && (!flag_nu_tensorial_) && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE"))
8931 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE", turbulent_mu_filtre_, 0);
8932 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_XX"))
8933 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_XX", turbulent_mu_filtre_tensor_[0], 0);
8934 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_XY"))
8935 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_XY", turbulent_mu_filtre_tensor_[1], 0);
8936 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_XZ"))
8937 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_XZ", turbulent_mu_filtre_tensor_[2], 0);
8938 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_YY"))
8939 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_YY", turbulent_mu_filtre_tensor_[3], 0);
8940 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_YZ"))
8941 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_YZ", turbulent_mu_filtre_tensor_[4], 0);
8942 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_ZZ"))
8943 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_ZZ", turbulent_mu_filtre_tensor_[5], 0);
8944 if (flag_turbulent_kappa_filtre_ && (!flag_kappa_vectorial_) && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE"))
8945 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE", turbulent_kappa_filtre_, 0);
8946 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE_X"))
8947 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE_X", turbulent_kappa_filtre_vector_[0], 0);
8948 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE_Y"))
8949 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE_Y", turbulent_kappa_filtre_vector_[1], 0);
8950 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE_Z"))
8951 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE_Z", turbulent_kappa_filtre_vector_[2], 0);
8952 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_XX"))
8953 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_XX", structural_uu_filtre_tensor_[0], 0);
8954 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_XY"))
8955 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_XY", structural_uu_filtre_tensor_[1], 0);
8956 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_XZ"))
8957 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_XZ", structural_uu_filtre_tensor_[2], 0);
8958 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_YY"))
8959 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_YY", structural_uu_filtre_tensor_[3], 0);
8960 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_YZ"))
8961 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_YZ", structural_uu_filtre_tensor_[4], 0);
8962 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_ZZ"))
8963 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_ZZ", structural_uu_filtre_tensor_[5], 0);
8964 if (flag_structural_uscalar_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_FILTRE_X"))
8965 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_FILTRE_X", structural_uscalar_filtre_vector_[0], 0);
8966 if (flag_structural_uscalar_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_FILTRE_Y"))
8967 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_FILTRE_Y", structural_uscalar_filtre_vector_[1], 0);
8968 if (flag_structural_uscalar_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_FILTRE_Z"))
8969 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_FILTRE_Z", structural_uscalar_filtre_vector_[2], 0);
8970 if (n>0)
8971 {
8972 Cerr << " Martinn n2= " << n << finl;
8973 Cerr << "Il y a des noms de champs a postraiter inconnus ou dupliques dans la liste de champs a postraiter"
8974 << finl << liste_post_instantanes_ << finl;
8975 Process::exit();
8976 }
8978 }
8979
8981 {
8982 Nom nom_fichier("moyenne_spatiale_");
8983 nom_fichier += Nom(current_time);
8984 nom_fichier += Nom(".txt");
8985 SFichier f(nom_fichier);
8986 // F.A modification de la precision pour allez chercher les 4 ordres
8987 f.setf(ios::scientific);
8988 f.precision(15);
8989 statistiques_.postraiter(f, 1 /* flag pour ecrire la moyenne instantanee */);
8990 // modif AT 20/06/2013
8991 if (statistiques_.check_converge())
8992 {
8993 Nom nom_fichier_ec("spatiale_ec_");
8994 nom_fichier_ec += Nom(current_time);
8995 nom_fichier_ec += Nom(".txt");
8996 SFichier fk(nom_fichier_ec);
8997 // F.A modification de la precision pour allez chercher les 4 ordres
8998 fk.setf(ios::scientific);
8999 fk.precision(15);
9000 statistiques_.postraiter_k(fk,1 /* valeur spatiale */);
9001 }
9002 }
9003
9004 if (Process::je_suis_maitre() && statistiques_.t_integration() > 0.)
9005 {
9006 Nom nom_fichier("statistiques_");
9007 nom_fichier += Nom(current_time);
9008 nom_fichier += Nom(".txt");
9009 SFichier fs(nom_fichier);
9010 // F.A modification de la precision pour allez chercher les 4 ordres
9011 fs.setf(ios::scientific);
9012 fs.precision(15);
9013 statistiques_.postraiter(fs,0 /* moyenne temporelle */);
9014 }
9015
9016 if (Process::je_suis_maitre() && statistiques_.t_integration_k() > 0. )
9017 {
9018 Nom nom_fichier("stat_ec_");
9019 nom_fichier += Nom(current_time);
9020 nom_fichier += Nom(".txt");
9021 SFichier fk(nom_fichier);
9022 // F.A modification de la precision pour allez chercher les 4 ordres
9023 fk.setf(ios::scientific);
9024 fk.precision(15);
9025 statistiques_.postraiter_k(fk,0 /* moyenne temporelle */);
9026 }
9027}
9028
9029
9030void DNS_QC_double::save_raw_data(const char *lata_name, double current_time)
9031{
9032 // DD,2016-28-01: statistiques a partir de fichiers lata uniquement
9034 {
9035 Nom nom_fichier_sauvegarde(lata_name);
9036 nom_fichier_sauvegarde += Nom(compteur_post_instantanes_);
9037 nom_fichier_sauvegarde += Nom(".sauv");
9038
9039 Nom lata_name_lata(nom_fichier_sauvegarde);
9040 lata_name_lata += ".lata";
9041
9042 ecrire_fichier_sauv(nom_fichier_sauvegarde, lata_name_lata);
9043
9044 dumplata_header(lata_name_lata, rho_ /* on passe un champ pour ecrire la geometrie */);
9045 dumplata_newtime(lata_name_lata, current_time_);
9046
9047 if (liste_post_instantanes_.contient_("TOUS"))
9048 {
9049 liste_post_instantanes_.dimensionner_force(0);
9050 liste_post_instantanes_.add("VELOCITY");
9051 liste_post_instantanes_.add("VELOCITY_ELEM_X");
9052 liste_post_instantanes_.add("VELOCITY_ELEM_Y");
9053 liste_post_instantanes_.add("VELOCITY_ELEM_Z");
9054 liste_post_instantanes_.add("D_VELOCITY");
9055 liste_post_instantanes_.add("PRESSURE");
9056 liste_post_instantanes_.add("TEMPERATURE");
9057 liste_post_instantanes_.add("RHO");
9058 liste_post_instantanes_.add("LAMBDA");
9059 liste_post_instantanes_.add("MU");
9060 liste_post_instantanes_.add("PRESSURE_RHS");
9061 liste_post_instantanes_.add("DIV_LAMBDA_GRAD_T_VOLUME");
9062 liste_post_instantanes_.add("U_DIV_RHO_U");
9063 liste_post_instantanes_.add("DRHO_DT");
9075 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_XX");
9076 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_XY");
9077 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_XZ");
9078 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_YY");
9079 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_YZ");
9080 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_ZZ");
9081 if (structural_uscalar_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_X");
9082 if (structural_uscalar_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_Y");
9083 if (structural_uscalar_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_Z");
9084 if (flag_u_filtre_) liste_post_instantanes_.add("VELOCITY_FILTRE");
9085 if (flag_rho_filtre_) liste_post_instantanes_.add("RHO_FILTRE");
9086 if (flag_temperature_filtre_) liste_post_instantanes_.add("TEMPERATURE_FILTRE");
9087 if (flag_turbulent_mu_filtre_ && (!flag_nu_tensorial_)) liste_post_instantanes_.add("TURBULENT_MU_FILTRE");
9089 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_XY");
9090 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_XZ");
9091 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_YY");
9092 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_YZ");
9093 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_ZZ");
9094 if (flag_turbulent_kappa_filtre_ && (!flag_kappa_vectorial_)) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE");
9095 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE_X");
9096 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE_Y");
9097 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE_Z");
9098 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_XX");
9099 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_XY");
9100 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_XZ");
9101 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_YY");
9102 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_YZ");
9103 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_ZZ");
9104 if (flag_structural_uscalar_filtre_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_FILTRE_X");
9105 if (flag_structural_uscalar_filtre_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_FILTRE_Y");
9106 if (flag_structural_uscalar_filtre_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_FILTRE_Z");
9107 }
9108 int n = liste_post_instantanes_.size();
9109 Cerr << " Martinn n= " << n << finl;
9110
9111 if (liste_post_instantanes_.contient_("VELOCITY"))
9112 {
9113 n=n-1;
9114 dumplata_vector(lata_name_lata,"VELOCITY", velocity_[0], velocity_[1], velocity_[2], 0);
9115 }
9116 if (liste_post_instantanes_.contient_("VELOCITY_ELEM_X"))
9117 {
9118 n=n-1;
9120 if (sauvegarde_splitting_name_ != "??")
9121 {
9123 velocity_elem_X_sauvegarde_.echange_espace_virtuel(velocity_elem_X_sauvegarde_.ghost());
9124
9125 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9126 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9127 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9128
9129 if (ni > 0 || nj > 0 || nk > 0)
9130 {
9131 dumplata_scalar_parallele_plan(lata_name_lata, "VELOCITY_ELEM_X", velocity_elem_X_sauvegarde_, 0);
9132 }
9133 }
9134 else
9135 {
9136 dumplata_scalar(lata_name_lata,"VELOCITY_ELEM_X", velocity_elem_X_, 0);
9137 }
9138 }
9139
9140 if (liste_post_instantanes_.contient_("VELOCITY_ELEM_Y"))
9141 {
9142 n=n-1;
9143 if (sauvegarde_splitting_name_ != "??")
9144 {
9146 velocity_elem_Y_sauvegarde_.echange_espace_virtuel(velocity_elem_Y_sauvegarde_.ghost());
9147
9148 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9149 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9150 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9151
9152 if (ni > 0 || nj > 0 || nk > 0)
9153 {
9154 dumplata_scalar_parallele_plan(lata_name_lata, "VELOCITY_ELEM_Y", velocity_elem_Y_sauvegarde_, 0);
9155 }
9156 }
9157 else
9158 {
9159 dumplata_scalar(lata_name_lata,"VELOCITY_ELEM_Y", velocity_elem_Y_, 0);
9160 }
9161 }
9162
9163 if (liste_post_instantanes_.contient_("VELOCITY_ELEM_Z"))
9164 {
9165 n=n-1;
9166 if (sauvegarde_splitting_name_ != "??")
9167 {
9169 velocity_elem_Z_sauvegarde_.echange_espace_virtuel(velocity_elem_Z_sauvegarde_.ghost());
9170
9171 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9172 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9173 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9174
9175 if (ni > 0 || nj > 0 || nk > 0)
9176 {
9177 dumplata_scalar_parallele_plan(lata_name_lata, "VELOCITY_ELEM_Z", velocity_elem_Z_sauvegarde_, 0);
9178 }
9179 }
9180 else
9181 {
9182 dumplata_scalar(lata_name_lata,"VELOCITY_ELEM_Z", velocity_elem_Z_, 0);
9183 }
9184 }
9185 if (liste_post_instantanes_.contient_("D_VELOCITY"))
9186 n--, dumplata_vector(lata_name_lata,"D_VELOCITY", d_velocity_[0], d_velocity_[1], d_velocity_[2], 0);
9187 if (liste_post_instantanes_.contient_("PRESSURE"))
9188 {
9189 n=n-1;
9190 if (sauvegarde_splitting_name_ != "??")
9191 {
9193 pressure_sauvegarde_.echange_espace_virtuel(pressure_sauvegarde_.ghost());
9194
9195 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9196 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9197 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9198
9199 if (ni > 0 || nj > 0 || nk > 0)
9200 {
9201 dumplata_scalar_parallele_plan(lata_name_lata, "PRESSURE", pressure_sauvegarde_, 0);
9202 }
9203 }
9204 else
9205 {
9206 dumplata_scalar(lata_name_lata,"PRESSURE", pressure_, 0);
9207 }
9208 }
9209 if (liste_post_instantanes_.contient_("TEMPERATURE"))
9210 {
9211 n=n-1;
9212 if (sauvegarde_splitting_name_ != "??")
9213 {
9215 temperature_sauvegarde_.echange_espace_virtuel(temperature_sauvegarde_.ghost());
9216
9217 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9218 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9219 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9220
9221 if (ni > 0 || nj > 0 || nk > 0)
9222 {
9223 dumplata_scalar_parallele_plan(lata_name_lata, "TEMPERATURE", temperature_sauvegarde_, 0);
9224 }
9225 }
9226 else
9227 {
9228 dumplata_scalar(lata_name_lata,"TEMPERATURE", temperature_, 0);
9229 }
9230 }
9231 if (liste_post_instantanes_.contient_("RHO"))
9232 {
9233 n=n-1;
9234 if (sauvegarde_splitting_name_ != "??")
9235 {
9237 rho_sauvegarde_.echange_espace_virtuel(rho_sauvegarde_.ghost());
9238
9239 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9240 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9241 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9242
9243 if (ni > 0 || nj > 0 || nk > 0)
9244 {
9245 dumplata_scalar_parallele_plan(lata_name_lata, "RHO", rho_sauvegarde_, 0);
9246 }
9247 }
9248 else
9249 {
9250 dumplata_scalar(lata_name_lata,"RHO", rho_, 0);
9251 }
9252 }
9253 if (liste_post_instantanes_.contient_("LAMBDA"))
9254 {
9255 n=n-1;
9256 if (sauvegarde_splitting_name_ != "??")
9257 {
9259 molecular_lambda_sauvegarde_.echange_espace_virtuel(molecular_lambda_sauvegarde_.ghost());
9260
9261 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9262 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9263 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9264
9265 if (ni > 0 || nj > 0 || nk > 0)
9266 {
9267 dumplata_scalar_parallele_plan(lata_name_lata, "LAMBDA", molecular_lambda_sauvegarde_, 0);
9268 }
9269 }
9270 else
9271 {
9272 dumplata_scalar(lata_name_lata,"LAMBDA", molecular_lambda_, 0);
9273 }
9274 }
9275 if (liste_post_instantanes_.contient_("MU"))
9276 {
9277 n=n-1;
9278 if (sauvegarde_splitting_name_ != "??")
9279 {
9281 molecular_mu_sauvegarde_.echange_espace_virtuel(molecular_mu_sauvegarde_.ghost());
9282
9283 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9284 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9285 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9286
9287 if (ni > 0 || nj > 0 || nk > 0)
9288 {
9289 dumplata_scalar_parallele_plan(lata_name_lata, "MU", molecular_mu_sauvegarde_, 0);
9290 }
9291 }
9292 else
9293 {
9294 dumplata_scalar(lata_name_lata,"MU", molecular_mu_, 0);
9295 }
9296 }
9297 if (liste_post_instantanes_.contient_("PRESSURE_RHS"))
9298 n--,dumplata_scalar(lata_name_lata,"PRESSURE_RHS", pressure_rhs_, 0);
9299 if (liste_post_instantanes_.contient_("DIV_LAMBDA_GRAD_T_VOLUME"))
9300 n--,dumplata_scalar(lata_name_lata,"DIV_LAMBDA_GRAD_T_VOLUME", div_lambda_grad_T_volume_, 0);
9301 if (liste_post_instantanes_.contient_("U_DIV_RHO_U"))
9302 n--,dumplata_scalar(lata_name_lata,"U_DIV_RHO_U", u_div_rho_u_, 0);
9303 if (liste_post_instantanes_.contient_("DRHO_DT"))
9304 n--,dumplata_scalar(lata_name_lata,"DRHO_DT", d_rho_, 0);
9305 if (turbulent_viscosity_ && (!flag_nu_tensorial_) && liste_post_instantanes_.contient_("TURBULENT_MU"))
9306 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU", turbulent_mu_, 0);
9307 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_XX"))
9308 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_XX", turbulent_mu_tensor_[0], 0);
9309 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_XY"))
9310 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_XY", turbulent_mu_tensor_[1], 0);
9311 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_XZ"))
9312 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_XZ", turbulent_mu_tensor_[2], 0);
9313 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_YY"))
9314 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_YY", turbulent_mu_tensor_[3], 0);
9315 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_YZ"))
9316 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_YZ", turbulent_mu_tensor_[4], 0);
9317 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_ZZ"))
9318 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_ZZ", turbulent_mu_tensor_[5], 0);
9319 if (turbulent_diffusivity_ && (!flag_kappa_vectorial_) && liste_post_instantanes_.contient_("TURBULENT_KAPPA"))
9320 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA", turbulent_kappa_, 0);
9321 if (turbulent_diffusivity_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_X"))
9322 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_X", turbulent_kappa_vector_[0], 0);
9323 if (turbulent_diffusivity_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_Y"))
9324 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_Y", turbulent_kappa_vector_[1], 0);
9325 if (turbulent_diffusivity_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_Z"))
9326 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_Z", turbulent_kappa_vector_[2], 0);
9327 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_XX"))
9328 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_XX", structural_uu_tensor_[0], 0);
9329 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_XY"))
9330 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_XY", structural_uu_tensor_[1], 0);
9331 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_XZ"))
9332 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_XZ", structural_uu_tensor_[2], 0);
9333 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_YY"))
9334 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_YY", structural_uu_tensor_[3], 0);
9335 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_YZ"))
9336 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_YZ", structural_uu_tensor_[4], 0);
9337 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_ZZ"))
9338 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_ZZ", structural_uu_tensor_[5], 0);
9339 if (structural_uscalar_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_X"))
9340 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_X", structural_uscalar_vector_[0], 0);
9341 if (structural_uscalar_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_Y"))
9342 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_Y", structural_uscalar_vector_[1], 0);
9343 if (structural_uscalar_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_Z"))
9344 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_Z", structural_uscalar_vector_[2], 0);
9345 if (flag_u_filtre_ && liste_post_instantanes_.contient_("VELOCITY_FILTRE"))
9346 n--,dumplata_vector(lata_name_lata,"VELOCITY_FILTRE", velocity_filtre_[0], velocity_filtre_[1], velocity_filtre_[2], 0);
9347 if (flag_rho_filtre_ && liste_post_instantanes_.contient_("RHO_FILTRE"))
9348 n--,dumplata_scalar(lata_name_lata,"RHO_FILTRE", rho_filtre_, 0);
9349 if (flag_temperature_filtre_ && liste_post_instantanes_.contient_("TEMPERATURE_FILTRE"))
9350 n--,dumplata_scalar(lata_name_lata,"TEMPERATURE_FILTRE", temperature_filtre_, 0);
9351 if (flag_turbulent_mu_filtre_ && (!flag_nu_tensorial_) && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE"))
9352 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE", turbulent_mu_filtre_, 0);
9353 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_XX"))
9354 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_XX", turbulent_mu_filtre_tensor_[0], 0);
9355 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_XY"))
9356 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_XY", turbulent_mu_filtre_tensor_[1], 0);
9357 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_XZ"))
9358 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_XZ", turbulent_mu_filtre_tensor_[2], 0);
9359 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_YY"))
9360 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_YY", turbulent_mu_filtre_tensor_[3], 0);
9361 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_YZ"))
9362 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_YZ", turbulent_mu_filtre_tensor_[4], 0);
9363 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_ZZ"))
9364 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_ZZ", turbulent_mu_filtre_tensor_[5], 0);
9365 if (flag_turbulent_kappa_filtre_ && (!flag_kappa_vectorial_) && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE"))
9366 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE", turbulent_kappa_filtre_, 0);
9367 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE_X"))
9368 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE_X", turbulent_kappa_filtre_vector_[0], 0);
9369 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE_Y"))
9370 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE_Y", turbulent_kappa_filtre_vector_[1], 0);
9371 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE_Z"))
9372 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE_Z", turbulent_kappa_filtre_vector_[2], 0);
9373 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_XX"))
9374 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_XX", structural_uu_filtre_tensor_[0], 0);
9375 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_XY"))
9376 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_XY", structural_uu_filtre_tensor_[1], 0);
9377 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_XZ"))
9378 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_XZ", structural_uu_filtre_tensor_[2], 0);
9379 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_YY"))
9380 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_YY", structural_uu_filtre_tensor_[3], 0);
9381 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_YZ"))
9382 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_YZ", structural_uu_filtre_tensor_[4], 0);
9383 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_ZZ"))
9384 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_ZZ", structural_uu_filtre_tensor_[5], 0);
9385 if (flag_structural_uscalar_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_FILTRE_X"))
9386 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_FILTRE_X", structural_uscalar_filtre_vector_[0], 0);
9387 if (flag_structural_uscalar_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_FILTRE_Y"))
9388 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_FILTRE_Y", structural_uscalar_filtre_vector_[1], 0);
9389 if (flag_structural_uscalar_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_FILTRE_Z"))
9390 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_FILTRE_Z", structural_uscalar_filtre_vector_[2], 0);
9391 if (n>0)
9392 {
9393 Cerr << " Martinn n2= " << n << finl;
9394 Cerr << "Il y a des noms de champs a postraiter inconnus ou dupliques dans la liste de champs a postraiter"
9395 << finl << liste_post_instantanes_ << finl;
9396 Process::exit();
9397 }
9399 }
9400}
9401
9402
9403void DNS_QC_double::save_stats(double current_time)
9404{
9406 {
9407 Nom nom_fichier("moyenne_spatiale_");
9408 nom_fichier += Nom(current_time);
9409 nom_fichier += Nom(".txt");
9410 SFichier f(nom_fichier);
9411 // F.A modification de la precision pour allez chercher les 4 ordres
9412 f.setf(ios::scientific);
9413 f.precision(15);
9414 statistiques_.postraiter(f, 1 /* flag pour ecrire la moyenne instantanee */);
9415 // modif AT 20/06/2013
9416 if (statistiques_.check_converge())
9417 {
9418 Nom nom_fichier_ec("spatiale_ec_");
9419 nom_fichier_ec += Nom(current_time);
9420 nom_fichier_ec += Nom(".txt");
9421 SFichier fk(nom_fichier_ec);
9422 // F.A modification de la precision pour allez chercher les 4 ordres
9423 fk.setf(ios::scientific);
9424 fk.precision(15);
9425 statistiques_.postraiter_k(fk,1 /* valeur spatiale */);
9426 }
9427 }
9428
9429 if (Process::je_suis_maitre() && statistiques_.t_integration() > 0.)
9430 {
9431 Nom nom_fichier("statistiques_");
9432 nom_fichier += Nom(current_time);
9433 nom_fichier += Nom(".txt");
9434 SFichier fs(nom_fichier);
9435 // F.A modification de la precision pour allez chercher les 4 ordres
9436 fs.setf(ios::scientific);
9437 fs.precision(15);
9438 statistiques_.postraiter(fs,0 /* moyenne temporelle */);
9439 }
9440
9441 if (Process::je_suis_maitre() && statistiques_.t_integration_k() > 0. )
9442 {
9443 Nom nom_fichier("stat_ec_");
9444 nom_fichier += Nom(current_time);
9445 nom_fichier += Nom(".txt");
9446 SFichier fk(nom_fichier);
9447 // F.A modification de la precision pour allez chercher les 4 ordres
9448 fk.setf(ios::scientific);
9449 fk.precision(15);
9450 statistiques_.postraiter_k(fk,0 /* moyenne temporelle */);
9451 }
9452}
9453
9455{
9456 Cerr << "IJK_problem_double::run()" << finl;
9457
9458 if (dt_start_ == 1.e20)
9459 Cerr << " pas de dt_start choisi, si initialisation d'un calcul il faut faire un dt_start petit ou une projection initiale si isotherme " << finl;
9460
9462 Cerr << " Attention la convection de la vitesse est negligee " << finl;
9464 Cerr << " Attention la convection de la masse volumique est negligee " << finl;
9466 Cerr << " Attention la diffusion visqueuse est negligee " << finl;
9468 Cerr << " Attention la diffusion thermique est negligee " << finl;
9469
9470 kernel_ = nullptr;
9471 int ghost_size_filter = 0, ghost_size_d_velocity_tmp;
9477 {
9478 int ghost_size = 0;
9479
9480 choix_filter_kernel(ghost_size, filter_kernel_name_, kernel_);
9481 Cerr << "Filter: The ghost size is " << kernel_->ghost_size() << finl;
9482
9483 ghost_size_filter = 1 + kernel_->ghost_size();
9484 }
9485
9486 int ghost_size_velocity = flag_u_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9487 int ghost_size_rho = flag_rho_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9488 int ghost_size_temperature = flag_temperature_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9489 int ghost_size_pressure = (lecture_post_instantanes_filtrer_p_ || lecture_post_instantanes_filtrer_tous_) ? max((int) 1, ghost_size_filter) : 1;
9490
9491 /* allocation des tableaux */
9492 allocate_velocity(velocity_, domaine_, ghost_size_velocity);
9496 rho_.allocate(domaine_, Domaine_IJK::ELEM, ghost_size_rho);
9497 allocate_velocity(rho_v_, domaine_, 2);
9498 allocate_velocity(d_velocity_, domaine_, 1);
9499 allocate_velocity(RK3_F_velocity_, domaine_, 0);
9500 pressure_.allocate(domaine_, Domaine_IJK::ELEM, ghost_size_pressure);
9503 d_rho_.allocate(domaine_, Domaine_IJK::ELEM, 1);
9504 temperature_.allocate(domaine_, Domaine_IJK::ELEM, ghost_size_temperature);
9510
9511 //Modif Martin
9512 if (sauvegarde_splitting_name_ != "??")
9513 {
9514 if (( sauvegarde_splitting_.get_local_slice_index(0) == sauvegarde_splitting_.get_nprocessor_per_direction(0) - 1) || ( sauvegarde_splitting_.get_local_slice_index(1) == sauvegarde_splitting_.get_nprocessor_per_direction(1) - 1) || ( sauvegarde_splitting_.get_local_slice_index(2) == sauvegarde_splitting_.get_nprocessor_per_direction(2) - 1))
9515 {
9516 allocate_velocity(velocity_sauvegarde_, sauvegarde_splitting_, 1);
9525 }
9526 else
9527 {
9528 allocate_velocity(velocity_sauvegarde_, sauvegarde_splitting_, 0);
9537 }
9538 }
9539
9540 /* initialisation des tableaux */
9541 // Fill with valid floating point data in walls and ghost cells:
9542 velocity_[0].data() = 0.;
9543 velocity_[1].data() = 0.;
9544 velocity_[2].data() = 0.;
9545 velocity_elem_X_.data()=0.;
9546 velocity_elem_Y_.data()=0.;
9547 velocity_elem_Z_.data()=0.;
9548 rho_.data() = 1.; // not zero=> might want 1./rho and must not crash
9549 rho_v_[0].data() = 0.;
9550 rho_v_[1].data() = 0.;
9551 rho_v_[2].data() = 0.;
9552 d_velocity_[0].data() = 0.;
9553 d_velocity_[1].data() = 0.;
9554 d_velocity_[2].data() = 0.;
9555 RK3_F_velocity_[0].data() = 0.;
9556 RK3_F_velocity_[1].data() = 0.;
9557 RK3_F_velocity_[2].data() = 0.;
9558 pressure_.data() = 0.;
9559 molecular_mu_.data() = 0.;
9560 pressure_rhs_.data() = 0.;
9561 d_rho_.data() = 0.;
9562 temperature_.data() = 293.; // like rho: not zero
9563 RK3_F_rho_.data() = 0.;
9564 molecular_lambda_.data() = 0.;
9565 div_lambda_grad_T_volume_.data() = 0.;
9566 u_div_rho_u_.data() = 0.;
9567 divergence_.data() = 0.;
9568
9569
9570 // bool save_next_timestep=false;
9571 bool save_current_timestep=false;
9572
9573
9579 {
9580 if (filter_kernel_name_ == Nom("laplacian"))
9581 {
9582 Cerr << "Taille du filtre explicite identique a celle du filtre." << finl;
9586 calculer_delta_z_filtre_identique(domaine_, delta_z_local_pour_delta_, delta_z_local_pour_delta_filtre_);
9587 }
9588 else
9589 {
9590 const double n_mailles = kernel_->n_mailles();
9591 Cerr << "Taille du filtre explicite fixee a " << n_mailles << " mailles." << finl;
9592
9593 facteur_delta_filtre_x_ = sqrt(n_mailles*n_mailles + facteur_delta_x_*facteur_delta_x_);
9594 facteur_delta_filtre_y_ = sqrt(n_mailles*n_mailles + facteur_delta_y_*facteur_delta_y_);
9596 calculer_delta_z_filtre_n_mailles((int)n_mailles, domaine_, delta_z_local_, delta_z_local_pour_delta_, delta_z_local_pour_delta_filtre_);
9597 }
9599 for (int i=0 ; i<18 ; i++)
9600 {
9601 const int ni = velocity_[2].ni();
9602 const int nj = velocity_[2].nj();
9603
9604 // On voudrait
9605 // tmp_b_[i].allocate(ni, nj, 1, ghost_size_filter);
9606 // tmp_a_[i].allocate(ni, 1, 1, ghost_size_filter);
9607 // mais 'allocate' interdit ghost_size < ni, nj ou nk.
9608 tmp_b_[i].allocate(ni, nj, ghost_size_filter, ghost_size_filter);
9609 tmp_a_[i].allocate(ni, ghost_size_filter, ghost_size_filter, ghost_size_filter);
9610 }
9611 const int nktot = velocity_[2].get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
9612 for (int i=0; i<8; i++)
9613 {
9614 for (int j=0; j<7; j++)
9615 {
9616 ml_[i][j].resize_array(nktot+1);
9617 }
9618 }
9619 }
9620
9621 // DD,2017-04-27: diffusion modifie en vue de l'ajout de modeles
9623 {
9624 int ghost_size_turbulent_mu = flag_turbulent_mu_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9625
9627 {
9628 turbulent_mu_tensor_[0].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9629 turbulent_mu_tensor_[1].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9630 turbulent_mu_tensor_[2].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9631 turbulent_mu_tensor_[3].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9632 turbulent_mu_tensor_[4].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9633 turbulent_mu_tensor_[5].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9634 turbulent_mu_tensor_[0].data() = 0.;
9635 turbulent_mu_tensor_[1].data() = 0.;
9636 turbulent_mu_tensor_[2].data() = 0.;
9637 turbulent_mu_tensor_[3].data() = 0.;
9638 turbulent_mu_tensor_[4].data() = 0.;
9639 turbulent_mu_tensor_[5].data() = 0.;
9640 }
9641 else
9642 {
9643 turbulent_mu_.allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9644 turbulent_mu_.data() = 0.;
9645 }
9646 }
9648 {
9649 int ghost_size_turbulent_kappa = flag_turbulent_kappa_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9650
9652 {
9653 allocate_cell_vector(turbulent_kappa_vector_, domaine_, ghost_size_turbulent_kappa);
9654 turbulent_kappa_vector_[0].data() = 0.;
9655 turbulent_kappa_vector_[1].data() = 0.;
9656 turbulent_kappa_vector_[2].data() = 0.;
9657 }
9658 else
9659 {
9660 turbulent_kappa_.allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_kappa);
9661 turbulent_kappa_.data() = 0.;
9662 }
9663 }
9664
9665 if (flag_u_filtre_)
9666 {
9667 allocate_velocity(velocity_filtre_, domaine_, 2);
9668 velocity_filtre_[0].data() = 0.;
9669 velocity_filtre_[1].data() = 0.;
9670 velocity_filtre_[2].data() = 0.;
9671 }
9672 if (structural_uu_)
9673 {
9674 int ghost_size_structural_uu = flag_structural_uu_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9675
9676 structural_uu_tensor_[0].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu);
9677 structural_uu_tensor_[1].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu);
9678 structural_uu_tensor_[2].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu);
9679 structural_uu_tensor_[3].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu);
9680 structural_uu_tensor_[4].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu);
9681 structural_uu_tensor_[5].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu);
9682 structural_uu_tensor_[0].data() = 0.;
9683 structural_uu_tensor_[1].data() = 0.;
9684 structural_uu_tensor_[2].data() = 0.;
9685 structural_uu_tensor_[3].data() = 0.;
9686 structural_uu_tensor_[4].data() = 0.;
9687 structural_uu_tensor_[5].data() = 0.;
9688 }
9689
9690 if (flag_rho_filtre_)
9691 {
9693 rho_filtre_.data() = 1.; // not zero=> might want 1./rho and must not crash
9694 }
9696 {
9698 temperature_filtre_.data() = 293.; // like rho: not zero
9699 }
9701 {
9702 int ghost_size_structural_uscalar = flag_structural_uscalar_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9703 allocate_cell_vector(structural_uscalar_vector_, domaine_,ghost_size_structural_uscalar );
9704 structural_uscalar_vector_[0].data() = 0.;
9705 structural_uscalar_vector_[1].data() = 0.;
9706 structural_uscalar_vector_[2].data() = 0.;
9707 }
9708
9710 {
9712 {
9719 turbulent_mu_filtre_tensor_[0].data() = 0.;
9720 turbulent_mu_filtre_tensor_[1].data() = 0.;
9721 turbulent_mu_filtre_tensor_[2].data() = 0.;
9722 turbulent_mu_filtre_tensor_[3].data() = 0.;
9723 turbulent_mu_filtre_tensor_[4].data() = 0.;
9724 turbulent_mu_filtre_tensor_[5].data() = 0.;
9725 }
9726 else
9727 {
9729 turbulent_mu_filtre_.data() = 0.;
9730 }
9731 }
9733 {
9735 {
9736 allocate_cell_vector(turbulent_kappa_filtre_vector_, domaine_,2 );
9737 turbulent_kappa_filtre_vector_[0].data() = 0.;
9738 turbulent_kappa_filtre_vector_[1].data() = 0.;
9739 turbulent_kappa_filtre_vector_[2].data() = 0.;
9740 }
9741 else
9742 {
9744 turbulent_kappa_filtre_.data() = 0.;
9745 }
9746 }
9747
9749 {
9756 structural_uu_filtre_tensor_[0].data() = 0.;
9757 structural_uu_filtre_tensor_[1].data() = 0.;
9758 structural_uu_filtre_tensor_[2].data() = 0.;
9759 structural_uu_filtre_tensor_[3].data() = 0.;
9760 structural_uu_filtre_tensor_[4].data() = 0.;
9761 structural_uu_filtre_tensor_[5].data() = 0.;
9762 }
9764 {
9768 structural_uscalar_filtre_vector_[0].data() = 0.;
9769 structural_uscalar_filtre_vector_[1].data() = 0.;
9770 structural_uscalar_filtre_vector_[2].data() = 0.;
9771 }
9772
9774 {
9775 int ghost_size_structural_uu_tmp = flag_structural_uu_tmp_ ? max((int) 2, ghost_size_filter) : 2;
9776
9777 structural_uu_tmp_tensor_[0].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu_tmp);
9778 structural_uu_tmp_tensor_[1].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu_tmp);
9779 structural_uu_tmp_tensor_[2].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu_tmp);
9780 structural_uu_tmp_tensor_[3].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu_tmp);
9781 structural_uu_tmp_tensor_[4].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu_tmp);
9782 structural_uu_tmp_tensor_[5].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu_tmp);
9783 structural_uu_tmp_tensor_[0].data() = 0.;
9784 structural_uu_tmp_tensor_[1].data() = 0.;
9785 structural_uu_tmp_tensor_[2].data() = 0.;
9786 structural_uu_tmp_tensor_[3].data() = 0.;
9787 structural_uu_tmp_tensor_[4].data() = 0.;
9788 structural_uu_tmp_tensor_[5].data() = 0.;
9789 }
9791 {
9792 int ghost_size_structural_uscalar_tmp = flag_structural_uscalar_tmp_ ? max((int) 2, ghost_size_filter) : 2;
9793
9794 allocate_cell_vector(structural_uscalar_tmp_vector_, domaine_, ghost_size_structural_uscalar_tmp);
9795 structural_uscalar_tmp_vector_[0].data() = 0.;
9796 structural_uscalar_tmp_vector_[1].data() = 0.;
9797 structural_uscalar_tmp_vector_[2].data() = 0.;
9798 }
9800 {
9801 ghost_size_d_velocity_tmp = flag_d_velocity_tmp_ ? max((int) 2, ghost_size_filter) : 2;
9802
9803 allocate_velocity(d_velocity_tmp_, domaine_, ghost_size_d_velocity_tmp);
9804 d_velocity_tmp_[0].data() = 0.;
9805 d_velocity_tmp_[1].data() = 0.;
9806 d_velocity_tmp_[2].data() = 0.;
9807 }
9808
9809 const int nb_allocated_arrays = 21;
9810 Cerr << " Allocating " << nb_allocated_arrays << " arrays, approx total size= "
9811 << (double)(unsigned long)molecular_mu_.data().size_array() * sizeof(double) * nb_allocated_arrays * 9.537E-07 << " MB per core" << finl;
9812
9813
9814 // DD,2017-04-27: diffusion modifie en vue de l'ajout de modeles
9815 if (type_velocity_diffusion_ == Nom("simple"))
9816 {
9817 Cerr << "The diffusion is 'simple': the flux is 'molecular_mu * grad u'" << finl;
9820 }
9821 else if (type_velocity_diffusion_ == Nom("simple_with_transpose"))
9822 {
9823 Cerr << "The diffusion is 'simple_with_transpose': the flux is 'molecular_mu * (grad u + grad^T u)'" << finl;
9826 }
9827 else if (type_velocity_diffusion_ == Nom("full"))
9828 {
9829 Cerr << "The diffusion is 'full': the flux is 'molecular_mu * (grad u + grad^T u - 2/3 * div u * Id)'" << finl;
9832 }
9833 else if (type_velocity_diffusion_ == Nom("none"))
9834 {
9835 Cerr << "The diffusion is 'none': no molecular diffusion" << finl;
9836 }
9837 else
9838 {
9839 Cerr << "Unknown velocity diffusion operator! " << finl;
9840 Process::exit();
9841 }
9842
9843 if (type_velocity_turbulent_diffusion_ == Nom("simple"))
9844 {
9845 Cerr << "The velocity turbulent diffusion is 'simple': the flux is 'turbulent_mu * grad u'" << finl;
9848 }
9849 else if (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose"))
9850 {
9851 Cerr << "The velocity turbulent diffusion is 'simple_with_transpose': the flux is 'turbulent_mu * (grad u + grad^T u)'" << finl;
9854 }
9855 else if (type_velocity_turbulent_diffusion_ == Nom("full"))
9856 {
9857 Cerr << "The velocity turbulent diffusion is 'full': the flux is 'turbulent_mu * (grad u + grad^T u - 2/3 * div u * Id)'" << finl;
9860 }
9861 else if (type_velocity_turbulent_diffusion_ == Nom("simple_anisotropic"))
9862 {
9863 Cerr << "The velocity turbulent diffusion is 'simple_anisotropic': the flux is 'turbulent_mu^a * grad^a u' where (grad^a)_i = Delta_i (grad)_i" << finl;
9866 }
9867 else if (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose_anisotropic"))
9868 {
9869 Cerr << "The velocity turbulent diffusion is 'simple_with_transpose_anisotropic': the flux is 'turbulent_mu^a * (grad^a u + grad^a^T u)' where (grad^a)_i = Delta_i (grad)_i" << finl;
9872 }
9873 else if (type_velocity_turbulent_diffusion_ == Nom("full_anisotropic"))
9874 {
9875 Cerr << "The velocity turbulent diffusion is 'full_anisotropic': the flux is 'turbulent_mu^a * (grad^a u + grad^a^T u - 2/3 * div^a u * Id)' where (grad^a)_i = Delta_i (grad)_i" << finl;
9878 }
9879 else if (type_velocity_turbulent_diffusion_ == Nom("none"))
9880 {
9881 Cerr << "The velocity turbulent diffusion is 'none': no turbulent diffusion" << finl;
9882 }
9883 else
9884 {
9885 Cerr << "Unknown velocity turbulent diffusion operator! " << finl;
9886 Process::exit();
9887 }
9888
9889 if (structural_uu_)
9890 {
9891 Cerr << "A structural model will be added to the velocity turbulent diffusion. The structural uu tensor coefficients are:";
9892 Cerr << " xx: " << structural_uu_tensor_coefficients_[0];
9893 Cerr << " xy: " << structural_uu_tensor_coefficients_[1];
9894 Cerr << " xz: " << structural_uu_tensor_coefficients_[2];
9895 Cerr << " yy: " << structural_uu_tensor_coefficients_[3];
9896 Cerr << " yz: " << structural_uu_tensor_coefficients_[4];
9897 Cerr << " zz: " << structural_uu_tensor_coefficients_[5];
9898 Cerr << finl;
9901 }
9902
9904 {
9905 Cerr << "A structural model will be added to the scalar turbulent diffusion. The structural uscalar vector coefficients are:"
9909 << finl;
9911 }
9912
9913 if (type_scalar_turbulent_diffusion_ == Nom("normal"))
9914 {
9915 Cerr << "The scalar turbulent diffusion is 'normal': the flux is 'lambda * grad s'" << finl;
9917 }
9918 else if (type_scalar_turbulent_diffusion_ == Nom("anisotropic"))
9919 {
9920 Cerr << "The scalar turbulent diffusion is 'anisotropic': the flux is 'lambda^a * grad^a s' where (grad^a)_i = Delta_i (grad)_i" << finl;
9922 }
9923 else if (type_scalar_turbulent_diffusion_ == Nom("none"))
9924 {
9925 Cerr << "The scalar turbulent diffusion is 'none': no scalar turbulent diffusion" << finl;
9926 }
9927 else
9928 {
9929 Cerr << "Unknown scalar turbulent diffusion operator! " << finl;
9930 Process::exit();
9931 }
9932
9933 // On cree des variables ref_turbulent_mu_ij qui sont des references a
9934 // turbulent_mu_ij si la viscosite est tensorielle et
9935 // turbulent_mu_ si la viscosite n'est pas tensorielle.
9936 IJK_Field_double* ptr_turbulent_mu_xx;
9937 IJK_Field_double* ptr_turbulent_mu_xy;
9938 IJK_Field_double* ptr_turbulent_mu_xz;
9939 IJK_Field_double* ptr_turbulent_mu_yy;
9940 IJK_Field_double* ptr_turbulent_mu_yz;
9941 IJK_Field_double* ptr_turbulent_mu_zz;
9942
9944 {
9945 ptr_turbulent_mu_xx = &turbulent_mu_tensor_[0];
9946 ptr_turbulent_mu_xy = &turbulent_mu_tensor_[1];
9947 ptr_turbulent_mu_xz = &turbulent_mu_tensor_[2];
9948 ptr_turbulent_mu_yy = &turbulent_mu_tensor_[3];
9949 ptr_turbulent_mu_yz = &turbulent_mu_tensor_[4];
9950 ptr_turbulent_mu_zz = &turbulent_mu_tensor_[5];
9951 Cerr << "The turbulent viscosity is tensorial. The turbulent viscosity tensor coefficients are:"
9954 Cerr << " xz: " << turbulent_viscosity_tensor_coefficients_[2]
9957 Cerr << " zz: " << turbulent_viscosity_tensor_coefficients_[5]
9958 << finl;
9959 }
9960 else
9961 {
9962 ptr_turbulent_mu_xx = &turbulent_mu_;
9963 ptr_turbulent_mu_xy = &turbulent_mu_;
9964 ptr_turbulent_mu_xz = &turbulent_mu_;
9965 ptr_turbulent_mu_yy = &turbulent_mu_;
9966 ptr_turbulent_mu_yz = &turbulent_mu_;
9967 ptr_turbulent_mu_zz = &turbulent_mu_;
9968 Cerr << "The turbulent viscosity is not tensorial." << finl;
9969 }
9970
9971 IJK_Field_double& ref_turbulent_mu_xx = *ptr_turbulent_mu_xx;
9972 IJK_Field_double& ref_turbulent_mu_xy = *ptr_turbulent_mu_xy;
9973 IJK_Field_double& ref_turbulent_mu_xz = *ptr_turbulent_mu_xz;
9974 IJK_Field_double& ref_turbulent_mu_yy = *ptr_turbulent_mu_yy;
9975 IJK_Field_double& ref_turbulent_mu_yz = *ptr_turbulent_mu_yz;
9976 IJK_Field_double& ref_turbulent_mu_zz = *ptr_turbulent_mu_zz;
9977
9978 // On cree des variables ref_turbulent_kappa_i qui sont des references a
9979 // turbulent_kappa_i si la diffusivite est vectorielle et
9980 // turbulent_kappa_ si la diffusivite n'est pas vectorielle.
9981 IJK_Field_double* ptr_turbulent_kappa_x;
9982 IJK_Field_double* ptr_turbulent_kappa_y;
9983 IJK_Field_double* ptr_turbulent_kappa_z;
9984
9986 {
9987 ptr_turbulent_kappa_x = &turbulent_kappa_vector_[0];
9988 ptr_turbulent_kappa_y = &turbulent_kappa_vector_[1];
9989 ptr_turbulent_kappa_z = &turbulent_kappa_vector_[2];
9990 Cerr << "The turbulent diffusivity is vectorial. The turbulent diffusivity vector coefficients are:"
9994 << finl;
9995 }
9996 else
9997 {
9998 ptr_turbulent_kappa_x = &turbulent_kappa_;
9999 ptr_turbulent_kappa_y = &turbulent_kappa_;
10000 ptr_turbulent_kappa_z = &turbulent_kappa_;
10001 Cerr << "The turbulent diffusivity is not tensorial." << finl;
10002 }
10003
10004 IJK_Field_double& ref_turbulent_kappa_x = *ptr_turbulent_kappa_x;
10005 IJK_Field_double& ref_turbulent_kappa_y = *ptr_turbulent_kappa_y;
10006 IJK_Field_double& ref_turbulent_kappa_z = *ptr_turbulent_kappa_z;
10007
10008// velocity_convection_op_.initialize(splitting_);
10009
10011 {
10013 }
10015 {
10017 }
10019 {
10022 }
10023 else
10024 {
10025 // Schema centre4 (utilise par defaut)
10028 }
10029
10031 {
10033 }
10034 else if (convection_rho_amont_)
10035 {
10037 }
10038 else if (convection_rho_centre4_)
10039 {
10040 // ATTENTION le schema centre 4 OpCentre4IJK a ete modifie pour devenir un centre 2
10043 }
10044 else
10045 {
10046 // Schema quick (utilise par defaut)
10047 rho_convection_op_.initialize(domaine_);
10048 }
10051 {
10052 poisson_solver_.initialize(domaine_);
10053 }
10054
10055 initialise();
10056 force_zero_normal_velocity_on_walls(velocity_[2]);
10057
10058 statistics().create_custom_counter("calcul dtstab QC",2,"TrioCFD");
10059 statistics().create_custom_counter("update statistiques",2,"TrioCFD");
10060 statistics().create_custom_counter("calcul terme acceleration",2,"TrioCFD");
10061 statistics().create_custom_counter("checkpointing",2,"TrioCFD");
10062 statistics().create_custom_counter("TF update",2,"TrioCFD");
10063 // modif FA AT 16/07/2013 necessaire pour le calcul des derivees
10064 // dans statistiques_.update_stat_k(...)
10065 temperature_.echange_espace_virtuel(1);
10066 molecular_lambda_.echange_espace_virtuel(1);
10067 molecular_mu_.echange_espace_virtuel(1);
10068 pressure_.echange_espace_virtuel(1);
10069 rho_.echange_espace_virtuel(2); // rho est echange sur deux mailles en prevision de rk_step
10070 velocity_[0].echange_espace_virtuel(2); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
10071 velocity_[1].echange_espace_virtuel(2); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
10072 velocity_[2].echange_espace_virtuel(2); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
10073
10074 // Projection initiale sur div(u)=0, si demande: (attention, ne pas le faire en reprise)
10076 {
10078 {
10079 Cerr << "*****************************************************************************\n"
10080 << " Attention : projection du champ de vitesse initial sur div(u)=0\n"
10081 << "*****************************************************************************" << finl;
10082
10083 pressure_projection_with_rho(rho_,velocity_[0], velocity_[1], velocity_[2],
10084 pressure_, 1.0 /* dt */, pressure_rhs_,
10085 poisson_solver_,0);
10086 pressure_.data() = 0.;
10087 pressure_rhs_.data() = 0.;
10088 // Echange espace virtuel inutiles car deja fait dans pressure_projection_with_rho
10089 velocity_[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
10090 velocity_[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
10091 velocity_[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
10092 }
10093 }
10094
10095 const Nom lata_name = nom_du_cas() + Nom("_lata_");
10096
10097 ArrOfDouble tmp_size3(3);
10098 // Postraiter la condition initiale:
10099 // Calcul des moyennes spatiales sur la condition initiale:
10102 flag_nu_anisotropic_, turbulent_viscosity_, ref_turbulent_mu_xx, ref_turbulent_mu_xy, ref_turbulent_mu_xz, ref_turbulent_mu_yy, ref_turbulent_mu_yz, ref_turbulent_mu_zz,
10103 flag_kappa_anisotropic_, turbulent_diffusivity_, ref_turbulent_kappa_x, ref_turbulent_kappa_y, ref_turbulent_kappa_z,
10108 if (statistiques_.check_converge())
10109 {
10111 }
10113
10114 // ATTENTION PARTIE pour le test et debugage
10115 if ( 0 )
10116 {
10118 Cerr << " Post-traitement Spectral " << finl;
10119 Nom Nom_post_test = "Spectrale";
10120 partie_fourier_.postraiter(Nom_post_test);
10121 Process::exit();
10122 }
10123
10124 int stop = 0;
10125 double previous_time = 0;
10126
10127 // DD,2016-28-01: statistiques a partir de fichiers lata uniquement
10129 {
10131
10132 Cerr << "*****************************************************************************\n"
10133 << " Attention : On ne fait que postraiter les statistiques depuis les lata\n"
10134 << "*****************************************************************************" << finl;
10135 }
10136
10137 statistics().start_timeloop();
10138 for (int tstep = 0; tstep < nb_timesteps_ && stop == 0; tstep++)
10139 {
10140 statistics().start_time_step();
10141 statistics().begin_count(STD_COUNTERS::timeloop,statistics().get_last_opened_counter_level()+1);
10142 DebogIJK::verifier("Vitesse_X init", velocity_[0]);
10143 DebogIJK::verifier("Vitesse_Y init", velocity_[1]);
10144 DebogIJK::verifier("Vitesse_Z init", velocity_[2]);
10145 DebogIJK::verifier("rho init", rho_);
10146
10147 // DD,2016-28-01: statistiques a partir de fichiers lata uniquement
10149 {
10150 Nom statlata_fichier = Nom(statlata_namelist_[tstep]);
10151 statlata_fichier += Nom(".sauv");
10152
10153 previous_time = current_time_;
10154 reprendre_qc(statlata_fichier); // current_time_ mis a jour
10155 timestep_ = current_time_ - previous_time;
10156
10157 Cout << "T= " << current_time_
10158 << " timestep= " << timestep_ << finl;
10159
10160 const Nom& geom_name = domaine_.le_nom();
10161
10162 Cout << "Lecture rho dans fichier " << fichier_reprise_rho_ << " timestep= " << timestep_reprise_rho_ << finl;
10163 lire_dans_lata(fichier_reprise_rho_, timestep_reprise_rho_, geom_name, "RHO", rho_);
10164
10165 Cout << "Lecture pression dans fichier " << fichier_reprise_rho_ << " timestep= " << timestep_reprise_rho_ << finl;
10166 lire_dans_lata(fichier_reprise_rho_, timestep_reprise_rho_, geom_name, "PRESSURE", pressure_);
10167
10168 Cout << "Lecture vitesse dans fichier " << fichier_reprise_vitesse_ << " timestep= " << timestep_reprise_vitesse_ << finl;
10169 lire_dans_lata(fichier_reprise_vitesse_, timestep_reprise_vitesse_, geom_name, "VELOCITY",
10170 velocity_[0], velocity_[1], velocity_[2]);
10171
10173 {
10174 const int flag_add = 0;
10175 velocity_[0].echange_espace_virtuel(ghost_size_velocity);
10176 velocity_[1].echange_espace_virtuel(ghost_size_velocity);
10177 velocity_[2].echange_espace_virtuel(ghost_size_velocity);
10181 }
10182
10184 {
10185 const int flag_add = 0;
10186 rho_.echange_espace_virtuel(ghost_size_rho);
10188 }
10189
10191 {
10192 const int flag_add = 0;
10193 pressure_.echange_espace_virtuel(ghost_size_pressure);
10195 }
10196
10197 rho_.echange_espace_virtuel(1);
10199
10200 temperature_.echange_espace_virtuel(1);
10201 molecular_lambda_.echange_espace_virtuel(1);
10202 molecular_mu_.echange_espace_virtuel(1);
10203 pressure_.echange_espace_virtuel(1);
10204 rho_.echange_espace_virtuel(2);
10205 velocity_[0].echange_espace_virtuel(2);
10206 velocity_[1].echange_espace_virtuel(2);
10207 velocity_[2].echange_espace_virtuel(2);
10208 }
10209 else
10210 {
10211 // Calcul du pas de temps:
10212
10213 velocity_[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
10214 velocity_[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
10215 velocity_[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
10216
10217 statistics().begin_count("calcul dtstab QC",statistics().get_last_opened_counter_level()+1);
10219
10220 double dt_conv = conv_qdm_negligeable_ ? 1.e20 : velocity_convection_op_.compute_dtstab_convection_local(velocity_[0], velocity_[1], velocity_[2]);
10221 double dt_diff = 1.e20;
10222 double dt_diff_mu = 1.e20;
10223 if (old_dtstab_)
10224 {
10225 dt_diff_mu = diff_qdm_negligeable_ ? 1.e20 : calculer_dtstab_diffusion_temperature_local(molecular_mu_, rho_, 1.);
10226 dt_diff = diff_temp_negligeable_ ? 1.e20 : calculer_dtstab_diffusion_temperature_local(molecular_lambda_, rho_, Cp_gaz_);
10227 }
10228 else
10229 {
10233 {
10234 dt_diff_mu = diff_qdm_negligeable_ ? 1.e20 : calculer_dtstab_diffusion_temperature_local(molecular_mu_, rho_, 1.);
10235 dt_diff = dt_diff_mu;
10236 }
10238 {
10239 dt_diff_mu = diff_qdm_negligeable_ ? 1.e20 : calculer_dtstab_diffusion_temperature_local_avec_turbulent_favre(flag_nu_anisotropic_, molecular_mu_, ref_turbulent_mu_xx, ref_turbulent_mu_xy, ref_turbulent_mu_xz, ref_turbulent_mu_yy, ref_turbulent_mu_yz, ref_turbulent_mu_zz, rho_, 1.);
10240 dt_diff = dt_diff_mu;
10241 }
10243 {
10244 dt_diff_mu = diff_qdm_negligeable_ ? 1.e20 : calculer_dtstab_diffusion_temperature_local_avec_turbulent_velocity(flag_nu_anisotropic_, molecular_mu_, ref_turbulent_mu_xx, ref_turbulent_mu_xy, ref_turbulent_mu_xz, ref_turbulent_mu_yy, ref_turbulent_mu_yz, ref_turbulent_mu_zz, rho_, 1.);
10245 double dt_diff_kappa = calculer_dtstab_diffusion_temperature_local_sans_rho(flag_kappa_anisotropic_, ref_turbulent_kappa_x, ref_turbulent_kappa_y, ref_turbulent_kappa_z, 1.);
10246 dt_diff = min(dt_diff_mu, dt_diff_kappa);
10247 }
10249 {
10250 dt_diff_mu = diff_qdm_negligeable_ ? 1.e20 : calculer_dtstab_diffusion_temperature_local(molecular_mu_, rho_, 1.);
10251 double dt_diff_kappa = calculer_dtstab_diffusion_temperature_local_sans_rho(flag_kappa_anisotropic_, ref_turbulent_kappa_x, ref_turbulent_kappa_y, ref_turbulent_kappa_z, 1.);
10252 dt_diff = min(dt_diff_mu, dt_diff_kappa);
10253 }
10255 {
10256 dt_diff_mu = diff_qdm_negligeable_ ? 1.e20 : calculer_dtstab_diffusion_temperature_local_avec_turbulent_velocity(flag_nu_anisotropic_, molecular_mu_, ref_turbulent_mu_xx, ref_turbulent_mu_xy, ref_turbulent_mu_xz, ref_turbulent_mu_yy, ref_turbulent_mu_yz, ref_turbulent_mu_zz, rho_, 1.);
10257 dt_diff = dt_diff_mu;
10258 }
10259 else
10260 {
10261 Cerr << "This should not happen." << finl;
10262 Process::exit();
10263 }
10264 }
10265
10266 statistics().end_count("calcul dtstab QC");
10267 tmp_size3[0] = dt_conv;
10268 tmp_size3[1] = dt_diff;
10269 tmp_size3[2] = dt_diff_mu;
10270 mp_min_for_each_item(tmp_size3);
10271 dt_conv = tmp_size3[0];
10272 dt_diff = tmp_size3[1];
10273 dt_diff_mu = tmp_size3[2];
10274
10275 // ajouter ici methode de non progression du dt si trop faible. (stats plus stables => plus precise).
10276 const double dt_theorique = 1. / (1./dt_conv + 1./dt_diff);
10277 double dt_regule = min(dt_theorique * timestep_facsec_, timestep_max_);
10278
10279 // FA 17/03/14 amelioration pour le pas de temps !
10280 if (tstep == 0 ) /* au cas ou on a un dt_start */
10281 timestep_ = min(dt_regule,dt_start_);
10282 else if ( (dt_regule < timestep_) || ((dt_regule-timestep_)/timestep_ > 0.05 )) // on change le pas de temps si on gagne 5% ou si il faut descendre
10283 {
10284 timestep_ = dt_regule;
10285 }
10286 // We want to save each delta_t
10288 {
10289 // If the stability timestep makes us go beyond
10290 // the desired next timestep
10291 // change the timestep to match the next point
10293 {
10294 assert(timestep_ >= dt_save_cycle_ - current_time_ && "Something went wrong while trying to adapt the delta_t timestep");
10296 /* save_next_timestep = true; */
10297 save_current_timestep = true;
10298 }
10299 assert(timestep_ > 0 && "You can't have a null timestep");
10300 }
10301
10302 Cout << "T= " << current_time_
10303 << " dtconv= " << dt_conv
10304 << " dtdiff_t= " << dt_diff
10305 << " dtdiff_v= " << dt_diff_mu;
10306 Cout << " theorique_dt= " << dt_theorique
10307 << " dt_limited " << dt_regule
10308 << " timestep= " << timestep_ << finl;
10309
10310 // // F.A 3 /04/2014 changement de la source est maintenant calculee au debut de rk_sub_step
10311 // double v_moy, rho_v_moy;
10312 // calculer_v_et_rhov_moyen(velocity_[0], rho_, delta_z_local_, volume_total_domaine_, v_moy, rho_v_moy);
10313 // double derivee_acceleration;
10314 // if (Process::je_suis_maitre()) {
10315 // // Mise a jour de l'acceleration
10316 // parser_derivee_acceleration_.setVar("force", terme_source_acceleration_);
10317 // parser_derivee_acceleration_.setVar("v_moyen", v_moy);
10318 // parser_derivee_acceleration_.setVar("rho_v_moyen", rho_v_moy);
10319 // derivee_acceleration = parser_derivee_acceleration_.eval();
10320 // terme_source_acceleration_ += derivee_acceleration * timestep_;
10321 // }
10322 //
10323
10324 // F.A 16/04/14 changement de source (encore ...)
10325 // calcul de la force de recirculation avant modification des tableaux
10326
10327 statistics().begin_count("calcul terme acceleration",statistics().get_last_opened_counter_level()+1);
10328 double debit_old = debit_actuel_;
10329 calculer_debit(velocity_[0], rho_, delta_z_local_, Lx_tot_, debit_actuel_);
10330 double old_t_bulk = actual_t_bulk_;
10333 {
10334 double acceleration_du_dt = 0.;
10336 {
10338 }
10339 else
10340 {
10341 double ecart_debit = (debit_cible_ - debit_actuel_);
10342 double ecart_ancien = (debit_actuel_ - debit_old);
10343 acceleration_du_dt = ecart_debit - ecart_ancien;
10344 acceleration_du_dt /= dump_factor_ * Ly_tot_ * Lz_tot_ * timestep_;
10345
10346 terme_source_acceleration_ += acceleration_du_dt;
10347 }
10348
10350 {
10351 /* double derivative_flux = (sum_entering_flux_ - old_entering_hf)/Lz_tot_; */
10352 double derivative_2nd_order_t = aim_t_bulk_ - 2 * actual_t_bulk_ + old_t_bulk;
10353 double d = derivative_2nd_order_t / timestep_;
10354 /* double fac = dump_factor_2_ *( rho_bulk_ * constante_specifique_gaz_ * d / (gamma_ - 1) - derivative_flux); */
10355 double fac = dump_factor_2_ * rho_bulk_ * constante_specifique_gaz_ * d / (gamma_ - 1);
10356 puit_ -= fac;
10357 Cout << "Current heat sink: " << puit_
10358 << " Current T_bulk: " << actual_t_bulk_
10359 << " Aim T_bulk: " << aim_t_bulk_
10360 << " Old T_bulk: " << old_t_bulk
10361 << " factor " << fac
10362 << " Timestep " << timestep_
10363 << " rho bulk " << rho_bulk_
10364 /* << " sum_fluxes: " << sum_entering_flux_ */
10365 /* << " old_sum_fluxes: " << old_entering_hf */
10366 << finl;
10367 }
10368
10369
10370 // la derivee_acceleration n'est connue que sur le maitre
10371 Cout << "T= " << current_time_
10372 << " debit cible= " << debit_cible_
10373 << " debit actuel= " << debit_actuel_
10374 << " acceleration= " << terme_source_acceleration_
10375 << " da/dt= " << acceleration_du_dt << finl;
10376
10377
10378 }
10379 envoyer_broadcast(terme_source_acceleration_, 0);
10380 envoyer_broadcast(puit_, 0);
10381
10382
10383 // // F.A 3 /04/2014 changement de la source
10384 // if (Process::je_suis_maitre()) {
10385 // // la derivee_acceleration n'est connue que sur le maitre
10386 // Cout << "T= " << current_time_
10387 // << " Vx_moyen= " << v_moy
10388 // << " rho_vx_moyen= " << rho_v_moy
10389 // << " acceleration= " << terme_source_acceleration_
10390 // << " da/dt= " << derivee_acceleration << finl;
10391 // }
10392 //
10393
10394 statistics().end_count("calcul terme acceleration");
10395
10396 //////////////////////////
10397 for (int rk_step = 0; rk_step < 3; rk_step++)
10398 {
10399 rk3_sub_step(rk_step, timestep_);
10401 {
10402 statistics().begin_count(STD_COUNTERS::postreatment,statistics().get_last_opened_counter_level()+1);
10403 posttraiter_champs_instantanes(lata_name, current_time_ + timestep_ * rk_step / 3.0);
10404 statistics().end_count(STD_COUNTERS::postreatment);
10405 }
10406 }
10407 }
10408 // on s'assure que la force est la meme entre chaque pas de temps.
10409 // if (Process::je_suis_maitre())
10410 // envoyer_broadcast(terme_source_acceleration_, 0);
10411
10413 {
10414 statistics().begin_count(STD_COUNTERS::postreatment,statistics().get_last_opened_counter_level()+1);
10415 statistics().begin_count("update statistiques",statistics().get_last_opened_counter_level()+1);
10418 flag_nu_anisotropic_, turbulent_viscosity_, ref_turbulent_mu_xx, ref_turbulent_mu_xy, ref_turbulent_mu_xz, ref_turbulent_mu_yy, ref_turbulent_mu_yz, ref_turbulent_mu_zz,
10419 flag_kappa_anisotropic_, turbulent_diffusivity_, ref_turbulent_kappa_x, ref_turbulent_kappa_y, ref_turbulent_kappa_z,
10423 Cp_gaz_, P_thermodynamique_, timestep_); // stats standard
10424 if (statistiques_.check_converge())
10426 statistics().end_count("update statistiques");
10427 statistics().begin_count("TF update",statistics().get_last_opened_counter_level()+1);
10428 if ( dt_post_spectral_ > 0 )
10429 {
10430 int un_sur_20 = tstep%20;
10431 if ( !un_sur_20 )
10433 }
10434 statistics().end_count("TF update");
10435 statistics().end_count(STD_COUNTERS::postreatment);
10436 }
10437
10439 {
10440 // do nothing
10441 }
10442 else
10443 {
10445 }
10446 // verification du fichier stop
10447 stop = 0;
10448 if (check_stop_file_ != "??")
10449 {
10450 if (je_suis_maitre())
10451 {
10452 EFichier f;
10453 stop = f.ouvrir(check_stop_file_);
10454 if (stop)
10455 {
10456 // file exists, check if it contains 1:
10457 f >> stop;
10458 }
10459 }
10460 envoyer_broadcast(stop, 0);
10461 }
10462 if (tstep == nb_timesteps_ - 1)
10463 stop = true;
10464
10465 if (tstep % dt_sauvegarde_ == dt_sauvegarde_-1 || stop)
10466 {
10467 statistics().begin_count("checkpointing",statistics().get_last_opened_counter_level()+1);
10469 statistics().end_count("checkpointing");
10470 }
10471
10472 if (tstep % dt_post_ == dt_post_-1 || stop)
10473 {
10474 statistics().end_count(STD_COUNTERS::timeloop,0,0);
10476 statistics().begin_count(STD_COUNTERS::timeloop,statistics().get_last_opened_counter_level()+1);
10477 }
10478
10479 if (save_current_timestep)
10480 {
10481 save_current_timestep=false;
10482 // save_next_timestep=false;
10483 Cerr << "Yanis: Raw data cycle " << finl;
10485 statistics().end_count(STD_COUNTERS::timeloop,0,0);
10486 save_raw_data(lata_name, current_time_);
10487 statistics().begin_count(STD_COUNTERS::timeloop,statistics().get_last_opened_counter_level()+1);
10488 }
10489
10490 /*
10491 if (current_time_ > dt_save_cycle_)
10492 {
10493 Cerr << "Yanis: Raw data cycle " << finl;
10494 dt_save_cycle_ += dt_save_oscillating_cycle_raw_data_;
10495 save_raw_data(lata_name, current_time_);
10496 }
10497 */
10498 if (tstep % dt_raw_data_ == dt_raw_data_-1)
10499 {
10500 Cerr << "Yanis: Raw data " << finl;
10501 statistics().end_count(STD_COUNTERS::timeloop,0,0);
10502 save_raw_data(lata_name, current_time_);
10503 statistics().begin_count(STD_COUNTERS::timeloop,statistics().get_last_opened_counter_level()+1);
10504 }
10505 if (tstep % dt_stats_ == dt_stats_-1)
10506 {
10507 Cerr << "Yanis: Stats " << finl;
10509 }
10510 if ((tstep % dt_post_spectral_ == dt_post_-1 || stop) && (dt_post_spectral_ != -1))
10511 {
10512 statistics().end_count(STD_COUNTERS::timeloop,0,0);
10513 Nom Nom_post = "Spectrale_";
10514 Nom_post += Nom(current_time_);
10515 partie_fourier_.postraiter(Nom_post);
10516 statistics().begin_count(STD_COUNTERS::timeloop,statistics().get_last_opened_counter_level()+1);
10517 }
10518 // calculer_moyennes_flux();
10519
10521 {
10522 Cerr << "tstep " << tstep
10523 << " currenttime " << current_time_
10524 << " cpu_time " << statistics().get_time_since_last_open(STD_COUNTERS::timeloop) << finl;
10525 }
10526 statistics().end_count(STD_COUNTERS::timeloop);
10527 statistics().end_time_step(tstep);
10528 }
10529 statistics().end_timeloop();
10530 statistics().print_TU_files("Time loop statistics");
10531 delete kernel_;
10532}
10533
10534
10535int calculer_k_pour_bord(const IJK_Field_double& temperature, const bool bord_kmax)
10536{
10537 const int kmin = temperature.get_domaine().get_offset_local(DIRECTION_K);
10538 const int nktot = temperature.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
10539 int k;
10540 // calcul l'indice k de la couche de mailles voisine du bord. Si je n'ai pas de bord, on met k = -1
10541 if (!bord_kmax)
10542 {
10543 // on veut le bord "k_global = 0"
10544 if (kmin == 0)
10545 {
10546 // ce bord est chez moi... et il est en k=0
10547 k = 0;
10548 }
10549 else
10550 {
10551 // ce bord n'est pas chez moi
10552 k = -1;
10553 }
10554 }
10555 else
10556 {
10557 // on veut le bord kmax
10558 if (kmin + temperature.nk() == nktot)
10559 {
10560 // ce bord est chez moi... et il est en k= truc...
10561 k = temperature.nk() - 1;
10562 }
10563 else
10564 {
10565 k = -1;
10566 }
10567 }
10568 return k;
10569}
10570
10571// valeur de retour: indice local du plan de temperature voisin utilise,
10572// -1 si on n'a pas le bord sur ce processeur
10573// Calcule l'integrale sur chaque face du bord demande du flux de chaleur a travers la face
10574// positif si le flux va vers les k positifs.
10575int calculer_flux_thermique_bord(const IJK_Field_double& temperature,
10576 const double lambda_de_t_paroi,
10577 const int turbulent_diffusivity,
10578 const IJK_Field_double& lambda_turbulent,
10579 const int flag_lambda_anisotropic,
10580 const int structural_uscalar,
10581 const IJK_Field_double& structural_uscalar_z,
10582 const double T_paroi_impose,
10583 IJK_Field_local_double& flux_bord,
10584 const bool bord_kmax)
10585{
10586 const int kmin = temperature.get_domaine().get_offset_local(DIRECTION_K);
10587 int k = calculer_k_pour_bord(temperature, bord_kmax);
10588 if (k == -1)
10589 return k;
10590
10591 // redimensionne flux_bord avec ni * nj:
10592 const int ni = temperature.ni(); // nombre d'element local sur ce processeur
10593 const int nj = temperature.nj();
10594 flux_bord.allocate(ni, nj, 1, 0);
10595
10596 const Domaine_IJK& geometry = temperature.get_domaine();
10597 const double delta_k = geometry.get_delta(DIRECTION_K)[k + kmin]; // k+kmin est l'indice global de la maille locale k
10598 const ArrOfDouble& coord_z = geometry.get_node_coordinates(DIRECTION_K);
10599
10600 for (int j = 0; j < nj; j++)
10601 {
10602 for (int i = 0; i < ni; i++)
10603 {
10604 const int sens = bord_kmax ? -1 : 1;
10605
10606 // si bord bas: x_p=coord_z[p]; y_k=velocity_k(i,j,p)
10607 // si bord haut: x_p=coord_z[k+kmin+1-p]; y_k=velocity_k(i,j,k+1-p)
10608 const double xf_0 = coord_z[k+kmin+bord_kmax];
10609 const double xf_1 = coord_z[k+kmin+bord_kmax+sens*1];
10610 const double xf_2 = coord_z[k+kmin+bord_kmax+sens*2];
10611
10612 const double x_p = xf_0;
10613 const double x_0 = 0.5*(xf_0+xf_1);
10614 const double x_1 = 0.5*(xf_1+xf_2);
10615
10616 double T_p = T_paroi_impose;
10617
10618 const double T_0 = temperature(i,j,k);
10619 const double T_1 = temperature(i,j,k+sens*1);
10620 double derivee_premiere = (x_1-x_p)*(x_0-x_p)/((x_0-x_p)-(x_1-x_p))*(T_1/((x_1-x_p)*(x_1-x_p))-T_0/((x_0-x_p)*(x_0-x_p))-T_p*(((x_0-x_p)*(x_0-x_p))-((x_1-x_p)*(x_1-x_p)))/(((x_0-x_p)*(x_0-x_p))*((x_1-x_p)*(x_1-x_p))));
10621
10622 double l;
10623 double flux;
10624 if (turbulent_diffusivity && (!flag_lambda_anisotropic))
10625 {
10626 l = lambda_turbulent(i,j,k) + lambda_de_t_paroi;
10627 }
10628 else if (turbulent_diffusivity && flag_lambda_anisotropic)
10629 {
10630 l = delta_k*lambda_turbulent(i,j,k) + lambda_de_t_paroi;
10631 }
10632 else
10633 {
10634 l = lambda_de_t_paroi;
10635 }
10636 /*
10637 // Faut-il ajouter ce if ? Si oui ou ajouter s ?
10638 if (structural_uscalar) {
10639 const double s = structural_uscalar_z(i,j,k);
10640 flux = ((T_paroi_impose - t) * l + s) * facteur;
10641 } else {
10642 // le flux est positif s'il va vers les k croissants
10643 flux = (T_paroi_impose - t) * l * facteur;
10644 }
10645 */
10646 if (structural_uscalar)
10647 {
10648 const double s = structural_uscalar_z(i,j,k);
10649 flux = -( derivee_premiere * l + s ) * geometry.get_constant_delta(DIRECTION_I) * geometry.get_constant_delta(DIRECTION_J);
10650 }
10651 else
10652 {
10653 flux = -( derivee_premiere * l ) * geometry.get_constant_delta(DIRECTION_I) * geometry.get_constant_delta(DIRECTION_J);
10654 }
10655 flux_bord(i,j,0) = flux;
10656 }
10657 }
10658 return k;
10659}
10660
10661
10662// p_thermo = pression thermodynamique
10663void DNS_QC_double::calcul_p_thermo_et_bilan(const IJK_Field_double& rho,
10664 IJK_Field_double& temperature,
10665 const int turbulent_diffusivity,
10666 const IJK_Field_double& lambda_turbulent,
10667 const int flag_lambda_anisotropic,
10668 const int structural_uscalar,
10669 const IJK_Field_double& structural_uscalar_z,
10670 const double P_th_initial,
10671 double& P_th_final,
10672 const double fractionnal_timestep,
10673 double& d_Pth_divise_par_gammamoins1) const
10674{
10675 IJK_Field_local_double flux_bord;
10676
10677 const int imax = temperature.ni();
10678 const int jmax = temperature.nj();
10679
10680 double P_th = P_th_initial;
10681 // Boucle point fixe:
10682 const int max_point_fixe = 3;
10683 double somme_flux_entrants;
10684
10685 for (int point_fixe_iter = 0; point_fixe_iter < max_point_fixe; point_fixe_iter++)
10686 {
10687 // Calcul t_star a partir de rho et de la valeur courante de pthermo
10688 // boucle sur les deux plans conditions aux limites:
10689 double somme_flux_kmin = 0.;
10690 double somme_flux_kmax = 0.;
10691 for (int plan_cl = 0; plan_cl < 2; plan_cl++)
10692 {
10693 double somme_flux = 0.;
10694 // indice local du plan de mailles voisin de ce bord:
10695 int k = calculer_k_pour_bord(temperature, plan_cl);
10696 if (k > -1)
10697 {
10698 for (int j = 0; j < jmax; j++)
10699 {
10700 for (int i = 0; i < imax; i++)
10701 {
10702 temperature(i,j,k) = P_th / (constante_specifique_gaz_ * rho(i,j,k));
10703 }
10704 }
10705 const double lambda_de_t_paroi = (plan_cl ? lambda_de_t_paroi_kmax_ : lambda_de_t_paroi_kmin_);
10706 const double T_paroi_impose = (plan_cl ? T_paroi_impose_kmax_ : T_paroi_impose_kmin_);
10707
10708 calculer_flux_thermique_bord(temperature, lambda_de_t_paroi,
10709 0, lambda_turbulent, flag_lambda_anisotropic,
10710 0, structural_uscalar_z,
10711 T_paroi_impose, flux_bord, plan_cl);
10712 // integrale du flux:
10713 for (int j = 0; j < jmax; j++)
10714 {
10715 for (int i = 0; i < imax; i++)
10716 {
10717 somme_flux += flux_bord(i,j,0);
10718 }
10719 }
10720 }
10721 // le flux est positif si la chaleur va vers les k croissants:
10722 if (plan_cl)
10723 somme_flux_kmax = somme_flux;
10724 else
10725 somme_flux_kmin = somme_flux;
10726 }
10727 // Reduce 2 mp_sum calls to 1 by using mp_sum_for_each
10728 mp_sum_for_each(somme_flux_kmin, somme_flux_kmax);
10729 // Somme des flux entrants dans le domaine:
10730 if ( diff_temp_negligeable_ && !(formulation_favre_ && turbulent_diffusivity) && !(formulation_favre_ && structural_uscalar) ) // si diffusion negligable
10731 somme_flux_entrants =0;
10732 else
10733 somme_flux_entrants = somme_flux_kmin - somme_flux_kmax;
10734 P_th = P_th_initial / (1. - (gamma_ - 1) * fractionnal_timestep / P_th * ( somme_flux_entrants / volume_total_domaine_ - puit_ ));
10735
10736 assert_parallel(P_th);
10737 if (point_fixe_iter== max_point_fixe-1)
10738 {
10739 Cout << "calcul_p_thermo iter " << point_fixe_iter << " flux k=0: " << somme_flux_kmin
10740 << " flux k=kmax: " << somme_flux_kmax << " P_th: " << P_th << " ";
10741 }
10742 }
10743 P_th_final = P_th;
10744
10745 d_Pth_divise_par_gammamoins1 = somme_flux_entrants / volume_total_domaine_ - puit_;
10746 Cout << "dP_th/dt= " << d_Pth_divise_par_gammamoins1 * (gamma_ - 1) << finl;
10747}
10748
10749static void force_2d(IJK_Field_double& f)
10750{
10751 const int ni = f.ni();
10752 const int nj = f.nj();
10753 const int nk = f.nk();
10754 for (int k = 0; k < nk; k++)
10755 {
10756 for (int j = 1; j < nj; j++)
10757 {
10758 for (int i = 0; i < ni; i++)
10759 {
10760 f(i, j, k) = f(i, 0, k);
10761 }
10762 }
10763 }
10764}
10765
10766template<class T>
10767void DNS_QC_double::calculer_convection_vitesse(IJK_Field_vector3_double& rho_v,
10768 IJK_Field_vector3_double& velocity,
10769 const ArrOfDouble_with_ghost& delta_z,
10770 const double facteur_delta_x,
10771 const double facteur_delta_y,
10772 const ArrOfDouble_with_ghost& delta_z_pour_delta,
10773 T& kernel,
10776 IJK_Field_vector3_double& d_velocity_tmp,
10777 IJK_Field_vector3_double& d_velocity,
10778 IJK_Field_double& u_div_rho_u)
10779{
10780 int ghost_size_filter;
10781 int ghost_size_d_velocity_tmp;
10783 {
10785 {
10786 rho_v[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
10787 rho_v[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
10788 rho_v[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
10789 compute_divergence_times_constant(rho_v[0], rho_v[1], rho_v[2], 1., u_div_rho_u);
10790 u_div_rho_u.echange_espace_virtuel(1);
10791
10792 multiplier_champ_rho_face_i(false, u_div_rho_u, 1., velocity[0], d_velocity_tmp[0]);
10793 multiplier_champ_rho_face_j(false, u_div_rho_u, 1., velocity[1], d_velocity_tmp[1]);
10794 multiplier_champ_rho_face_k(false, u_div_rho_u, 1., 0., velocity[2], d_velocity_tmp[2]);
10795
10796 ghost_size_filter = 1 + kernel->ghost_size();
10797 ghost_size_d_velocity_tmp = max((int) 2, ghost_size_filter);
10798 d_velocity_tmp[0].echange_espace_virtuel(ghost_size_d_velocity_tmp);
10799 d_velocity_tmp[1].echange_espace_virtuel(ghost_size_d_velocity_tmp);
10800 d_velocity_tmp[2].echange_espace_virtuel(ghost_size_d_velocity_tmp);
10801
10802 const int flag_add = 1;
10803 filtrer_champ_elem(flag_add, d_velocity_tmp[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, d_velocity[0]);
10804 filtrer_champ_elem(flag_add, d_velocity_tmp[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, d_velocity[1]);
10805 filtrer_champ_face(flag_add, d_velocity_tmp[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, d_velocity[2]);
10806 }
10807 else
10808 {
10809 rho_v[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
10810 rho_v[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
10811 rho_v[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
10812 compute_divergence_times_constant(rho_v[0], rho_v[1], rho_v[2], 1., u_div_rho_u);
10813 u_div_rho_u.echange_espace_virtuel(1);
10814
10815 multiplier_champ_rho_face_i(true, u_div_rho_u, 1., velocity[0], d_velocity[0]);
10816 multiplier_champ_rho_face_j(true, u_div_rho_u, 1., velocity[1], d_velocity[1]);
10817 multiplier_champ_rho_face_k(true, u_div_rho_u, 1., 0., velocity[2], d_velocity[2]);
10818 }
10819 }
10820 else
10821 {
10823 {
10825 {
10826 velocity_convection_op_amont_.calculer(rho_v[0], rho_v[1], rho_v[2],
10827 velocity[0], velocity[1], velocity[2],
10828 d_velocity[0], d_velocity[1], d_velocity[2]);
10829
10830 }
10832 {
10833 velocity_convection_op_quicksharp_.calculer(rho_v[0], rho_v[1], rho_v[2],
10834 velocity[0], velocity[1], velocity[2],
10835 d_velocity[0], d_velocity[1], d_velocity[2]);
10836 }
10838 {
10839 velocity_convection_op_centre_2_.ajouter_avec_u_div_rhou(rho_v[0], rho_v[1], rho_v[2],
10840 velocity[0], velocity[1], velocity[2],
10841 d_velocity[0], d_velocity[1], d_velocity[2],
10842 u_div_rho_u);
10843 }
10844 else
10845 {
10846 // Schema centre4 (utilise par defaut)
10847 velocity_convection_op_.ajouter_avec_u_div_rhou(rho_v[0], rho_v[1], rho_v[2],
10848 velocity[0], velocity[1], velocity[2],
10849 d_velocity[0], d_velocity[1], d_velocity[2],
10850 u_div_rho_u);
10851 }
10852
10853 ghost_size_filter = 1 + kernel->ghost_size();
10854 ghost_size_d_velocity_tmp = max((int) 2, ghost_size_filter);
10855 d_velocity_tmp[0].echange_espace_virtuel(ghost_size_d_velocity_tmp);
10856 d_velocity_tmp[1].echange_espace_virtuel(ghost_size_d_velocity_tmp);
10857 d_velocity_tmp[2].echange_espace_virtuel(ghost_size_d_velocity_tmp);
10858
10859 const int flag_add = 1;
10860 filtrer_champ_elem(flag_add, d_velocity_tmp[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, d_velocity[0]);
10861 filtrer_champ_elem(flag_add, d_velocity_tmp[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, d_velocity[1]);
10862 filtrer_champ_face(flag_add, d_velocity_tmp[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, d_velocity[2]);
10863 }
10864 else
10865 {
10867 {
10868 velocity_convection_op_amont_.calculer(rho_v[0], rho_v[1], rho_v[2],
10869 velocity[0], velocity[1], velocity[2],
10870 d_velocity[0], d_velocity[1], d_velocity[2]);
10871 }
10873 {
10874 velocity_convection_op_quicksharp_.calculer(rho_v[0], rho_v[1], rho_v[2],
10875 velocity[0], velocity[1], velocity[2],
10876 d_velocity[0], d_velocity[1], d_velocity[2]);
10877 }
10879 {
10880 velocity_convection_op_centre_2_.ajouter_avec_u_div_rhou(rho_v[0], rho_v[1], rho_v[2],
10881 velocity[0], velocity[1], velocity[2],
10882 d_velocity[0], d_velocity[1], d_velocity[2],
10883 u_div_rho_u);
10884 }
10885 else
10886 {
10887 // Schema centre4 (utilise par defaut)
10888 velocity_convection_op_.ajouter_avec_u_div_rhou(rho_v[0], rho_v[1], rho_v[2],
10889 velocity[0], velocity[1], velocity[2],
10890 d_velocity[0], d_velocity[1], d_velocity[2],
10891 u_div_rho_u);
10892 }
10893 }
10894 }
10895}
10896
10897template<class T>
10898void DNS_QC_double::calculer_turbulent_diffusion_vitesse(IJK_Field_vector3_double& velocity,
10899 const IJK_Field_double& turbulent_mu_xx,
10900 const IJK_Field_double& turbulent_mu_xy,
10901 const IJK_Field_double& turbulent_mu_xz,
10902 const IJK_Field_double& turbulent_mu_yy,
10903 const IJK_Field_double& turbulent_mu_yz,
10904 const IJK_Field_double& turbulent_mu_zz,
10905 const ArrOfDouble_with_ghost& delta_z,
10906 const double facteur_delta_x,
10907 const double facteur_delta_y,
10908 const ArrOfDouble_with_ghost& delta_z_pour_delta,
10909 T& kernel,
10912 IJK_Field_vector3_double& d_velocity_tmp,
10913 IJK_Field_vector3_double& d_velocity)
10914{
10915 const IJK_Field_double& turbulent_mu_yx = turbulent_mu_xy;
10916 const IJK_Field_double& turbulent_mu_zx = turbulent_mu_xz;
10917 const IJK_Field_double& turbulent_mu_zy = turbulent_mu_yz;
10918 int ghost_size_filter;
10919 int ghost_size_d_velocity_tmp;
10921 {
10922 if (type_velocity_turbulent_diffusion_ == Nom("simple"))
10923 {
10924 velocity_turbulent_diffusion_op_simple_.set_coeff_x_y_z(turbulent_mu_xx,
10925 turbulent_mu_xy,
10926 turbulent_mu_xz,
10927 turbulent_mu_yx,
10928 turbulent_mu_yy,
10929 turbulent_mu_yz,
10930 turbulent_mu_zx,
10931 turbulent_mu_zy,
10932 turbulent_mu_zz);
10933 velocity_turbulent_diffusion_op_simple_.calculer(velocity[0], velocity[1], velocity[2],
10934 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
10935 }
10936 else if (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose"))
10937 {
10938 velocity_turbulent_diffusion_op_simple_with_transpose_.set_coeff_x_y_z(turbulent_mu_xx,
10939 turbulent_mu_xy,
10940 turbulent_mu_xz,
10941 turbulent_mu_yx,
10942 turbulent_mu_yy,
10943 turbulent_mu_yz,
10944 turbulent_mu_zx,
10945 turbulent_mu_zy,
10946 turbulent_mu_zz);
10947 velocity_turbulent_diffusion_op_simple_with_transpose_.calculer(velocity[0], velocity[1], velocity[2],
10948 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
10949 }
10950 else if (type_velocity_turbulent_diffusion_ == Nom("full"))
10951 {
10952 velocity[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
10953 velocity[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
10954 velocity[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
10955 compute_divergence(velocity[0], velocity[1], velocity[2], divergence_);
10956 divergence_.echange_espace_virtuel(1);
10957 velocity_turbulent_diffusion_op_full_.set_coeff_x_y_z(turbulent_mu_xx,
10958 turbulent_mu_xy,
10959 turbulent_mu_xz,
10960 turbulent_mu_yx,
10961 turbulent_mu_yy,
10962 turbulent_mu_yz,
10963 turbulent_mu_zx,
10964 turbulent_mu_zy,
10965 turbulent_mu_zz);
10967 velocity_turbulent_diffusion_op_full_.calculer(velocity[0], velocity[1], velocity[2],
10968 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
10969 }
10970 else if (type_velocity_turbulent_diffusion_ == Nom("simple_anisotropic"))
10971 {
10972 velocity_turbulent_diffusion_op_simple_anisotropic_.set_coeff_x_y_z(turbulent_mu_xx,
10973 turbulent_mu_xy,
10974 turbulent_mu_xz,
10975 turbulent_mu_yx,
10976 turbulent_mu_yy,
10977 turbulent_mu_yz,
10978 turbulent_mu_zx,
10979 turbulent_mu_zy,
10980 turbulent_mu_zz);
10981 velocity_turbulent_diffusion_op_simple_anisotropic_.calculer(velocity[0], velocity[1], velocity[2],
10982 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
10983 }
10984 else if (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose_anisotropic"))
10985 {
10987 turbulent_mu_xy,
10988 turbulent_mu_xz,
10989 turbulent_mu_yx,
10990 turbulent_mu_yy,
10991 turbulent_mu_yz,
10992 turbulent_mu_zx,
10993 turbulent_mu_zy,
10994 turbulent_mu_zz);
10995 velocity_turbulent_diffusion_op_simple_with_transpose_anisotropic_.calculer(velocity[0], velocity[1], velocity[2],
10996 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
10997 }
10998 else if (type_velocity_turbulent_diffusion_ == Nom("full_anisotropic"))
10999 {
11000 velocity[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
11001 velocity[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
11002 velocity[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
11003 compute_divergence(velocity[0], velocity[1], velocity[2], divergence_);
11004 divergence_.echange_espace_virtuel(1);
11005 velocity_turbulent_diffusion_op_full_anisotropic_.set_coeff_x_y_z(turbulent_mu_xx,
11006 turbulent_mu_xy,
11007 turbulent_mu_xz,
11008 turbulent_mu_yx,
11009 turbulent_mu_yy,
11010 turbulent_mu_yz,
11011 turbulent_mu_zx,
11012 turbulent_mu_zy,
11013 turbulent_mu_zz);
11015 velocity_turbulent_diffusion_op_full_anisotropic_.calculer(velocity[0], velocity[1], velocity[2],
11016 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
11017 }
11018 else
11019 {
11020 Cerr << "Unknown velocity turbulent diffusion operator! " << finl;
11021 Process::exit();
11022 }
11023
11024 ghost_size_filter = 1 + kernel->ghost_size();
11025 ghost_size_d_velocity_tmp = max((int) 2, ghost_size_filter);
11026 d_velocity_tmp[0].echange_espace_virtuel(ghost_size_d_velocity_tmp);
11027 d_velocity_tmp[1].echange_espace_virtuel(ghost_size_d_velocity_tmp);
11028 d_velocity_tmp[2].echange_espace_virtuel(ghost_size_d_velocity_tmp);
11029
11030 const int flag_add = 1;
11031 filtrer_champ_elem(flag_add, d_velocity_tmp[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, d_velocity[0]);
11032 filtrer_champ_elem(flag_add, d_velocity_tmp[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, d_velocity[1]);
11033 filtrer_champ_face(flag_add, d_velocity_tmp[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, d_velocity[2]);
11034 }
11035 else
11036 {
11037 if (type_velocity_turbulent_diffusion_ == Nom("simple"))
11038 {
11039 velocity_turbulent_diffusion_op_simple_.set_coeff_x_y_z(turbulent_mu_xx,
11040 turbulent_mu_xy,
11041 turbulent_mu_xz,
11042 turbulent_mu_yx,
11043 turbulent_mu_yy,
11044 turbulent_mu_yz,
11045 turbulent_mu_zx,
11046 turbulent_mu_zy,
11047 turbulent_mu_zz);
11048 velocity_turbulent_diffusion_op_simple_.ajouter(velocity[0], velocity[1], velocity[2],
11049 d_velocity[0], d_velocity[1], d_velocity[2]);
11050 }
11051 else if (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose"))
11052 {
11053 velocity_turbulent_diffusion_op_simple_with_transpose_.set_coeff_x_y_z(turbulent_mu_xx,
11054 turbulent_mu_xy,
11055 turbulent_mu_xz,
11056 turbulent_mu_yx,
11057 turbulent_mu_yy,
11058 turbulent_mu_yz,
11059 turbulent_mu_zx,
11060 turbulent_mu_zy,
11061 turbulent_mu_zz);
11062 velocity_turbulent_diffusion_op_simple_with_transpose_.ajouter(velocity[0], velocity[1], velocity[2],
11063 d_velocity[0], d_velocity[1], d_velocity[2]);
11064 }
11065 else if (type_velocity_turbulent_diffusion_ == Nom("full"))
11066 {
11067 velocity[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
11068 velocity[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
11069 velocity[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
11070 compute_divergence(velocity[0], velocity[1], velocity[2], divergence_);
11071 divergence_.echange_espace_virtuel(1);
11072 velocity_turbulent_diffusion_op_full_.set_coeff_x_y_z(turbulent_mu_xx,
11073 turbulent_mu_xy,
11074 turbulent_mu_xz,
11075 turbulent_mu_yx,
11076 turbulent_mu_yy,
11077 turbulent_mu_yz,
11078 turbulent_mu_zx,
11079 turbulent_mu_zy,
11080 turbulent_mu_zz);
11082 velocity_turbulent_diffusion_op_full_.ajouter(velocity[0], velocity[1], velocity[2],
11083 d_velocity[0], d_velocity[1], d_velocity[2]);
11084 }
11085 else if (type_velocity_turbulent_diffusion_ == Nom("simple_anisotropic"))
11086 {
11087 velocity_turbulent_diffusion_op_simple_anisotropic_.set_coeff_x_y_z(turbulent_mu_xx,
11088 turbulent_mu_xy,
11089 turbulent_mu_xz,
11090 turbulent_mu_yx,
11091 turbulent_mu_yy,
11092 turbulent_mu_yz,
11093 turbulent_mu_zx,
11094 turbulent_mu_zy,
11095 turbulent_mu_zz);
11096 velocity_turbulent_diffusion_op_simple_anisotropic_.ajouter(velocity[0], velocity[1], velocity[2],
11097 d_velocity[0], d_velocity[1], d_velocity[2]);
11098 }
11099 else if (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose_anisotropic"))
11100 {
11102 turbulent_mu_xy,
11103 turbulent_mu_xz,
11104 turbulent_mu_yx,
11105 turbulent_mu_yy,
11106 turbulent_mu_yz,
11107 turbulent_mu_zx,
11108 turbulent_mu_zy,
11109 turbulent_mu_zz);
11110 velocity_turbulent_diffusion_op_simple_with_transpose_anisotropic_.ajouter(velocity[0], velocity[1], velocity[2],
11111 d_velocity[0], d_velocity[1], d_velocity[2]);
11112 }
11113 else if (type_velocity_turbulent_diffusion_ == Nom("full_anisotropic"))
11114 {
11115 velocity[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
11116 velocity[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
11117 velocity[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
11118 compute_divergence(velocity[0], velocity[1], velocity[2], divergence_);
11119 divergence_.echange_espace_virtuel(1);
11120 velocity_turbulent_diffusion_op_full_anisotropic_.set_coeff_x_y_z(turbulent_mu_xx,
11121 turbulent_mu_xy,
11122 turbulent_mu_xz,
11123 turbulent_mu_yx,
11124 turbulent_mu_yy,
11125 turbulent_mu_yz,
11126 turbulent_mu_zx,
11127 turbulent_mu_zy,
11128 turbulent_mu_zz);
11130 velocity_turbulent_diffusion_op_full_anisotropic_.ajouter(velocity[0], velocity[1], velocity[2],
11131 d_velocity[0], d_velocity[1], d_velocity[2]);
11132 }
11133 else
11134 {
11135 Cerr << "Unknown velocity turbulent diffusion operator! " << finl;
11136 Process::exit();
11137 }
11138 }
11139}
11140
11141template<class T>
11142void DNS_QC_double::calculer_structural_diffusion_vitesse(IJK_Field_vector3_double& velocity,
11143 const FixedVector<IJK_Field_double, 6>& structural_uu_tensor,
11144 const ArrOfDouble_with_ghost& delta_z,
11145 const double facteur_delta_x,
11146 const double facteur_delta_y,
11147 const ArrOfDouble_with_ghost& delta_z_pour_delta,
11148 T& kernel,
11151 IJK_Field_vector3_double& d_velocity_tmp,
11152 IJK_Field_vector3_double& d_velocity)
11153{
11154 const IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
11155 const IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
11156 const IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
11157 const IJK_Field_double& structural_uu_yx = structural_uu_tensor[1];
11158 const IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
11159 const IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
11160 const IJK_Field_double& structural_uu_zx = structural_uu_tensor[2];
11161 const IJK_Field_double& structural_uu_zy = structural_uu_tensor[4];
11162 const IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
11163 int ghost_size_filter;
11164 int ghost_size_d_velocity_tmp;
11166 {
11167 velocity_turbulent_diffusion_op_structural_.set_coeff_x_y_z(structural_uu_xx,
11168 structural_uu_xy,
11169 structural_uu_xz,
11170 structural_uu_yx,
11171 structural_uu_yy,
11172 structural_uu_yz,
11173 structural_uu_zx,
11174 structural_uu_zy,
11175 structural_uu_zz);
11176 velocity_turbulent_diffusion_op_structural_.calculer(velocity[0], velocity[1], velocity[2],
11177 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
11178
11179 ghost_size_filter = 1 + kernel->ghost_size();
11180 ghost_size_d_velocity_tmp = max((int) 2, ghost_size_filter);
11181 d_velocity_tmp[0].echange_espace_virtuel(ghost_size_d_velocity_tmp);
11182 d_velocity_tmp[1].echange_espace_virtuel(ghost_size_d_velocity_tmp);
11183 d_velocity_tmp[2].echange_espace_virtuel(ghost_size_d_velocity_tmp);
11184
11185 const int flag_add = 1;
11186 filtrer_champ_elem(flag_add, d_velocity_tmp[0], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, d_velocity[0]);
11187 filtrer_champ_elem(flag_add, d_velocity_tmp[1], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, d_velocity[1]);
11188 filtrer_champ_face(flag_add, d_velocity_tmp[2], delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta, kernel, tmp_b, tmp_a, d_velocity[2]);
11189 }
11190 else
11191 {
11192 velocity_turbulent_diffusion_op_structural_.set_coeff_x_y_z(structural_uu_xx,
11193 structural_uu_xy,
11194 structural_uu_xz,
11195 structural_uu_yx,
11196 structural_uu_yy,
11197 structural_uu_yz,
11198 structural_uu_zx,
11199 structural_uu_zy,
11200 structural_uu_zz);
11201 velocity_turbulent_diffusion_op_structural_.ajouter(velocity[0], velocity[1], velocity[2],
11202 d_velocity[0], d_velocity[1], d_velocity[2]);
11203 }
11204}
11205
11206void DNS_QC_double::calculer_diffusion_scalar(const IJK_Field_double& rho,
11207 const IJK_Field_double& turbulent_kappa_x,
11208 const IJK_Field_double& turbulent_kappa_y,
11209 const IJK_Field_double& turbulent_kappa_z,
11210 IJK_Field_double& d_rho,
11211 const IJK_Field_local_double& boundary_flux_kmin,
11212 const IJK_Field_local_double& boundary_flux_kmax)
11213{
11214 if (type_scalar_turbulent_diffusion_ == Nom("normal"))
11215 {
11216 operateur_diffusion_turbulent_scalar_.set_coeff_x_y_z(turbulent_kappa_x,
11217 turbulent_kappa_y,
11218 turbulent_kappa_z);
11220 d_rho,
11221 boundary_flux_kmin, boundary_flux_kmax);
11222 }
11223 else if (type_scalar_turbulent_diffusion_ == Nom("anisotropic"))
11224 {
11225 operateur_diffusion_turbulent_scalar_anisotropic_.set_coeff_x_y_z(turbulent_kappa_x,
11226 turbulent_kappa_y,
11227 turbulent_kappa_z);
11229 d_rho,
11230 boundary_flux_kmin, boundary_flux_kmax);
11231 }
11232 else
11233 {
11234 Cerr << "Unknown scalar turbulent diffusion operator! " << finl;
11235 Process::exit();
11236 }
11237}
11238
11239// Perform one sub-step of rk3 for QC algorithm, called 3 times per time step.
11240// rk_step = 0, 1 or 2
11241// total_timestep = not the fractionnal timestep !
11242void DNS_QC_double::rk3_sub_step(const int rk_step, const double total_timestep)
11243{
11244 statistics().create_custom_counter("qc convection rho",2,"TrioCFD");
11245 statistics().create_custom_counter("qc calcul pthermo,t,rho_v,etc",2,"TrioCFD");
11246 statistics().create_custom_counter("qc diffusion vitesse",2,"TrioCFD");
11247 statistics().create_custom_counter("qc diffusion turbulente vitesse",2,"TrioCFD");
11248 statistics().create_custom_counter("qc diffusion vitesse modele structurel",2,"TrioCFD");
11249 statistics().create_custom_counter("qc convection vitesse",2,"TrioCFD");
11250 statistics().create_custom_counter("qc rk3 update",2,"TrioCFD");
11251 statistics().create_custom_counter("qc diffusion temperature",2,"TrioCFD");
11252 statistics().create_custom_counter("qc turbulent diffusivity",2,"TrioCFD");
11253 statistics().create_custom_counter("qc turbulent diffusivity structurel",2,"TrioCFD");
11254 statistics().create_custom_counter("qc prepare rhs",2,"TrioCFD");
11255 statistics().create_custom_counter("qc resoudre systeme",2,"TrioCFD");
11256 statistics().create_custom_counter("qc ajouter grad p",2,"TrioCFD");
11257
11258
11259 const double fractionnal_timestep = compute_fractionnal_timestep_rk3(total_timestep, rk_step);
11260
11261 if (calcul_2d_)
11262 {
11263 velocity_[1].data() = 0;
11264 force_2d(rho_);
11265 force_2d(velocity_[0]);
11266 force_2d(velocity_[2]);
11267 }
11268
11269 assert(rk_step>=0 && rk_step<3);
11270 // F.A deplace a la fin du sous pas de temps, pour le premier dt du premier rk_step c est fait pour post traitrer les champs initiaux.
11271 // rho_.echange_espace_virtuel(2);
11272 // velocity_[0].echange_espace_virtuel(1);
11273 // velocity_[1].echange_espace_virtuel(1);
11274 // velocity_[2].echange_espace_virtuel(1);
11275
11276 //
11277 // Convection du champ de masse volumique
11278 //
11279 // L'operateur de convection calcule drho/dt integre sur le volume de controle:
11280 statistics().begin_count("qc convection rho",statistics().get_last_opened_counter_level()+1);
11281 if (conv_rho_negligeable_) // cas ou la convection de rho serait negligeable
11282 {
11283 d_rho_.data()=0;
11284 }
11285 else
11286 {
11288 {
11290 }
11291 else if (convection_rho_amont_)
11292 {
11294 }
11295 else if (convection_rho_centre4_)
11296 {
11298 }
11299 else
11300 {
11301 // Schema quick (utilise par defaut)
11303 }
11304 }
11305 statistics().end_count("qc convection rho");
11306
11307 DebogIJK::verifier("op_conv(rho)", d_rho_);
11308
11310 {
11312 {
11313 statistics().begin_count("qc turbulent diffusivity",statistics().get_last_opened_counter_level()+1);
11315 {
11316 calculer_turbulent_mu_vector(flag_kappa_anisotropic_,
11328 }
11329 else
11330 {
11331 calculer_turbulent_mu_scalar(flag_kappa_anisotropic_,
11341 }
11342 statistics().end_count("qc turbulent diffusivity");
11343 }
11344
11346 {
11347 statistics().begin_count("qc turbulent diffusivity structurel",statistics().get_last_opened_counter_level()+1);
11350 rho_,
11358
11359 statistics().end_count("qc turbulent diffusivity structurel");
11360 }
11361
11363 {
11364 modification_modele_dynamic_uscalar_vector(flag_kappa_anisotropic_,
11374 }
11375 else
11376 {
11377 modification_modele_dynamic_uscalar_scalar(flag_kappa_anisotropic_,
11387 }
11388
11390 {
11391 statistics().begin_count("qc turbulent diffusivity",statistics().get_last_opened_counter_level()+1);
11393 {
11394 turbulent_kappa_vector_[0].echange_espace_virtuel(1);
11395 turbulent_kappa_vector_[1].echange_espace_virtuel(1);
11396 turbulent_kappa_vector_[2].echange_espace_virtuel(1);
11397
11398 // on impose le flux au bord a zero dans tous les cas
11399 calculer_flux_thermique_bord(rho_, 0.,
11402 rho_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
11403 calculer_flux_thermique_bord(rho_, 0.,
11406 rho_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
11407
11408 rho_.echange_espace_virtuel(1);
11409 turbulent_kappa_vector_[0].echange_espace_virtuel(1);
11410 turbulent_kappa_vector_[1].echange_espace_virtuel(1);
11411 turbulent_kappa_vector_[2].echange_espace_virtuel(1);
11412
11417 d_rho_,
11419 }
11420 else
11421 {
11422 turbulent_kappa_.echange_espace_virtuel(1);
11423
11424 // on impose le flux au bord a zero dans tous les cas
11425 calculer_flux_thermique_bord(rho_, 0.,
11428 rho_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
11429 calculer_flux_thermique_bord(rho_, 0.,
11432 rho_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
11433
11434 rho_.echange_espace_virtuel(1);
11435 turbulent_kappa_.echange_espace_virtuel(1);
11436
11441 d_rho_,
11443 }
11444 statistics().end_count("qc turbulent diffusivity");
11445 DebogIJK::verifier("rho", rho_);
11446 DebogIJK::verifier("op_conv(rho)_kappa", d_rho_);
11447 }
11448
11450 {
11451 statistics().begin_count("qc turbulent diffusivity structurel",statistics().get_last_opened_counter_level()+1);
11452
11453 structural_uscalar_vector_[0].echange_espace_virtuel(1);
11454 structural_uscalar_vector_[1].echange_espace_virtuel(1);
11455 structural_uscalar_vector_[2].echange_espace_virtuel(1);
11456
11457 // on impose le flux au bord a zero dans tous les cas
11458 calculer_flux_thermique_bord(rho_, 0.,
11461 rho_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
11462 calculer_flux_thermique_bord(rho_, 0.,
11465 rho_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
11466
11467 rho_.echange_espace_virtuel(1);
11468 structural_uscalar_vector_[0].echange_espace_virtuel(1);
11469 structural_uscalar_vector_[1].echange_espace_virtuel(1);
11470 structural_uscalar_vector_[2].echange_espace_virtuel(1);
11471
11472 DebogIJK::verifier("rho", rho_);
11473 DebogIJK::verifier("structural_uscalar_x", structural_uscalar_vector_[0]);
11474 DebogIJK::verifier("structural_uscalar_y", structural_uscalar_vector_[1]);
11475 DebogIJK::verifier("structural_uscalar_z", structural_uscalar_vector_[2]);
11480 d_rho_,
11482
11483 statistics().end_count("qc turbulent diffusivity structurel");
11484
11485 DebogIJK::verifier("op_conv(rho)_struct", d_rho_);
11486 }
11487 }
11488
11489 {
11490 const int kmax = d_rho_.nk();
11491 for (int k = 0; k < kmax; k++)
11492 {
11493 // division par le volume de controle
11494 mass_solver_scalar(d_rho_, delta_z_local_, k);
11495 // calcul de rho_ au sous-pas de temps suivant, et mise a jour F_rho_ (valeur intermediaire de l'algo rk3)
11496 runge_kutta3_update(d_rho_, RK3_F_rho_, rho_, rk_step, k, total_timestep);
11497 }
11498 }
11499 DebogIJK::verifier("rk3 update rho", rho_);
11500
11501 // On a besoin d'une epaisseur de 1 sur rho (pour calculer rho aux faces et ensuite
11502 // pour calculer l'epaisseur 1 de la temperature et de mu/lambda.
11503 rho_.echange_espace_virtuel(1);
11504
11505 statistics().begin_count("qc calcul pthermo,t,rho_v,etc",statistics().get_last_opened_counter_level()+1);
11506 // Resoudre EDO Pthermo: calcul de P_th_final et de la temperature en fonction de rho_
11507 const double P_th_initial = P_thermodynamique_;
11508 double P_th_final;
11509 double d_Pth_divise_par_gammamoins1;
11510
11512 {
11514 {
11515 statistics().begin_count("qc turbulent diffusivity",statistics().get_last_opened_counter_level()+1);
11517 {
11518 calculer_turbulent_mu_vector(flag_kappa_anisotropic_,
11530 }
11531 else
11532 {
11533 calculer_turbulent_mu_scalar(flag_kappa_anisotropic_,
11543 }
11544 statistics().end_count("qc turbulent diffusivity");
11545 }
11546
11548 {
11549 statistics().begin_count("qc turbulent diffusivity structurel",statistics().get_last_opened_counter_level()+1);
11552 rho_,
11560
11561 statistics().end_count("qc turbulent diffusivity structurel");
11562 }
11563
11565 {
11566 modification_modele_dynamic_uscalar_vector(flag_kappa_anisotropic_,
11576 }
11577 else
11578 {
11579 modification_modele_dynamic_uscalar_scalar(flag_kappa_anisotropic_,
11589 }
11590
11592 {
11593 statistics().begin_count("qc turbulent diffusivity",statistics().get_last_opened_counter_level()+1);
11595 {
11596 // we multiply by rho cp = rho (r/Pth) (Pth CP/r):
11597 // * r/Pth: because we use grad T instead of grad 1/rho
11598 // * Pth Cp/r: because div_lambda_grad_T will be multiplied by r/Cp/Pth
11599 // but this should not
11600 // * rho: required in the favre formulation
11601 multiplier_champ(rho_, Cp_gaz_, turbulent_kappa_vector_[0]);
11602 multiplier_champ(rho_, Cp_gaz_, turbulent_kappa_vector_[1]);
11603 multiplier_champ(rho_, Cp_gaz_, turbulent_kappa_vector_[2]);
11604
11605 turbulent_kappa_vector_[0].echange_espace_virtuel(1);
11606 turbulent_kappa_vector_[1].echange_espace_virtuel(1);
11607 turbulent_kappa_vector_[2].echange_espace_virtuel(1);
11608 }
11609 else
11610 {
11611 // we multiply by rho cp = rho (r/Pth) (Pth CP/r):
11612 // * r/Pth: because we use grad T instead of grad 1/rho
11613 // * Pth Cp/r: because div_lambda_grad_T will be multiplied by r/Cp/Pth
11614 // but this should not
11615 // * rho: required in the favre formulation
11616 multiplier_champ(rho_, Cp_gaz_, turbulent_kappa_);
11617
11618 turbulent_kappa_.echange_espace_virtuel(1);
11619 }
11620 statistics().end_count("qc turbulent diffusivity");
11621 }
11622
11624 {
11625 statistics().begin_count("qc turbulent diffusivity structurel",statistics().get_last_opened_counter_level()+1);
11626 // we multiply by rho cp = rho (r/Pth) (Pth CP/r):
11627 // * r/Pth: because we use grad T instead of grad 1/rho
11628 // * Pth Cp/r: because div_lambda_grad_T will be multiplied by r/Cp/Pth
11629 // but this should not
11630 // * rho: required in the favre formulation
11631 multiplier_champ_rho_face_i(rho_, Cp_gaz_, structural_uscalar_vector_[0]);
11632 multiplier_champ_rho_face_j(rho_, Cp_gaz_, structural_uscalar_vector_[1]);
11633 multiplier_champ_rho_face_k(rho_, Cp_gaz_, rho_paroi_impose_kmin_, structural_uscalar_vector_[2]);
11634
11635 structural_uscalar_vector_[0].echange_espace_virtuel(1);
11636 structural_uscalar_vector_[1].echange_espace_virtuel(1);
11637 structural_uscalar_vector_[2].echange_espace_virtuel(1);
11638
11639 statistics().end_count("qc turbulent diffusivity structurel");
11640 }
11641 }
11642
11644 {
11645 calcul_p_thermo_et_bilan(rho_, temperature_, turbulent_diffusivity_, turbulent_kappa_vector_[2], flag_kappa_anisotropic_, structural_uscalar_, structural_uscalar_vector_[2], P_th_initial, P_th_final, fractionnal_timestep, d_Pth_divise_par_gammamoins1);
11646 }
11647 else
11648 {
11649 calcul_p_thermo_et_bilan(rho_, temperature_, turbulent_diffusivity_, turbulent_kappa_, flag_kappa_anisotropic_, structural_uscalar_, structural_uscalar_vector_[2], P_th_initial, P_th_final, fractionnal_timestep, d_Pth_divise_par_gammamoins1);
11650 }
11651 P_thermodynamique_ = P_th_final;
11652
11653 const double Pth_sur_R = P_thermodynamique_ / constante_specifique_gaz_;
11656
11657 // Mise a jour de temperature, mu et lambda en fonction de rho, sur une epaisseur de 1
11658 calculer_temperature_mu_lambda_air(P_th_final, constante_specifique_gaz_,
11659 rho_, temperature_, molecular_mu_, molecular_lambda_, 1 /* epaisseur de joint */);
11660
11661 DebogIJK::verifier("temperature", temperature_);
11662
11663 // derivee_en_temps_impl_p1 Navier Stokes
11664 calculer_rho_v(rho_, velocity_, rho_v_);
11665 DebogIJK::verifier("rho_v_X", rho_v_[0]);
11666 DebogIJK::verifier("rho_v_Y", rho_v_[1]);
11667 DebogIJK::verifier("rho_v_Z", rho_v_[2]);
11668 statistics().end_count("qc calcul pthermo,t,rho_v,etc");
11669
11670 // Pour l'operateur de convection, on a besoin d'une epaisseur 2 sur la quantite convectee:
11671 rho_v_[0].echange_espace_virtuel(2);
11672 rho_v_[1].echange_espace_virtuel(2);
11673 rho_v_[2].echange_espace_virtuel(2);
11674 // on a besoin de l'epaisseur 1 sur mu et lambda
11675
11676 // Le coefficient de diffusion est mu => resultat homogene a d(rho_v)/dt
11677 statistics().begin_count("qc diffusion vitesse",statistics().get_last_opened_counter_level()+1);
11678 if(diff_qdm_negligeable_) // si la diffusion est negligable
11679 {
11680 d_velocity_[0].data()=0;
11681 d_velocity_[1].data()=0;
11682 d_velocity_[2].data()=0;
11683 }
11684 else
11685 {
11686 if (type_velocity_diffusion_ == Nom("simple"))
11687 {
11691 }
11692 else if (type_velocity_diffusion_ == Nom("simple_with_transpose"))
11693 {
11697 }
11698 else if (type_velocity_diffusion_ == Nom("full"))
11699 {
11700 velocity_[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
11701 velocity_[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
11702 velocity_[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
11703 compute_divergence(velocity_[0], velocity_[1], velocity_[2], divergence_);
11704 divergence_.echange_espace_virtuel(1);
11709 }
11710 else if (type_velocity_diffusion_ == Nom("none"))
11711 {
11712 d_velocity_[0].data()=0;
11713 d_velocity_[1].data()=0;
11714 d_velocity_[2].data()=0;
11715 }
11716 else
11717 {
11718 Cerr << "Unknown velocity diffusion operator! " << finl;
11719 Process::exit();
11720 }
11721 }
11722 statistics().end_count("qc diffusion vitesse");
11723 DebogIJK::verifier("op_diff(velocity)X", d_velocity_[0]);
11724 DebogIJK::verifier("op_diff(velocity)Y", d_velocity_[1]);
11725 DebogIJK::verifier("op_diff(velocity)Z", d_velocity_[2]);
11726
11728 {
11730 {
11731 statistics().begin_count("qc diffusion turbulente vitesse",statistics().get_last_opened_counter_level()+1);
11732
11734 {
11735 calculer_turbulent_mu_tensor(flag_nu_anisotropic_,
11747 }
11748 else
11749 {
11750 calculer_turbulent_mu_scalar(flag_nu_anisotropic_,
11760 }
11761 statistics().end_count("qc diffusion turbulente vitesse");
11762 }
11763
11764 if (structural_uu_)
11765 {
11766 statistics().begin_count("qc diffusion vitesse modele structurel",statistics().get_last_opened_counter_level()+1);
11769 rho_,
11776 statistics().end_count("qc diffusion vitesse modele structurel");
11777 }
11778
11780 {
11781 modification_modele_dynamic_uu_tensor(flag_nu_anisotropic_,
11791 }
11792 else
11793 {
11794 modification_modele_dynamic_uu_scalar(flag_nu_anisotropic_,
11804 }
11805
11807 {
11808 statistics().begin_count("qc diffusion turbulente vitesse",statistics().get_last_opened_counter_level()+1);
11809
11811 {
11812 multiplier_champ(rho_, turbulent_mu_tensor_[0]);
11813 multiplier_champ(rho_, turbulent_mu_tensor_[1]);
11814 multiplier_champ(rho_, turbulent_mu_tensor_[2]);
11815 multiplier_champ(rho_, turbulent_mu_tensor_[3]);
11816 multiplier_champ(rho_, turbulent_mu_tensor_[4]);
11817 multiplier_champ(rho_, turbulent_mu_tensor_[5]);
11818
11819 turbulent_mu_tensor_[0].echange_espace_virtuel(1);
11820 turbulent_mu_tensor_[1].echange_espace_virtuel(1);
11821 turbulent_mu_tensor_[2].echange_espace_virtuel(1);
11822 turbulent_mu_tensor_[3].echange_espace_virtuel(1);
11823 turbulent_mu_tensor_[4].echange_espace_virtuel(1);
11824 turbulent_mu_tensor_[5].echange_espace_virtuel(1);
11825
11836 d_velocity_);
11837 }
11838 else
11839 {
11840 multiplier_champ(rho_, turbulent_mu_);
11841
11842 turbulent_mu_.echange_espace_virtuel(1);
11843
11854 d_velocity_);
11855 }
11856 statistics().end_count("qc diffusion turbulente vitesse");
11857
11858 DebogIJK::verifier("op_difft(velocity)X", d_velocity_[0]);
11859 DebogIJK::verifier("op_difft(velocity)Y", d_velocity_[1]);
11860 DebogIJK::verifier("op_difft(velocity)Z", d_velocity_[2]);
11861 }
11862
11863 if (structural_uu_)
11864 {
11865 statistics().begin_count("qc diffusion vitesse modele structurel",statistics().get_last_opened_counter_level()+1);
11866
11867 multiplier_champ(rho_, structural_uu_tensor_[0]);
11868 multiplier_champ_rho_arete_ij(rho_, structural_uu_tensor_[1]);
11869 multiplier_champ_rho_arete_ik(rho_, rho_paroi_impose_kmin_, structural_uu_tensor_[2]);
11870 multiplier_champ(rho_, structural_uu_tensor_[3]);
11871 multiplier_champ_rho_arete_jk(rho_, rho_paroi_impose_kmin_, structural_uu_tensor_[4]);
11872 multiplier_champ(rho_, structural_uu_tensor_[5]);
11873
11874 structural_uu_tensor_[0].echange_espace_virtuel(1);
11875 structural_uu_tensor_[1].echange_espace_virtuel(1);
11876 structural_uu_tensor_[2].echange_espace_virtuel(1);
11877 structural_uu_tensor_[3].echange_espace_virtuel(1);
11878 structural_uu_tensor_[4].echange_espace_virtuel(1);
11879 structural_uu_tensor_[5].echange_espace_virtuel(1);
11880
11886 d_velocity_);
11887
11888 statistics().end_count("qc diffusion vitesse modele structurel");
11889 DebogIJK::verifier("op_diffstruct(velocity)X", d_velocity_[0]);
11890 DebogIJK::verifier("op_diffstruct(velocity)Y", d_velocity_[1]);
11891 DebogIJK::verifier("op_diffstruct(velocity)Z", d_velocity_[2]);
11892 }
11893 }
11894
11895 // On transporte le champ rho_v par le champ v
11896 statistics().begin_count("qc convection vitesse",statistics().get_last_opened_counter_level()+1);
11898 {
11899 u_div_rho_u_.data()=0;
11900 }
11901 else // sinon on calcule rho u div(u) comme div(rho u u) - u div(rho u)
11902 {
11904 velocity_,
11909 u_div_rho_u_);
11910 }
11911 statistics().end_count("qc convection vitesse");
11912 DebogIJK::verifier("op_conv(velocity)X", d_velocity_[0]);
11913 DebogIJK::verifier("op_conv(velocity)Y", d_velocity_[1]);
11914 DebogIJK::verifier("op_conv(velocity)Z", d_velocity_[2]);
11915
11916
11918 {
11919 int dir = DIRECTION_J;
11920 IJK_Field_double& dv = d_velocity_[dir];
11921 const int ni = dv.ni();
11922 const int nj = dv.nj();
11923 const int kmax = d_velocity_[dir].nk();
11925 for(int k = 0; k < kmax; k++)
11926 {
11927 for (int j = 0; j < nj; j++)
11928 {
11929 for (int i = 0; i < ni; i++)
11930 {
11931 const double volume = get_channel_control_volume(dv, k, delta_z_local_);
11932 const double force = volumic_force * volume * (rho_(i, j, k) + rho_(i, j-1, k))*0.5;
11933 dv(i, j, k) += force;
11934 }
11935 }
11936 }
11937 /* Cout << "Volumic force at edge: " << volumic_force * get_channel_control_volume(dv, 0, delta_z_local_) */
11938 /* << " Volumic force at middle: " << volumic_force * get_channel_control_volume(dv, kmax/2, delta_z_local_) */
11939 /* << finl; */
11940 }
11941
11942
11943
11944
11945 // force_oscillating_boundary(
11946 // velocity_[DIRECTION_J],
11947 // current_time_,
11948 // amplitude_oscillating_boundary_2_,
11949 // frequency_oscillating_boundary_2_
11950 // );
11951 statistics().begin_count("qc rk3 update",statistics().get_last_opened_counter_level()+1);
11952 for (int dir = 0; dir < 3; dir++)
11953 {
11954 const int kmax = d_velocity_[dir].nk();
11955 for (int k = 0; k < kmax; k++)
11956 {
11957 // Le terme source est ajouter avant solveur masse, donc homogene a des Newton:
11958 if (dir == DIRECTION_I)
11959 {
11960 const double force_volumique = terme_source_acceleration_;
11961 IJK_Field_double& dvx = d_velocity_[dir];
11962 const double volume = get_channel_control_volume(dvx, k, delta_z_local_);
11963 const double f = force_volumique * volume;
11964 const int ni = dvx.ni();
11965 const int nj = dvx.nj();
11966
11967 for (int j = 0; j < nj; j++)
11968 {
11969 for (int i = 0; i < ni; i++)
11970 {
11971 dvx(i,j,k) += f;
11972 }
11973 }
11974 }
11975
11976 if (dir == DIRECTION_K)
11977 {
11978 const double force_volumique = terme_source_acceleration_z_;
11979 IJK_Field_double& dvx = d_velocity_[dir];
11980 const double volume = get_channel_control_volume(dvx, k, delta_z_local_);
11981 const double f = force_volumique * volume;
11982 const int ni = dvx.ni();
11983 const int nj = dvx.nj();
11984
11985 for (int j = 0; j < nj; j++)
11986 {
11987 for (int i = 0; i < ni; i++)
11988 {
11989 dvx(i,j,k) += f;
11990 }
11991 }
11992 }
11993
11994 density_solver_with_rho(d_velocity_[dir], rho_, delta_z_local_, k);
11995 }
11996 }
11997
11998 // On transporte le champ v par le champ v
11999 statistics().begin_count("qc convection vitesse",statistics().get_last_opened_counter_level()+1);
12001 {
12002 // on calcule u div(u) comme div(u u) - u div(u)
12004 velocity_,
12009 u_div_rho_u_);
12010 }
12011 statistics().end_count("qc convection vitesse");
12012 DebogIJK::verifier("op_conv(velocity)X", d_velocity_[0]);
12013 DebogIJK::verifier("op_conv(velocity)Y", d_velocity_[1]);
12014 DebogIJK::verifier("op_conv(velocity)Z", d_velocity_[2]);
12015
12017 {
12019 {
12020 statistics().begin_count("qc diffusion turbulente vitesse",statistics().get_last_opened_counter_level()+1);
12021
12023 {
12024 calculer_turbulent_mu_tensor(flag_nu_anisotropic_,
12036 }
12037 else
12038 {
12039 calculer_turbulent_mu_scalar(flag_nu_anisotropic_,
12049 }
12050
12051 statistics().end_count("qc diffusion turbulente vitesse");
12052 }
12053
12054 if (structural_uu_)
12055 {
12056 statistics().begin_count("qc diffusion vitesse modele structurel",statistics().get_last_opened_counter_level()+1);
12057 Cerr << "avant calculer_structural_uu" << finl;
12060 rho_,
12067 statistics().end_count("qc diffusion vitesse modele structurel");
12068 }
12069
12071 {
12072 modification_modele_dynamic_uu_tensor(flag_nu_anisotropic_,
12082 }
12083 else
12084 {
12085 modification_modele_dynamic_uu_scalar(flag_nu_anisotropic_,
12095 }
12096
12098 {
12099 statistics().begin_count("qc diffusion turbulente vitesse",statistics().get_last_opened_counter_level()+1);
12101 {
12102 turbulent_mu_tensor_[0].echange_espace_virtuel(1);
12103 turbulent_mu_tensor_[1].echange_espace_virtuel(1);
12104 turbulent_mu_tensor_[2].echange_espace_virtuel(1);
12105 turbulent_mu_tensor_[3].echange_espace_virtuel(1);
12106 turbulent_mu_tensor_[4].echange_espace_virtuel(1);
12107 turbulent_mu_tensor_[5].echange_espace_virtuel(1);
12108
12119 d_velocity_);
12120 }
12121 else
12122 {
12123 turbulent_mu_.echange_espace_virtuel(1);
12124
12135 d_velocity_);
12136 }
12137
12138 statistics().end_count("qc diffusion turbulente vitesse");
12139
12140 DebogIJK::verifier("op_difft(velocity)X", d_velocity_[0]);
12141 DebogIJK::verifier("op_difft(velocity)Y", d_velocity_[1]);
12142 DebogIJK::verifier("op_difft(velocity)Z", d_velocity_[2]);
12143 }
12144
12145 if (structural_uu_)
12146 {
12147 statistics().begin_count("qc diffusion vitesse modele structurel",statistics().get_last_opened_counter_level()+1);
12148
12149 structural_uu_tensor_[0].echange_espace_virtuel(1);
12150 structural_uu_tensor_[1].echange_espace_virtuel(1);
12151 structural_uu_tensor_[2].echange_espace_virtuel(1);
12152 structural_uu_tensor_[3].echange_espace_virtuel(1);
12153 structural_uu_tensor_[4].echange_espace_virtuel(1);
12154 structural_uu_tensor_[5].echange_espace_virtuel(1);
12155
12161 d_velocity_);
12162
12163 statistics().end_count("qc diffusion vitesse modele structurel");
12164 DebogIJK::verifier("op_diffstruct(velocity)X", d_velocity_[0]);
12165 DebogIJK::verifier("op_diffstruct(velocity)Y", d_velocity_[1]);
12166 DebogIJK::verifier("op_diffstruct(velocity)Z", d_velocity_[2]);
12167 }
12168 }
12169
12170 // diffusion creates non zero velocity at walls, restore zero
12171 force_zero_normal_velocity_on_walls(d_velocity_[2]);
12172
12173 for (int dir = 0; dir < 3; dir++)
12174 {
12175 const int kmax = d_velocity_[dir].nk();
12176 for (int k = 0; k < kmax; k++)
12177 {
12178 mass_solver_scalar(d_velocity_[dir], delta_z_local_, k);
12179
12180 runge_kutta3_update(d_velocity_[dir], RK3_F_velocity_[dir], velocity_[dir], rk_step, k, total_timestep);
12181 }
12182 }
12183 statistics().end_count("qc rk3 update");
12184 DebogIJK::verifier("rk3update(velocity)X", velocity_[0]);
12185 DebogIJK::verifier("rk3update(velocity)Y", velocity_[1]);
12186 DebogIJK::verifier("rk3update(velocity)Z", velocity_[2]);
12187 // --------------------------------------
12188 // Projection sur div(u)=quelque chose
12189 // --------------------------------------
12190 // vpoint -= gradP / rho
12191 // secmem = - R / (Cp * Pth) * (div((lambda*grad(T))*volume+source) - dpth2 / gamma_moins1 * volume)
12192
12193
12194 // B secmem = [ ( ( R/(Cp*Pth)*(tab_W(i) + dpth2/gamma_moins_1*volumes(i) )) - div(v)) / dt - div(vpoint) ]
12195
12196 // trouver P tel que div ( v + dt * vpoint - dt * 1/rho*grad(P) ) = (R/(cp*Pth)...)
12197 // equivalent a
12198 // trouver P tel que div ( dt * 1/rho*gradP ) = div( v + dt * vpoint - (R/(cp*Pth)...) )
12199 // A trouver P tel que div ( 1/rho*gradP ) = div( v/dt + vpoint - (R/(cp*Pth)...)/dt )
12200
12201 // calculer ici div(lambda*grad(T))*volume)
12202
12203 calculer_flux_thermique_bord(temperature_, lambda_de_t_paroi_kmin_,
12206 T_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
12207 calculer_flux_thermique_bord(temperature_, lambda_de_t_paroi_kmax_,
12210 T_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
12211
12212 temperature_.echange_espace_virtuel(1);
12213 molecular_lambda_.echange_espace_virtuel(1);
12216
12217 statistics().begin_count("qc diffusion temperature",statistics().get_last_opened_counter_level()+1);
12218 if (diff_temp_negligeable_) // si diffusion negligeable
12219 {
12221 }
12222 else
12223 {
12228 }
12229 statistics().end_count("qc diffusion temperature");
12230
12231 DebogIJK::verifier("div_lambda_grad_T_volume", div_lambda_grad_T_volume_);
12232
12234 {
12236 {
12237 statistics().begin_count("qc turbulent diffusivity",statistics().get_last_opened_counter_level()+1);
12239 {
12240 calculer_flux_thermique_bord(temperature_, 0.,
12243 T_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
12244 calculer_flux_thermique_bord(temperature_, 0.,
12247 T_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
12248
12249 temperature_.echange_espace_virtuel(1);
12250 turbulent_kappa_vector_[0].echange_espace_virtuel(1);
12251 turbulent_kappa_vector_[1].echange_espace_virtuel(1);
12252 turbulent_kappa_vector_[2].echange_espace_virtuel(1);
12253
12260 }
12261 else
12262 {
12263 calculer_flux_thermique_bord(temperature_, 0.,
12266 T_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
12267 calculer_flux_thermique_bord(temperature_, 0.,
12270 T_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
12271
12272 temperature_.echange_espace_virtuel(1);
12273 turbulent_kappa_.echange_espace_virtuel(1);
12274
12281 }
12282 statistics().end_count("qc turbulent diffusivity");
12284 DebogIJK::verifier("div_lambda_grad_T_volume_kappa", div_lambda_grad_T_volume_);
12285 }
12286
12288 {
12289 statistics().begin_count("qc turbulent diffusivity structurel",statistics().get_last_opened_counter_level()+1);
12290
12291 calculer_flux_thermique_bord(temperature_, 0.,
12294 T_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
12295 calculer_flux_thermique_bord(temperature_, 0.,
12298 T_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
12299
12300 temperature_.echange_espace_virtuel(1);
12301 structural_uscalar_vector_[0].echange_espace_virtuel(1);
12302 structural_uscalar_vector_[1].echange_espace_virtuel(1);
12303 structural_uscalar_vector_[2].echange_espace_virtuel(1);
12304
12306 DebogIJK::verifier("structural_uscalar_x", structural_uscalar_vector_[0]);
12307 DebogIJK::verifier("structural_uscalar_y", structural_uscalar_vector_[1]);
12308 DebogIJK::verifier("structural_uscalar_z", structural_uscalar_vector_[2]);
12315
12316 statistics().end_count("qc turbulent diffusivity structurel");
12317 DebogIJK::verifier("div_lambda_grad_T_volume_kappa_struct", div_lambda_grad_T_volume_);
12318 }
12319 }
12320
12321 // Pour calculer la divergence, il faut les valeurs sur les faces de "droite" des elements, qui sont
12322 // des faces virtuelles a l'extremite du domaine, donc mettre a jour les faces de droite
12323 // A ete modifie lors de l'ajout de la source !!!!!
12324 velocity_[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
12325 velocity_[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
12326 velocity_[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
12327
12328 statistics().begin_count("qc prepare rhs",statistics().get_last_opened_counter_level()+1);
12329
12330 compute_divergence_times_constant(velocity_[0], velocity_[1], velocity_[2],
12331 - 1. / fractionnal_timestep, pressure_rhs_);
12332 DebogIJK::verifier("-div(u)/dt", pressure_rhs_);
12333 {
12334// Modif Martin 28-05-2019
12335 const int ni = rho_.ni();
12336 const int nj = rho_.nj();
12337 const int nk = rho_.nk();
12338 const double R_divise_par_Cp_Pth = constante_specifique_gaz_ / (Cp_gaz_ * P_th_final);
12339 const Domaine_IJK& geom = rho_.get_domaine();
12340// On a besoin de vx et rho pour la pondération du terme source par la vitesse
12341 IJK_Field_double& vx = velocity_[0];
12342 IJK_Field_double& rho = rho_;
12343 const double delta_x = geom.get_constant_delta(0);
12344 const double delta_y = geom.get_constant_delta(1);
12345 for (int k = 0; k < nk; k++)
12346 {
12347 const double delta_z = delta_z_local_[k];
12348 const double volume_maille = delta_x * delta_y * delta_z;
12349 const double facteur = d_Pth_divise_par_gammamoins1 * volume_maille;
12350// S il n y a pas d'ecoulement dans le canal, la source n'est pas ponderee par la vitesse
12351 if (debit_actuel_ < 0.0000001)
12352 {
12353 for (int j = 0; j < nj; j++)
12354 {
12355 for (int i = 0; i < ni; i++)
12356 {
12357 pressure_rhs_(i,j,k) += R_divise_par_Cp_Pth * (div_lambda_grad_T_volume_(i,j,k) - facteur - puit_ * volume_maille) / fractionnal_timestep;
12358 }
12359 }
12360 }
12361 else
12362 {
12363 for (int j = 0; j < nj; j++)
12364 {
12365 for (int i = 0; i < ni; i++)
12366 {
12367 pressure_rhs_(i,j,k) += R_divise_par_Cp_Pth * (div_lambda_grad_T_volume_(i,j,k) - facteur - puit_ * rho(i,j,k) * vx(i,j,k) * Ly_tot_ * Lz_tot_ / debit_actuel_ * volume_maille) / fractionnal_timestep;
12368 }
12369 }
12370 }
12371 }
12372 }
12373 DebogIJK::verifier("pressure_rhs", pressure_rhs_);
12374 statistics().end_count("qc prepare rhs");
12375 // Appel au solveur multigrille:
12377 {
12378 statistics().begin_count("qc resoudre systeme",statistics().get_last_opened_counter_level()+1);
12379 poisson_solver_.set_rho(rho_);
12380 poisson_solver_.resoudre_systeme_IJK(pressure_rhs_, pressure_);
12381 statistics().end_count("qc resoudre systeme");
12382 DebogIJK::verifier("pressure", pressure_);
12383
12384// pressure gradient requires the "left" value in all directions:
12385 pressure_.echange_espace_virtuel(1 /*, IJK_Field_double::EXCHANGE_GET_AT_LEFT_IJK*/);
12386 statistics().begin_count("qc ajouter grad p",statistics().get_last_opened_counter_level()+1);
12387 add_gradient_times_constant_over_rho(pressure_, rho_, -fractionnal_timestep,
12388 velocity_[0], velocity_[1], velocity_[2]);
12389 statistics().end_count("qc ajouter grad p");
12390 }
12391
12392 // DD,2016-01-20: decalage de la pression en prenant comme reference la moyenne de la pression sur le volume.
12393 double reference_pression = 0;
12394 fixer_reference_pression(reference_pression);
12395 Cout << "reference_pression= " << reference_pression << finl;
12396 translation_pression(reference_pression);
12397
12398 // Mise a jour des stats en prevision du prochain rk_step et du post_traitement. !!! (positionement optimum !!)
12399 rho_.echange_espace_virtuel(2);
12400 velocity_[0].echange_espace_virtuel(2);
12401 velocity_[1].echange_espace_virtuel(2);
12402 velocity_[2].echange_espace_virtuel(2);
12403}
12404
12405void DNS_QC_double::fixer_reference_pression(double& reference_pression)
12406{
12407 const int ni = pressure_.ni();
12408 const int nj = pressure_.nj();
12409 const int nk = pressure_.nk();
12410 const double dx = pressure_.get_domaine().get_constant_delta(DIRECTION_I);
12411 const double dy = pressure_.get_domaine().get_constant_delta(DIRECTION_J);
12412
12413 double integrale_pression = 0.;
12414 for (int k = 0; k < nk; k++)
12415 {
12416 for (int j = 0; j < nj; j++)
12417 {
12418 for (int i = 0; i < ni; i++)
12419 {
12420 integrale_pression += pressure_(i,j,k) * dx * dy * delta_z_local_[k];
12421 }
12422 }
12423 }
12424 ArrOfDouble tmp(1);
12425 tmp[0] = integrale_pression;
12427
12428 reference_pression = tmp[0] / (Lx_tot_*Ly_tot_*Lz_tot_);
12429}
12430void DNS_QC_double::translation_pression(const double& reference_pression)
12431{
12432 const int ni = pressure_.ni();
12433 const int nj = pressure_.nj();
12434 const int nk = pressure_.nk();
12435 for (int k = 0; k < nk; k++)
12436 {
12437 for (int j = 0; j < nj; j++)
12438 {
12439 for (int i = 0; i < ni; i++)
12440 {
12441 pressure_(i,j,k) -= reference_pression;
12442 }
12443 }
12444 }
12445}
12446
12448{
12449 const int ni = rho_.ni();
12450 const int nj = rho_.nj();
12451 const int nk = rho_.nk();
12452 const double dx = rho_.get_domaine().get_constant_delta(DIRECTION_I);
12453 const double dy = rho_.get_domaine().get_constant_delta(DIRECTION_J);
12454
12455 double integral_rho = 0.;
12456 for (int k = 0; k < nk; k++)
12457 {
12458 for (int j = 0; j < nj; j++)
12459 {
12460 for (int i = 0; i < ni; i++)
12461 {
12462 integral_rho += rho_(i,j,k) * dx * dy * delta_z_local_[k];
12463 }
12464 }
12465 }
12466 ArrOfDouble tmp(1);
12467 tmp[0] = integral_rho;
12469
12470 rho_bulk = tmp[0] / (Lx_tot_*Ly_tot_*Lz_tot_);
12471}
12472
12473
12475{
12476 const int ni = temperature_.ni();
12477 const int nj = temperature_.nj();
12478 const int nk = temperature_.nk();
12479 const double dx = temperature_.get_domaine().get_constant_delta(DIRECTION_I);
12480 const double dy = temperature_.get_domaine().get_constant_delta(DIRECTION_J);
12481
12482 double integral_t = 0.;
12483 for (int k = 0; k < nk; k++)
12484 {
12485 for (int j = 0; j < nj; j++)
12486 {
12487 for (int i = 0; i < ni; i++)
12488 {
12489 integral_t += temperature_(i,j,k) * dx * dy * delta_z_local_[k];
12490 }
12491 }
12492 }
12493 ArrOfDouble tmp(1);
12494 tmp[0] = integral_t;
12496
12497 t_bulk = tmp[0] / (Lx_tot_*Ly_tot_*Lz_tot_);
12498}
12499
12500void DNS_QC_double::compute_rho_t_bulk(double& rho_bulk, double& t_bulk)
12501{
12502 const int ni = rho_.ni();
12503 const int nj = rho_.nj();
12504 const int nk = rho_.nk();
12505 const double dx = rho_.get_domaine().get_constant_delta(DIRECTION_I);
12506 const double dy = rho_.get_domaine().get_constant_delta(DIRECTION_J);
12507
12508 double integral_t = 0.;
12509 double integral_rho = 0.;
12510 for (int k = 0; k < nk; k++)
12511 {
12512 for (int j = 0; j < nj; j++)
12513 {
12514 for (int i = 0; i < ni; i++)
12515 {
12516 integral_t += temperature_(i,j,k) * dx * dy * delta_z_local_[k];
12517 integral_rho += rho_(i,j,k) * dx * dy * delta_z_local_[k];
12518 }
12519 }
12520 }
12521 ArrOfDouble tmp(1);
12522 tmp[0] = integral_t;
12524
12525 t_bulk = tmp[0] / (Lx_tot_*Ly_tot_*Lz_tot_);
12526
12527 ArrOfDouble tmp2(1);
12528 tmp2[0] = integral_rho;
12530
12531 rho_bulk = tmp2[0] / (Lx_tot_*Ly_tot_*Lz_tot_);
12532}
IJK_Field_double velocity_elem_Y_sauvegarde_
Definition DNS.h:191
bool disable_solveur_poisson_
Definition DNS.h:438
bool structural_uu_
Definition DNS.h:316
void run()
Definition DNS.cpp:9454
Entree & interpreter(Entree &) override
Definition DNS.cpp:7229
bool check_divergence_
Definition DNS.h:381
IJK_Field_double velocity_elem_X_
Definition DNS.h:197
bool diff_qdm_negligeable_
Definition DNS.h:431
bool sauvegarde_post_instantanes_
Definition DNS.h:454
IJK_Field_double pressure_sauvegarde_
Definition DNS.h:189
OpConvQuickSharpIJK_double velocity_convection_op_quicksharp_
Definition DNS.h:346
FixedVector< IJK_Field_double, 6 > turbulent_mu_tensor_
Definition DNS.h:256
OpDiffTensorialAnisotropicZeroatwallIJK_double velocity_turbulent_diffusion_op_simple_anisotropic_
Definition DNS.h:245
IJK_Field_double molecular_mu_
Definition DNS.h:212
double Re_tau_fr_
Definition DNS.h:262
double smoothing_factor_fr_
Definition DNS.h:261
IJK_Field_vector3_double turbulent_kappa_vector_
Definition DNS.h:278
double T_paroi_impose_kmin_
Definition DNS.h:425
double timestep_max_
Definition DNS.h:362
double lambda_de_t_paroi_kmin_
Definition DNS.h:447
OpDiffStdWithLaminarTransposeAndDivergenceTensorialAnisotropicZeroatwallIJK_double velocity_turbulent_diffusion_op_full_anisotropic_
Definition DNS.h:247
Nom turbulent_viscosity_dynamic_type_
Definition DNS.h:250
int compteur_post_instantanes_
Definition DNS.h:378
bool formulation_favre_
Definition DNS.h:334
OpConvCentre2IJKScalar_double rho_convection_op_centre2_
Definition DNS.h:350
bool flag_rho_filtre_
Definition DNS.h:301
double pond_ch_
Definition DNS.h:265
bool flag_oscillating_boundary
Definition DNS.h:469
OpConvAmontIJK_double velocity_convection_op_amont_
Definition DNS.h:347
bool flag_nu_anisotropic_
Definition DNS.h:254
ArrOfDouble turbulent_viscosity_tensor_coefficients_
Definition DNS.h:252
int dt_post_spectral_
Definition DNS.h:175
OpDiffStdWithLaminarTransposeAndDivergenceTensorialZeroatwallIJK_double velocity_turbulent_diffusion_op_full_
Definition DNS.h:244
double constante_specifique_gaz_
Definition DNS.h:449
bool flag_structural_uu_tmp_
Definition DNS.h:314
bool calcul_2d_
Definition DNS.h:379
bool variation_cste_modele_fonctionnel_
Definition DNS.h:258
IJK_Field_local_double boundary_flux_kmin_
Definition DNS.h:232
IJK_Field_double velocity_elem_Z_
Definition DNS.h:201
IJK_Field_double temperature_filtre_
Definition DNS.h:293
double Cp_gaz_
Definition DNS.h:427
Nom structural_uu_model_
Definition DNS.h:309
Domaine_IJK post_splitting_
Definition DNS.h:177
IJK_Field_double turbulent_mu_filtre_
Definition DNS.h:294
IJK_Field_double turbulent_kappa_filtre_
Definition DNS.h:296
bool flag_u_filtre_
Definition DNS.h:300
double terme_source_acceleration_
Definition DNS.h:157
double dt_start_
Definition DNS.h:441
IJK_Field_double turbulent_kappa_
Definition DNS.h:277
bool diff_temp_negligeable_
Definition DNS.h:432
Filter_kernel_base * kernel_
Definition DNS.h:282
bool conv_rho_negligeable_
Definition DNS.h:435
Nom check_stop_file_
Definition DNS.h:380
void calculer_velocity_elem()
Definition DNS.cpp:8582
double smoothing_center_fr_
Definition DNS.h:260
IJK_Field_vector3_double turbulent_kappa_filtre_vector_
Definition DNS.h:297
IJK_Field_double div_lambda_grad_T_volume_
Definition DNS.h:224
bool turbulent_diffusivity_
Definition DNS.h:279
double debit_actuel_
Definition DNS.h:398
double facteur_delta_y_
Definition DNS.h:329
Noms expression_vitesse_initiale_
Definition DNS.h:392
IJK_Field_double pressure_rhs_
Definition DNS.h:214
Motcles liste_post_instantanes_
Definition DNS.h:367
FixedVector< IJK_Field_double, 6 > structural_uu_tensor_
Definition DNS.h:313
IJK_Field_double rho_sauvegarde_
Definition DNS.h:188
FixedVector< IJK_Field_double, 6 > turbulent_mu_filtre_tensor_
Definition DNS.h:295
IJK_Field_vector3_double velocity_filtre_
Definition DNS.h:288
double dt_save_cycle_
Definition DNS.h:373
Nom nom_sauvegarde_
Definition DNS.h:375
IJK_Field_double temperature_
Definition DNS.h:218
void compute_rho_bulk(double &rho_bulk_)
Definition DNS.cpp:12447
bool flag_filtrage_turbulent_diffusion_qdm_
Definition DNS.h:284
void calculer_convection_vitesse(IJK_Field_vector3_double &rho_v, IJK_Field_vector3_double &velocity, const ArrOfDouble_with_ghost &delta_z, const double facteur_delta_x, const double facteur_delta_y, const ArrOfDouble_with_ghost &delta_z_pour_delta, T &kernel, FixedVector< IJK_Field_local_double, 18 > &tmp_b, FixedVector< IJK_Field_local_double, 18 > &tmp_a, IJK_Field_vector3_double &d_velocity_tmp, IJK_Field_vector3_double &d_velocity, IJK_Field_double &u_div_rho_u)
Definition DNS.cpp:10767
void calculer_diffusion_scalar(const IJK_Field_double &rho, const IJK_Field_double &turbulent_kappa_x, const IJK_Field_double &turbulent_kappa_y, const IJK_Field_double &turbulent_kappa_z, IJK_Field_double &d_rho, const IJK_Field_local_double &boundary_flux_kmin, const IJK_Field_local_double &boundary_flux_kmax)
Definition DNS.cpp:11206
double lambda_de_t_paroi_kmax_
Definition DNS.h:448
bool structural_uscalar_
Definition DNS.h:325
int dt_raw_data_
Definition DNS.h:369
IJK_Field_double u_div_rho_u_
Definition DNS.h:226
int timestep_reprise_rho_
Definition DNS.h:387
OpDiffStructuralOnlyZeroatwallIJK_double velocity_turbulent_diffusion_op_structural_
Definition DNS.h:308
Statistiques_dns_qc_ijk statistiques_
Definition DNS.h:170
OpDiffTensorialZeroatwallIJK_double velocity_turbulent_diffusion_op_simple_
Definition DNS.h:242
Nom filter_kernel_name_
Definition DNS.h:281
Boundary_Conditions boundary_conditions_
Definition DNS.h:146
IJK_Field_vector3_double d_velocity_
Definition DNS.h:206
IJK_Field_double molecular_lambda_sauvegarde_
Definition DNS.h:186
OpConvCentre4IJK_double velocity_convection_op_
Definition DNS.h:343
IJK_Field_local_double boundary_flux_kmax_
Definition DNS.h:233
IJK_Field_double rho_
Definition DNS.h:153
OpDiffStdWithLaminarTransposeTensorialAnisotropicZeroatwallIJK_double velocity_turbulent_diffusion_op_simple_with_transpose_anisotropic_
Definition DNS.h:246
Nom structural_uu_dynamic_type_
Definition DNS.h:310
IJK_Field_double divergence_
Definition DNS.h:229
double terme_source_acceleration_constant_
Definition DNS.h:159
ArrOfDouble turbulent_diffusivity_vector_coefficients_
Definition DNS.h:274
OpDiffStdWithLaminarTransposeTensorialZeroatwallIJK_double velocity_turbulent_diffusion_op_simple_with_transpose_
Definition DNS.h:243
int nb_timesteps_
Definition DNS.h:360
bool flag_structural_uscalar_tmp_
Definition DNS.h:323
IJK_Field_vector3_double structural_uscalar_filtre_vector_
Definition DNS.h:299
double current_time_
Definition DNS.h:162
double turbulent_viscosity_model_constant_
Definition DNS.h:251
IJK_Field_double pressure_
Definition DNS.h:210
Domaine_IJK domaine_
Definition DNS.h:142
double old_timestep_
Definition DNS.h:365
bool flag_kappa_vectorial_
Definition DNS.h:275
void calculer_moyennes_flux()
Definition DNS.cpp:8407
Nom sauvegarde_splitting_name_
Definition DNS.h:181
FixedVector< IJK_Field_double, 6 > structural_uu_filtre_tensor_
Definition DNS.h:298
IJK_Field_double rho_filtre_
Definition DNS.h:289
IJK_Field_vector3_double velocity_sauvegarde_
Definition DNS.h:184
double facteur_delta_x_
Definition DNS.h:328
bool projection_initiale_demandee_
Definition DNS.h:382
bool lecture_post_instantanes_filtrer_p_
Definition DNS.h:458
bool convection_velocity_centre2_
Definition DNS.h:413
double Re_tau_ch_
Definition DNS.h:263
int dt_stats_
Definition DNS.h:370
void save_stats(double current_time)
Definition DNS.cpp:9403
bool flag_save_each_delta_t_
Definition DNS.h:472
double rho_paroi_impose_kmin_
Definition DNS.h:445
bool flag_d_velocity_tmp_
Definition DNS.h:340
Multigrille_Adrien poisson_solver_
Definition DNS.h:355
void initialise()
Definition DNS.cpp:8032
bool lecture_post_instantanes_filtrer_rho_
Definition DNS.h:457
double Lx_tot_
Definition DNS.h:421
bool convection_rho_centre4_
Definition DNS.h:410
ArrOfDouble_with_ghost delta_z_local_pour_delta_filtre_
Definition DNS.h:333
double dump_factor_2_
Definition DNS.h:404
double aim_t_bulk_
Definition DNS.h:401
Nom expression_temperature_initiale_
Definition DNS.h:391
double t_debut_statistiques_
Definition DNS.h:171
bool old_dtstab_
Definition DNS.h:463
bool flag_nu_tensorial_
Definition DNS.h:253
OpDiffIJK_double velocity_diffusion_op_simple_
Definition DNS.h:237
void ecrire_fichier_sauv(const char *fichier_sauvegarde, const char *lata_name)
Definition DNS.cpp:8494
bool formulation_velocity_
Definition DNS.h:335
OpDiffStdWithLaminarTransposeAndDivergenceIJK_double velocity_diffusion_op_full_
Definition DNS.h:239
IJK_Field_double turbulent_mu_
Definition DNS.h:255
bool conv_qdm_negligeable_
Definition DNS.h:434
double T_paroi_impose_kmax_
Definition DNS.h:426
void sauvegarder_qc(const char *fichier_sauvegarde)
Definition DNS.cpp:8517
IJK_Field_double temperature_sauvegarde_
Definition DNS.h:185
OpConvCentre2IJK_double velocity_convection_op_centre_2_
Definition DNS.h:344
Nom turbulent_diffusivity_model_
Definition DNS.h:271
bool flag_structural_uscalar_filtre_
Definition DNS.h:306
double structural_uu_model_constant_
Definition DNS.h:311
OpConvAmontIJK_double rho_convection_op_amont_
Definition DNS.h:352
int timestep_reprise_vitesse_
Definition DNS.h:389
bool convection_rho_centre2_
Definition DNS.h:409
OpDiffStructuralOnlyIJKScalar_double operateur_diffusion_temperature_structural_
Definition DNS.h:354
void compute_rho_t_bulk(double &rho_bulk_, double &t_bulk_)
Definition DNS.cpp:12500
OpConvCentre4IJK_double rho_convection_op_centre4_
Definition DNS.h:351
bool flag_turbulent_mu_filtre_
Definition DNS.h:303
double rho_paroi_impose_kmax_
Definition DNS.h:446
Nom large_eddy_simulation_formulation_
Definition DNS.h:327
FixedVector< IJK_Field_local_double, 18 > tmp_a_
Definition DNS.h:338
void save_raw_data(const char *lata_name, double current_time)
Definition DNS.cpp:9030
IJK_Field_vector3_double rho_v_
Definition DNS.h:204
double structural_uscalar_model_constant_
Definition DNS.h:320
Nom type_velocity_diffusion_
Definition DNS.h:240
bool flag_structural_uu_filtre_
Definition DNS.h:305
double center_constant_
Definition DNS.h:266
IJK_Field_double velocity_elem_X_sauvegarde_
Definition DNS.h:190
Noms statlata_namelist_
Definition DNS.h:453
Nom turbulent_viscosity_model_
Definition DNS.h:249
bool flag_kappa_anisotropic_
Definition DNS.h:276
void calculer_turbulent_diffusion_vitesse(IJK_Field_vector3_double &velocity, const IJK_Field_double &turbulent_mu_xx, const IJK_Field_double &turbulent_mu_xy, const IJK_Field_double &turbulent_mu_xz, const IJK_Field_double &turbulent_mu_yy, const IJK_Field_double &turbulent_mu_yz, const IJK_Field_double &turbulent_mu_zz, const ArrOfDouble_with_ghost &delta_z, const double facteur_delta_x, const double facteur_delta_y, const ArrOfDouble_with_ghost &delta_z_pour_delta, T &kernel, FixedVector< IJK_Field_local_double, 18 > &tmp_b, FixedVector< IJK_Field_local_double, 18 > &tmp_a, IJK_Field_vector3_double &d_velocity_tmp, IJK_Field_vector3_double &d_velocity)
Definition DNS.cpp:10898
Domaine_IJK sauvegarde_splitting_
Definition DNS.h:180
bool flag_temperature_filtre_
Definition DNS.h:302
double Lz_tot_
Definition DNS.h:423
OpDiffStdWithLaminarTransposeIJK_double velocity_diffusion_op_simple_with_transpose_
Definition DNS.h:238
ArrOfDouble_with_ghost constante_modele_
Definition DNS.h:336
double actual_t_bulk_
Definition DNS.h:402
Nom fichier_reprise_vitesse_
Definition DNS.h:388
Nom type_scalar_turbulent_diffusion_
Definition DNS.h:270
ArrOfDouble structural_uu_tensor_coefficients_
Definition DNS.h:312
double dt_save_oscillating_cycle_raw_data_
Definition DNS.h:372
bool reprise_spectrale_
Definition DNS.h:176
bool lecture_post_instantanes_filtrer_tous_
Definition DNS.h:459
void calculer_structural_diffusion_vitesse(IJK_Field_vector3_double &velocity, const FixedVector< IJK_Field_double, 6 > &structural_uu_tensor, const ArrOfDouble_with_ghost &delta_z, const double facteur_delta_x, const double facteur_delta_y, const ArrOfDouble_with_ghost &delta_z_pour_delta, T &kernel, FixedVector< IJK_Field_local_double, 18 > &tmp_b, FixedVector< IJK_Field_local_double, 18 > &tmp_a, IJK_Field_vector3_double &d_velocity_tmp, IJK_Field_vector3_double &d_velocity)
Definition DNS.cpp:11142
double amplitude_oscillating_boundary_
Definition DNS.h:467
bool flag_convection_qdm_sans_divergence_
Definition DNS.h:287
double P_thermodynamique_
Definition DNS.h:155
double gamma_
Definition DNS.h:428
Nom turbulent_diffusivity_dynamic_type_
Definition DNS.h:272
Nom fichier_reprise_rho_
Definition DNS.h:386
Nom structural_uscalar_model_
Definition DNS.h:318
IJK_Field_vector3_double structural_uscalar_tmp_vector_
Definition DNS.h:324
bool convection_rho_amont_
Definition DNS.h:408
void compute_t_bulk(double &t_bulk_)
Definition DNS.cpp:12474
IJK_Field_double velocity_elem_Y_
Definition DNS.h:199
FixedVector< FixedVector< ArrOfDouble, 7 >, 8 > ml_
Definition DNS.h:339
OpDiffVectorialAnisotropicIJKScalar_double operateur_diffusion_turbulent_scalar_anisotropic_
Definition DNS.h:269
double pond_fr_
Definition DNS.h:264
FixedVector< Redistribute_Field, 3 > redistribute_to_sauvegarde_splitting_faces_
Definition DNS.h:182
double timestep_
Definition DNS.h:364
bool postraiter_sous_pas_de_temps_
Definition DNS.h:374
int mode_terme_source_impose_
Definition DNS.h:160
double debit_cible_
Definition DNS.h:399
Nom nom_reprise_
Definition DNS.h:376
IJK_Field_double RK3_F_rho_
Definition DNS.h:220
double facteur_delta_filtre_y_
Definition DNS.h:332
double Ly_tot_
Definition DNS.h:422
void fixer_reference_pression(double &reference_pression)
Definition DNS.cpp:12405
int dt_sauvegarde_
Definition DNS.h:368
ArrOfDouble_with_ghost delta_z_local_pour_delta_
Definition DNS.h:330
bool flag_t_bulk_forced_
Definition DNS.h:403
void translation_pression(const double &reference_pression)
Definition DNS.cpp:12430
bool flag_convection_qdm_sans_rho_
Definition DNS.h:286
void rk3_sub_step(const int rk_step, const double total_timestep)
Definition DNS.cpp:11242
IJK_Field_double molecular_mu_sauvegarde_
Definition DNS.h:187
double puit_
Definition DNS.h:383
double dump_factor_
Definition DNS.h:397
bool flag_filtrage_structural_diffusion_qdm_
Definition DNS.h:285
void calcul_p_thermo_et_bilan(const IJK_Field_double &rho, IJK_Field_double &temperature, const int turbulent_diffusivity, const IJK_Field_double &lambda_turbulent, const int flag_lambda_anisotropic, const int structural_uscalar, const IJK_Field_double &structural_uscalar_z, const double P_th_initial, double &P_th_final, const double fractionnal_timestep, double &d_Pth_divise_par_gammamoins1) const
Definition DNS.cpp:10663
IJK_Field_vector3_double d_velocity_tmp_
Definition DNS.h:341
double frequency_oscillating_boundary_
Definition DNS.h:468
double terme_source_acceleration_z_
Definition DNS.h:158
double turbulent_diffusivity_model_constant_
Definition DNS.h:273
bool lecture_post_instantanes_
Definition DNS.h:455
double timestep_facsec_
Definition DNS.h:363
OpDiffVectorialIJKScalar_double operateur_diffusion_turbulent_scalar_
Definition DNS.h:268
Redistribute_Field redistribute_to_sauvegarde_splitting_elem_
Definition DNS.h:183
IJK_Field_vector3_double velocity_
Definition DNS.h:151
int dt_post_
Definition DNS.h:366
double facteur_delta_filtre_x_
Definition DNS.h:331
bool flag_filtrage_convection_qdm_
Definition DNS.h:283
IJK_Field_vector3_double RK3_F_velocity_
Definition DNS.h:208
FixedVector< IJK_Field_double, 6 > structural_uu_tmp_tensor_
Definition DNS.h:315
IJK_Field_vector3_double structural_uscalar_vector_
Definition DNS.h:322
double volume_total_domaine_
Definition DNS.h:450
Nom type_velocity_turbulent_diffusion_
Definition DNS.h:248
Fourier_trans partie_fourier_
Definition DNS.h:174
bool flag_turbulent_kappa_filtre_
Definition DNS.h:304
bool lecture_post_instantanes_filtrer_u_
Definition DNS.h:456
IJK_Field_double molecular_lambda_
Definition DNS.h:222
OpConvQuickIJKScalar_double rho_convection_op_
Definition DNS.h:349
void posttraiter_champs_instantanes(const char *lata_name, double time)
Definition DNS.cpp:8609
ArrOfDouble structural_uscalar_vector_coefficients_
Definition DNS.h:321
bool turbulent_viscosity_
Definition DNS.h:257
FixedVector< IJK_Field_local_double, 18 > tmp_b_
Definition DNS.h:337
Nom structural_uscalar_dynamic_type_
Definition DNS.h:319
ArrOfDouble_with_ghost delta_z_local_
Definition DNS.h:144
void reprendre_qc(const char *fichier_reprise)
Definition DNS.cpp:8558
IJK_Field_double velocity_elem_Z_sauvegarde_
Definition DNS.h:192
bool convection_velocity_amont_
Definition DNS.h:412
OpDiffIJKScalar_double operateur_diffusion_temperature_
Definition DNS.h:353
double rho_bulk_
Definition DNS.h:405
bool convection_velocity_quicksharp_
Definition DNS.h:414
IJK_Field_double d_rho_
Definition DNS.h:216
static void verifier(const char *msg, const IJK_Field_float &)
Definition DebogIJK.cpp:117
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
Definition Domaine_IJK.h:47
int get_offset_local(int direction) const
Returns the local offset in requested direction.
int get_nb_elem_local(int direction) const
Returns the number of elements owned by this processor in the given direction.
int get_nb_items_local(Localisation loc, int direction) const
Returns the number of local items (on this processor) for the given localisation in the requested dir...
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_items_global(Localisation loc, int direction) const
Returns the number of local items (on this processor) for the given localisation in the requested dir...
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.
Fichier en lecture Cette classe est a la classe C++ ifstream ce que la classe Entree est a la.
Definition EFichier.h:29
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::in)
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
const Domaine_IJK & get_domaine() const
Definition FixedVector.h:49
void echange_espace_virtuel()
Definition FixedVector.h:44
void resize(int n, int new_ghost)
void allocate(int ni, int nj, int nk, int ghosts, int additional_k_layers=0, int nb_compo=1, bool external_storage=false)
void echange_espace_virtuel(int ghost)
Exchange data over "ghost" number of cells.
const Domaine_IJK & get_domaine() const
static Objet_U & objet_global(const Nom &nom)
cherche l'objet demande dans l'Interprete_bloc courant (Interprete_bloc::interprete_courant()) et dan...
Classe de base des objets "interprete".
Definition Interprete.h:38
Cette classe implemente les operateurs et les methodes virtuelles de la classe EFichier de la facon s...
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
virtual int finit_par(const char *const n) const
Definition Nom.cpp:324
const Nom getPrefix(const char *const) const
Definition Nom.cpp:340
friend class Entree
Definition Objet_U.h:76
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
static const Nom & nom_du_cas()
Renvoie une reference constante vers le nom du cas.
Definition Objet_U.cpp:146
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter_flag(const char *keyword, const bool *value)
Register a boolean flag whose mere presence switches it to true.
Definition Param.cpp:474
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
@ REQUIRED
Definition Param.h:115
int lire_avec_accolades(Entree &is)
Alias of lire_avec_accolades_depuis.
Definition Param.h:577
static void mp_sum_for_each(T &arg1, T &arg2)
C++14 compatible mp_sum_for_each: combine multiple mp_sum calls into one collective operation Usage: ...
Definition Process.cpp:207
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
static void mp_min_for_each_item(TRUSTArray< _TYPE_ > &x, int n=-1)
Definition Process.cpp:199
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
void precision(int pre) override
void setf(IOS_FORMAT code) override
Classe de base des flux de sortie.
Definition Sortie.h:52