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 BRACE Quasi-compressible DNS solver in IJK discretization.
41
42
44{
45 return s;
46}
48{
49 return s;
50}
51
52
53// Programme principal pour le calcul DNS QC sur SuperMUC
54
55// formule pour gnuplot
56// 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
57// mu(x)=(((((x*(-5.05628e-18)+2.469e-14 ) *x-4.98344e-11)*x)+7.06714e-08)*x+1.0894e-06)
58static inline double calculer_lambda_air(double temperature)
59{
60 const double fac_a = -5.05628e-18;
61 const double fac_b = 2.469e-14;
62 const double fac_c = -4.98344e-11;
63 const double fac_d = 7.06714e-08;
64 const double fac_e = 1.0894e-06;
65 const double facteur = 1.93198026315789000e-3 / 1.461e-6;
66
67 double val = temperature;
68 double calc = val * fac_a + fac_b;
69 calc = val * calc + fac_c;
70 calc = val * calc + fac_d;
71 calc = val * calc + fac_e;
72 return calc * facteur;
73}
74
75static inline void choix_filter_kernel(const int ghost_size,
76 const Nom& filter_kernel_name,
77 Filter_kernel_base*& filter_kernel)
78{
79 // Choose a filter_kernel to compute the filter.
80 // Note: THE CALLER _MUdouble_ FREE THE MEMORY USING DELETE.
81 // example of use :
82 // Filter_kernel_base* filter_kernel = nullptr;
83 // choix_filter_kernel(ghost_size, filter_kernel_name, filter_kernel);
84 // /* do something with filter_kernel */
85 // delete filter_kernel;
86
87 if ( filter_kernel_name == Nom("box") )
88 {
89 filter_kernel = new Filter_kernel_box(ghost_size);
90 }
91 else if ( filter_kernel_name == Nom("weight_13_13_pondere") )
92 {
93 filter_kernel = new Filter_kernel_weight_13_13_pondere(ghost_size);
94 }
95 else if ( filter_kernel_name == Nom("weight_13_13_sansponderation") )
96 {
97 filter_kernel = new Filter_kernel_weight_13_13_sansponderation(ghost_size);
98 }
99 else if ( filter_kernel_name == Nom("weight_13_13_conservatif") )
100 {
101 filter_kernel = new Filter_kernel_weight_13_13_conservatif(ghost_size);
102 }
103 else if ( filter_kernel_name == Nom("weight_12_14_pondere") )
104 {
105 filter_kernel = new Filter_kernel_weight_12_14_pondere(ghost_size);
106 }
107 else if ( filter_kernel_name == Nom("weight_12_14_sansponderation") )
108 {
109 filter_kernel = new Filter_kernel_weight_12_14_sansponderation(ghost_size);
110 }
111 else if ( filter_kernel_name == Nom("weight_12_14_conservatif") )
112 {
113 filter_kernel = new Filter_kernel_weight_12_14_conservatif(ghost_size);
114 }
115 else if ( filter_kernel_name == Nom("weight_23_16_pondere") )
116 {
117 filter_kernel = new Filter_kernel_weight_23_16_pondere(ghost_size);
118 }
119 else if ( filter_kernel_name == Nom("weight_23_16_sansponderation") )
120 {
121 filter_kernel = new Filter_kernel_weight_23_16_sansponderation(ghost_size);
122 }
123 else if ( filter_kernel_name == Nom("weight_23_16_conservatif") )
124 {
125 filter_kernel = new Filter_kernel_weight_23_16_conservatif(ghost_size);
126 }
127 else if ( filter_kernel_name == Nom("weight_14_14_18_pondere") )
128 {
129 filter_kernel = new Filter_kernel_weight_14_14_18_pondere(ghost_size);
130 }
131 else if ( filter_kernel_name == Nom("weight_14_14_18_sansponderation") )
132 {
133 filter_kernel = new Filter_kernel_weight_14_14_18_sansponderation(ghost_size);
134 }
135 else if ( filter_kernel_name == Nom("weight_14_14_18_conservatif") )
136 {
137 filter_kernel = new Filter_kernel_weight_14_14_18_conservatif(ghost_size);
138 }
139 else if ( filter_kernel_name == Nom("weight_15_15_15_pondere") )
140 {
141 filter_kernel = new Filter_kernel_weight_15_15_15_pondere(ghost_size);
142 }
143 else if ( filter_kernel_name == Nom("weight_15_15_15_sansponderation") )
144 {
145 filter_kernel = new Filter_kernel_weight_15_15_15_sansponderation(ghost_size);
146 }
147 else if ( filter_kernel_name == Nom("weight_15_15_15_conservatif") )
148 {
149 filter_kernel = new Filter_kernel_weight_15_15_15_conservatif(ghost_size);
150 }
151 else if ( filter_kernel_name == Nom("weight_16_16_16_112_pondere") )
152 {
153 filter_kernel = new Filter_kernel_weight_16_16_16_112_pondere(ghost_size);
154 }
155 else if ( filter_kernel_name == Nom("weight_16_16_16_112_sansponderation") )
156 {
157 filter_kernel = new Filter_kernel_weight_16_16_16_112_sansponderation(ghost_size);
158 }
159 else if ( filter_kernel_name == Nom("weight_16_16_16_112_conservatif") )
160 {
161 filter_kernel = new Filter_kernel_weight_16_16_16_112_conservatif(ghost_size);
162 }
163 else if ( filter_kernel_name == Nom("weight_14_38_pondere") )
164 {
165 filter_kernel = new Filter_kernel_weight_14_38_pondere(ghost_size);
166 }
167 else if ( filter_kernel_name == Nom("weight_14_38_sansponderation") )
168 {
169 filter_kernel = new Filter_kernel_weight_14_38_sansponderation(ghost_size);
170 }
171 else if ( filter_kernel_name == Nom("weight_14_38_conservatif") )
172 {
173 filter_kernel = new Filter_kernel_weight_14_38_conservatif(ghost_size);
174 }
175 else if ( filter_kernel_name == Nom("laplacian") )
176 {
177 filter_kernel = new Filter_kernel_laplacian(ghost_size);
178 }
179 else
180 {
181 Cerr << "Error: (Inconsistent parameters) "
182 << "The large eddy simulation model requires filtering but the filter kernel name is unknown or unspecified. "
183 << "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;
185 }
186}
187
188static inline void choix_modele(const Nom& turbulent_viscosity_model,
190{
191 // Choose a model to compute the turbulent viscosity.
192 // Note: THE CALLER _MUdouble_ FREE THE MEMORY USING DELETE.
193 // example of use :
194 // Turbulent_viscosity_base* model = nullptr;
195 // choix_modele(turbulent_viscosity_model, model);
196 // /* do something with model */
197 // delete model;
198
199 if ( turbulent_viscosity_model == Nom("constant") )
200 {
202 }
203 else if ( turbulent_viscosity_model == Nom("unsrho") )
204 {
205 model = new Turbulent_viscosity_unsrho;
206 }
207 else if ( turbulent_viscosity_model == Nom("smagorinsky") )
208 {
210 }
211 else if ( turbulent_viscosity_model == Nom("vreman") )
212 {
213 model = new Turbulent_viscosity_vreman;
214 }
215 else if ( turbulent_viscosity_model == Nom("sigma") )
216 {
217 model = new Turbulent_viscosity_sigma;
218 }
219 else if ( turbulent_viscosity_model == Nom("wale") )
220 {
221 model = new Turbulent_viscosity_wale;
222 }
223 else if ( turbulent_viscosity_model == Nom("amd") )
224 {
225 model = new Turbulent_viscosity_amd;
226 }
227 else if ( turbulent_viscosity_model == Nom("amd_comp") )
228 {
230 }
231 else if ( turbulent_viscosity_model == Nom("amdnoclip") )
232 {
234 }
235 else if ( turbulent_viscosity_model == Nom("amdscalar") )
236 {
238 }
239 else if ( turbulent_viscosity_model == Nom("amdscalarnoclip") )
240 {
242 }
243 else if ( turbulent_viscosity_model == Nom("rds") )
244 {
245 model = new Turbulent_viscosity_rds;
246 }
247 else if ( turbulent_viscosity_model == Nom("vss") )
248 {
249 model = new Turbulent_viscosity_vss;
250 }
251 else if ( turbulent_viscosity_model == Nom("kobayashi") )
252 {
254 }
255 else
256 {
257 Cerr << "The turbulent diffusion model name is unknown." << finl;
259 }
260}
261
262void calculer_delta_z_pour_delta(const Domaine_IJK& splitting,
263 const Domaine_IJK& geom_pour_delta,
264 const int ghost_size,
265 ArrOfDouble_with_ghost& delta_z_pour_delta)
266{
267 const int nktot = splitting.get_nb_elem_tot(DIRECTION_K);
268 const ArrOfDouble& coord_z = splitting.get_node_coordinates(DIRECTION_K);
269 ArrOfDouble elem_coord(nktot);
270 for (int i = 0; i < nktot; i++)
271 {
272 elem_coord[i] = 0.5 * (coord_z[i] + coord_z[i+1]);
273 }
274
275 const int nktot_pour_delta = geom_pour_delta.get_nb_elem_tot(DIRECTION_K);
276 const ArrOfDouble& global_delta_pour_delta = geom_pour_delta.get_delta(DIRECTION_K);
277 const ArrOfDouble& coord_z_pour_delta = geom_pour_delta.get_node_coordinates(DIRECTION_K);
278 ArrOfDouble elem_coord_pour_delta(nktot_pour_delta);
279 for (int i = 0; i < nktot_pour_delta; i++)
280 {
281 elem_coord_pour_delta[i] = 0.5 * (coord_z_pour_delta[i] + coord_z_pour_delta[i+1]);
282 }
283
284 const int offset = splitting.get_offset_local(DIRECTION_K);
285 const int nk = splitting.get_nb_elem_local(DIRECTION_K);
286 delta_z_pour_delta.resize(nk, ghost_size);
287
288 double d0 = 0.;
289 double d1 = 0.;
290 double coord_0 = 0.;
291 double coord_1 = 0.;
292 int kg_1 = - ghost_size;
293 for (int k = -ghost_size; k < nk + ghost_size; k++)
294 {
295 const int kg = k + offset;
296
297 double coord;
298 if (kg < 0)
299 {
300 coord = elem_coord[0];
301 }
302 else if (kg >= nktot)
303 {
304 coord = elem_coord[nktot - 1];
305 }
306 else
307 {
308 coord = elem_coord[kg];
309 }
310
311 while (coord_1 < coord)
312 {
313 d0 = d1;
314 coord_0 = coord_1;
315
316 if (kg_1 < 0)
317 {
318 d1 = 0.;
319 coord_1 = coord_z_pour_delta[0];
320 }
321 else if (kg_1 >= nktot_pour_delta)
322 {
323 d1 = 0.;
324 coord_1 = coord_z_pour_delta[nktot_pour_delta];
325 }
326 else
327 {
328 d1 = global_delta_pour_delta[kg_1];
329 coord_1 = elem_coord_pour_delta[kg_1];
330 }
331
332 kg_1++;
333 }
334
335 if (coord_1 == coord_0)
336 {
337 if (coord_1 != coord || d0 != d1)
338 {
339 Cerr << "Ce n'est pas normal." << finl;
341 }
342 else
343 {
344 delta_z_pour_delta[k] = d0;
345 }
346 }
347 else
348 {
349 delta_z_pour_delta[k] = d0 + (d1 - d0)/(coord_1 - coord_0)*(coord - coord_0);
350 }
351 }
352}
353
354void calculer_delta_z_filtre_identique(const Domaine_IJK& splitting,
355 const ArrOfDouble_with_ghost& delta_z_pour_delta,
356 ArrOfDouble_with_ghost& delta_z_filtre)
357{
358 const int nk = splitting.get_nb_items_local(Domaine_IJK::FACES_K, DIRECTION_K);
359 const int nktot = splitting.get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
360 const int offset = splitting.get_offset_local(DIRECTION_K);
361
362 for (int k = 0; k < nk; k++)
363 {
364 const int kg = k + offset;
365 const double dz_pour_delta = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
366 delta_z_filtre[k] = sqrt(dz_pour_delta*dz_pour_delta + dz_pour_delta*dz_pour_delta);
367 }
368}
369
370void calculer_delta_z_filtre_n_mailles(const int taille_filtre,
371 const Domaine_IJK& splitting,
372 const ArrOfDouble_with_ghost& delta_z,
373 const ArrOfDouble_with_ghost& delta_z_pour_delta,
374 ArrOfDouble_with_ghost& delta_z_filtre)
375{
376 Cerr << "Taille du filtre explicite fixee a " << taille_filtre << " mailles." << finl;
377
378 const int nk = splitting.get_nb_items_local(Domaine_IJK::FACES_K, DIRECTION_K);
379 const int nktot = splitting.get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
380 const int offset = splitting.get_offset_local(DIRECTION_K);
381
382 const bool impair = (taille_filtre%2 != 0);
383 const int kp_min = impair ? (taille_filtre-1)/2 : (taille_filtre-2)/2;
384 const int kp_max = impair ? (taille_filtre-1)/2 : (taille_filtre-2)/2;
385
386 for (int k = 0; k < nk; k++)
387 {
388 const int kg = k + offset;
389
390 double longueur_elem = 0.;
391 for (int kp = -kp_min; kp < kp_max+1; kp++)
392 {
393 const int kpg = kg + kp;
394 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
395 longueur_elem += dz;
396 }
397
398 if (!impair)
399 {
400 {
401 const int kp = -kp_min - 1;
402 const int kpg = kg + kp;
403 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
404 longueur_elem += dz;
405 }
406 {
407 const int kp = kp_max + 1;
408 const int kpg = kg + kp;
409 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
410 longueur_elem += dz;
411 }
412 }
413 const double dz_pour_delta = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
414 delta_z_filtre[k] = sqrt(longueur_elem*longueur_elem + dz_pour_delta*dz_pour_delta);
415 }
416}
417
418// On suppose que rho a un espace virtuel a jour sur au moins l'epaisseur de joint demandee.
419void calculer_temperature_mu_lambda_air(const double P_th,
420 const double constante_specifique_gaz,
421 const IJK_Field_double& rho,
422 IJK_Field_double& temperature,
423 IJK_Field_double& molecular_mu,
424 IJK_Field_double& molecular_lambda,
425 int epaisseur_joint)
426{
427 const int imax = rho.ni() + epaisseur_joint;
428 const int jmax = rho.nj() + epaisseur_joint;
429 const int kmax = rho.nk() + epaisseur_joint;
430
431 const double fac_a = -5.05628e-18;
432 const double fac_b = 2.469e-14;
433 const double fac_c = -4.98344e-11;
434 const double fac_d = 7.06714e-08;
435 const double fac_e = 1.0894e-06;
436
437 const double facteur = 1.93198026315789000e-3 / 1.461e-6;
438
439 const double facteur_temperature = P_th / constante_specifique_gaz;
440
441 for (int k = -epaisseur_joint; k < kmax; k++)
442 {
443 for (int j = -epaisseur_joint; j < jmax; j++)
444 {
445 for (int i = -epaisseur_joint; i < imax; i++)
446 {
447 const double r = rho(i, j, k);
448 const double temp = facteur_temperature / r;
449 temperature(i,j,k) = temp;
450 double calc = temp * fac_a + fac_b;
451 calc = temp * calc + fac_c;
452 calc = temp * calc + fac_d;
453 calc = temp * calc + fac_e;
454 molecular_lambda(i,j,k) = calc * facteur;
455 molecular_mu(i,j,k) = calc;
456 }
457 }
458 }
459}
460
461void multiplier_champ(const double coefficient,
462 const IJK_Field_double& champ_in,
463 IJK_Field_double& champ_out)
464{
465 const int ni = champ_out.ni();
466 const int nj = champ_out.nj();
467 const int nk = champ_out.nk();
468
469 for (int k = 0; k < nk; k++)
470 {
471 for (int j = 0; j < nj; j++)
472 {
473 for (int i = 0; i < ni; i++)
474 {
475 champ_out(i,j,k) = coefficient * champ_in(i,j,k);
476 }
477 }
478 }
479}
480
481void multiplier_champ(const IJK_Field_double& champ_rho,
482 IJK_Field_double& champ)
483{
484 const int ni = champ.ni();
485 const int nj = champ.nj();
486 const int nk = champ.nk();
487
488 for (int k = 0; k < nk; k++)
489 {
490 for (int j = 0; j < nj; j++)
491 {
492 for (int i = 0; i < ni; i++)
493 {
494 champ(i,j,k) = champ_rho(i,j,k) * champ(i,j,k);
495 }
496 }
497 }
498}
499
500
501
502// Adds field1 to field2 by reference
503void add_fields(const IJK_Field_double& field1, IJK_Field_double& field2)
504{
505 const int ni = field2.ni();
506 const int nj = field2.nj();
507 const int nk = field2.nk();
508 for (int k = 0; k < nk; k++)
509 {
510 for (int j = 0; j < nj; j++)
511 {
512 for (int i = 0; i < ni; i++)
513 {
514 field2(i,j,k) += field1(i,j,k);
515 }
516 }
517 }
518}
519
520// Adds field1 to field2 by reference, on the k^{th} layer of the channel
521void add_fields_k(const IJK_Field_double& field1, IJK_Field_double& field2, const int k)
522{
523 const int ni = field2.ni();
524 const int nj = field2.nj();
525 for (int j = 0; j < nj; j++)
526 {
527 for (int i = 0; i < ni; i++)
528 {
529 field2(i,j,k) += field1(i,j,k);
530 }
531 }
532}
533
534void multiplier_champ_rho_arete_ij(const IJK_Field_double& champ_rho,
535 IJK_Field_double& champ)
536{
537 const int ni = champ.ni();
538 const int nj = champ.nj();
539 const int nk = champ.nk();
540
541 for (int k = 0; k < nk; k++)
542 {
543 for (int j = 0; j < nj; j++)
544 {
545 for (int i = 0; i < ni; i++)
546 {
547 const double rho = champ_rho(i,j,k);
548 const double rho_im1 = champ_rho(i-1,j,k);
549 const double rho_jm1 = champ_rho(i,j-1,k);
550 const double rho_im1_jm1 = champ_rho(i-1,j-1,k);
551 const double rho_ij = 0.25 * (rho + rho_im1 + rho_jm1 + rho_im1_jm1);
552 champ(i,j,k) = rho_ij * champ(i,j,k);
553 }
554 }
555 }
556}
557
558void multiplier_champ_rho_arete_ik(const IJK_Field_double& champ_rho,
559 double rho_kmin,
560 IJK_Field_double& champ)
561{
562 const int offset = champ_rho.get_domaine().get_offset_local(DIRECTION_K);
563
564 const int ni = champ.ni();
565 const int nj = champ.nj();
566 const int nk = champ.nk();
567
568 for (int k = 0; k < nk; k++)
569 {
570 for (int j = 0; j < nj; j++)
571 {
572 for (int i = 0; i < ni; i++)
573 {
574 const int kg = k + offset;
575 const double rho = champ_rho(i,j,k);
576 const double rho_im1 = champ_rho(i-1,j,k);
577 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));
578 champ(i,j,k) = rho_ik * champ(i,j,k);
579 }
580 }
581 }
582}
583
584void multiplier_champ_rho_arete_jk(const IJK_Field_double& champ_rho,
585 double rho_kmin,
586 IJK_Field_double& champ)
587{
588 const int offset = champ_rho.get_domaine().get_offset_local(DIRECTION_K);
589
590 const int ni = champ.ni();
591 const int nj = champ.nj();
592 const int nk = champ.nk();
593
594 for (int k = 0; k < nk; k++)
595 {
596 for (int j = 0; j < nj; j++)
597 {
598 for (int i = 0; i < ni; i++)
599 {
600 const int kg = k + offset;
601 const double rho = champ_rho(i,j,k);
602 const double rho_jm1 = champ_rho(i,j-1,k);
603 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));
604 champ(i,j,k) = rho_jk * champ(i,j,k);
605 }
606 }
607 }
608}
609
610void multiplier_champ(const IJK_Field_double& champ_rho,
611 const double& constant,
612 IJK_Field_double& champ)
613{
614 const int ni = champ.ni();
615 const int nj = champ.nj();
616 const int nk = champ.nk();
617
618 for (int k = 0; k < nk; k++)
619 {
620 for (int j = 0; j < nj; j++)
621 {
622 for (int i = 0; i < ni; i++)
623 {
624 champ(i,j,k) = champ_rho(i,j,k) * champ(i,j,k) * constant;
625 }
626 }
627 }
628}
629
630void multiplier_champ_rho_face_i(const int flag_add,
631 const IJK_Field_double& champ_rho,
632 const double& constant,
633 const IJK_Field_double& champ_in,
634 IJK_Field_double& champ_out)
635{
636 const int ni = champ_in.ni();
637 const int nj = champ_in.nj();
638 const int nk = champ_in.nk();
639
640 for (int k = 0; k < nk; k++)
641 {
642 for (int j = 0; j < nj; j++)
643 {
644 for (int i = 0; i < ni; i++)
645 {
646 const double rho = champ_rho(i,j,k);
647 const double rho_im1 = champ_rho(i-1,j,k);
648 const double rhof_i = 0.5 * (rho + rho_im1);
649 if (flag_add)
650 {
651 champ_out(i,j,k) += rhof_i * champ_in(i,j,k) * constant;
652 }
653 else
654 {
655 champ_out(i,j,k) = rhof_i * champ_in(i,j,k) * constant;
656 }
657 }
658 }
659 }
660}
661
662void multiplier_champ_rho_face_j(const int flag_add,
663 const IJK_Field_double& champ_rho,
664 const double& constant,
665 const IJK_Field_double& champ_in,
666 IJK_Field_double& champ_out)
667{
668 const int ni = champ_in.ni();
669 const int nj = champ_in.nj();
670 const int nk = champ_in.nk();
671
672 for (int k = 0; k < nk; k++)
673 {
674 for (int j = 0; j < nj; j++)
675 {
676 for (int i = 0; i < ni; i++)
677 {
678 const double rho = champ_rho(i,j,k);
679 const double rho_jm1 = champ_rho(i,j-1,k);
680 const double rhof_j = 0.5 * (rho + rho_jm1);
681 if (flag_add)
682 {
683 champ_out(i,j,k) += rhof_j * champ_in(i,j,k) * constant;
684 }
685 else
686 {
687 champ_out(i,j,k) = rhof_j * champ_in(i,j,k) * constant;
688 }
689 }
690 }
691 }
692}
693
694void multiplier_champ_rho_face_k(const int flag_add,
695 const IJK_Field_double& champ_rho,
696 const double& constant,
697 double rho_kmin,
698 const IJK_Field_double& champ_in,
699 IJK_Field_double& champ_out)
700{
701 const int offset = champ_rho.get_domaine().get_offset_local(DIRECTION_K);
702
703 const int ni = champ_in.ni();
704 const int nj = champ_in.nj();
705 const int nk = champ_in.nk();
706
707 for (int k = 0; k < nk; k++)
708 {
709 for (int j = 0; j < nj; j++)
710 {
711 for (int i = 0; i < ni; i++)
712 {
713 const int kg = k + offset;
714 const double rho = champ_rho(i,j,k);
715 const double rhof_k = kg==0 ? rho_kmin : 0.5 * (rho + champ_rho(i,j,k-1));
716 if (flag_add)
717 {
718 champ_out(i,j,k) += rhof_k * champ_in(i,j,k) * constant;
719 }
720 else
721 {
722 champ_out(i,j,k) = rhof_k * champ_in(i,j,k) * constant;
723 }
724 }
725 }
726 }
727}
728
729inline void multiplier_champ_rho_face_i(const IJK_Field_double& champ_rho,
730 const double& constant,
731 IJK_Field_double& champ)
732{
733 multiplier_champ_rho_face_i(false, champ_rho, constant, champ, champ);
734}
735
736inline void multiplier_champ_rho_face_j(const IJK_Field_double& champ_rho,
737 const double& constant,
738 IJK_Field_double& champ)
739{
740 multiplier_champ_rho_face_j(false, champ_rho, constant, champ, champ);
741}
742
743inline void multiplier_champ_rho_face_k(const IJK_Field_double& champ_rho,
744 const double& constant,
745 double rho_kmin,
746 IJK_Field_double& champ)
747{
748 multiplier_champ_rho_face_k(false, champ_rho, constant, rho_kmin, champ, champ);
749}
750
751template<class T>
752void filtrer_champ_elem(const int flag_add,
753 const IJK_Field_double& champ,
754 const ArrOfDouble_with_ghost& delta_z,
755 const double facteur_delta_x,
756 const double facteur_delta_y,
757 const ArrOfDouble_with_ghost& delta_z_pour_delta,
758 T& kernel,
761 IJK_Field_double& champ_filtre)
762{
763 const double dx = champ.get_domaine().get_constant_delta(DIRECTION_I);
764 const double dy = champ.get_domaine().get_constant_delta(DIRECTION_J);
765 const double dx_pour_delta = facteur_delta_x*dx;
766 const double dy_pour_delta = facteur_delta_y*dy;
767
768 const int ni = champ.ni();
769 const int nj = champ.nj();
770 const int nk = champ.nk();
771
772 const int nktot = champ.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
773 const int offset = champ.get_domaine().get_offset_local(DIRECTION_K);
774
775 IJK_Field_local_double& b = tmp_b[0];
776 IJK_Field_local_double& a = tmp_a[0];
777
778 const int ghost_size_filter = kernel->ghost_size();
779 const int size_uniform = kernel->size_uniform();
780 const int shift_uniform = kernel->shift_uniform();
781 for (int k = 0; k < nk; k++)
782 {
783 const int kg = k + offset;
784
785 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
786 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
787
788 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
789 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
790 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
791 const int size_k_elem = kernel->size_k_elem(kg, nktot);
792 const int shift_k_elem = kernel->shift_k_elem(kg);
793 const bool ponderation_filter_kernel = kernel->ponderation();
794 const bool normalisation_filter_kernel = kernel->normalisation();
795
796 double facteur_elem = 0.;
797 if (ponderation_filter_kernel)
798 {
799 if (normalisation_filter_kernel)
800 {
801 double longueur_elem = 0.;
802 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
803 {
804 const int kpg = kg + kp;
805 if (kpg<-1 || kpg>nktot)
806 {
807 Cerr << "This should not happen." << finl;
809 }
810 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
811 const double filter_coef_z = filter_kernel_z[kp+10];
812 longueur_elem += filter_coef_z * dz;
813 }
814 facteur_elem = 1./longueur_elem;
815 }
816 else
817 {
818 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
819 }
820 }
821
822 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
823 {
824 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
825 {
826 b(i, j, 0) = 0.;
827 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
828 {
829 const int kpg = kg + kp;
830 if (!(kernel->is_at_wall_elem(kpg, nktot)))
831 {
832 const double filter_coef_z = filter_kernel_z[kp+10];
833 if (ponderation_filter_kernel)
834 {
835 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
836 b(i, j, 0) += champ(i,j,k+kp) * filter_coef_z * dz * facteur_elem;
837 }
838 else
839 {
840 b(i, j, 0) += champ(i,j,k+kp) * filter_coef_z;
841 }
842 }
843 }
844 }
845 }
846 for (int j = 0; j < nj; j++)
847 {
848 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
849 {
850 a(i, 0, 0) = 0.;
851 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
852 {
853 const double filter_coef_y = filter_kernel_y[jp+10];
854 a(i, 0, 0) += b(i, j+jp, 0) * filter_coef_y;
855 }
856 }
857
858 for (int i = 0; i < ni; i++)
859 {
860 double r = 0.;
861 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
862 {
863 const double filter_coef_x = filter_kernel_x[ip+10];
864 r += a(i+ip, 0, 0) * filter_coef_x;
865 }
866
867 if (flag_add)
868 {
869 champ_filtre(i,j,k) += r;
870 }
871 else
872 {
873 champ_filtre(i,j,k) = r;
874 }
875 }
876 }
877 }
878}
879
880template<class T>
881void filtrer_champ_face(const int flag_add,
882 const IJK_Field_double& champ,
883 const ArrOfDouble_with_ghost& delta_z,
884 const double facteur_delta_x,
885 const double facteur_delta_y,
886 const ArrOfDouble_with_ghost& delta_z_pour_delta,
887 T& kernel,
890 IJK_Field_double& champ_filtre)
891{
892 const double dx = champ.get_domaine().get_constant_delta(DIRECTION_I);
893 const double dy = champ.get_domaine().get_constant_delta(DIRECTION_J);
894 const double dx_pour_delta = facteur_delta_x*dx;
895 const double dy_pour_delta = facteur_delta_y*dy;
896
897 const int ni = champ.ni();
898 const int nj = champ.nj();
899 const int nk = champ.nk();
900
901 const int nktot = champ.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
902 const int offset = champ.get_domaine().get_offset_local(DIRECTION_K);
903
904 IJK_Field_local_double& b = tmp_b[0];
905 IJK_Field_local_double& a = tmp_a[0];
906
907 const int ghost_size_filter = kernel->ghost_size();
908 const int size_uniform = kernel->size_uniform();
909 const int shift_uniform = kernel->shift_uniform();
910 for (int k = 0; k < nk; k++)
911 {
912 const int kg = k + offset;
913
914 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
915 const double dz_m1_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z[k-1];
916 const double delta_m_glo = kg==0 ? 0.5*dz_glo : 0.5*(dz_glo + dz_m1_glo);
917 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
918 const double dz_m1_pour_delta_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1];
919 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);
920
921 const FixedVector<double, 21> filter_kernel_z_face = kernel->inhomogeneous(false, k, kg, nktot, delta_m_pour_delta_glo, delta_z);
922 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
923 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
924 const int size_k_face = kernel->size_k_face(kg, nktot);
925 const int shift_k_face = kernel->shift_k_face(kg);
926 const bool ponderation_filter_kernel = kernel->ponderation();
927 const bool normalisation_filter_kernel = kernel->normalisation();
928
929 double facteur_face = 0.;
930 if (ponderation_filter_kernel)
931 {
932 if (normalisation_filter_kernel)
933 {
934 double longueur_face = 0.;
935 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
936 {
937 const int kpg = kg + kp;
938 if (kpg<0 || kpg>nktot)
939 {
940 Cerr << "This should not happen." << finl;
942 }
943 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
944 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
945 const double dzf = 0.5*(dz + dz_m1);
946 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
947 longueur_face += filter_coef_z_face * dzf;
948 }
949 facteur_face = 1./longueur_face;
950 }
951 else
952 {
953 facteur_face = delta_m_glo==0. ? 0. : 1./delta_m_glo;
954 }
955 }
956
957 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
958 {
959 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
960 {
961 b(i, j, 0) = 0.;
962 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
963 {
964 const int kpg = kg + kp;
965 if (!(kernel->is_at_wall_face(kpg, nktot)))
966 {
967 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
968 if (ponderation_filter_kernel)
969 {
970 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
971 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
972 const double dzf = 0.5*(dz + dz_m1);
973 b(i, j, 0) += champ(i,j,k+kp) * filter_coef_z_face * dzf * facteur_face;
974 }
975 else
976 {
977 b(i, j, 0) += champ(i,j,k+kp) * filter_coef_z_face;
978 }
979 }
980 }
981 }
982 }
983 for (int j = 0; j < nj; j++)
984 {
985 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
986 {
987 a(i, 0, 0) = 0.;
988 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
989 {
990 const double filter_coef_y = filter_kernel_y[jp+10];
991 a(i, 0, 0) += b(i, j+jp, 0) * filter_coef_y;
992 }
993 }
994
995 for (int i = 0; i < ni; i++)
996 {
997 double r = 0.;
998 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
999 {
1000 const double filter_coef_x = filter_kernel_x[ip+10];
1001 r += a(i+ip, 0, 0) * filter_coef_x;
1002 }
1003
1004 if (flag_add)
1005 {
1006 champ_filtre(i,j,k) += r;
1007 }
1008 else
1009 {
1010 champ_filtre(i,j,k) = r;
1011 }
1012 }
1013 }
1014 }
1015}
1016
1017static inline void calculer_g(int i, int j, int k,
1018 const IJK_Field_vector3_double& velocity,
1019 const ArrOfDouble_with_ghost& delta_z_maillage,
1020 const double dx_delta,
1021 const double dy_delta,
1022 const double dz_delta,
1023 const double delta_m_delta,
1024 const double delta_p_delta,
1026{
1027 const IJK_Field_double& vitesse_i = velocity[0];
1028 const IJK_Field_double& vitesse_j = velocity[1];
1029 const IJK_Field_double& vitesse_k = velocity[2];
1030
1031 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
1032 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
1033 const double deltaunsurdx = dx_delta * 1./dx;
1034 const double deltaunsurdy = dy_delta * 1./dy;
1035
1036 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
1037 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
1038
1039 const int kg = k + offset;
1040 const double dz = delta_z_maillage[k];
1041 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
1042 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
1043
1044 const double deltaunsurdz = dz_delta * 1./dz;
1045 const double deltaunsurdelta_m = delta_m_delta * 1./delta_m;
1046 const double deltaunsurdelta_p = delta_p_delta * 1./delta_p;
1047
1048 const double uf_i = vitesse_i(i,j,k);
1049 const double uf_ip1 = vitesse_i(i+1,j,k);
1050 const double uf_i_jm1 = vitesse_i(i,j-1,k);
1051 const double uf_i_jp1 = vitesse_i(i,j+1,k);
1052 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
1053 const double uf_i_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i,j,k+1);
1054 const double uf_ip1_jp1 = vitesse_i(i+1,j+1,k);
1055 const double uf_ip1_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i+1,j,k+1);
1056 const double uf_ip1_jm1 = vitesse_i(i+1,j-1,k);
1057 const double uf_ip1_km1 = kg==0 ? 0. : vitesse_i(i+1,j,k-1);
1058
1059 const double vf_j = vitesse_j(i,j,k);
1060 const double vf_j_im1 = vitesse_j(i-1,j,k);
1061 const double vf_j_ip1 = vitesse_j(i+1,j,k);
1062 const double vf_jp1 = vitesse_j(i,j+1,k);
1063 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
1064 const double vf_j_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j,k+1);
1065 const double vf_jp1_ip1 = vitesse_j(i+1,j+1,k);
1066 const double vf_jp1_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j+1,k+1);
1067 const double vf_jp1_im1 = vitesse_j(i-1,j+1,k);
1068 const double vf_jp1_km1 = kg==0 ? 0. : vitesse_j(i,j+1,k-1);
1069
1070 const double wf_k = vitesse_k(i,j,k);
1071 const double wf_k_im1 = vitesse_k(i-1,j,k);
1072 const double wf_k_ip1 = vitesse_k(i+1,j,k);
1073 const double wf_k_jm1 = vitesse_k(i,j-1,k);
1074 const double wf_k_jp1 = vitesse_k(i,j+1,k);
1075 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
1076 const double wf_kp1_ip1 = kg==(nktot-1) ? 0. : vitesse_k(i+1,j,k+1);
1077 const double wf_kp1_jp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j+1,k+1);
1078 const double wf_kp1_im1 = kg==(nktot-1) ? 0. : vitesse_k(i-1,j,k+1);
1079 const double wf_kp1_jm1 = kg==(nktot-1) ? 0. : vitesse_k(i,j-1,k+1);
1080
1081 const double duidx = deltaunsurdx * (uf_ip1 - uf_i);
1082 const double dujdy = deltaunsurdy * (vf_jp1 - vf_j);
1083 const double dukdz = deltaunsurdz * (wf_kp1 - wf_k);
1084
1085 const double duidy_ij = deltaunsurdy * (uf_i - uf_i_jm1);
1086 const double duidy_ip1j = deltaunsurdy * (uf_ip1 - uf_ip1_jm1);
1087 const double duidy_ijp1 = deltaunsurdy * (uf_i_jp1 - uf_i);
1088 const double duidy_ip1jp1 = deltaunsurdy * (uf_ip1_jp1 - uf_ip1);
1089
1090 const double duidz_ik = deltaunsurdelta_m * (uf_i - uf_i_km1);
1091 const double duidz_ip1k = deltaunsurdelta_m * (uf_ip1 - uf_ip1_km1);
1092 const double duidz_ikp1 = deltaunsurdelta_p * (uf_i_kp1 - uf_i);
1093 const double duidz_ip1kp1 = deltaunsurdelta_p * (uf_ip1_kp1 - uf_ip1);
1094
1095 const double dujdx_ij = deltaunsurdx * (vf_j - vf_j_im1);
1096 const double dujdx_ip1j = deltaunsurdx * (vf_j_ip1 - vf_j);
1097 const double dujdx_ijp1 = deltaunsurdx * (vf_jp1 - vf_jp1_im1);
1098 const double dujdx_ip1jp1 = deltaunsurdx * (vf_jp1_ip1 - vf_jp1);
1099
1100 const double dujdz_jk = deltaunsurdelta_m * (vf_j - vf_j_km1);
1101 const double dujdz_jp1k = deltaunsurdelta_m * (vf_jp1 - vf_jp1_km1);
1102 const double dujdz_jkp1 = deltaunsurdelta_p * (vf_j_kp1 - vf_j);
1103 const double dujdz_jp1kp1 = deltaunsurdelta_p * (vf_jp1_kp1 - vf_jp1);
1104
1105 const double dukdx_ik = deltaunsurdx * (wf_k - wf_k_im1);
1106 const double dukdx_ip1k = deltaunsurdx * (wf_k_ip1 - wf_k);
1107 const double dukdx_ikp1 = deltaunsurdx * (wf_kp1 - wf_kp1_im1);
1108 const double dukdx_ip1kp1 = deltaunsurdx * (wf_kp1_ip1 - wf_kp1);
1109
1110 const double dukdy_jk = deltaunsurdy * (wf_k - wf_k_jm1);
1111 const double dukdy_jp1k = deltaunsurdy * (wf_k_jp1 - wf_k);
1112 const double dukdy_jkp1 = deltaunsurdy * (wf_kp1 - wf_kp1_jm1);
1113 const double dukdy_jp1kp1 = deltaunsurdy * (wf_kp1_jp1 - wf_kp1);
1114
1115 g[0][0] = duidx;
1116 g[0][1] = 0.25 * (duidy_ip1jp1 + duidy_ijp1 + duidy_ip1j + duidy_ij);
1117 g[0][2] = 0.25 * (duidz_ip1kp1 + duidz_ikp1 + duidz_ip1k + duidz_ik);
1118 g[1][0] = 0.25 * (dujdx_ip1jp1 + dujdx_ip1j + dujdx_ijp1 + dujdx_ij);
1119 g[1][1] = dujdy;
1120 g[1][2] = 0.25 * (dujdz_jp1kp1 + dujdz_jkp1 + dujdz_jp1k + dujdz_jk);
1121 g[2][0] = 0.25 * (dukdx_ip1kp1 + dukdx_ip1k + dukdx_ikp1 + dukdx_ik);
1122 g[2][1] = 0.25 * (dukdy_jp1kp1 + dukdy_jp1k + dukdy_jkp1 + dukdy_jk);
1123 g[2][2] = dukdz;
1124}
1125
1126static inline void calculer_tau(int i, int j, int k,
1127 const IJK_Field_vector3_double& velocity,
1128 const IJK_Field_double& turbulent_mu_xx,
1129 const IJK_Field_double& turbulent_mu_xy,
1130 const IJK_Field_double& turbulent_mu_xz,
1131 const IJK_Field_double& turbulent_mu_yy,
1132 const IJK_Field_double& turbulent_mu_yz,
1133 const IJK_Field_double& turbulent_mu_zz,
1134 const ArrOfDouble_with_ghost& delta_z_maillage,
1135 const double dx_delta,
1136 const double dy_delta,
1137 const double dz_delta,
1138 const double delta_m_delta,
1139 const double delta_p_delta,
1141{
1142 const IJK_Field_double& vitesse_i = velocity[0];
1143 const IJK_Field_double& vitesse_j = velocity[1];
1144 const IJK_Field_double& vitesse_k = velocity[2];
1145
1146 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
1147 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
1148 const double deltaunsurdx = dx_delta * 1./dx;
1149 const double deltaunsurdy = dy_delta * 1./dy;
1150
1151 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
1152 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
1153
1154 const int kg = k + offset;
1155 const double dz = delta_z_maillage[k];
1156 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
1157 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
1158
1159 const double deltaunsurdz = dz_delta * 1./dz;
1160 const double deltaunsurdelta_m = delta_m_delta * 1./delta_m;
1161 const double deltaunsurdelta_p = delta_p_delta * 1./delta_p;
1162
1163 const double nu_xx = turbulent_mu_xx(i,j,k);
1164
1165 const double nu_xy = turbulent_mu_xy(i,j,k);
1166 const double nu_xy_im1 = turbulent_mu_xy(i-1,j,k);
1167 const double nu_xy_jm1 = turbulent_mu_xy(i,j-1,k);
1168 const double nu_xy_im1_jm1 = turbulent_mu_xy(i-1,j-1,k);
1169 const double nu_xy_ip1 = turbulent_mu_xy(i+1,j,k);
1170 const double nu_xy_jp1 = turbulent_mu_xy(i,j+1,k);
1171 const double nu_xy_ip1_jp1 = turbulent_mu_xy(i+1,j+1,k);
1172 const double nu_xy_im1_jp1 = turbulent_mu_xy(i-1,j+1,k);
1173 const double nu_xy_ip1_jm1 = turbulent_mu_xy(i+1,j-1,k);
1174
1175 const double nu_xz = turbulent_mu_xz(i,j,k);
1176 const double nu_xz_im1 = turbulent_mu_xz(i-1,j,k);
1177 const double nu_xz_km1 = kg==0 ? 0. : turbulent_mu_xz(i,j,k-1);
1178 const double nu_xz_im1_km1 = kg==0 ? 0. : turbulent_mu_xz(i-1,j,k-1);
1179 const double nu_xz_ip1 = turbulent_mu_xz(i+1,j,k);
1180 const double nu_xz_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_xz(i,j,k+1);
1181 const double nu_xz_ip1_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_xz(i+1,j,k+1);
1182 const double nu_xz_im1_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_xz(i-1,j,k+1);
1183 const double nu_xz_ip1_km1 = kg==0 ? 0. : turbulent_mu_xz(i+1,j,k-1);
1184
1185 const double nu_yy = turbulent_mu_yy(i,j,k);
1186
1187 const double nu_yz = turbulent_mu_yz(i,j,k);
1188 const double nu_yz_jm1 = turbulent_mu_yz(i,j-1,k);
1189 const double nu_yz_km1 = kg==0 ? 0. : turbulent_mu_yz(i,j,k-1);
1190 const double nu_yz_jm1_km1 = kg==0 ? 0. : turbulent_mu_yz(i,j-1,k-1);
1191 const double nu_yz_jp1 = turbulent_mu_yz(i,j+1,k);
1192 const double nu_yz_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_yz(i,j,k+1);
1193 const double nu_yz_jp1_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_yz(i,j+1,k+1);
1194 const double nu_yz_jm1_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_yz(i,j-1,k+1);
1195 const double nu_yz_jp1_km1 = kg==0 ? 0. : turbulent_mu_yz(i,j+1,k-1);
1196
1197 const double nu_xy_ij = 0.25 * (nu_xy + nu_xy_im1 + nu_xy_jm1 + nu_xy_im1_jm1);
1198 const double nu_xy_ip1j = 0.25 * (nu_xy_ip1 + nu_xy + nu_xy_ip1_jm1 + nu_xy_jm1);
1199 const double nu_xy_ijp1 = 0.25 * (nu_xy_jp1 + nu_xy_im1_jp1 + nu_xy + nu_xy_im1);
1200 const double nu_xy_ip1jp1 = 0.25 * (nu_xy_ip1_jp1 + nu_xy_jp1 + nu_xy_ip1 + nu_xy);
1201 const double nu_xz_ik = 0.25 * (nu_xz + nu_xz_im1 + nu_xz_km1 + nu_xz_im1_km1);
1202 const double nu_xz_ip1k = 0.25 * (nu_xz_ip1 + nu_xz + nu_xz_ip1_km1 + nu_xz_km1);
1203 const double nu_xz_ikp1 = 0.25 * (nu_xz_kp1 + nu_xz_im1_kp1 + nu_xz + nu_xz_im1);
1204 const double nu_xz_ip1kp1 = 0.25 * (nu_xz_ip1_kp1 + nu_xz_kp1 + nu_xz_ip1 + nu_xz);
1205 const double nu_yz_jk = 0.25 * (nu_yz + nu_yz_jm1 + nu_yz_km1 + nu_yz_jm1_km1);
1206 const double nu_yz_jp1k = 0.25 * (nu_yz_jp1 + nu_yz + nu_yz_jp1_km1 + nu_yz_km1);
1207 const double nu_yz_jkp1 = 0.25 * (nu_yz_kp1 + nu_yz_jm1_kp1 + nu_yz + nu_yz_jm1);
1208 const double nu_yz_jp1kp1 = 0.25 * (nu_yz_jp1_kp1 + nu_yz_kp1 + nu_yz_jp1 + nu_yz);
1209
1210 const double nu_zz = turbulent_mu_zz(i,j,k);
1211
1212 const double uf_i = vitesse_i(i,j,k);
1213 const double uf_i_jm1 = vitesse_i(i,j-1,k);
1214 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
1215
1216 const double vf_j = vitesse_j(i,j,k);
1217 const double vf_j_im1 = vitesse_j(i-1,j,k);
1218 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
1219
1220 const double wf_k = vitesse_k(i,j,k);
1221 const double wf_k_im1 = vitesse_k(i-1,j,k);
1222 const double wf_k_jm1 = vitesse_k(i,j-1,k);
1223
1224 const double uf_ip1 = vitesse_i(i+1,j,k);
1225 const double uf_i_jp1 = vitesse_i(i,j+1,k);
1226 const double uf_i_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i,j,k+1);
1227 const double uf_ip1_jp1 = vitesse_i(i+1,j+1,k);
1228 const double uf_ip1_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i+1,j,k+1);
1229 const double uf_ip1_jm1 = vitesse_i(i+1,j-1,k);
1230 const double uf_ip1_km1 = kg==0 ? 0. : vitesse_i(i+1,j,k-1);
1231
1232 const double vf_j_ip1 = vitesse_j(i+1,j,k);
1233 const double vf_jp1 = vitesse_j(i,j+1,k);
1234 const double vf_j_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j,k+1);
1235 const double vf_jp1_ip1 = vitesse_j(i+1,j+1,k);
1236 const double vf_jp1_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j+1,k+1);
1237 const double vf_jp1_im1 = vitesse_j(i-1,j+1,k);
1238 const double vf_jp1_km1 = kg==0 ? 0. : vitesse_j(i,j+1,k-1);
1239
1240 const double wf_k_ip1 = vitesse_k(i+1,j,k);
1241 const double wf_k_jp1 = vitesse_k(i,j+1,k);
1242 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
1243 const double wf_kp1_ip1 = kg==(nktot-1) ? 0. : vitesse_k(i+1,j,k+1);
1244 const double wf_kp1_jp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j+1,k+1);
1245 const double wf_kp1_im1 = kg==(nktot-1) ? 0. : vitesse_k(i-1,j,k+1);
1246 const double wf_kp1_jm1 = kg==(nktot-1) ? 0. : vitesse_k(i,j-1,k+1);
1247
1248 const double duidx = deltaunsurdx * (uf_ip1 - uf_i);
1249 const double dujdy = deltaunsurdy * (vf_jp1 - vf_j);
1250 const double dukdz = deltaunsurdz * (wf_kp1 - wf_k);
1251
1252 const double duidy_ij = deltaunsurdy * (uf_i - uf_i_jm1);
1253 const double duidy_ip1j = deltaunsurdy * (uf_ip1 - uf_ip1_jm1);
1254 const double duidy_ijp1 = deltaunsurdy * (uf_i_jp1 - uf_i);
1255 const double duidy_ip1jp1 = deltaunsurdy * (uf_ip1_jp1 - uf_ip1);
1256
1257 const double duidz_ik = deltaunsurdelta_m * (uf_i - uf_i_km1);
1258 const double duidz_ip1k = deltaunsurdelta_m * (uf_ip1 - uf_ip1_km1);
1259 const double duidz_ikp1 = deltaunsurdelta_p * (uf_i_kp1 - uf_i);
1260 const double duidz_ip1kp1 = deltaunsurdelta_p * (uf_ip1_kp1 - uf_ip1);
1261
1262 const double dujdx_ij = deltaunsurdx * (vf_j - vf_j_im1);
1263 const double dujdx_ip1j = deltaunsurdx * (vf_j_ip1 - vf_j);
1264 const double dujdx_ijp1 = deltaunsurdx * (vf_jp1 - vf_jp1_im1);
1265 const double dujdx_ip1jp1 = deltaunsurdx * (vf_jp1_ip1 - vf_jp1);
1266
1267 const double dujdz_jk = deltaunsurdelta_m * (vf_j - vf_j_km1);
1268 const double dujdz_jp1k = deltaunsurdelta_m * (vf_jp1 - vf_jp1_km1);
1269 const double dujdz_jkp1 = deltaunsurdelta_p * (vf_j_kp1 - vf_j);
1270 const double dujdz_jp1kp1 = deltaunsurdelta_p * (vf_jp1_kp1 - vf_jp1);
1271
1272 const double dukdx_ik = deltaunsurdx * (wf_k - wf_k_im1);
1273 const double dukdx_ip1k = deltaunsurdx * (wf_k_ip1 - wf_k);
1274 const double dukdx_ikp1 = deltaunsurdx * (wf_kp1 - wf_kp1_im1);
1275 const double dukdx_ip1kp1 = deltaunsurdx * (wf_kp1_ip1 - wf_kp1);
1276
1277 const double dukdy_jk = deltaunsurdy * (wf_k - wf_k_jm1);
1278 const double dukdy_jp1k = deltaunsurdy * (wf_k_jp1 - wf_k);
1279 const double dukdy_jkp1 = deltaunsurdy * (wf_kp1 - wf_kp1_jm1);
1280 const double dukdy_jp1kp1 = deltaunsurdy * (wf_kp1_jp1 - wf_kp1);
1281
1282 const double s_ii = 0.5 * (duidx + duidx);
1283 const double s_jj = 0.5 * (dujdy + dujdy);
1284 const double s_kk = 0.5 * (dukdz + dukdz);
1285
1286 const double s_ij = 0.5 * (duidy_ij + dujdx_ij);
1287 const double s_ik = 0.5 * (duidz_ik + dukdx_ik);
1288 const double s_jk = 0.5 * (dujdz_jk + dukdy_jk);
1289
1290 const double s_ip1j = 0.5 * (duidy_ip1j + dujdx_ip1j);
1291 const double s_ip1k = 0.5 * (duidz_ip1k + dukdx_ip1k);
1292 const double s_jp1k = 0.5 * (dujdz_jp1k + dukdy_jp1k);
1293
1294 const double s_ijp1 = 0.5 * (duidy_ijp1 + dujdx_ijp1);
1295 const double s_ikp1 = 0.5 * (duidz_ikp1 + dukdx_ikp1);
1296 const double s_jkp1 = 0.5 * (dujdz_jkp1 + dukdy_jkp1);
1297
1298 const double s_ip1jp1 = 0.5 * (duidy_ip1jp1 + dujdx_ip1jp1);
1299 const double s_ip1kp1 = 0.5 * (duidz_ip1kp1 + dukdx_ip1kp1);
1300 const double s_jp1kp1 = 0.5 * (dujdz_jp1kp1 + dukdy_jp1kp1);
1301
1302 f[0][0] = - 2. * nu_xx * s_ii;
1303 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);
1304 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);
1305 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);
1306 f[1][1] = - 2. * nu_yy * s_jj;
1307 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);
1308 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);
1309 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);
1310 f[2][2] = - 2. * nu_zz * s_kk;
1311}
1312
1313static inline void calculer_q(int i, int j, int k,
1314 const IJK_Field_vector3_double& velocity,
1315 const IJK_Field_double& champ_scalar,
1316 double scalar_kmin, double scalar_kmax,
1317 const ArrOfDouble_with_ghost& delta_z_maillage,
1318 const double dx_delta,
1319 const double dy_delta,
1320 const double dz_delta,
1321 const double delta_m_delta,
1322 const double delta_p_delta,
1324{
1325 const IJK_Field_double& vitesse_k = velocity[2];
1326
1327 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
1328 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
1329 const double deltaunsurdx = dx_delta * 1./dx;
1330 const double deltaunsurdy = dy_delta * 1./dy;
1331
1332 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
1333 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
1334
1335 const int kg = k + offset;
1336 const double dz = delta_z_maillage[k];
1337 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
1338 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
1339
1340 const double deltaunsurdelta_m = delta_m_delta * 1./delta_m;
1341 const double deltaunsurdelta_p = delta_p_delta * 1./delta_p;
1342
1343 const double scalar = champ_scalar(i,j,k);
1344
1345 const double scalar_im1 = champ_scalar(i-1,j,k);
1346 const double scalar_ip1 = champ_scalar(i+1,j,k);
1347
1348 const double scalar_jm1 = champ_scalar(i,j-1,k);
1349 const double scalar_jp1 = champ_scalar(i,j+1,k);
1350
1351 const double scalar_km1 = kg==0 ? scalar_kmin : champ_scalar(i,j,k-1);
1352 const double scalar_kp1 = kg==(nktot-1) ? scalar_kmax : champ_scalar(i,j,k+1);
1353
1354 const double dscalardxf_i = deltaunsurdx * (scalar - scalar_im1);
1355 const double dscalardxf_ip1 = deltaunsurdx * (scalar_ip1 - scalar);
1356
1357 const double dscalardyf_j = deltaunsurdy * (scalar - scalar_jm1);
1358 const double dscalardyf_jp1 = deltaunsurdy * (scalar_jp1 - scalar);
1359
1360 const double dscalardzf_k = deltaunsurdelta_m * (scalar - scalar_km1);
1361 const double dscalardzf_kp1 = deltaunsurdelta_p * (scalar_kp1 - scalar);
1362
1363 q[0] = 0.5 * (dscalardxf_i + dscalardxf_ip1);
1364 q[1] = 0.5 * (dscalardyf_j + dscalardyf_jp1);
1365 q[2] = 0.5 * (dscalardzf_k + dscalardzf_kp1);
1366}
1367
1368static inline void calculer_pi(int i, int j, int k,
1369 const IJK_Field_vector3_double& velocity,
1370 const IJK_Field_double& champ_scalar,
1371 double scalar_kmin, double scalar_kmax,
1372 const IJK_Field_double& turbulent_mu_x,
1373 const IJK_Field_double& turbulent_mu_y,
1374 const IJK_Field_double& turbulent_mu_z,
1375 const ArrOfDouble_with_ghost& delta_z_maillage,
1376 const double dx_delta,
1377 const double dy_delta,
1378 const double dz_delta,
1379 const double delta_m_delta,
1380 const double delta_p_delta,
1382{
1383 const IJK_Field_double& vitesse_k = velocity[2];
1384
1385 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
1386 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
1387 const double deltaunsurdx = dx_delta * 1./dx;
1388 const double deltaunsurdy = dy_delta * 1./dy;
1389
1390 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
1391 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
1392
1393 const int kg = k + offset;
1394 const double dz = delta_z_maillage[k];
1395 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
1396 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
1397
1398 const double deltaunsurdelta_m = delta_m_delta * 1./delta_m;
1399 const double deltaunsurdelta_p = delta_p_delta * 1./delta_p;
1400
1401 const double nu_x = turbulent_mu_x(i,j,k);
1402 const double nu_x_im1 = turbulent_mu_x(i-1,j,k);
1403 const double nu_x_ip1 = turbulent_mu_x(i+1,j,k);
1404
1405 const double nu_y = turbulent_mu_y(i,j,k);
1406 const double nu_y_jm1 = turbulent_mu_y(i,j-1,k);
1407 const double nu_y_jp1 = turbulent_mu_y(i,j+1,k);
1408
1409 const double nu_z = turbulent_mu_z(i,j,k);
1410 const double nu_z_km1 = kg==0 ? 0. : turbulent_mu_z(i,j,k-1);
1411 const double nu_z_kp1 = kg==(nktot-1) ? 0. : turbulent_mu_z(i,j,k+1);
1412
1413 const double nu_xf_i = 0.5 * (nu_x + nu_x_im1);
1414 const double nu_yf_j = 0.5 * (nu_y + nu_y_jm1);
1415 const double nu_zf_k = 0.5 * (nu_z + nu_z_km1);
1416 const double nu_xf_ip1 = 0.5 * (nu_x + nu_x_ip1);
1417 const double nu_yf_jp1 = 0.5 * (nu_y + nu_y_jp1);
1418 const double nu_zf_kp1 = 0.5 * (nu_z + nu_z_kp1);
1419
1420 const double scalar = champ_scalar(i,j,k);
1421
1422 const double scalar_im1 = champ_scalar(i-1,j,k);
1423 const double scalar_ip1 = champ_scalar(i+1,j,k);
1424
1425 const double scalar_jm1 = champ_scalar(i,j-1,k);
1426 const double scalar_jp1 = champ_scalar(i,j+1,k);
1427
1428 const double scalar_km1 = kg==0 ? scalar_kmin : champ_scalar(i,j,k-1);
1429 const double scalar_kp1 = kg==(nktot-1) ? scalar_kmax : champ_scalar(i,j,k+1);
1430
1431 const double dscalardxf_i = deltaunsurdx * (scalar - scalar_im1);
1432 const double dscalardxf_ip1 = deltaunsurdx * (scalar_ip1 - scalar);
1433
1434 const double dscalardyf_j = deltaunsurdy * (scalar - scalar_jm1);
1435 const double dscalardyf_jp1 = deltaunsurdy * (scalar_jp1 - scalar);
1436
1437 const double dscalardzf_k = deltaunsurdelta_m * (scalar - scalar_km1);
1438 const double dscalardzf_kp1 = deltaunsurdelta_p * (scalar_kp1 - scalar);
1439
1440 f[0] = - 0.5 * (nu_xf_i*dscalardxf_i + nu_xf_ip1*dscalardxf_ip1);
1441 f[1] = - 0.5 * (nu_yf_j*dscalardyf_j + nu_yf_jp1*dscalardyf_jp1);
1442 f[2] = - 0.5 * (nu_zf_k*dscalardzf_k + nu_zf_kp1*dscalardzf_kp1);
1443}
1444
1445template<class T>
1446void calculer_turbulent_mu(const bool anisotropic,
1447 T& model,
1448 const double turbulent_viscosity_model_constant,
1449 const double variation_cste_modele_fonctionnel_,
1450 const double smoothing_center_fr_,
1451 const double smoothing_factor_fr_,
1452 const double Re_tau_fr_,
1453 const double Re_tau_ch_,
1454 const double pond_fr_,
1455 const double pond_ch_,
1456 const double center_constant_,
1457 const double Lz_tot_,
1458 const IJK_Field_vector3_double& velocity,
1459 const IJK_Field_double& champ_rho,
1460 const IJK_Field_double& champ_scalar,
1461 double scalar_kmin, double scalar_kmax,
1462 const ArrOfDouble_with_ghost& delta_z_maillage,
1463 const double facteur_x_pour_delta,
1464 const double facteur_y_pour_delta,
1465 const ArrOfDouble_with_ghost& delta_z_pour_delta,
1466 IJK_Field_double& turbulent_mu,
1467 const Domaine_IJK& splitting)
1468{
1469 const IJK_Field_double& vitesse_k = velocity[2];
1470
1471 const double dx_pour_delta = facteur_x_pour_delta * vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
1472 const double dy_pour_delta = facteur_y_pour_delta * vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
1473
1474 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
1475 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
1476
1477 const int ni = vitesse_k.ni();
1478 const int nj = vitesse_k.nj();
1479 const int nk = vitesse_k.nk();
1480
1481 const ArrOfDouble& coord_z = splitting.get_node_coordinates(DIRECTION_K);
1482 ArrOfDouble elem_coord(nk);
1483 for (int i = 0; i < nktot; i++)
1484 {
1485 elem_coord[i] = 0.5 * (coord_z[i] + coord_z[i+1]);
1486 }
1487 elem_coord[nktot]=Lz_tot_;
1488
1491// Modif Martin
1492// const int nktot_elem = splitting.get_nb_elem_tot(DIRECTION_K);
1493 // Quick fix using the C++ std::vector
1494 // double turbulent_viscosity_model_constant_tab[nk];
1495 std::vector<double> turbulent_viscosity_model_constant_tab(nk);
1496 if ( !variation_cste_modele_fonctionnel_ )
1497 {
1498 if ( ( smoothing_factor_fr_ != 0. ) || ( smoothing_center_fr_ != 0. ) || pond_ch_ != 0. || pond_fr_ != 0. )
1499 {
1500 Cerr << "Error: (Inconsistent parameters) "
1501 << "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."
1502 << "" << finl;
1503 Process::exit();
1504 }
1505 for (int k = 0; k <= nktot; k++)
1506 {
1507 turbulent_viscosity_model_constant_tab[k]=turbulent_viscosity_model_constant;
1508 }
1509 }
1510 else
1511 {
1512 if ( smoothing_factor_fr_ == 0. )
1513 {
1514 Cerr << "Error: (Inconsistent parameters) "
1515 << "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_."
1516 << "" << finl;
1517 Process::exit();
1518 }
1519 else if ((pond_fr_ == 0.) || (pond_ch_ == 0.))
1520 {
1521 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." ;
1522 }
1523 for (int k = 0; k < nktot/2; k++)
1524 {
1525 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_);
1526 }
1527 for (int k = nktot; k > nktot/2-1; --k)
1528 {
1529 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_);
1530 }
1531 }
1532// Fin modif Martin
1533
1534 for (int k = 0; k < nk; k++)
1535 {
1536 for (int j = 0; j < nj; j++)
1537 {
1538 for (int i = 0; i < ni; i++)
1539 {
1540 const int kg = k + offset;
1541 const double dz_pour_delta = delta_z_pour_delta[k];
1542
1543 const double rho = champ_rho(i,j,k);
1544
1545 if (!anisotropic)
1546 {
1547 calculer_g(i, j, k, velocity, delta_z_maillage, 1., 1., 1., 1., 1., g);
1548 calculer_q(i, j, k, velocity, champ_scalar, scalar_kmin, scalar_kmax, delta_z_maillage, 1., 1., 1., 1., 1., q);
1549// Modif Martin
1550 turbulent_mu(i,j,k) = model(turbulent_viscosity_model_constant_tab[k], dx_pour_delta, dy_pour_delta, dz_pour_delta, rho, g, q);
1551// Fin modif Martin
1552 }
1553 else
1554 {
1555 const double delta_m_pour_delta = kg==0 ? 0. : 0.5*(dz_pour_delta + delta_z_pour_delta[k-1]);
1556 const double delta_p_pour_delta = kg==(nktot-1) ? 0. : 0.5*(dz_pour_delta + delta_z_pour_delta[k+1]);
1557 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);
1558 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);
1559// Modif Martin
1560 turbulent_mu(i,j,k) = model(turbulent_viscosity_model_constant_tab[k], 1., 1., 1., rho, g, q);
1561// Fin modif Martin
1562 }
1563 }
1564 }
1565 }
1566}
1567
1568template<class T>
1569void calculer_ml_dynamic_uu_tensor(const bool anisotropic,
1570 const bool tensorial,
1571 const IJK_Field_vector3_double& velocity,
1572 const IJK_Field_vector3_double& velocity_filtre,
1573 const int turbulent_viscosity,
1574 const IJK_Field_double& turbulent_mu_xx,
1575 const IJK_Field_double& turbulent_mu_xy,
1576 const IJK_Field_double& turbulent_mu_xz,
1577 const IJK_Field_double& turbulent_mu_yy,
1578 const IJK_Field_double& turbulent_mu_yz,
1579 const IJK_Field_double& turbulent_mu_zz,
1580 const IJK_Field_double& turbulent_mu_filtre_xx,
1581 const IJK_Field_double& turbulent_mu_filtre_xy,
1582 const IJK_Field_double& turbulent_mu_filtre_xz,
1583 const IJK_Field_double& turbulent_mu_filtre_yy,
1584 const IJK_Field_double& turbulent_mu_filtre_yz,
1585 const IJK_Field_double& turbulent_mu_filtre_zz,
1586 const int structural_uu,
1587 const FixedVector<IJK_Field_double, 6>& structural_uu_tensor,
1588 const FixedVector<IJK_Field_double, 6>& structural_uu_filtre_tensor,
1589 const ArrOfDouble_with_ghost& delta_z,
1590 const double facteur_delta_x,
1591 const double facteur_delta_y,
1592 const ArrOfDouble_with_ghost& delta_z_pour_delta,
1593 const double facteur_delta_filtre_x,
1594 const double facteur_delta_filtre_y,
1595 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
1596 T& kernel,
1600{
1601 const IJK_Field_double& vitesse_i = velocity[0];
1602 const IJK_Field_double& vitesse_j = velocity[1];
1603 const IJK_Field_double& vitesse_k = velocity[2];
1604
1605 const IJK_Field_double& vitesse_i_filtre = velocity_filtre[0];
1606 const IJK_Field_double& vitesse_j_filtre = velocity_filtre[1];
1607 const IJK_Field_double& vitesse_k_filtre = velocity_filtre[2];
1608
1609 const IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
1610 const IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
1611 const IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
1612 const IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
1613 const IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
1614 const IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
1615
1616 const IJK_Field_double& structural_uu_filtre_xx = structural_uu_filtre_tensor[0];
1617 const IJK_Field_double& structural_uu_filtre_xy = structural_uu_filtre_tensor[1];
1618 const IJK_Field_double& structural_uu_filtre_xz = structural_uu_filtre_tensor[2];
1619 const IJK_Field_double& structural_uu_filtre_yy = structural_uu_filtre_tensor[3];
1620 const IJK_Field_double& structural_uu_filtre_yz = structural_uu_filtre_tensor[4];
1621 const IJK_Field_double& structural_uu_filtre_zz = structural_uu_filtre_tensor[5];
1622
1623 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
1624 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
1625 const double dx_pour_delta = facteur_delta_x*dx;
1626 const double dy_pour_delta = facteur_delta_y*dy;
1627
1628 const int ni = vitesse_k.ni();
1629 const int nj = vitesse_k.nj();
1630 const int nk = vitesse_k.nk();
1631
1632 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
1633 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
1634
1635 IJK_Field_local_double& bf_ii = tmp_b[0];
1636 IJK_Field_local_double& bf_ij = tmp_b[1];
1637 IJK_Field_local_double& bf_ik = tmp_b[2];
1638 IJK_Field_local_double& bf_jj = tmp_b[3];
1639 IJK_Field_local_double& bf_jk = tmp_b[4];
1640 IJK_Field_local_double& bf_kk = tmp_b[5];
1641 IJK_Field_local_double& buu_ii = tmp_b[6];
1642 IJK_Field_local_double& buu_ij = tmp_b[7];
1643 IJK_Field_local_double& buu_ik = tmp_b[8];
1644 IJK_Field_local_double& buu_jj = tmp_b[9];
1645 IJK_Field_local_double& buu_jk = tmp_b[10];
1646 IJK_Field_local_double& buu_kk = tmp_b[11];
1647 IJK_Field_local_double& bg_ii = tmp_b[12];
1648 IJK_Field_local_double& bg_ij = tmp_b[13];
1649 IJK_Field_local_double& bg_ik = tmp_b[14];
1650 IJK_Field_local_double& bg_jj = tmp_b[15];
1651 IJK_Field_local_double& bg_jk = tmp_b[16];
1652 IJK_Field_local_double& bg_kk = tmp_b[17];
1653
1654 IJK_Field_local_double& af_ii = tmp_a[0];
1655 IJK_Field_local_double& af_ij = tmp_a[1];
1656 IJK_Field_local_double& af_ik = tmp_a[2];
1657 IJK_Field_local_double& af_jj = tmp_a[3];
1658 IJK_Field_local_double& af_jk = tmp_a[4];
1659 IJK_Field_local_double& af_kk = tmp_a[5];
1660 IJK_Field_local_double& auu_ii = tmp_a[6];
1661 IJK_Field_local_double& auu_ij = tmp_a[7];
1662 IJK_Field_local_double& auu_ik = tmp_a[8];
1663 IJK_Field_local_double& auu_jj = tmp_a[9];
1664 IJK_Field_local_double& auu_jk = tmp_a[10];
1665 IJK_Field_local_double& auu_kk = tmp_a[11];
1666 IJK_Field_local_double& ag_ii = tmp_a[12];
1667 IJK_Field_local_double& ag_ij = tmp_a[13];
1668 IJK_Field_local_double& ag_ik = tmp_a[14];
1669 IJK_Field_local_double& ag_jj = tmp_a[15];
1670 IJK_Field_local_double& ag_jk = tmp_a[16];
1671 IJK_Field_local_double& ag_kk = tmp_a[17];
1672
1673 ArrOfDouble& moy_lij_xx = ml[0][0];
1674 ArrOfDouble& moy_lij_xy = ml[0][1];
1675 ArrOfDouble& moy_lij_xz = ml[0][2];
1676 ArrOfDouble& moy_lij_yy = ml[0][3];
1677 ArrOfDouble& moy_lij_yz = ml[0][4];
1678 ArrOfDouble& moy_lij_zz = ml[0][5];
1679
1680 ArrOfDouble& moy_mij_xx = ml[1][0];
1681 ArrOfDouble& moy_mij_xy = ml[1][1];
1682 ArrOfDouble& moy_mij_xz = ml[1][2];
1683 ArrOfDouble& moy_mij_yy = ml[1][3];
1684 ArrOfDouble& moy_mij_yz = ml[1][4];
1685 ArrOfDouble& moy_mij_zz = ml[1][5];
1686
1687 ArrOfDouble& moy_hij_xx = ml[2][0];
1688 ArrOfDouble& moy_hij_xy = ml[2][1];
1689 ArrOfDouble& moy_hij_xz = ml[2][2];
1690 ArrOfDouble& moy_hij_yy = ml[2][3];
1691 ArrOfDouble& moy_hij_yz = ml[2][4];
1692 ArrOfDouble& moy_hij_zz = ml[2][5];
1693
1694 ArrOfDouble& moy_mijmij_xx = ml[3][0];
1695 ArrOfDouble& moy_mijmij_xy = ml[3][1];
1696 ArrOfDouble& moy_mijmij_xz = ml[3][2];
1697 ArrOfDouble& moy_mijmij_yy = ml[3][3];
1698 ArrOfDouble& moy_mijmij_yz = ml[3][4];
1699 ArrOfDouble& moy_mijmij_zz = ml[3][5];
1700 ArrOfDouble& moy_mijmij = ml[3][6];
1701
1702 ArrOfDouble& moy_hijhij_xx = ml[4][0];
1703 ArrOfDouble& moy_hijhij_xy = ml[4][1];
1704 ArrOfDouble& moy_hijhij_xz = ml[4][2];
1705 ArrOfDouble& moy_hijhij_yy = ml[4][3];
1706 ArrOfDouble& moy_hijhij_yz = ml[4][4];
1707 ArrOfDouble& moy_hijhij_zz = ml[4][5];
1708 ArrOfDouble& moy_hijhij = ml[4][6];
1709
1710 ArrOfDouble& moy_mijlij_xx = ml[5][0];
1711 ArrOfDouble& moy_mijlij_xy = ml[5][1];
1712 ArrOfDouble& moy_mijlij_xz = ml[5][2];
1713 ArrOfDouble& moy_mijlij_yy = ml[5][3];
1714 ArrOfDouble& moy_mijlij_yz = ml[5][4];
1715 ArrOfDouble& moy_mijlij_zz = ml[5][5];
1716 ArrOfDouble& moy_mijlij = ml[5][6];
1717
1718 ArrOfDouble& moy_hijlij_xx = ml[6][0];
1719 ArrOfDouble& moy_hijlij_xy = ml[6][1];
1720 ArrOfDouble& moy_hijlij_xz = ml[6][2];
1721 ArrOfDouble& moy_hijlij_yy = ml[6][3];
1722 ArrOfDouble& moy_hijlij_yz = ml[6][4];
1723 ArrOfDouble& moy_hijlij_zz = ml[6][5];
1724 ArrOfDouble& moy_hijlij = ml[6][6];
1725
1726 ArrOfDouble& moy_mijhij_xx = ml[7][0];
1727 ArrOfDouble& moy_mijhij_xy = ml[7][1];
1728 ArrOfDouble& moy_mijhij_xz = ml[7][2];
1729 ArrOfDouble& moy_mijhij_yy = ml[7][3];
1730 ArrOfDouble& moy_mijhij_yz = ml[7][4];
1731 ArrOfDouble& moy_mijhij_zz = ml[7][5];
1732 ArrOfDouble& moy_mijhij = ml[7][6];
1733
1734 double m_ii = 0.;
1735 double m_ij = 0.;
1736 double m_ik = 0.;
1737 double m_jj = 0.;
1738 double m_jk = 0.;
1739 double m_kk = 0.;
1740
1741 double h_ii = 0.;
1742 double h_ij = 0.;
1743 double h_ik = 0.;
1744 double h_jj = 0.;
1745 double h_jk = 0.;
1746 double h_kk = 0.;
1747
1750
1751 const int ghost_size_filter = kernel->ghost_size();
1752 const int size_uniform = kernel->size_uniform();
1753 const int shift_uniform = kernel->shift_uniform();
1754 for (int k = 0; k < nk; k++)
1755 {
1756 const int kg = k + offset;
1757
1758 if (tensorial)
1759 {
1760 moy_lij_xx[kg] = 0;
1761 moy_lij_xy[kg] = 0;
1762 moy_lij_xz[kg] = 0;
1763 moy_lij_yy[kg] = 0;
1764 moy_lij_yz[kg] = 0;
1765 moy_lij_zz[kg] = 0;
1766
1767 moy_mij_xx[kg] = 0;
1768 moy_mij_xy[kg] = 0;
1769 moy_mij_xz[kg] = 0;
1770 moy_mij_yy[kg] = 0;
1771 moy_mij_yz[kg] = 0;
1772 moy_mij_zz[kg] = 0;
1773
1774 moy_hij_xx[kg] = 0;
1775 moy_hij_xy[kg] = 0;
1776 moy_hij_xz[kg] = 0;
1777 moy_hij_yy[kg] = 0;
1778 moy_hij_yz[kg] = 0;
1779 moy_hij_zz[kg] = 0;
1780
1781 moy_mijmij_xx[kg] = 0;
1782 moy_mijmij_xy[kg] = 0;
1783 moy_mijmij_xz[kg] = 0;
1784 moy_mijmij_yy[kg] = 0;
1785 moy_mijmij_yz[kg] = 0;
1786 moy_mijmij_zz[kg] = 0;
1787
1788 moy_hijhij_xx[kg] = 0;
1789 moy_hijhij_xy[kg] = 0;
1790 moy_hijhij_xz[kg] = 0;
1791 moy_hijhij_yy[kg] = 0;
1792 moy_hijhij_yz[kg] = 0;
1793 moy_hijhij_zz[kg] = 0;
1794
1795 moy_mijlij_xx[kg] = 0;
1796 moy_mijlij_xy[kg] = 0;
1797 moy_mijlij_xz[kg] = 0;
1798 moy_mijlij_yy[kg] = 0;
1799 moy_mijlij_yz[kg] = 0;
1800 moy_mijlij_zz[kg] = 0;
1801
1802 moy_hijlij_xx[kg] = 0;
1803 moy_hijlij_xy[kg] = 0;
1804 moy_hijlij_xz[kg] = 0;
1805 moy_hijlij_yy[kg] = 0;
1806 moy_hijlij_yz[kg] = 0;
1807 moy_hijlij_zz[kg] = 0;
1808
1809 moy_mijhij_xx[kg] = 0;
1810 moy_mijhij_xy[kg] = 0;
1811 moy_mijhij_xz[kg] = 0;
1812 moy_mijhij_yy[kg] = 0;
1813 moy_mijhij_yz[kg] = 0;
1814 moy_mijhij_zz[kg] = 0;
1815 }
1816
1817 moy_mijmij[kg] = 0;
1818 moy_hijhij[kg] = 0;
1819 moy_mijlij[kg] = 0;
1820 moy_hijlij[kg] = 0;
1821 moy_mijhij[kg] = 0;
1822
1823 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
1824 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
1825
1826 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
1827 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
1828 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
1829 const int size_k_elem = kernel->size_k_elem(kg, nktot);
1830 const int shift_k_elem = kernel->shift_k_elem(kg);
1831 const bool ponderation_filter_kernel = kernel->ponderation();
1832 const bool normalisation_filter_kernel = kernel->normalisation();
1833
1834 double facteur_elem = 0.;
1835 if (ponderation_filter_kernel)
1836 {
1837 if (normalisation_filter_kernel)
1838 {
1839 double longueur_elem = 0.;
1840 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
1841 {
1842 const int kpg = kg + kp;
1843 if (kpg<-1 || kpg>nktot)
1844 {
1845 Cerr << "This should not happen." << finl;
1846 Process::exit();
1847 }
1848 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
1849 const double filter_coef_z = filter_kernel_z[kp+10];
1850 longueur_elem += filter_coef_z * dz;
1851 }
1852 facteur_elem = 1./longueur_elem;
1853 }
1854 else
1855 {
1856 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
1857 }
1858 }
1859
1860 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
1861 {
1862 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
1863 {
1864 buu_ii(i, j, 0) = 0.;
1865 buu_ij(i, j, 0) = 0.;
1866 buu_ik(i, j, 0) = 0.;
1867 buu_jj(i, j, 0) = 0.;
1868 buu_jk(i, j, 0) = 0.;
1869 buu_kk(i, j, 0) = 0.;
1870 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
1871 {
1872 const int kpg = kg + kp;
1873 if (!(kernel->is_at_wall_elem(kpg, nktot)))
1874 {
1875 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
1876 const double filter_coef_z = filter_kernel_z[kp+10];
1877 const double uf_i = vitesse_i(i,j,k+kp);
1878 const double vf_j = vitesse_j(i,j,k+kp);
1879 const double wf_k = vitesse_k(i,j,k+kp);
1880
1881 const double uf_ip1 = vitesse_i(i+1,j,k+kp);
1882 const double vf_jp1 = vitesse_j(i,j+1,k+kp);
1883 const double wf_kp1 = kpg==(nktot-1) ? 0. : vitesse_k(i,j,k+1+kp);
1884
1885 const double ue = 0.5 * (uf_i + uf_ip1);
1886 const double ve = 0.5 * (vf_j + vf_jp1);
1887 const double we = 0.5 * (wf_k + wf_kp1);
1888
1889 const double uu_e = ue * ue;
1890 const double uv_e = ue * ve;
1891 const double uw_e = ue * we;
1892 const double vv_e = ve * ve;
1893 const double vw_e = ve * we;
1894 const double ww_e = we * we;
1895
1896 if (ponderation_filter_kernel)
1897 {
1898 buu_ii(i, j, 0) += uu_e * filter_coef_z * dz * facteur_elem;
1899 buu_ij(i, j, 0) += uv_e * filter_coef_z * dz * facteur_elem;
1900 buu_ik(i, j, 0) += uw_e * filter_coef_z * dz * facteur_elem;
1901 buu_jj(i, j, 0) += vv_e * filter_coef_z * dz * facteur_elem;
1902 buu_jk(i, j, 0) += vw_e * filter_coef_z * dz * facteur_elem;
1903 buu_kk(i, j, 0) += ww_e * filter_coef_z * dz * facteur_elem;
1904 }
1905 else
1906 {
1907 buu_ii(i, j, 0) += uu_e * filter_coef_z;
1908 buu_ij(i, j, 0) += uv_e * filter_coef_z;
1909 buu_ik(i, j, 0) += uw_e * filter_coef_z;
1910 buu_jj(i, j, 0) += vv_e * filter_coef_z;
1911 buu_jk(i, j, 0) += vw_e * filter_coef_z;
1912 buu_kk(i, j, 0) += ww_e * filter_coef_z;
1913 }
1914 }
1915 }
1916
1917 if (turbulent_viscosity)
1918 {
1919 bf_ii(i, j, 0) = 0.;
1920 bf_ij(i, j, 0) = 0.;
1921 bf_ik(i, j, 0) = 0.;
1922 bf_jj(i, j, 0) = 0.;
1923 bf_jk(i, j, 0) = 0.;
1924 bf_kk(i, j, 0) = 0.;
1925 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
1926 {
1927 const int kpg = kg + kp;
1928 if (!(kernel->is_at_wall_elem(kpg, nktot)))
1929 {
1930 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
1931 const double filter_coef_z = filter_kernel_z[kp+10];
1932 if (!anisotropic)
1933 {
1934 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);
1935 }
1936 else
1937 {
1938 const double dz_pour_delta = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z_pour_delta[k+kp];
1939 const double dz_m1_pour_delta = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1+kp];
1940 const double dz_p1_pour_delta = (kpg+1<0 || kpg+1>(nktot-1)) ? 0. : delta_z_pour_delta[k+1+kp];
1941 const double delta_m_pour_delta = (kpg-1<0 || kpg>(nktot-1)) ? 0. : 0.5*(dz_pour_delta + dz_m1_pour_delta);
1942 const double delta_p_pour_delta = (kpg<0 || kpg+1>(nktot-1)) ? 0. : 0.5*(dz_pour_delta + dz_p1_pour_delta);
1943 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);
1944 }
1945
1946 if (ponderation_filter_kernel)
1947 {
1948 bf_ii(i, j, 0) += f[0][0] * filter_coef_z * dz * facteur_elem;
1949 bf_ij(i, j, 0) += f[0][1] * filter_coef_z * dz * facteur_elem;
1950 bf_ik(i, j, 0) += f[0][2] * filter_coef_z * dz * facteur_elem;
1951 bf_jj(i, j, 0) += f[1][1] * filter_coef_z * dz * facteur_elem;
1952 bf_jk(i, j, 0) += f[1][2] * filter_coef_z * dz * facteur_elem;
1953 bf_kk(i, j, 0) += f[2][2] * filter_coef_z * dz * facteur_elem;
1954 }
1955 else
1956 {
1957 bf_ii(i, j, 0) += f[0][0] * filter_coef_z;
1958 bf_ij(i, j, 0) += f[0][1] * filter_coef_z;
1959 bf_ik(i, j, 0) += f[0][2] * filter_coef_z;
1960 bf_jj(i, j, 0) += f[1][1] * filter_coef_z;
1961 bf_jk(i, j, 0) += f[1][2] * filter_coef_z;
1962 bf_kk(i, j, 0) += f[2][2] * filter_coef_z;
1963 }
1964 }
1965 }
1966 }
1967
1968 if (structural_uu)
1969 {
1970 bg_ii(i, j, 0) = 0.;
1971 bg_ij(i, j, 0) = 0.;
1972 bg_ik(i, j, 0) = 0.;
1973 bg_jj(i, j, 0) = 0.;
1974 bg_jk(i, j, 0) = 0.;
1975 bg_kk(i, j, 0) = 0.;
1976 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
1977 {
1978 const int kpg = kg + kp;
1979 if (!(kernel->is_at_wall_elem(kpg, nktot)))
1980 {
1981 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
1982 const double filter_coef_z = filter_kernel_z[kp+10];
1983 const double gxx_e = -structural_uu_xx(i,j,k+kp);
1984 const double gyy_e = -structural_uu_yy(i,j,k+kp);
1985 const double gzz_e = -structural_uu_zz(i,j,k+kp);
1986
1987 const double gxy_ij = -structural_uu_xy(i,j,k+kp);
1988 const double gxz_ik = -structural_uu_xz(i,j,k+kp);
1989 const double gyz_jk = -structural_uu_yz(i,j,k+kp);
1990
1991 const double gxy_ip1j = -structural_uu_xy(i+1,j,k+kp);
1992 const double gxz_ip1k = -structural_uu_xz(i+1,j,k+kp);
1993 const double gyz_jp1k = -structural_uu_yz(i,j+1,k+kp);
1994
1995 const double gxy_ijp1 = -structural_uu_xy(i,j+1,k+kp);
1996 const double gxz_ikp1 = kpg==(nktot-1) ? 0. : -structural_uu_xz(i,j,k+1+kp);
1997 const double gyz_jkp1 = kpg==(nktot-1) ? 0. : -structural_uu_yz(i,j,k+1+kp);
1998
1999 const double gxy_ip1jp1 = -structural_uu_xy(i+1,j+1,k+kp);
2000 const double gxz_ip1kp1 = kpg==(nktot-1) ? 0. : -structural_uu_xz(i+1,j,k+1+kp);
2001 const double gyz_jp1kp1 = kpg==(nktot-1) ? 0. : -structural_uu_yz(i,j+1,k+1+kp);
2002
2003 const double gxy_e = 0.25 * (gxy_ij + gxy_ip1j + gxy_ijp1 + gxy_ip1jp1);
2004 const double gxz_e = 0.25 * (gxz_ik + gxz_ip1k + gxz_ikp1 + gxz_ip1kp1);
2005 const double gyz_e = 0.25 * (gyz_jk + gyz_jp1k + gyz_jkp1 + gyz_jp1kp1);
2006
2007 if (ponderation_filter_kernel)
2008 {
2009 bg_ii(i, j, 0) += gxx_e * filter_coef_z * dz * facteur_elem;
2010 bg_ij(i, j, 0) += gxy_e * filter_coef_z * dz * facteur_elem;
2011 bg_ik(i, j, 0) += gxz_e * filter_coef_z * dz * facteur_elem;
2012 bg_jj(i, j, 0) += gyy_e * filter_coef_z * dz * facteur_elem;
2013 bg_jk(i, j, 0) += gyz_e * filter_coef_z * dz * facteur_elem;
2014 bg_kk(i, j, 0) += gzz_e * filter_coef_z * dz * facteur_elem;
2015 }
2016 else
2017 {
2018 bg_ii(i, j, 0) += gxx_e * filter_coef_z;
2019 bg_ij(i, j, 0) += gxy_e * filter_coef_z;
2020 bg_ik(i, j, 0) += gxz_e * filter_coef_z;
2021 bg_jj(i, j, 0) += gyy_e * filter_coef_z;
2022 bg_jk(i, j, 0) += gyz_e * filter_coef_z;
2023 bg_kk(i, j, 0) += gzz_e * filter_coef_z;
2024 }
2025 }
2026 }
2027 }
2028 }
2029 }
2030 for (int j = 0; j < nj; j++)
2031 {
2032 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
2033 {
2034 auu_ii(i, 0, 0) = 0.;
2035 auu_ij(i, 0, 0) = 0.;
2036 auu_ik(i, 0, 0) = 0.;
2037 auu_jj(i, 0, 0) = 0.;
2038 auu_jk(i, 0, 0) = 0.;
2039 auu_kk(i, 0, 0) = 0.;
2040 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
2041 {
2042 const double filter_coef_y = filter_kernel_y[jp+10];
2043 auu_ii(i, 0, 0) += buu_ii(i, j+jp, 0) * filter_coef_y;
2044 auu_ij(i, 0, 0) += buu_ij(i, j+jp, 0) * filter_coef_y;
2045 auu_ik(i, 0, 0) += buu_ik(i, j+jp, 0) * filter_coef_y;
2046 auu_jj(i, 0, 0) += buu_jj(i, j+jp, 0) * filter_coef_y;
2047 auu_jk(i, 0, 0) += buu_jk(i, j+jp, 0) * filter_coef_y;
2048 auu_kk(i, 0, 0) += buu_kk(i, j+jp, 0) * filter_coef_y;
2049 }
2050 if (turbulent_viscosity)
2051 {
2052 af_ii(i, 0, 0) = 0.;
2053 af_ij(i, 0, 0) = 0.;
2054 af_ik(i, 0, 0) = 0.;
2055 af_jj(i, 0, 0) = 0.;
2056 af_jk(i, 0, 0) = 0.;
2057 af_kk(i, 0, 0) = 0.;
2058 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
2059 {
2060 const double filter_coef_y = filter_kernel_y[jp+10];
2061 af_ii(i, 0, 0) += bf_ii(i, j+jp, 0) * filter_coef_y;
2062 af_ij(i, 0, 0) += bf_ij(i, j+jp, 0) * filter_coef_y;
2063 af_ik(i, 0, 0) += bf_ik(i, j+jp, 0) * filter_coef_y;
2064 af_jj(i, 0, 0) += bf_jj(i, j+jp, 0) * filter_coef_y;
2065 af_jk(i, 0, 0) += bf_jk(i, j+jp, 0) * filter_coef_y;
2066 af_kk(i, 0, 0) += bf_kk(i, j+jp, 0) * filter_coef_y;
2067 }
2068 }
2069 if (structural_uu)
2070 {
2071 ag_ii(i, 0, 0) = 0.;
2072 ag_ij(i, 0, 0) = 0.;
2073 ag_ik(i, 0, 0) = 0.;
2074 ag_jj(i, 0, 0) = 0.;
2075 ag_jk(i, 0, 0) = 0.;
2076 ag_kk(i, 0, 0) = 0.;
2077 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
2078 {
2079 const double filter_coef_y = filter_kernel_y[jp+10];
2080 ag_ii(i, 0, 0) += bg_ii(i, j+jp, 0) * filter_coef_y;
2081 ag_ij(i, 0, 0) += bg_ij(i, j+jp, 0) * filter_coef_y;
2082 ag_ik(i, 0, 0) += bg_ik(i, j+jp, 0) * filter_coef_y;
2083 ag_jj(i, 0, 0) += bg_jj(i, j+jp, 0) * filter_coef_y;
2084 ag_jk(i, 0, 0) += bg_jk(i, j+jp, 0) * filter_coef_y;
2085 ag_kk(i, 0, 0) += bg_kk(i, j+jp, 0) * filter_coef_y;
2086 }
2087 }
2088 }
2089
2090 for (int i = 0; i < ni; i++)
2091 {
2092 double ruu_ii = 0.;
2093 double ruu_ij = 0.;
2094 double ruu_ik = 0.;
2095 double ruu_jj = 0.;
2096 double ruu_jk = 0.;
2097 double ruu_kk = 0.;
2098 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
2099 {
2100 const double filter_coef_x = filter_kernel_x[ip+10];
2101 ruu_ii += auu_ii(i+ip, 0, 0) * filter_coef_x;
2102 ruu_ij += auu_ij(i+ip, 0, 0) * filter_coef_x;
2103 ruu_ik += auu_ik(i+ip, 0, 0) * filter_coef_x;
2104 ruu_jj += auu_jj(i+ip, 0, 0) * filter_coef_x;
2105 ruu_jk += auu_jk(i+ip, 0, 0) * filter_coef_x;
2106 ruu_kk += auu_kk(i+ip, 0, 0) * filter_coef_x;
2107 }
2108
2109 const double uf_i = vitesse_i_filtre(i,j,k);
2110 const double vf_j = vitesse_j_filtre(i,j,k);
2111 const double wf_k = vitesse_k_filtre(i,j,k);
2112
2113 const double uf_ip1 = vitesse_i_filtre(i+1,j,k);
2114 const double vf_jp1 = vitesse_j_filtre(i,j+1,k);
2115 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k_filtre(i,j,k+1);
2116
2117 const double ue = 0.5 * (uf_i + uf_ip1);
2118 const double ve = 0.5 * (vf_j + vf_jp1);
2119 const double we = 0.5 * (wf_k + wf_kp1);
2120
2121 const double l_ii = ruu_ii - ue*ue;
2122 const double l_ij = ruu_ij - ue*ve;
2123 const double l_ik = ruu_ik - ue*we;
2124 const double l_jj = ruu_jj - ve*ve;
2125 const double l_jk = ruu_jk - ve*we;
2126 const double l_kk = ruu_kk - we*we;
2127
2128 if (tensorial)
2129 {
2130 moy_lij_xx[kg] += l_ii;
2131 moy_lij_xy[kg] += l_ij;
2132 moy_lij_xz[kg] += l_ik;
2133 moy_lij_yy[kg] += l_jj;
2134 moy_lij_yz[kg] += l_jk;
2135 moy_lij_zz[kg] += l_kk;
2136 }
2137
2138 if (turbulent_viscosity)
2139 {
2140 double rf_ii = 0.;
2141 double rf_ij = 0.;
2142 double rf_ik = 0.;
2143 double rf_jj = 0.;
2144 double rf_jk = 0.;
2145 double rf_kk = 0.;
2146 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
2147 {
2148 const double filter_coef_x = filter_kernel_x[ip+10];
2149 rf_ii += af_ii(i+ip, 0, 0) * filter_coef_x;
2150 rf_ij += af_ij(i+ip, 0, 0) * filter_coef_x;
2151 rf_ik += af_ik(i+ip, 0, 0) * filter_coef_x;
2152 rf_jj += af_jj(i+ip, 0, 0) * filter_coef_x;
2153 rf_jk += af_jk(i+ip, 0, 0) * filter_coef_x;
2154 rf_kk += af_kk(i+ip, 0, 0) * filter_coef_x;
2155 }
2156
2157 if (!anisotropic)
2158 {
2159 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);
2160 }
2161 else
2162 {
2163 const double dx_filtre = facteur_delta_filtre_x*dx;
2164 const double dy_filtre = facteur_delta_filtre_y*dy;
2165 const double dz_filtre = delta_z_pour_delta_filtre[k];
2166 const double delta_m_filtre = kg==0 ? 0. : 0.5*(dz_filtre + delta_z_pour_delta_filtre[k-1]);
2167 const double delta_p_filtre = kg==(nktot-1) ? 0. : 0.5*(dz_filtre + delta_z_pour_delta_filtre[k+1]);
2168 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);
2169 }
2170
2171 m_ii = f_filtre[0][0] - rf_ii;
2172 m_ij = f_filtre[0][1] - rf_ij;
2173 m_ik = f_filtre[0][2] - rf_ik;
2174 m_jj = f_filtre[1][1] - rf_jj;
2175 m_jk = f_filtre[1][2] - rf_jk;
2176 m_kk = f_filtre[2][2] - rf_kk;
2177
2178 const double mijmij = m_ii * m_ii
2179 + m_ij * m_ij
2180 + m_ik * m_ik
2181 + m_ij * m_ij
2182 + m_jj * m_jj
2183 + m_jk * m_jk
2184 + m_ik * m_ik
2185 + m_jk * m_jk
2186 + m_kk * m_kk;
2187
2188 const double mijlij = m_ii * l_ii
2189 + m_ij * l_ij
2190 + m_ik * l_ik
2191 + m_ij * l_ij
2192 + m_jj * l_jj
2193 + m_jk * l_jk
2194 + m_ik * l_ik
2195 + m_jk * l_jk
2196 + m_kk * l_kk;
2197
2198 moy_mijmij[kg] += mijmij;
2199 moy_mijlij[kg] += mijlij;
2200
2201 if (tensorial)
2202 {
2203 moy_mij_xx[kg] += m_ii;
2204 moy_mij_xy[kg] += m_ij;
2205 moy_mij_xz[kg] += m_ik;
2206 moy_mij_yy[kg] += m_jj;
2207 moy_mij_yz[kg] += m_jk;
2208 moy_mij_zz[kg] += m_kk;
2209
2210 moy_mijmij_xx[kg] += m_ii * m_ii;
2211 moy_mijmij_xy[kg] += m_ij * m_ij;
2212 moy_mijmij_xz[kg] += m_ik * m_ik;
2213 moy_mijmij_yy[kg] += m_jj * m_jj;
2214 moy_mijmij_yz[kg] += m_jk * m_jk;
2215 moy_mijmij_zz[kg] += m_kk * m_kk;
2216
2217 moy_mijlij_xx[kg] += m_ii * l_ii;
2218 moy_mijlij_xy[kg] += m_ij * l_ij;
2219 moy_mijlij_xz[kg] += m_ik * l_ik;
2220 moy_mijlij_yy[kg] += m_jj * l_jj;
2221 moy_mijlij_yz[kg] += m_jk * l_jk;
2222 moy_mijlij_zz[kg] += m_kk * l_kk;
2223 }
2224 }
2225
2226 if (structural_uu)
2227 {
2228 double rg_ii = 0.;
2229 double rg_ij = 0.;
2230 double rg_ik = 0.;
2231 double rg_jj = 0.;
2232 double rg_jk = 0.;
2233 double rg_kk = 0.;
2234 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
2235 {
2236 const double filter_coef_x = filter_kernel_x[ip+10];
2237 rg_ii += ag_ii(i+ip, 0, 0) * filter_coef_x;
2238 rg_ij += ag_ij(i+ip, 0, 0) * filter_coef_x;
2239 rg_ik += ag_ik(i+ip, 0, 0) * filter_coef_x;
2240 rg_jj += ag_jj(i+ip, 0, 0) * filter_coef_x;
2241 rg_jk += ag_jk(i+ip, 0, 0) * filter_coef_x;
2242 rg_kk += ag_kk(i+ip, 0, 0) * filter_coef_x;
2243 }
2244
2245 const double gxx_e = -structural_uu_filtre_xx(i,j,k);
2246 const double gyy_e = -structural_uu_filtre_yy(i,j,k);
2247 const double gzz_e = -structural_uu_filtre_zz(i,j,k);
2248
2249 const double gxy_ij = -structural_uu_filtre_xy(i,j,k);
2250 const double gxz_ik = -structural_uu_filtre_xz(i,j,k);
2251 const double gyz_jk = -structural_uu_filtre_yz(i,j,k);
2252
2253 const double gxy_ip1j = -structural_uu_filtre_xy(i+1,j,k);
2254 const double gxz_ip1k = -structural_uu_filtre_xz(i+1,j,k);
2255 const double gyz_jp1k = -structural_uu_filtre_yz(i,j+1,k);
2256
2257 const double gxy_ijp1 = -structural_uu_filtre_xy(i,j+1,k);
2258 const double gxz_ikp1 = kg==(nktot-1) ? 0. : -structural_uu_filtre_xz(i,j,k+1);
2259 const double gyz_jkp1 = kg==(nktot-1) ? 0. : -structural_uu_filtre_yz(i,j,k+1);
2260
2261 const double gxy_ip1jp1 = -structural_uu_filtre_xy(i+1,j+1,k);
2262 const double gxz_ip1kp1 = kg==(nktot-1) ? 0. : -structural_uu_filtre_xz(i+1,j,k+1);
2263 const double gyz_jp1kp1 = kg==(nktot-1) ? 0. : -structural_uu_filtre_yz(i,j+1,k+1);
2264
2265 const double gxy_e = 0.25 * (gxy_ij + gxy_ip1j + gxy_ijp1 + gxy_ip1jp1);
2266 const double gxz_e = 0.25 * (gxz_ik + gxz_ip1k + gxz_ikp1 + gxz_ip1kp1);
2267 const double gyz_e = 0.25 * (gyz_jk + gyz_jp1k + gyz_jkp1 + gyz_jp1kp1);
2268
2269 h_ii = gxx_e - rg_ii;
2270 h_ij = gxy_e - rg_ij;
2271 h_ik = gxz_e - rg_ik;
2272 h_jj = gyy_e - rg_jj;
2273 h_jk = gyz_e - rg_jk;
2274 h_kk = gzz_e - rg_kk;
2275
2276 const double hijhij = h_ii * h_ii
2277 + h_ij * h_ij
2278 + h_ik * h_ik
2279 + h_ij * h_ij
2280 + h_jj * h_jj
2281 + h_jk * h_jk
2282 + h_ik * h_ik
2283 + h_jk * h_jk
2284 + h_kk * h_kk;
2285
2286 const double hijlij = h_ii * l_ii
2287 + h_ij * l_ij
2288 + h_ik * l_ik
2289 + h_ij * l_ij
2290 + h_jj * l_jj
2291 + h_jk * l_jk
2292 + h_ik * l_ik
2293 + h_jk * l_jk
2294 + h_kk * l_kk;
2295
2296 moy_hijhij[kg] += hijhij;
2297 moy_hijlij[kg] += hijlij;
2298
2299 if (tensorial)
2300 {
2301 moy_hij_xx[kg] += h_ii;
2302 moy_hij_xy[kg] += h_ij;
2303 moy_hij_xz[kg] += h_ik;
2304 moy_hij_yy[kg] += h_jj;
2305 moy_hij_yz[kg] += h_jk;
2306 moy_hij_zz[kg] += h_kk;
2307
2308 moy_hijhij_xx[kg] += h_ii * h_ii;
2309 moy_hijhij_xy[kg] += h_ij * h_ij;
2310 moy_hijhij_xz[kg] += h_ik * h_ik;
2311 moy_hijhij_yy[kg] += h_jj * h_jj;
2312 moy_hijhij_yz[kg] += h_jk * h_jk;
2313 moy_hijhij_zz[kg] += h_kk * h_kk;
2314
2315 moy_hijlij_xx[kg] += h_ii * l_ii;
2316 moy_hijlij_xy[kg] += h_ij * l_ij;
2317 moy_hijlij_xz[kg] += h_ik * l_ik;
2318 moy_hijlij_yy[kg] += h_jj * l_jj;
2319 moy_hijlij_yz[kg] += h_jk * l_jk;
2320 moy_hijlij_zz[kg] += h_kk * l_kk;
2321 }
2322
2323 if (turbulent_viscosity)
2324 {
2325 const double mijhij = m_ii * h_ii
2326 + m_ij * h_ij
2327 + m_ik * h_ik
2328 + m_ij * h_ij
2329 + m_jj * h_jj
2330 + m_jk * h_jk
2331 + m_ik * h_ik
2332 + m_jk * h_jk
2333 + m_kk * h_kk;
2334
2335 moy_mijhij[kg] += mijhij;
2336
2337 if (tensorial)
2338 {
2339 moy_mijhij_xx[kg] += m_ii * h_ii;
2340 moy_mijhij_xy[kg] += m_ij * h_ij;
2341 moy_mijhij_xz[kg] += m_ik * h_ik;
2342 moy_mijhij_yy[kg] += m_jj * h_jj;
2343 moy_mijhij_yz[kg] += m_jk * h_jk;
2344 moy_mijhij_zz[kg] += m_kk * h_kk;
2345 }
2346 }
2347 }
2348 }
2349 }
2350 }
2351}
2352
2353void calculer_constante_direct(const bool global,
2354 const bool clipping,
2355 const Nom& description,
2356 const ArrOfDouble& moy_mij_0,
2357 const ArrOfDouble& moy_lij_0,
2358 const bool flag_mixte,
2359 const ArrOfDouble& moy_hij_0,
2360 const IJK_Field_vector3_double& velocity,
2361 const ArrOfDouble_with_ghost& delta_z,
2362 ArrOfDouble_with_ghost& constante_modele)
2363{
2364 const IJK_Field_double& vitesse_k = velocity[2];
2365
2366 // Copie des tableaux
2367 ArrOfDouble moy_mij = moy_mij_0;
2368 ArrOfDouble moy_lij = moy_lij_0;
2369 ArrOfDouble moy_hij = moy_hij_0;
2370
2371 const int nk = vitesse_k.nk();
2372 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
2373
2374 Cout <<
2375 "Dynamic correction of constant [ " << description <<
2376 " ] type= direct global= " << (int)global <<
2377 " clipping= " << (int)clipping <<
2378 " mixte= " << (int)flag_mixte << " :"
2379 << finl;
2380
2381 if (global)
2382 {
2383 double moy_mij_global = 0;
2384 double moy_lij_global = 0;
2385 double moy_hij_global = 0;
2386 for (int k = 0; k < nk; k++)
2387 {
2388 const int kg = k + offset;
2389
2390 moy_mij_global += moy_mij[kg]*delta_z[k];
2391 moy_lij_global += moy_lij[kg]*delta_z[k];
2392 if (flag_mixte)
2393 {
2394 moy_hij_global += moy_hij[kg]*delta_z[k];
2395 }
2396 }
2397
2398 ArrOfDouble tmp(3);
2399 tmp[0] = moy_mij_global;
2400 tmp[1] = moy_lij_global;
2401 tmp[2] = moy_hij_global;
2403
2404 double c_global = (tmp[0]==0.) ? 1. : (tmp[1] - tmp[2])/tmp[0];
2405 if (clipping)
2406 {
2407 c_global = max(0., c_global);
2408 }
2409 Cout << "(global) constante_modele= " << c_global << finl;
2410
2411 for (int k = 0; k < nk; k++)
2412 {
2413 constante_modele[k] = c_global;
2414 }
2415 }
2416 else
2417 {
2420 if (flag_mixte)
2421 {
2423 }
2424
2425 for (int k = 0; k < nk; k++)
2426 {
2427 const int kg = k + offset;
2428
2429 if (flag_mixte)
2430 {
2431 constante_modele[k] = (moy_mij[kg]==0.) ? 1. : (moy_lij[kg] - moy_hij[kg])/moy_mij[kg];
2432 }
2433 else
2434 {
2435 constante_modele[k] = (moy_mij[kg]==0.) ? 1. : moy_lij[kg]/moy_mij[kg];
2436 }
2437 if (clipping)
2438 {
2439 constante_modele[k] = max(0., constante_modele[k]);
2440 }
2441 Cout << "k= " << kg << " constante_modele= " << constante_modele[k] << finl;
2442 }
2443 }
2444}
2445
2446void calculer_constante_lilly(const bool global,
2447 const bool clipping,
2448 const Nom& description,
2449 const ArrOfDouble& moy_mijmij_0,
2450 const ArrOfDouble& moy_mijlij_0,
2451 const bool flag_mixte,
2452 const ArrOfDouble& moy_mijhij_0,
2453 const IJK_Field_vector3_double& velocity,
2454 const ArrOfDouble_with_ghost& delta_z,
2455 ArrOfDouble_with_ghost& constante_modele)
2456{
2457 const IJK_Field_double& vitesse_k = velocity[2];
2458
2459 // Copie des tableaux
2460 ArrOfDouble moy_mijmij = moy_mijmij_0;
2461 ArrOfDouble moy_mijlij = moy_mijlij_0;
2462 ArrOfDouble moy_mijhij = moy_mijhij_0;
2463
2464 const int nk = vitesse_k.nk();
2465 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
2466
2467 Cout << "Dynamic correction of constant [ " << description << " ] type= lilly global= " << (int)global << " clipping= " << (int)clipping << " mixte= " << (int)flag_mixte << " :" << finl;
2468
2469 if (global)
2470 {
2471 double moy_mijmij_global = 0;
2472 double moy_mijlij_global = 0;
2473 double moy_mijhij_global = 0;
2474 for (int k = 0; k < nk; k++)
2475 {
2476 const int kg = k + offset;
2477
2478 moy_mijmij_global += moy_mijmij[kg]*delta_z[k];
2479 moy_mijlij_global += moy_mijlij[kg]*delta_z[k];
2480 if (flag_mixte)
2481 {
2482 moy_mijhij_global += moy_mijhij[kg]*delta_z[k];
2483 }
2484 }
2485
2486 ArrOfDouble tmp(3);
2487 tmp[0] = moy_mijmij_global;
2488 tmp[1] = moy_mijlij_global;
2489 tmp[2] = moy_mijhij_global;
2491
2492 double c_global = (tmp[0]==0.) ? 1. : (tmp[1] - tmp[2])/tmp[0];
2493 if (clipping)
2494 {
2495 c_global = max(0., c_global);
2496 }
2497 Cout << "(global) constante_modele= " << c_global << finl;
2498
2499 for (int k = 0; k < nk; k++)
2500 {
2501 constante_modele[k] = c_global;
2502 }
2503 }
2504 else
2505 {
2508 if (flag_mixte)
2509 {
2511 }
2512
2513 for (int k = 0; k < nk; k++)
2514 {
2515 const int kg = k + offset;
2516
2517 if (flag_mixte)
2518 {
2519 constante_modele[k] = (moy_mijmij[kg]==0.) ? 1. : (moy_mijlij[kg] - moy_mijhij[kg])/moy_mijmij[kg];
2520 }
2521 else
2522 {
2523 constante_modele[k] = (moy_mijmij[kg]==0.) ? 1. : moy_mijlij[kg]/moy_mijmij[kg];
2524 }
2525 if (clipping)
2526 {
2527 constante_modele[k] = max(0., constante_modele[k]);
2528 }
2529 Cout << "k= " << kg << " constante_modele= " << constante_modele[k] << finl;
2530 }
2531 }
2532}
2533
2534void calculer_constante_twoparameters(const bool global,
2535 const bool clipping,
2536 const Nom& description,
2537 const ArrOfDouble& moy_mijmij_0,
2538 const ArrOfDouble& moy_hijhij_0,
2539 const ArrOfDouble& moy_mijlij_0,
2540 const ArrOfDouble& moy_hijlij_0,
2541 const ArrOfDouble& moy_mijhij_0,
2542 const IJK_Field_vector3_double& velocity,
2543 const ArrOfDouble_with_ghost& delta_z,
2544 ArrOfDouble_with_ghost& constante_modele)
2545{
2546 const IJK_Field_double& vitesse_k = velocity[2];
2547
2548 // Copie des tableaux
2549 ArrOfDouble moy_mijmij = moy_mijmij_0;
2550 ArrOfDouble moy_hijhij = moy_hijhij_0;
2551 ArrOfDouble moy_mijlij = moy_mijlij_0;
2552 ArrOfDouble moy_hijlij = moy_hijlij_0;
2553 ArrOfDouble moy_mijhij = moy_mijhij_0;
2554
2555 const int nk = vitesse_k.nk();
2556 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
2557
2558 Cout << "Dynamic correction of constant [ " << description << " ] type= twoparameters global= " << (int)global << " clipping= " << (int)clipping << " :" << finl;
2559
2560 if (global)
2561 {
2562 double moy_mijmij_global = 0;
2563 double moy_hijhij_global = 0;
2564 double moy_mijlij_global = 0;
2565 double moy_hijlij_global = 0;
2566 double moy_mijhij_global = 0;
2567 for (int k = 0; k < nk; k++)
2568 {
2569 const int kg = k + offset;
2570
2571 moy_mijmij_global += moy_mijmij[kg]*delta_z[k];
2572 moy_hijhij_global += moy_hijhij[kg]*delta_z[k];
2573 moy_mijlij_global += moy_mijlij[kg]*delta_z[k];
2574 moy_hijlij_global += moy_hijlij[kg]*delta_z[k];
2575 moy_mijhij_global += moy_mijhij[kg]*delta_z[k];
2576 }
2577
2578 ArrOfDouble tmp(5);
2579 tmp[0] = moy_mijmij_global;
2580 tmp[1] = moy_hijhij_global;
2581 tmp[2] = moy_mijlij_global;
2582 tmp[3] = moy_hijlij_global;
2583 tmp[4] = moy_mijhij_global;
2585
2586 double c_global = ((tmp[0]*tmp[1] - tmp[4]*tmp[4])==0.) ? 1. :
2587 (tmp[2]*tmp[1] - tmp[3]*tmp[4])/(tmp[0]*tmp[1] - tmp[4]*tmp[4]);
2588 if (clipping)
2589 {
2590 c_global = max(0., c_global);
2591 }
2592 Cout << "(global) constante_modele= " << c_global << finl;
2593
2594 for (int k = 0; k < nk; k++)
2595 {
2596 constante_modele[k] = c_global;
2597 }
2598 }
2599 else
2600 {
2606
2607 for (int k = 0; k < nk; k++)
2608 {
2609 const int kg = k + offset;
2610
2611 constante_modele[k] = ((moy_mijmij[kg]*moy_hijhij[kg] - moy_mijhij[kg]*moy_mijhij[kg])==0.) ? 1. :
2612 (moy_mijlij[kg]*moy_hijhij[kg] - moy_hijlij[kg]*moy_mijhij[kg])/(moy_mijmij[kg]*moy_hijhij[kg] - moy_mijhij[kg]*moy_mijhij[kg]);
2613 if (clipping)
2614 {
2615 constante_modele[k] = max(0., constante_modele[k]);
2616 }
2617 Cout << "k= " << kg << " constante_modele= " << constante_modele[k] << finl;
2618 }
2619 }
2620}
2621
2622void calculer_constante_twonoerror(const bool global,
2623 const bool clipping,
2624 const Nom& description,
2625 const ArrOfDouble& moy_lij_0,
2626 const ArrOfDouble& moy_mij_0,
2627 const ArrOfDouble& moy_hij_0,
2628 const ArrOfDouble& moy_mijmij_0,
2629 const ArrOfDouble& moy_hijhij_0,
2630 const ArrOfDouble& moy_mijlij_0,
2631 const ArrOfDouble& moy_hijlij_0,
2632 const ArrOfDouble& moy_mijhij_0,
2633 const IJK_Field_vector3_double& velocity,
2634 const ArrOfDouble_with_ghost& delta_z,
2635 ArrOfDouble_with_ghost& constante_modele)
2636{
2637 const IJK_Field_double& vitesse_k = velocity[2];
2638
2639 // Copie des tableaux
2640 ArrOfDouble moy_lij = moy_lij_0;
2641 ArrOfDouble moy_mij = moy_mij_0;
2642 ArrOfDouble moy_hij = moy_hij_0;
2643 ArrOfDouble moy_mijmij = moy_mijmij_0;
2644 ArrOfDouble moy_hijhij = moy_hijhij_0;
2645 ArrOfDouble moy_mijlij = moy_mijlij_0;
2646 ArrOfDouble moy_hijlij = moy_hijlij_0;
2647 ArrOfDouble moy_mijhij = moy_mijhij_0;
2648
2649 const int nk = vitesse_k.nk();
2650 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
2651
2652 Cout << "Dynamic correction of constant [ " << description << " ] type= twonoerror global= " << (int)global << " clipping= " << (int)clipping << " :" << finl;
2653
2654 if (global)
2655 {
2656 double moy_lij_global = 0;
2657 double moy_mij_global = 0;
2658 double moy_hij_global = 0;
2659 double moy_mijmij_global = 0;
2660 double moy_hijhij_global = 0;
2661 double moy_mijlij_global = 0;
2662 double moy_hijlij_global = 0;
2663 double moy_mijhij_global = 0;
2664 for (int k = 0; k < nk; k++)
2665 {
2666 const int kg = k + offset;
2667
2668 moy_lij_global += moy_lij[kg]*delta_z[k];
2669 moy_mij_global += moy_mij[kg]*delta_z[k];
2670 moy_hij_global += moy_hij[kg]*delta_z[k];
2671 moy_mijmij_global += moy_mijmij[kg]*delta_z[k];
2672 moy_hijhij_global += moy_hijhij[kg]*delta_z[k];
2673 moy_mijlij_global += moy_mijlij[kg]*delta_z[k];
2674 moy_hijlij_global += moy_hijlij[kg]*delta_z[k];
2675 moy_mijhij_global += moy_mijhij[kg]*delta_z[k];
2676 }
2677
2678 ArrOfDouble tmp(8);
2679 tmp[0] = moy_lij_global;
2680 tmp[1] = moy_mij_global;
2681 tmp[2] = moy_hij_global;
2682 tmp[3] = moy_mijmij_global;
2683 tmp[4] = moy_hijhij_global;
2684 tmp[5] = moy_mijlij_global;
2685 tmp[6] = moy_hijlij_global;
2686 tmp[7] = moy_mijhij_global;
2688
2689 double c_global = ((tmp[2]*tmp[3] - tmp[1]*tmp[7] + tmp[2]*tmp[7] - tmp[1]*tmp[4])==0.) ? 1. :
2690 (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]);
2691 if (clipping)
2692 {
2693 c_global = max(0., c_global);
2694 }
2695 Cout << "(global) constante_modele= " << c_global << finl;
2696
2697 for (int k = 0; k < nk; k++)
2698 {
2699 constante_modele[k] = c_global;
2700 }
2701 }
2702 else
2703 {
2712
2713 for (int k = 0; k < nk; k++)
2714 {
2715 const int kg = k + offset;
2716
2717 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. :
2718 (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]);
2719 if (clipping)
2720 {
2721 constante_modele[k] = max(0., constante_modele[k]);
2722 }
2723 Cout << "k= " << kg << " constante_modele= " << constante_modele[k] << finl;
2724 }
2725 }
2726}
2727
2728void multiplier_par_constante(const bool face,
2729 ArrOfDouble_with_ghost& constante_modele,
2730 const IJK_Field_vector3_double& velocity,
2731 IJK_Field_double& turbulent_mu)
2732{
2733 const IJK_Field_double& vitesse_k = velocity[2];
2734 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
2735
2736 const int ni = vitesse_k.ni();
2737 const int nj = vitesse_k.nj();
2738 const int nk = vitesse_k.nk();
2739
2740 if (face)
2741 {
2742 for (int k = 0; k < nk; k++)
2743 {
2744 for (int j = 0; j < nj; j++)
2745 {
2746 for (int i = 0; i < ni; i++)
2747 {
2748 const int kg = k + offset;
2749 const double constante_face = kg==0 ? 0. : 0.5*(constante_modele[k] + constante_modele[k-1]);
2750 turbulent_mu(i,j,k) = constante_face * turbulent_mu(i,j,k);
2751 }
2752 }
2753 }
2754 }
2755 else
2756 {
2757 for (int k = 0; k < nk; k++)
2758 {
2759 for (int j = 0; j < nj; j++)
2760 {
2761 for (int i = 0; i < ni; i++)
2762 {
2763 turbulent_mu(i,j,k) = constante_modele[k] * turbulent_mu(i,j,k);
2764 }
2765 }
2766 }
2767 }
2768}
2769
2770bool calculer_constante_modele(const Nom& turbulent_viscosity_dynamic_type,
2771 const Nom& description,
2772 const ArrOfDouble& moy_lij,
2773 const ArrOfDouble& moy_mij,
2774 const ArrOfDouble& moy_hij,
2775 const ArrOfDouble& moy_mijmij,
2776 const ArrOfDouble& moy_hijhij,
2777 const ArrOfDouble& moy_mijlij,
2778 const ArrOfDouble& moy_hijlij,
2779 const ArrOfDouble& moy_mijhij,
2780 const IJK_Field_vector3_double& velocity,
2781 const ArrOfDouble_with_ghost& delta_z,
2782 ArrOfDouble_with_ghost& constante_modele)
2783{
2784 bool mot_cle_reconnu = 0;
2785
2786 const bool clipping = turbulent_viscosity_dynamic_type.finit_par("clipping");
2787 Nom dynamic_type = clipping ? turbulent_viscosity_dynamic_type.getPrefix("clipping") : turbulent_viscosity_dynamic_type;
2788
2789 const bool global = dynamic_type.finit_par("global");
2790 dynamic_type = global ? dynamic_type.getPrefix("global") : dynamic_type;
2791
2792 if ( dynamic_type == Nom("direct")
2793 || dynamic_type == Nom("directmixte") )
2794 {
2795 mot_cle_reconnu = 1;
2796 const bool mixte = ( dynamic_type == Nom("directmixte") );
2797
2798 calculer_constante_direct(global, clipping,
2799 description,
2800 moy_mij, moy_lij,
2801 mixte, moy_hij,
2802 velocity, delta_z,
2803 constante_modele);
2804 }
2805 else if ( dynamic_type == Nom("lilly")
2806 || dynamic_type == Nom("lillymixte") )
2807 {
2808 mot_cle_reconnu = 1;
2809 const bool mixte = ( dynamic_type == Nom("lillymixte") );
2810
2811 calculer_constante_lilly(global, clipping,
2812 description,
2813 moy_mijmij, moy_mijlij,
2814 mixte, moy_mijhij,
2815 velocity, delta_z,
2816 constante_modele);
2817 }
2818 else if ( dynamic_type == Nom("twoparameters") )
2819 {
2820 mot_cle_reconnu = 1;
2821 calculer_constante_twoparameters(global, clipping,
2822 description,
2823 moy_mijmij, moy_hijhij,
2824 moy_mijlij, moy_hijlij,
2825 moy_mijhij,
2826 velocity, delta_z,
2827 constante_modele);
2828 }
2829 else if ( dynamic_type == Nom("twonoerror") )
2830 {
2831 mot_cle_reconnu = 1;
2832 calculer_constante_twonoerror(global, clipping,
2833 description,
2834 moy_lij, moy_mij, moy_hij,
2835 moy_mijmij, moy_hijhij,
2836 moy_mijlij, moy_hijlij,
2837 moy_mijhij,
2838 velocity, delta_z,
2839 constante_modele);
2840 }
2841 return mot_cle_reconnu;
2842}
2843
2844template<class T>
2845void calculer_ml_dynamic_uscalar_vector(const bool anisotropic,
2846 const bool vectorial,
2847 const IJK_Field_vector3_double& velocity,
2848 const IJK_Field_vector3_double& velocity_filtre,
2849 const IJK_Field_double& champ_scalar,
2850 const IJK_Field_double& champ_scalar_filtre,
2851 double scalar_kmin, double scalar_kmax,
2852 const int turbulent_viscosity,
2853 const IJK_Field_double& turbulent_mu_x,
2854 const IJK_Field_double& turbulent_mu_y,
2855 const IJK_Field_double& turbulent_mu_z,
2856 const IJK_Field_double& turbulent_mu_filtre_x,
2857 const IJK_Field_double& turbulent_mu_filtre_y,
2858 const IJK_Field_double& turbulent_mu_filtre_z,
2859 const int structural_uscalar,
2860 const IJK_Field_vector3_double& structural_uscalar_vector,
2861 const IJK_Field_vector3_double& structural_uscalar_filtre_vector,
2862 const ArrOfDouble_with_ghost& delta_z,
2863 const double facteur_delta_x,
2864 const double facteur_delta_y,
2865 const ArrOfDouble_with_ghost& delta_z_pour_delta,
2866 const double facteur_delta_filtre_x,
2867 const double facteur_delta_filtre_y,
2868 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
2869 T& kernel,
2873{
2874 const IJK_Field_double& vitesse_i = velocity[0];
2875 const IJK_Field_double& vitesse_j = velocity[1];
2876 const IJK_Field_double& vitesse_k = velocity[2];
2877
2878 const IJK_Field_double& vitesse_i_filtre = velocity_filtre[0];
2879 const IJK_Field_double& vitesse_j_filtre = velocity_filtre[1];
2880 const IJK_Field_double& vitesse_k_filtre = velocity_filtre[2];
2881
2882 const IJK_Field_double& structural_uscalar_x = structural_uscalar_vector[0];
2883 const IJK_Field_double& structural_uscalar_y = structural_uscalar_vector[1];
2884 const IJK_Field_double& structural_uscalar_z = structural_uscalar_vector[2];
2885
2886 const IJK_Field_double& structural_uscalar_filtre_x = structural_uscalar_filtre_vector[0];
2887 const IJK_Field_double& structural_uscalar_filtre_y = structural_uscalar_filtre_vector[1];
2888 const IJK_Field_double& structural_uscalar_filtre_z = structural_uscalar_filtre_vector[2];
2889
2890 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
2891 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
2892 const double dx_pour_delta = facteur_delta_x*dx;
2893 const double dy_pour_delta = facteur_delta_y*dy;
2894
2895 const int ni = vitesse_k.ni();
2896 const int nj = vitesse_k.nj();
2897 const int nk = vitesse_k.nk();
2898
2899 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
2900 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
2901
2902 IJK_Field_local_double& bf_i = tmp_b[0];
2903 IJK_Field_local_double& bf_j = tmp_b[1];
2904 IJK_Field_local_double& bf_k = tmp_b[2];
2905 IJK_Field_local_double& bus_i = tmp_b[3];
2906 IJK_Field_local_double& bus_j = tmp_b[4];
2907 IJK_Field_local_double& bus_k = tmp_b[5];
2908 IJK_Field_local_double& bg_i = tmp_b[6];
2909 IJK_Field_local_double& bg_j = tmp_b[7];
2910 IJK_Field_local_double& bg_k = tmp_b[8];
2911
2912 IJK_Field_local_double& af_i = tmp_a[0];
2913 IJK_Field_local_double& af_j = tmp_a[1];
2914 IJK_Field_local_double& af_k = tmp_a[2];
2915 IJK_Field_local_double& aus_i = tmp_a[3];
2916 IJK_Field_local_double& aus_j = tmp_a[4];
2917 IJK_Field_local_double& aus_k = tmp_a[5];
2918 IJK_Field_local_double& ag_i = tmp_a[6];
2919 IJK_Field_local_double& ag_j = tmp_a[7];
2920 IJK_Field_local_double& ag_k = tmp_a[8];
2921
2922 ArrOfDouble& moy_li_x = ml[0][0];
2923 ArrOfDouble& moy_li_y = ml[0][1];
2924 ArrOfDouble& moy_li_z = ml[0][2];
2925
2926 ArrOfDouble& moy_mi_x = ml[1][0];
2927 ArrOfDouble& moy_mi_y = ml[1][1];
2928 ArrOfDouble& moy_mi_z = ml[1][2];
2929
2930 ArrOfDouble& moy_hi_x = ml[2][0];
2931 ArrOfDouble& moy_hi_y = ml[2][1];
2932 ArrOfDouble& moy_hi_z = ml[2][2];
2933
2934 ArrOfDouble& moy_mimi_x = ml[3][0];
2935 ArrOfDouble& moy_mimi_y = ml[3][1];
2936 ArrOfDouble& moy_mimi_z = ml[3][2];
2937 ArrOfDouble& moy_mimi = ml[3][6];
2938
2939 ArrOfDouble& moy_hihi_x = ml[4][0];
2940 ArrOfDouble& moy_hihi_y = ml[4][1];
2941 ArrOfDouble& moy_hihi_z = ml[4][2];
2942 ArrOfDouble& moy_hihi = ml[4][6];
2943
2944 ArrOfDouble& moy_mili_x = ml[5][0];
2945 ArrOfDouble& moy_mili_y = ml[5][1];
2946 ArrOfDouble& moy_mili_z = ml[5][2];
2947 ArrOfDouble& moy_mili = ml[5][6];
2948
2949 ArrOfDouble& moy_hili_x = ml[6][0];
2950 ArrOfDouble& moy_hili_y = ml[6][1];
2951 ArrOfDouble& moy_hili_z = ml[6][2];
2952 ArrOfDouble& moy_hili = ml[6][6];
2953
2954 ArrOfDouble& moy_mihi_x = ml[7][0];
2955 ArrOfDouble& moy_mihi_y = ml[7][1];
2956 ArrOfDouble& moy_mihi_z = ml[7][2];
2957 ArrOfDouble& moy_mihi = ml[7][6];
2958
2959 double m_i = 0.;
2960 double m_j = 0.;
2961 double m_k = 0.;
2962
2963 double h_i = 0.;
2964 double h_j = 0.;
2965 double h_k = 0.;
2966
2968 FixedVector<double, 3> f_filtre;
2969
2970 const int ghost_size_filter = kernel->ghost_size();
2971 const int size_uniform = kernel->size_uniform();
2972 const int shift_uniform = kernel->shift_uniform();
2973 for (int k = 0; k < nk; k++)
2974 {
2975 const int kg = k + offset;
2976
2977 if (vectorial)
2978 {
2979 moy_li_x[kg] = 0;
2980 moy_li_y[kg] = 0;
2981 moy_li_z[kg] = 0;
2982
2983 moy_mi_x[kg] = 0;
2984 moy_mi_y[kg] = 0;
2985 moy_mi_z[kg] = 0;
2986
2987 moy_hi_x[kg] = 0;
2988 moy_hi_y[kg] = 0;
2989 moy_hi_z[kg] = 0;
2990
2991 moy_mimi_x[kg] = 0;
2992 moy_mimi_y[kg] = 0;
2993 moy_mimi_z[kg] = 0;
2994
2995 moy_hihi_x[kg] = 0;
2996 moy_hihi_y[kg] = 0;
2997 moy_hihi_z[kg] = 0;
2998
2999 moy_mili_x[kg] = 0;
3000 moy_mili_y[kg] = 0;
3001 moy_mili_z[kg] = 0;
3002
3003 moy_hili_x[kg] = 0;
3004 moy_hili_y[kg] = 0;
3005 moy_hili_z[kg] = 0;
3006
3007 moy_mihi_x[kg] = 0;
3008 moy_mihi_y[kg] = 0;
3009 moy_mihi_z[kg] = 0;
3010 }
3011
3012 moy_mimi[kg] = 0;
3013 moy_hihi[kg] = 0;
3014 moy_mili[kg] = 0;
3015 moy_hili[kg] = 0;
3016 moy_mihi[kg] = 0;
3017
3018 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
3019 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
3020
3021 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
3022 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
3023 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
3024 const int size_k_elem = kernel->size_k_elem(kg, nktot);
3025 const int shift_k_elem = kernel->shift_k_elem(kg);
3026 const bool ponderation_filter_kernel = kernel->ponderation();
3027 const bool normalisation_filter_kernel = kernel->normalisation();
3028
3029 double facteur_elem = 0.;
3030 if (ponderation_filter_kernel)
3031 {
3032 if (normalisation_filter_kernel)
3033 {
3034 double longueur_elem = 0.;
3035 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
3036 {
3037 const int kpg = kg + kp;
3038 if (kpg<-1 || kpg>nktot)
3039 {
3040 Cerr << "This should not happen." << finl;
3041 Process::exit();
3042 }
3043 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
3044 const double filter_coef_z = filter_kernel_z[kp+10];
3045 longueur_elem += filter_coef_z * dz;
3046 }
3047 facteur_elem = 1./longueur_elem;
3048 }
3049 else
3050 {
3051 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
3052 }
3053 }
3054
3055 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
3056 {
3057 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
3058 {
3059 bus_i(i, j, 0) = 0.;
3060 bus_j(i, j, 0) = 0.;
3061 bus_k(i, j, 0) = 0.;
3062 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
3063 {
3064 const int kpg = kg + kp;
3065 if (!(kernel->is_at_wall_elem(kpg, nktot)))
3066 {
3067 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
3068 const double filter_coef_z = filter_kernel_z[kp+10];
3069 const double scalar = champ_scalar(i,j,k+kp);
3070
3071 const double uf_i = vitesse_i(i,j,k+kp);
3072 const double vf_j = vitesse_j(i,j,k+kp);
3073 const double wf_k = vitesse_k(i,j,k+kp);
3074
3075 const double uf_ip1 = vitesse_i(i+1,j,k+kp);
3076 const double vf_jp1 = vitesse_j(i,j+1,k+kp);
3077 const double wf_kp1 = kpg==(nktot-1) ? 0. : vitesse_k(i,j,k+1+kp);
3078
3079 const double ue = 0.5 * (uf_i + uf_ip1);
3080 const double ve = 0.5 * (vf_j + vf_jp1);
3081 const double we = 0.5 * (wf_k + wf_kp1);
3082
3083 if (ponderation_filter_kernel)
3084 {
3085 bus_i(i, j, 0) += ue*scalar * filter_coef_z * dz * facteur_elem;
3086 bus_j(i, j, 0) += ve*scalar * filter_coef_z * dz * facteur_elem;
3087 bus_k(i, j, 0) += we*scalar * filter_coef_z * dz * facteur_elem;
3088 }
3089 else
3090 {
3091 bus_i(i, j, 0) += ue*scalar * filter_coef_z;
3092 bus_j(i, j, 0) += ve*scalar * filter_coef_z;
3093 bus_k(i, j, 0) += we*scalar * filter_coef_z;
3094 }
3095 }
3096 }
3097
3098 if (turbulent_viscosity)
3099 {
3100 bf_i(i, j, 0) = 0.;
3101 bf_j(i, j, 0) = 0.;
3102 bf_k(i, j, 0) = 0.;
3103 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
3104 {
3105 const int kpg = kg + kp;
3106 if (!(kernel->is_at_wall_elem(kpg, nktot)))
3107 {
3108 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
3109 const double filter_coef_z = filter_kernel_z[kp+10];
3110 if (!anisotropic)
3111 {
3112 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);
3113 }
3114 else
3115 {
3116 const double dz_pour_delta = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z_pour_delta[k+kp];
3117 const double dz_m1_pour_delta = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1+kp];
3118 const double dz_p1_pour_delta = (kpg+1<0 || kpg+1>(nktot-1)) ? 0. : delta_z_pour_delta[k+1+kp];
3119 const double delta_m_pour_delta = (kpg-1<0 || kpg>(nktot-1)) ? 0. : 0.5*(dz_pour_delta + dz_m1_pour_delta);
3120 const double delta_p_pour_delta = (kpg<0 || kpg+1>(nktot-1)) ? 0. : 0.5*(dz_pour_delta + dz_p1_pour_delta);
3121 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);
3122 }
3123
3124 if (ponderation_filter_kernel)
3125 {
3126 bf_i(i, j, 0) += f[0] * filter_coef_z * dz * facteur_elem;
3127 bf_j(i, j, 0) += f[1] * filter_coef_z * dz * facteur_elem;
3128 bf_k(i, j, 0) += f[2] * filter_coef_z * dz * facteur_elem;
3129 }
3130 else
3131 {
3132 bf_i(i, j, 0) += f[0] * filter_coef_z;
3133 bf_j(i, j, 0) += f[1] * filter_coef_z;
3134 bf_k(i, j, 0) += f[2] * filter_coef_z;
3135 }
3136 }
3137 }
3138 }
3139
3140 if (structural_uscalar)
3141 {
3142 bg_i(i, j, 0) = 0.;
3143 bg_j(i, j, 0) = 0.;
3144 bg_k(i, j, 0) = 0.;
3145 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
3146 {
3147 const int kpg = kg + kp;
3148 if (!(kernel->is_at_wall_elem(kpg, nktot)))
3149 {
3150 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
3151 const double filter_coef_z = filter_kernel_z[kp+10];
3152 const double gxf_i = -structural_uscalar_x(i,j,k+kp);
3153 const double gyf_j = -structural_uscalar_y(i,j,k+kp);
3154 const double gzf_k = -structural_uscalar_z(i,j,k+kp);
3155
3156 const double gxf_ip1 = -structural_uscalar_x(i+1,j,k+kp);
3157 const double gyf_jp1 = -structural_uscalar_y(i,j+1,k+kp);
3158 const double gzf_kp1 = kpg==(nktot-1) ? 0. : -structural_uscalar_z(i,j,k+1+kp);
3159
3160 const double gx_e = 0.5 * (gxf_i + gxf_ip1);
3161 const double gy_e = 0.5 * (gyf_j + gyf_jp1);
3162 const double gz_e = 0.5 * (gzf_k + gzf_kp1);
3163
3164 if (ponderation_filter_kernel)
3165 {
3166 bg_i(i, j, 0) += gx_e * filter_coef_z * dz * facteur_elem;
3167 bg_j(i, j, 0) += gy_e * filter_coef_z * dz * facteur_elem;
3168 bg_k(i, j, 0) += gz_e * filter_coef_z * dz * facteur_elem;
3169 }
3170 else
3171 {
3172 bg_i(i, j, 0) += gx_e * filter_coef_z;
3173 bg_j(i, j, 0) += gy_e * filter_coef_z;
3174 bg_k(i, j, 0) += gz_e * filter_coef_z;
3175 }
3176 }
3177 }
3178 }
3179 }
3180 }
3181 for (int j = 0; j < nj; j++)
3182 {
3183 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
3184 {
3185 aus_i(i, 0, 0) = 0.;
3186 aus_j(i, 0, 0) = 0.;
3187 aus_k(i, 0, 0) = 0.;
3188 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
3189 {
3190 const double filter_coef_y = filter_kernel_y[jp+10];
3191 aus_i(i, 0, 0) += bus_i(i, j+jp, 0) * filter_coef_y;
3192 aus_j(i, 0, 0) += bus_j(i, j+jp, 0) * filter_coef_y;
3193 aus_k(i, 0, 0) += bus_k(i, j+jp, 0) * filter_coef_y;
3194 }
3195 if (turbulent_viscosity)
3196 {
3197 af_i(i, 0, 0) = 0.;
3198 af_j(i, 0, 0) = 0.;
3199 af_k(i, 0, 0) = 0.;
3200 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
3201 {
3202 const double filter_coef_y = filter_kernel_y[jp+10];
3203 af_i(i, 0, 0) += bf_i(i, j+jp, 0) * filter_coef_y;
3204 af_j(i, 0, 0) += bf_j(i, j+jp, 0) * filter_coef_y;
3205 af_k(i, 0, 0) += bf_k(i, j+jp, 0) * filter_coef_y;
3206 }
3207 }
3208 if (structural_uscalar)
3209 {
3210 ag_i(i, 0, 0) = 0.;
3211 ag_j(i, 0, 0) = 0.;
3212 ag_k(i, 0, 0) = 0.;
3213 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
3214 {
3215 const double filter_coef_y = filter_kernel_y[jp+10];
3216 ag_i(i, 0, 0) += bg_i(i, j+jp, 0) * filter_coef_y;
3217 ag_j(i, 0, 0) += bg_j(i, j+jp, 0) * filter_coef_y;
3218 ag_k(i, 0, 0) += bg_k(i, j+jp, 0) * filter_coef_y;
3219 }
3220 }
3221 }
3222
3223 for (int i = 0; i < ni; i++)
3224 {
3225 double rus_i = 0.;
3226 double rus_j = 0.;
3227 double rus_k = 0.;
3228 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
3229 {
3230 const double filter_coef_x = filter_kernel_x[ip+10];
3231 rus_i += aus_i(i+ip, 0, 0) * filter_coef_x;
3232 rus_j += aus_j(i+ip, 0, 0) * filter_coef_x;
3233 rus_k += aus_k(i+ip, 0, 0) * filter_coef_x;
3234 }
3235
3236 const double scalar = champ_scalar_filtre(i,j,k);
3237
3238 const double uf_i = vitesse_i_filtre(i,j,k);
3239 const double vf_j = vitesse_j_filtre(i,j,k);
3240 const double wf_k = vitesse_k_filtre(i,j,k);
3241
3242 const double uf_ip1 = vitesse_i_filtre(i+1,j,k);
3243 const double vf_jp1 = vitesse_j_filtre(i,j+1,k);
3244 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k_filtre(i,j,k+1);
3245
3246 const double ue = 0.5 * (uf_i + uf_ip1);
3247 const double ve = 0.5 * (vf_j + vf_jp1);
3248 const double we = 0.5 * (wf_k + wf_kp1);
3249
3250 const double l_i = rus_i - ue*scalar;
3251 const double l_j = rus_j - ve*scalar;
3252 const double l_k = rus_k - we*scalar;
3253
3254 if (vectorial)
3255 {
3256 moy_li_x[kg] += l_i;
3257 moy_li_y[kg] += l_j;
3258 moy_li_z[kg] += l_k;
3259 }
3260
3261 if (turbulent_viscosity)
3262 {
3263 double rf_i = 0.;
3264 double rf_j = 0.;
3265 double rf_k = 0.;
3266 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
3267 {
3268 const double filter_coef_x = filter_kernel_x[ip+10];
3269 rf_i += af_i(i+ip, 0, 0) * filter_coef_x;
3270 rf_j += af_j(i+ip, 0, 0) * filter_coef_x;
3271 rf_k += af_k(i+ip, 0, 0) * filter_coef_x;
3272 }
3273
3274 if (!anisotropic)
3275 {
3276 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);
3277 }
3278 else
3279 {
3280 const double dx_filtre = facteur_delta_filtre_x*dx;
3281 const double dy_filtre = facteur_delta_filtre_y*dy;
3282 const double dz_filtre = delta_z_pour_delta_filtre[k];
3283 const double delta_m_filtre = kg==0 ? 0. : 0.5*(dz_filtre + delta_z_pour_delta_filtre[k-1]);
3284 const double delta_p_filtre = kg==(nktot-1) ? 0. : 0.5*(dz_filtre + delta_z_pour_delta_filtre[k+1]);
3285 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);
3286 }
3287
3288 m_i = f_filtre[0] - rf_i;
3289 m_j = f_filtre[1] - rf_j;
3290 m_k = f_filtre[2] - rf_k;
3291
3292 const double mimi = m_i * m_i
3293 + m_j * m_j
3294 + m_k * m_k;
3295
3296 const double mili = m_i * l_i
3297 + m_j * l_j
3298 + m_k * l_k;
3299
3300 moy_mimi[kg] += mimi;
3301 moy_mili[kg] += mili;
3302
3303 if (vectorial)
3304 {
3305 moy_mi_x[kg] += m_i;
3306 moy_mi_y[kg] += m_j;
3307 moy_mi_z[kg] += m_k;
3308
3309 moy_mimi_x[kg] += m_i * m_i;
3310 moy_mimi_y[kg] += m_j * m_j;
3311 moy_mimi_z[kg] += m_k * m_k;
3312
3313 moy_mili_x[kg] += m_i * l_i;
3314 moy_mili_y[kg] += m_j * l_j;
3315 moy_mili_z[kg] += m_k * l_k;
3316 }
3317 }
3318
3319 if (structural_uscalar)
3320 {
3321 double rg_i = 0.;
3322 double rg_j = 0.;
3323 double rg_k = 0.;
3324 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
3325 {
3326 const double filter_coef_x = filter_kernel_x[ip+10];
3327 rg_i += ag_i(i+ip, 0, 0) * filter_coef_x;
3328 rg_j += ag_j(i+ip, 0, 0) * filter_coef_x;
3329 rg_k += ag_k(i+ip, 0, 0) * filter_coef_x;
3330 }
3331
3332 const double gxf_i = -structural_uscalar_filtre_x(i,j,k);
3333 const double gyf_j = -structural_uscalar_filtre_y(i,j,k);
3334 const double gzf_k = -structural_uscalar_filtre_z(i,j,k);
3335
3336 const double gxf_ip1 = -structural_uscalar_filtre_x(i+1,j,k);
3337 const double gyf_jp1 = -structural_uscalar_filtre_y(i,j+1,k);
3338 const double gzf_kp1 = kg==(nktot-1) ? 0. : -structural_uscalar_filtre_z(i,j,k+1);
3339
3340 const double gx_e = 0.5 * (gxf_i + gxf_ip1);
3341 const double gy_e = 0.5 * (gyf_j + gyf_jp1);
3342 const double gz_e = 0.5 * (gzf_k + gzf_kp1);
3343
3344 h_i = gx_e - rg_i;
3345 h_j = gy_e - rg_j;
3346 h_k = gz_e - rg_k;
3347
3348 const double hihi = h_i * h_i
3349 + h_j * h_j
3350 + h_k * h_k;
3351
3352 const double hili = h_i * l_i
3353 + h_j * l_j
3354 + h_k * l_k;
3355
3356 moy_hihi[kg] += hihi;
3357 moy_hili[kg] += hili;
3358
3359 if (vectorial)
3360 {
3361 moy_hi_x[kg] += h_i;
3362 moy_hi_y[kg] += h_j;
3363 moy_hi_z[kg] += h_k;
3364
3365 moy_hihi_x[kg] += h_i * h_i;
3366 moy_hihi_y[kg] += h_j * h_j;
3367 moy_hihi_z[kg] += h_k * h_k;
3368
3369 moy_hili_x[kg] += h_i * l_i;
3370 moy_hili_y[kg] += h_j * l_j;
3371 moy_hili_z[kg] += h_k * l_k;
3372 }
3373
3374 if (turbulent_viscosity)
3375 {
3376 const double mihi = m_i * h_i
3377 + m_j * h_j
3378 + m_k * h_k;
3379
3380 moy_mihi[kg] += mihi;
3381
3382 if (vectorial)
3383 {
3384 moy_mihi_x[kg] += m_i * h_i;
3385 moy_mihi_y[kg] += m_j * h_j;
3386 moy_mihi_z[kg] += m_k * h_k;
3387 }
3388 }
3389 }
3390 }
3391 }
3392 }
3393}
3394
3395template<class T>
3396void calculer_turbulent_mu_scalar(const bool anisotropic,
3397 const Nom& turbulent_viscosity_model,
3398 const double turbulent_viscosity_model_constant,
3399 const double variation_cste_modele_fonctionnel_,
3400 const double smoothing_center_fr_,
3401 const double smoothing_factor_fr_,
3402 const double Re_tau_fr_,
3403 const double Re_tau_ch_,
3404 const double pond_fr_,
3405 const double pond_ch_,
3406 const double center_constant_,
3407 const double Lz_tot_,
3408 IJK_Field_vector3_double& velocity,
3409 IJK_Field_vector3_double& velocity_filtre,
3410 IJK_Field_double& rho,
3411 IJK_Field_double& rho_filtre,
3412 double rho_kmin, double rho_kmax,
3413 IJK_Field_double& scalar,
3414 IJK_Field_double& scalar_filtre,
3415 double scalar_kmin, double scalar_kmax,
3416 const ArrOfDouble_with_ghost& delta_z,
3417 const double facteur_delta_x,
3418 const double facteur_delta_y,
3419 const ArrOfDouble_with_ghost& delta_z_pour_delta,
3420 const double facteur_delta_filtre_x,
3421 const double facteur_delta_filtre_y,
3422 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
3423 T& kernel,
3426 const bool flag_turbulent_mu_filtre,
3427 IJK_Field_double& turbulent_mu_filtre,
3428 IJK_Field_double& turbulent_mu,
3429 const Domaine_IJK& splitting)
3430{
3431 Turbulent_viscosity_base* model = nullptr;
3432
3433 choix_modele(turbulent_viscosity_model, model);
3434
3435 calculer_turbulent_mu(anisotropic,
3436 *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_,
3437 velocity, rho, scalar, scalar_kmin, scalar_kmax,
3438 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
3439 turbulent_mu, splitting);
3440 int ghost_size_filter;
3441 int ghost_size_velocity;
3442 int ghost_size_scalar;
3443 if (flag_turbulent_mu_filtre)
3444 {
3445 ghost_size_filter = 1 + kernel->ghost_size();
3446 ghost_size_velocity = max((int) 2, ghost_size_filter);
3447 ghost_size_scalar = max((int) 2, ghost_size_filter);
3448 velocity[0].echange_espace_virtuel(ghost_size_velocity);
3449 velocity[1].echange_espace_virtuel(ghost_size_velocity);
3450 velocity[2].echange_espace_virtuel(ghost_size_velocity);
3451 rho.echange_espace_virtuel(ghost_size_scalar);
3452
3453 const int flag_add = 0;
3454 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]);
3455 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]);
3456 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]);
3457 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);
3458
3459 velocity_filtre[0].echange_espace_virtuel(2);
3460 velocity_filtre[1].echange_espace_virtuel(2);
3461 velocity_filtre[2].echange_espace_virtuel(2);
3462 rho_filtre.echange_espace_virtuel(2);
3463
3464 // si scalar et rho ne sont pas le meme objet
3465 if (&scalar != &rho)
3466 {
3467 scalar.echange_espace_virtuel(ghost_size_scalar);
3468 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);
3469 scalar_filtre.echange_espace_virtuel(2);
3470 }
3471
3472 calculer_turbulent_mu(anisotropic,
3473 *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_,
3474 velocity_filtre, rho_filtre, scalar_filtre, scalar_kmin, scalar_kmax,
3475 delta_z, facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
3476 turbulent_mu_filtre, splitting);
3477 }
3478
3479 delete model;
3480}
3481
3482template<class T>
3483void calculer_turbulent_mu_tensor(const bool anisotropic,
3484 const Nom& turbulent_viscosity_model,
3485 const double turbulent_viscosity_model_constant,
3486 const ArrOfDouble& turbulent_viscosity_tensor_coefficients,
3487 const double variation_cste_modele_fonctionnel_,
3488 const double smoothing_center_fr_,
3489 const double smoothing_factor_fr_,
3490 const double Re_tau_fr_,
3491 const double Re_tau_ch_,
3492 const double pond_fr_,
3493 const double pond_ch_,
3494 const double center_constant_,
3495 const double Lz_tot_,
3496 IJK_Field_vector3_double& velocity,
3497 IJK_Field_vector3_double& velocity_filtre,
3498 IJK_Field_double& rho,
3499 IJK_Field_double& rho_filtre,
3500 double rho_kmin, double rho_kmax,
3501 IJK_Field_double& scalar,
3502 IJK_Field_double& scalar_filtre,
3503 double scalar_kmin, double scalar_kmax,
3504 const ArrOfDouble_with_ghost& delta_z,
3505 const double facteur_delta_x,
3506 const double facteur_delta_y,
3507 const ArrOfDouble_with_ghost& delta_z_pour_delta,
3508 const double facteur_delta_filtre_x,
3509 const double facteur_delta_filtre_y,
3510 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
3511 T& kernel,
3514 const bool flag_turbulent_mu_filtre,
3515 FixedVector<IJK_Field_double, 6>& turbulent_mu_filtre_tensor,
3516 FixedVector<IJK_Field_double, 6>& turbulent_mu_tensor,
3517 const Domaine_IJK& splitting)
3518{
3519 Turbulent_viscosity_base* model = nullptr;
3520
3521 const double& coefficient_xx = turbulent_viscosity_tensor_coefficients[0];
3522 const double& coefficient_xy = turbulent_viscosity_tensor_coefficients[1];
3523 const double& coefficient_xz = turbulent_viscosity_tensor_coefficients[2];
3524 const double& coefficient_yy = turbulent_viscosity_tensor_coefficients[3];
3525 const double& coefficient_yz = turbulent_viscosity_tensor_coefficients[4];
3526 const double& coefficient_zz = turbulent_viscosity_tensor_coefficients[5];
3527
3528 IJK_Field_double& turbulent_mu_xx = turbulent_mu_tensor[0];
3529 IJK_Field_double& turbulent_mu_xy = turbulent_mu_tensor[1];
3530 IJK_Field_double& turbulent_mu_xz = turbulent_mu_tensor[2];
3531 IJK_Field_double& turbulent_mu_yy = turbulent_mu_tensor[3];
3532 IJK_Field_double& turbulent_mu_yz = turbulent_mu_tensor[4];
3533 IJK_Field_double& turbulent_mu_zz = turbulent_mu_tensor[5];
3534
3535 IJK_Field_double& turbulent_mu_filtre_xx = turbulent_mu_filtre_tensor[0];
3536 IJK_Field_double& turbulent_mu_filtre_xy = turbulent_mu_filtre_tensor[1];
3537 IJK_Field_double& turbulent_mu_filtre_xz = turbulent_mu_filtre_tensor[2];
3538 IJK_Field_double& turbulent_mu_filtre_yy = turbulent_mu_filtre_tensor[3];
3539 IJK_Field_double& turbulent_mu_filtre_yz = turbulent_mu_filtre_tensor[4];
3540 IJK_Field_double& turbulent_mu_filtre_zz = turbulent_mu_filtre_tensor[5];
3541
3542 choix_modele(turbulent_viscosity_model, model);
3543
3544 if (0)
3545 {
3546 // do nothing
3547 }
3548 else
3549 {
3550 calculer_turbulent_mu_scalar(anisotropic,
3551 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_,
3552 velocity, velocity_filtre,
3553 rho, rho_filtre, rho_kmin, rho_kmax,
3554 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
3555 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
3556 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
3557 kernel, tmp_b, tmp_a,
3558 flag_turbulent_mu_filtre, turbulent_mu_filtre_xx,
3559 turbulent_mu_xx, splitting);
3560
3561 multiplier_champ(coefficient_xy, turbulent_mu_xx, turbulent_mu_xy);
3562 multiplier_champ(coefficient_xz, turbulent_mu_xx, turbulent_mu_xz);
3563 multiplier_champ(coefficient_yy, turbulent_mu_xx, turbulent_mu_yy);
3564 multiplier_champ(coefficient_yz, turbulent_mu_xx, turbulent_mu_yz);
3565 multiplier_champ(coefficient_zz, turbulent_mu_xx, turbulent_mu_zz);
3566 multiplier_champ(coefficient_xx, turbulent_mu_xx, turbulent_mu_xx);
3567
3568 if (flag_turbulent_mu_filtre)
3569 {
3570 multiplier_champ(coefficient_xy, turbulent_mu_filtre_xx, turbulent_mu_filtre_xy);
3571 multiplier_champ(coefficient_xz, turbulent_mu_filtre_xx, turbulent_mu_filtre_xz);
3572 multiplier_champ(coefficient_yy, turbulent_mu_filtre_xx, turbulent_mu_filtre_yy);
3573 multiplier_champ(coefficient_yz, turbulent_mu_filtre_xx, turbulent_mu_filtre_yz);
3574 multiplier_champ(coefficient_zz, turbulent_mu_filtre_xx, turbulent_mu_filtre_zz);
3575 multiplier_champ(coefficient_xx, turbulent_mu_filtre_xx, turbulent_mu_filtre_xx);
3576 }
3577 }
3578
3579 delete model;
3580}
3581
3582template<class T>
3583void calculer_turbulent_mu_vector(const bool anisotropic,
3584 const Nom& turbulent_viscosity_model,
3585 const double turbulent_viscosity_model_constant,
3586 const ArrOfDouble& turbulent_diffusivity_vector_coefficients,
3587 const double variation_cste_modele_fonctionnel_,
3588 const double smoothing_center_fr_,
3589 const double smoothing_factor_fr_,
3590 const double Re_tau_fr_,
3591 const double Re_tau_ch_,
3592 const double pond_fr_,
3593 const double pond_ch_,
3594 const double center_constant_,
3595 const double Lz_tot_,
3596 IJK_Field_vector3_double& velocity,
3597 IJK_Field_vector3_double& velocity_filtre,
3598 IJK_Field_double& rho,
3599 IJK_Field_double& rho_filtre,
3600 double rho_kmin, double rho_kmax,
3601 IJK_Field_double& scalar,
3602 IJK_Field_double& scalar_filtre,
3603 double scalar_kmin, double scalar_kmax,
3604 const ArrOfDouble_with_ghost& delta_z,
3605 const double facteur_delta_x,
3606 const double facteur_delta_y,
3607 const ArrOfDouble_with_ghost& delta_z_pour_delta,
3608 const double facteur_delta_filtre_x,
3609 const double facteur_delta_filtre_y,
3610 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
3611 T& kernel,
3614 const bool flag_turbulent_mu_filtre,
3615 IJK_Field_vector3_double& turbulent_mu_filtre_vector,
3616 IJK_Field_vector3_double& turbulent_mu_vector,
3617 const Domaine_IJK& splitting)
3618{
3619 Turbulent_viscosity_base* model = nullptr;
3620
3621 const double& coefficient_x = turbulent_diffusivity_vector_coefficients[0];
3622 const double& coefficient_y = turbulent_diffusivity_vector_coefficients[1];
3623 const double& coefficient_z = turbulent_diffusivity_vector_coefficients[2];
3624
3625 IJK_Field_double& turbulent_mu_x = turbulent_mu_vector[0];
3626 IJK_Field_double& turbulent_mu_y = turbulent_mu_vector[1];
3627 IJK_Field_double& turbulent_mu_z = turbulent_mu_vector[2];
3628
3629 IJK_Field_double& turbulent_mu_filtre_x = turbulent_mu_filtre_vector[0];
3630 IJK_Field_double& turbulent_mu_filtre_y = turbulent_mu_filtre_vector[1];
3631 IJK_Field_double& turbulent_mu_filtre_z = turbulent_mu_filtre_vector[2];
3632
3633 choix_modele(turbulent_viscosity_model, model);
3634
3635 if (0)
3636 {
3637 // do nothing
3638 }
3639 else
3640 {
3641 calculer_turbulent_mu_scalar(anisotropic,
3642 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_,
3643 velocity, velocity_filtre,
3644 rho, rho_filtre, rho_kmin, rho_kmax,
3645 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
3646 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
3647 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
3648 kernel, tmp_b, tmp_a,
3649 flag_turbulent_mu_filtre, turbulent_mu_filtre_x,
3650 turbulent_mu_x, splitting);
3651
3652 multiplier_champ(coefficient_y, turbulent_mu_x, turbulent_mu_y);
3653 multiplier_champ(coefficient_z, turbulent_mu_x, turbulent_mu_z);
3654 multiplier_champ(coefficient_x, turbulent_mu_x, turbulent_mu_x);
3655
3656 if (flag_turbulent_mu_filtre)
3657 {
3658 multiplier_champ(coefficient_y, turbulent_mu_filtre_x, turbulent_mu_filtre_y);
3659 multiplier_champ(coefficient_z, turbulent_mu_filtre_x, turbulent_mu_filtre_z);
3660 multiplier_champ(coefficient_x, turbulent_mu_filtre_x, turbulent_mu_filtre_x);
3661 }
3662 }
3663
3664 delete model;
3665}
3666
3667void calculer_structural_uu_gradient(const double structural_uu_model_constant,
3668 const ArrOfDouble& structural_uu_tensor_coefficients,
3669 const IJK_Field_vector3_double& velocity,
3670 const ArrOfDouble_with_ghost& delta_z_maillage,
3671 const double facteur_x_pour_delta,
3672 const double facteur_y_pour_delta,
3673 const ArrOfDouble_with_ghost& delta_z_pour_delta,
3674 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
3675{
3676 const IJK_Field_double& vitesse_i = velocity[0];
3677 const IJK_Field_double& vitesse_j = velocity[1];
3678 const IJK_Field_double& vitesse_k = velocity[2];
3679
3680 IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
3681 IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
3682 IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
3683 IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
3684 IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
3685 IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
3686
3687 const double& coefficient_xx = structural_uu_tensor_coefficients[0];
3688 const double& coefficient_xy = structural_uu_tensor_coefficients[1];
3689 const double& coefficient_xz = structural_uu_tensor_coefficients[2];
3690 const double& coefficient_yy = structural_uu_tensor_coefficients[3];
3691 const double& coefficient_yz = structural_uu_tensor_coefficients[4];
3692 const double& coefficient_zz = structural_uu_tensor_coefficients[5];
3693
3694 const double deltaunsurdx = facteur_x_pour_delta;
3695 const double deltaunsurdy = facteur_y_pour_delta;
3696
3697 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
3698 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
3699
3700 const int ni = vitesse_k.ni();
3701 const int nj = vitesse_k.nj();
3702 const int nk = vitesse_k.nk();
3703
3704 for (int k = 0; k < nk; k++)
3705 {
3706 for (int j = 0; j < nj; j++)
3707 {
3708 for (int i = 0; i < ni; i++)
3709 {
3710 const int kg = k + offset;
3711
3712 const double dz = delta_z_maillage[k];
3713 const double dz_m1 = kg==0 ? 0. : delta_z_maillage[k-1];
3714 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
3715 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
3716
3717 const double deltaunsurdz = delta_z_pour_delta[k] * 1./dz;
3718 const double deltaunsurdz_m1 = kg==0 ? 0. : delta_z_pour_delta[k-1] * 1./dz_m1;
3719 const double deltaunsurdelta_m = kg==0 ? 0. : 0.5*(delta_z_pour_delta[k] + delta_z_pour_delta[k-1]) * 1./delta_m;
3720 const double deltaunsurdelta_p = kg==(nktot-1) ? 0. : 0.5*(delta_z_pour_delta[k] + delta_z_pour_delta[k+1]) * 1./delta_p;
3721
3722 const double uf_i = vitesse_i(i,j,k);
3723 const double uf_ip1 = vitesse_i(i+1,j,k);
3724 const double uf_im1 = vitesse_i(i-1,j,k);
3725 const double uf_i_jm1 = vitesse_i(i,j-1,k);
3726 const double uf_i_jp1 = vitesse_i(i,j+1,k);
3727 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
3728 const double uf_i_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i,j,k+1);
3729 const double uf_i_jm1_km1 = kg==0 ? 0. : vitesse_i(i,j-1,k-1);
3730 const double uf_i_jp1_km1 = kg==0 ? 0. : vitesse_i(i,j+1,k-1);
3731 const double uf_i_jm1_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i,j-1,k+1);
3732 const double uf_ip1_jp1 = vitesse_i(i+1,j+1,k);
3733 const double uf_ip1_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i+1,j,k+1);
3734 const double uf_ip1_jm1 = vitesse_i(i+1,j-1,k);
3735 const double uf_ip1_km1 = kg==0 ? 0. : vitesse_i(i+1,j,k-1);
3736 const double uf_im1_jm1 = vitesse_i(i-1,j-1,k);
3737 const double uf_im1_km1 = kg==0 ? 0. : vitesse_i(i-1,j,k-1);
3738
3739 const double vf_j = vitesse_j(i,j,k);
3740 const double vf_j_im1 = vitesse_j(i-1,j,k);
3741 const double vf_j_ip1 = vitesse_j(i+1,j,k);
3742 const double vf_jp1 = vitesse_j(i,j+1,k);
3743 const double vf_jm1 = vitesse_j(i,j-1,k);
3744 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
3745 const double vf_j_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j,k+1);
3746 const double vf_j_im1_km1 = kg==0 ? 0. : vitesse_j(i-1,j,k-1);
3747 const double vf_j_ip1_km1 = kg==0 ? 0. : vitesse_j(i+1,j,k-1);
3748 const double vf_j_im1_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i-1,j,k+1);
3749 const double vf_jp1_ip1 = vitesse_j(i+1,j+1,k);
3750 const double vf_jp1_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j+1,k+1);
3751 const double vf_jp1_im1 = vitesse_j(i-1,j+1,k);
3752 const double vf_jp1_km1 = kg==0 ? 0. : vitesse_j(i,j+1,k-1);
3753 const double vf_jm1_im1 = vitesse_j(i-1,j-1,k);
3754 const double vf_jm1_km1 = kg==0 ? 0. : vitesse_j(i,j-1,k-1);
3755
3756 const double wf_k = vitesse_k(i,j,k);
3757 const double wf_k_im1 = vitesse_k(i-1,j,k);
3758 const double wf_k_ip1 = vitesse_k(i+1,j,k);
3759 const double wf_k_jm1 = vitesse_k(i,j-1,k);
3760 const double wf_k_jp1 = vitesse_k(i,j+1,k);
3761 const double wf_k_im1_jm1 = vitesse_k(i-1,j-1,k);
3762 const double wf_k_ip1_jm1 = vitesse_k(i+1,j-1,k);
3763 const double wf_k_im1_jp1 = vitesse_k(i-1,j+1,k);
3764 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
3765 const double wf_km1 = kg==0 ? 0. : vitesse_k(i,j,k-1);
3766 const double wf_kp1_ip1 = kg==(nktot-1) ? 0. : vitesse_k(i+1,j,k+1);
3767 const double wf_kp1_jp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j+1,k+1);
3768 const double wf_kp1_im1 = kg==(nktot-1) ? 0. : vitesse_k(i-1,j,k+1);
3769 const double wf_kp1_jm1 = kg==(nktot-1) ? 0. : vitesse_k(i,j-1,k+1);
3770 const double wf_km1_im1 = kg==0 ? 0. : vitesse_k(i-1,j,k-1);
3771 const double wf_km1_jm1 = kg==0 ? 0. : vitesse_k(i,j-1,k-1);
3772
3773 const double duidx = deltaunsurdx * (uf_ip1 - uf_i);
3774 const double dujdy = deltaunsurdy * (vf_jp1 - vf_j);
3775 const double dukdz = deltaunsurdz * (wf_kp1 - wf_k);
3776
3777 const double duidx_im1 = deltaunsurdx * (uf_i - uf_im1);
3778 const double dujdy_im1 = deltaunsurdy * (vf_jp1_im1 - vf_j_im1);
3779 const double dukdz_im1 = deltaunsurdz * (wf_kp1_im1 - wf_k_im1);
3780
3781 const double duidx_jm1 = deltaunsurdx * (uf_ip1_jm1 - uf_i_jm1);
3782 const double dujdy_jm1 = deltaunsurdy * (vf_j - vf_jm1);
3783 const double dukdz_jm1 = deltaunsurdz * (wf_kp1_jm1 - wf_k_jm1);
3784
3785 const double duidx_km1 = deltaunsurdx * (uf_ip1_km1 - uf_i_km1);
3786 const double dujdy_km1 = deltaunsurdy * (vf_jp1_km1 - vf_j_km1);
3787 const double dukdz_km1 = deltaunsurdz_m1 * (wf_k - wf_km1);
3788
3789 const double duidx_im1_jm1 = deltaunsurdx * (uf_i_jm1 - uf_im1_jm1);
3790 const double dujdy_im1_jm1 = deltaunsurdy * (vf_j_im1 - vf_jm1_im1);
3791
3792 const double dujdy_jm1_km1 = deltaunsurdy * (vf_j_km1 - vf_jm1_km1);
3793 const double dukdz_jm1_km1 = deltaunsurdz * (wf_k_jm1 - wf_km1_jm1);
3794
3795 const double duidx_im1_km1 = deltaunsurdx * (uf_i_km1 - uf_im1_km1);
3796 const double dukdz_im1_km1 = deltaunsurdz * (wf_k_im1 - wf_km1_im1);
3797
3798 const double duidy_ij = deltaunsurdy * (uf_i - uf_i_jm1);
3799 const double duidy_ip1j = deltaunsurdy * (uf_ip1 - uf_ip1_jm1);
3800 const double duidy_ijp1 = deltaunsurdy * (uf_i_jp1 - uf_i);
3801 const double duidy_ip1jp1 = deltaunsurdy * (uf_ip1_jp1 - uf_ip1);
3802 const double duidy_ij_km1 = deltaunsurdy * (uf_i_km1 - uf_i_jm1_km1);
3803 const double duidy_ijp1_km1 = deltaunsurdy * (uf_i_jp1_km1 - uf_i_km1);
3804
3805 const double duidz_ik = deltaunsurdelta_m * (uf_i - uf_i_km1);
3806 const double duidz_ip1k = deltaunsurdelta_m * (uf_ip1 - uf_ip1_km1);
3807 const double duidz_ikp1 = deltaunsurdelta_p * (uf_i_kp1 - uf_i);
3808 const double duidz_ip1kp1 = deltaunsurdelta_p * (uf_ip1_kp1 - uf_ip1);
3809 const double duidz_ik_jm1 = deltaunsurdelta_m * (uf_i_jm1 - uf_i_jm1_km1);
3810 const double duidz_ikp1_jm1 = deltaunsurdelta_p * (uf_i_jm1_kp1 - uf_i_jm1);
3811
3812 const double dujdx_ij = deltaunsurdx * (vf_j - vf_j_im1);
3813 const double dujdx_ip1j = deltaunsurdx * (vf_j_ip1 - vf_j);
3814 const double dujdx_ijp1 = deltaunsurdx * (vf_jp1 - vf_jp1_im1);
3815 const double dujdx_ip1jp1 = deltaunsurdx * (vf_jp1_ip1 - vf_jp1);
3816 const double dujdx_ij_km1 = deltaunsurdx * (vf_j_km1 - vf_j_im1_km1);
3817 const double dujdx_ip1j_km1 = deltaunsurdx * (vf_j_ip1_km1 - vf_j_km1);
3818
3819 const double dujdz_jk = deltaunsurdelta_m * (vf_j - vf_j_km1);
3820 const double dujdz_jp1k = deltaunsurdelta_m * (vf_jp1 - vf_jp1_km1);
3821 const double dujdz_jkp1 = deltaunsurdelta_p * (vf_j_kp1 - vf_j);
3822 const double dujdz_jp1kp1 = deltaunsurdelta_p * (vf_jp1_kp1 - vf_jp1);
3823 const double dujdz_jk_im1 = deltaunsurdelta_m * (vf_j_im1 - vf_j_im1_km1);
3824 const double dujdz_jkp1_im1 = deltaunsurdelta_p * (vf_j_im1_kp1 - vf_j_im1);
3825
3826 const double dukdx_ik = deltaunsurdx * (wf_k - wf_k_im1);
3827 const double dukdx_ip1k = deltaunsurdx * (wf_k_ip1 - wf_k);
3828 const double dukdx_ikp1 = deltaunsurdx * (wf_kp1 - wf_kp1_im1);
3829 const double dukdx_ip1kp1 = deltaunsurdx * (wf_kp1_ip1 - wf_kp1);
3830 const double dukdx_ik_jm1 = deltaunsurdx * (wf_k_jm1 - wf_k_im1_jm1);
3831 const double dukdx_ip1k_jm1 = deltaunsurdx * (wf_k_ip1_jm1 - wf_k_jm1);
3832
3833 const double dukdy_jk = deltaunsurdy * (wf_k - wf_k_jm1);
3834 const double dukdy_jp1k = deltaunsurdy * (wf_k_jp1 - wf_k);
3835 const double dukdy_jkp1 = deltaunsurdy * (wf_kp1 - wf_kp1_jm1);
3836 const double dukdy_jp1kp1 = deltaunsurdy * (wf_kp1_jp1 - wf_kp1);
3837 const double dukdy_jk_im1 = deltaunsurdy * (wf_k_im1 - wf_k_im1_jm1);
3838 const double dukdy_jp1k_im1 = deltaunsurdy * (wf_k_im1_jp1 - wf_k_im1);
3839
3840 const double g_e_ii = duidx;
3841 const double g_e_ij = 0.25 * (duidy_ip1jp1 + duidy_ijp1 + duidy_ip1j + duidy_ij);
3842 const double g_e_ik = 0.25 * (duidz_ip1kp1 + duidz_ikp1 + duidz_ip1k + duidz_ik);
3843 const double g_e_ji = 0.25 * (dujdx_ip1jp1 + dujdx_ip1j + dujdx_ijp1 + dujdx_ij);
3844 const double g_e_jj = dujdy;
3845 const double g_e_jk = 0.25 * (dujdz_jp1kp1 + dujdz_jkp1 + dujdz_jp1k + dujdz_jk);
3846 const double g_e_ki = 0.25 * (dukdx_ip1kp1 + dukdx_ip1k + dukdx_ikp1 + dukdx_ik);
3847 const double g_e_kj = 0.25 * (dukdy_jp1kp1 + dukdy_jp1k + dukdy_jkp1 + dukdy_jk);
3848 const double g_e_kk = dukdz;
3849
3850 const double g_aij_ii = 0.25 * (duidx_im1_jm1 + duidx_jm1 + duidx_im1 + duidx);
3851 const double g_aij_ij = duidy_ij;
3852 const double g_aij_ik = 0.25 * (duidz_ikp1_jm1 + duidz_ikp1 + duidz_ik_jm1 + duidz_ik);
3853 const double g_aij_ji = dujdx_ij;
3854 const double g_aij_jj = 0.25 * (dujdy_im1_jm1 + dujdy_jm1 + dujdy_im1 + dujdy);
3855 const double g_aij_jk = 0.25 * (dujdz_jkp1_im1 + dujdz_jkp1 + dujdz_jk_im1 + dujdz_jk);
3856
3857 const double g_aik_ii = 0.25 * (duidx_im1_km1 + duidx_km1 + duidx_im1 + duidx);
3858 const double g_aik_ij = 0.25 * (duidy_ijp1_km1 + duidy_ijp1 + duidy_ij_km1 + duidy_ij);
3859 const double g_aik_ik = duidz_ik;
3860 const double g_aik_ki = dukdx_ik;
3861 const double g_aik_kj = 0.25 * (dukdy_jp1k_im1 + dukdy_jp1k + dukdy_jk_im1 + dukdy_jk);
3862 const double g_aik_kk = 0.25 * (dukdz_im1_km1 + dukdz_km1 + dukdz_im1 + dukdz);
3863
3864 const double g_ajk_ji = 0.25 * (dujdx_ip1j_km1 + dujdx_ip1j + dujdx_ij_km1 + dujdx_ij);
3865 const double g_ajk_jj = 0.25 * (dujdy_jm1_km1 + dujdy_km1 + dujdy_jm1 + dujdy);
3866 const double g_ajk_jk = dujdz_jk;
3867 const double g_ajk_ki = 0.25 * (dukdx_ip1k_jm1 + dukdx_ip1k + dukdx_ik_jm1 + dukdx_ik);
3868 const double g_ajk_kj = dukdy_jk;
3869 const double g_ajk_kk = 0.25 * (dukdz_jm1_km1 + dukdz_km1 + dukdz_jm1 + dukdz);
3870
3871 const double c_ii = g_e_ii*g_e_ii + g_e_ij*g_e_ij + g_e_ik*g_e_ik;
3872 const double c_ij = g_aij_ii*g_aij_ji + g_aij_ij*g_aij_jj + g_aij_ik*g_aij_jk;
3873 const double c_ik = g_aik_ii*g_aik_ki + g_aik_ij*g_aik_kj + g_aik_ik*g_aik_kk;
3874 const double c_jj = g_e_ji*g_e_ji + g_e_jj*g_e_jj + g_e_jk*g_e_jk;
3875 const double c_jk = g_ajk_ji*g_ajk_ki + g_ajk_jj*g_ajk_kj + g_ajk_jk*g_ajk_kk;
3876 const double c_kk = g_e_ki*g_e_ki + g_e_kj*g_e_kj + g_e_kk*g_e_kk;
3877
3878 structural_uu_xx(i,j,k) = - coefficient_xx * structural_uu_model_constant * c_ii/12.;
3879 structural_uu_xy(i,j,k) = - coefficient_xy * structural_uu_model_constant * c_ij/12.;
3880 structural_uu_xz(i,j,k) = - coefficient_xz * structural_uu_model_constant * c_ik/12.;
3881 structural_uu_yy(i,j,k) = - coefficient_yy * structural_uu_model_constant * c_jj/12.;
3882 structural_uu_yz(i,j,k) = - coefficient_yz * structural_uu_model_constant * c_jk/12.;
3883 structural_uu_zz(i,j,k) = - coefficient_zz * structural_uu_model_constant * c_kk/12.;
3884 }
3885 }
3886 }
3887}
3888
3889void calculer_laplacien_u(const IJK_Field_vector3_double& velocity,
3890 const ArrOfDouble_with_ghost& delta_z_maillage,
3891 const double facteur_x_pour_delta,
3892 const double facteur_y_pour_delta,
3893 const ArrOfDouble_with_ghost& delta_z_pour_delta,
3894 IJK_Field_vector3_double& laplacien_velocity)
3895{
3896 const IJK_Field_double& vitesse_i = velocity[0];
3897 const IJK_Field_double& vitesse_j = velocity[1];
3898 const IJK_Field_double& vitesse_k = velocity[2];
3899
3900 IJK_Field_double& laplacien_i = laplacien_velocity[0];
3901 IJK_Field_double& laplacien_j = laplacien_velocity[1];
3902 IJK_Field_double& laplacien_k = laplacien_velocity[2];
3903
3904 const double deltaunsurdx = facteur_x_pour_delta;
3905 const double deltaunsurdy = facteur_y_pour_delta;
3906
3907 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
3908 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
3909
3910 const int ni = vitesse_k.ni();
3911 const int nj = vitesse_k.nj();
3912 const int nk = vitesse_k.nk();
3913
3914 for (int k = 0; k < nk; k++)
3915 {
3916 for (int j = 0; j < nj; j++)
3917 {
3918 for (int i = 0; i < ni; i++)
3919 {
3920 const int kg = k + offset;
3921
3922 const double dz = delta_z_maillage[k];
3923 const double dz_m1 = kg==0 ? 0. : delta_z_maillage[k-1];
3924 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
3925 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
3926
3927 const double deltaunsurdz = delta_z_pour_delta[k] * 1./dz;
3928 const double deltaunsurdz_m1 = kg==0 ? 0. : delta_z_pour_delta[k-1] * 1./dz_m1;
3929 const double deltaunsurdelta_m = kg==0 ? 0. : 0.5*(delta_z_pour_delta[k] + delta_z_pour_delta[k-1]) * 1./delta_m;
3930 const double deltaunsurdelta_p = kg==(nktot-1) ? 0. : 0.5*(delta_z_pour_delta[k] + delta_z_pour_delta[k+1]) * 1./delta_p;
3931
3932 const double uf_i = vitesse_i(i,j,k);
3933 const double uf_ip1 = vitesse_i(i+1,j,k);
3934 const double uf_im1 = vitesse_i(i-1,j,k);
3935 const double uf_i_jm1 = vitesse_i(i,j-1,k);
3936 const double uf_i_jp1 = vitesse_i(i,j+1,k);
3937 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
3938 const double uf_i_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i,j,k+1);
3939
3940 const double vf_j = vitesse_j(i,j,k);
3941 const double vf_j_im1 = vitesse_j(i-1,j,k);
3942 const double vf_j_ip1 = vitesse_j(i+1,j,k);
3943 const double vf_jp1 = vitesse_j(i,j+1,k);
3944 const double vf_jm1 = vitesse_j(i,j-1,k);
3945 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
3946 const double vf_j_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j,k+1);
3947
3948 const double wf_k = vitesse_k(i,j,k);
3949 const double wf_k_im1 = vitesse_k(i-1,j,k);
3950 const double wf_k_ip1 = vitesse_k(i+1,j,k);
3951 const double wf_k_jm1 = vitesse_k(i,j-1,k);
3952 const double wf_k_jp1 = vitesse_k(i,j+1,k);
3953 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
3954 const double wf_km1 = kg==0 ? 0. : vitesse_k(i,j,k-1);
3955
3956 const double duidx = deltaunsurdx * (uf_ip1 - uf_i);
3957 const double dujdy = deltaunsurdy * (vf_jp1 - vf_j);
3958 const double dukdz = deltaunsurdz * (wf_kp1 - wf_k);
3959
3960 const double duidx_im1 = deltaunsurdx * (uf_i - uf_im1);
3961 const double dujdy_jm1 = deltaunsurdy * (vf_j - vf_jm1);
3962 const double dukdz_km1 = deltaunsurdz_m1 * (wf_k - wf_km1);
3963
3964 const double duidy_ij = deltaunsurdy * (uf_i - uf_i_jm1);
3965 const double duidy_ijp1 = deltaunsurdy * (uf_i_jp1 - uf_i);
3966
3967 const double duidz_ik = deltaunsurdelta_m * (uf_i - uf_i_km1);
3968 const double duidz_ikp1 = deltaunsurdelta_p * (uf_i_kp1 - uf_i);
3969
3970 const double dujdx_ij = deltaunsurdx * (vf_j - vf_j_im1);
3971 const double dujdx_ip1j = deltaunsurdx * (vf_j_ip1 - vf_j);
3972
3973 const double dujdz_jk = deltaunsurdelta_m * (vf_j - vf_j_km1);
3974 const double dujdz_jkp1 = deltaunsurdelta_p * (vf_j_kp1 - vf_j);
3975
3976 const double dukdx_ik = deltaunsurdx * (wf_k - wf_k_im1);
3977 const double dukdx_ip1k = deltaunsurdx * (wf_k_ip1 - wf_k);
3978
3979 const double dukdy_jk = deltaunsurdy * (wf_k - wf_k_jm1);
3980 const double dukdy_jp1k = deltaunsurdy * (wf_k_jp1 - wf_k);
3981
3982 const double d2uidx2f_i = deltaunsurdx * (duidx - duidx_im1);
3983 const double d2ujdy2f_j = deltaunsurdy * (dujdy - dujdy_jm1);
3984 const double d2ukdz2f_k = deltaunsurdelta_m * (dukdz - dukdz_km1);
3985
3986 const double d2uidy2f_i = deltaunsurdy * (duidy_ijp1 - duidy_ij);
3987 const double d2uidz2f_i = deltaunsurdz * (duidz_ikp1 - duidz_ik);
3988
3989 const double d2ujdx2f_j = deltaunsurdx * (dujdx_ip1j - dujdx_ij);
3990 const double d2ujdz2f_j = deltaunsurdz * (dujdz_jkp1 - dujdz_jk);
3991
3992 const double d2ukdx2f_k = deltaunsurdx * (dukdx_ip1k - dukdx_ik);
3993 const double d2ukdy2f_k = deltaunsurdy * (dukdy_jp1k - dukdy_jk);
3994
3995 const double laplacien_uf_i = d2uidx2f_i + d2uidy2f_i + d2uidz2f_i;
3996 const double laplacien_vf_j = d2ujdx2f_j + d2ujdy2f_j + d2ujdz2f_j;
3997 const double laplacien_wf_k = d2ukdx2f_k + d2ukdy2f_k + d2ukdz2f_k;
3998
3999 laplacien_i(i,j,k) = laplacien_uf_i;
4000 laplacien_j(i,j,k) = laplacien_vf_j;
4001 laplacien_k(i,j,k) = laplacien_wf_k;
4002 }
4003 }
4004 }
4005}
4006
4007void calculer_structural_uu_su_laplacien_u(const double structural_uu_model_constant,
4008 const ArrOfDouble& structural_uu_tensor_coefficients,
4009 const IJK_Field_vector3_double& velocity,
4010 const IJK_Field_vector3_double& laplacien_velocity,
4011 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
4012{
4013 const IJK_Field_double& vitesse_i = velocity[0];
4014 const IJK_Field_double& vitesse_j = velocity[1];
4015 const IJK_Field_double& vitesse_k = velocity[2];
4016
4017 const IJK_Field_double& laplacien_i = laplacien_velocity[0];
4018 const IJK_Field_double& laplacien_j = laplacien_velocity[1];
4019 const IJK_Field_double& laplacien_k = laplacien_velocity[2];
4020
4021 IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
4022 IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
4023 IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
4024 IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
4025 IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
4026 IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
4027
4028 const double& coefficient_xx = structural_uu_tensor_coefficients[0];
4029 const double& coefficient_xy = structural_uu_tensor_coefficients[1];
4030 const double& coefficient_xz = structural_uu_tensor_coefficients[2];
4031 const double& coefficient_yy = structural_uu_tensor_coefficients[3];
4032 const double& coefficient_yz = structural_uu_tensor_coefficients[4];
4033 const double& coefficient_zz = structural_uu_tensor_coefficients[5];
4034
4035 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
4036 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
4037
4038 const int ni = vitesse_k.ni();
4039 const int nj = vitesse_k.nj();
4040 const int nk = vitesse_k.nk();
4041
4042 for (int k = 0; k < nk; k++)
4043 {
4044 for (int j = 0; j < nj; j++)
4045 {
4046 for (int i = 0; i < ni; i++)
4047 {
4048 const int kg = k + offset;
4049
4050 const double uf_i = vitesse_i(i,j,k);
4051 const double uf_ip1 = vitesse_i(i+1,j,k);
4052 const double uf_i_jm1 = vitesse_i(i,j-1,k);
4053 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
4054
4055 const double vf_j = vitesse_j(i,j,k);
4056 const double vf_j_im1 = vitesse_j(i-1,j,k);
4057 const double vf_jp1 = vitesse_j(i,j+1,k);
4058 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
4059
4060 const double wf_k = vitesse_k(i,j,k);
4061 const double wf_k_im1 = vitesse_k(i-1,j,k);
4062 const double wf_k_jm1 = vitesse_k(i,j-1,k);
4063 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
4064
4065 const double u_ij = 0.5*(uf_i + uf_i_jm1);
4066 const double u_ik = 0.5*(uf_i + uf_i_km1);
4067 const double v_ij = 0.5*(vf_j + vf_j_im1);
4068 const double v_jk = 0.5*(vf_j + vf_j_km1);
4069 const double w_ik = 0.5*(wf_k + wf_k_im1);
4070 const double w_jk = 0.5*(wf_k + wf_k_jm1);
4071
4072 const double ue = 0.5 * (uf_i + uf_ip1);
4073 const double ve = 0.5 * (vf_j + vf_jp1);
4074 const double we = 0.5 * (wf_k + wf_kp1);
4075
4076 const double laplacien_uf_i = laplacien_i(i,j,k);
4077 const double laplacien_vf_j = laplacien_j(i,j,k);
4078 const double laplacien_wf_k = laplacien_k(i,j,k);
4079
4080 const double laplacien_uf_ip1 = laplacien_i(i+1,j,k);
4081 const double laplacien_vf_jp1 = laplacien_j(i,j+1,k);
4082 const double laplacien_wf_kp1 = kg==(nktot-1) ? 0. : laplacien_k(i,j,k+1);
4083
4084 const double laplacien_uf_i_jm1 = laplacien_i(i,j-1,k);
4085 const double laplacien_uf_i_km1 = kg==0 ? 0. : laplacien_i(i,j,k-1);
4086 const double laplacien_vf_j_im1 = laplacien_j(i-1,j,k);
4087 const double laplacien_vf_j_km1 = kg==0 ? 0. : laplacien_j(i,j,k-1);
4088 const double laplacien_wf_k_im1 = laplacien_k(i-1,j,k);
4089 const double laplacien_wf_k_jm1 = laplacien_k(i,j-1,k);
4090
4091 const double laplacien_u_aij = 0.5*(laplacien_uf_i + laplacien_uf_i_jm1);
4092 const double laplacien_u_aik = 0.5*(laplacien_uf_i + laplacien_uf_i_km1);
4093 const double laplacien_v_aij = 0.5*(laplacien_vf_j + laplacien_vf_j_im1);
4094 const double laplacien_v_ajk = 0.5*(laplacien_vf_j + laplacien_vf_j_km1);
4095 const double laplacien_w_aik = 0.5*(laplacien_wf_k + laplacien_wf_k_im1);
4096 const double laplacien_w_ajk = 0.5*(laplacien_wf_k + laplacien_wf_k_jm1);
4097
4098 const double laplacien_u_e = 0.5 * (laplacien_uf_i + laplacien_uf_ip1);
4099 const double laplacien_v_e = 0.5 * (laplacien_vf_j + laplacien_vf_jp1);
4100 const double laplacien_w_e = 0.5 * (laplacien_wf_k + laplacien_wf_kp1);
4101
4102 const double udu_ii = ue*laplacien_u_e/24.;
4103 const double udu_ij = u_ij*laplacien_v_aij/24.;
4104 const double udu_ik = u_ik*laplacien_w_aik/24.;
4105 const double udu_ji = v_ij*laplacien_u_aij/24.;
4106 const double udu_jj = ve*laplacien_v_e/24.;
4107 const double udu_jk = v_jk*laplacien_w_ajk/24.;
4108 const double udu_ki = w_ik*laplacien_u_aik/24.;
4109 const double udu_kj = w_jk*laplacien_v_ajk/24.;
4110 const double udu_kk = we*laplacien_w_e/24.;
4111
4112 const double su_laplacien_u_ii = - udu_ii - udu_ii;
4113 const double su_laplacien_u_ij = - udu_ij - udu_ji;
4114 const double su_laplacien_u_ik = - udu_ik - udu_ki;
4115 const double su_laplacien_u_jj = - udu_jj - udu_jj;
4116 const double su_laplacien_u_jk = - udu_jk - udu_kj;
4117 const double su_laplacien_u_kk = - udu_kk - udu_kk;
4118
4119 structural_uu_xx(i,j,k) = - coefficient_xx * structural_uu_model_constant * su_laplacien_u_ii;
4120 structural_uu_xy(i,j,k) = - coefficient_xy * structural_uu_model_constant * su_laplacien_u_ij;
4121 structural_uu_xz(i,j,k) = - coefficient_xz * structural_uu_model_constant * su_laplacien_u_ik;
4122 structural_uu_yy(i,j,k) = - coefficient_yy * structural_uu_model_constant * su_laplacien_u_jj;
4123 structural_uu_yz(i,j,k) = - coefficient_yz * structural_uu_model_constant * su_laplacien_u_jk;
4124 structural_uu_zz(i,j,k) = - coefficient_zz * structural_uu_model_constant * su_laplacien_u_kk;
4125 }
4126 }
4127 }
4128}
4129
4130void calculer_structural_uu_convection(const double structural_uu_model_constant,
4131 const ArrOfDouble& structural_uu_tensor_coefficients,
4132 const IJK_Field_vector3_double& velocity,
4133 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
4134{
4135 const IJK_Field_double& vitesse_i = velocity[0];
4136 const IJK_Field_double& vitesse_j = velocity[1];
4137 const IJK_Field_double& vitesse_k = velocity[2];
4138
4139 IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
4140 IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
4141 IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
4142 IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
4143 IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
4144 IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
4145
4146 const double& coefficient_xx = structural_uu_tensor_coefficients[0];
4147 const double& coefficient_xy = structural_uu_tensor_coefficients[1];
4148 const double& coefficient_xz = structural_uu_tensor_coefficients[2];
4149 const double& coefficient_yy = structural_uu_tensor_coefficients[3];
4150 const double& coefficient_yz = structural_uu_tensor_coefficients[4];
4151 const double& coefficient_zz = structural_uu_tensor_coefficients[5];
4152
4153 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
4154 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
4155
4156 const int ni = vitesse_k.ni();
4157 const int nj = vitesse_k.nj();
4158 const int nk = vitesse_k.nk();
4159
4160 for (int k = 0; k < nk; k++)
4161 {
4162 for (int j = 0; j < nj; j++)
4163 {
4164 for (int i = 0; i < ni; i++)
4165 {
4166 const int kg = k + offset;
4167
4168 const double uf_i = vitesse_i(i,j,k);
4169 const double uf_ip1 = vitesse_i(i+1,j,k);
4170 const double uf_i_jm1 = vitesse_i(i,j-1,k);
4171 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
4172
4173 const double vf_j = vitesse_j(i,j,k);
4174 const double vf_j_im1 = vitesse_j(i-1,j,k);
4175 const double vf_jp1 = vitesse_j(i,j+1,k);
4176 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
4177
4178 const double wf_k = vitesse_k(i,j,k);
4179 const double wf_k_im1 = vitesse_k(i-1,j,k);
4180 const double wf_k_jm1 = vitesse_k(i,j-1,k);
4181 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
4182
4183 const double u_ij = 0.5*(uf_i + uf_i_jm1);
4184 const double u_ik = 0.5*(uf_i + uf_i_km1);
4185 const double v_ij = 0.5*(vf_j + vf_j_im1);
4186 const double v_jk = 0.5*(vf_j + vf_j_km1);
4187 const double w_ik = 0.5*(wf_k + wf_k_im1);
4188 const double w_jk = 0.5*(wf_k + wf_k_jm1);
4189
4190 const double ue = 0.5 * (uf_i + uf_ip1);
4191 const double ve = 0.5 * (vf_j + vf_jp1);
4192 const double we = 0.5 * (wf_k + wf_kp1);
4193
4194 const double uu_ii = ue*ue;
4195 const double uu_ij = u_ij*v_ij;
4196 const double uu_ik = u_ik*w_ik;
4197 const double uu_jj = ve*ve;
4198 const double uu_jk = v_jk*w_jk;
4199 const double uu_kk = we*we;
4200
4201 structural_uu_xx(i,j,k) = - coefficient_xx * structural_uu_model_constant * uu_ii;
4202 structural_uu_xy(i,j,k) = - coefficient_xy * structural_uu_model_constant * uu_ij;
4203 structural_uu_xz(i,j,k) = - coefficient_xz * structural_uu_model_constant * uu_ik;
4204 structural_uu_yy(i,j,k) = - coefficient_yy * structural_uu_model_constant * uu_jj;
4205 structural_uu_yz(i,j,k) = - coefficient_yz * structural_uu_model_constant * uu_jk;
4206 structural_uu_zz(i,j,k) = - coefficient_zz * structural_uu_model_constant * uu_kk;
4207 }
4208 }
4209 }
4210}
4211template<class T>
4212void calculer_structural_uu_similarity_comp(const double structural_uu_model_constant,
4213 const ArrOfDouble& structural_uu_tensor_coefficients,
4214 const IJK_Field_double& rho,
4215 const IJK_Field_vector3_double& velocity,
4216 const IJK_Field_vector3_double& velocity_filtre,
4217 const ArrOfDouble_with_ghost& delta_z,
4218 const double facteur_delta_x,
4219 const double facteur_delta_y,
4220 const ArrOfDouble_with_ghost& delta_z_pour_delta,
4221 T& kernel,
4224 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
4225{
4226 const IJK_Field_double& vitesse_i = velocity[0];
4227 const IJK_Field_double& vitesse_j = velocity[1];
4228 const IJK_Field_double& vitesse_k = velocity[2];
4229 const IJK_Field_double& masse_vol_ijk = rho;
4230 IJK_Field_local_double& masse_vol_ijk_filtre = tmp_b[15];
4231 IJK_Field_local_double& aa_rho_ijk_filtre = tmp_a[15];
4232
4233 // const IJK_Field_double& vitesse_i_filtre = velocity_filtre[0];
4234 // const IJK_Field_double& vitesse_j_filtre = velocity_filtre[1];
4235 // const IJK_Field_double& vitesse_k_filtre = velocity_filtre[2];
4236
4237 IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
4238 IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
4239 IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
4240 IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
4241 IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
4242 IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
4243
4244 const double& coefficient_xx = structural_uu_tensor_coefficients[0];
4245 const double& coefficient_xy = structural_uu_tensor_coefficients[1];
4246 const double& coefficient_xz = structural_uu_tensor_coefficients[2];
4247 const double& coefficient_yy = structural_uu_tensor_coefficients[3];
4248 const double& coefficient_yz = structural_uu_tensor_coefficients[4];
4249 const double& coefficient_zz = structural_uu_tensor_coefficients[5];
4250
4251 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
4252 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
4253 const double dx_pour_delta = facteur_delta_x*dx;
4254 const double dy_pour_delta = facteur_delta_y*dy;
4255
4256 const int ni = vitesse_k.ni();
4257 const int nj = vitesse_k.nj();
4258 const int nk = vitesse_k.nk();
4259 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
4260 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
4261
4262 IJK_Field_local_double& b_ii = tmp_b[0];
4263 IJK_Field_local_double& b_ij = tmp_b[1];
4264 IJK_Field_local_double& b_ik = tmp_b[2];
4265 IJK_Field_local_double& b_jj = tmp_b[3];
4266 IJK_Field_local_double& b_jk = tmp_b[4];
4267 IJK_Field_local_double& b_kk = tmp_b[5];
4268 IJK_Field_local_double& bb_uii = tmp_b[6];
4269 IJK_Field_local_double& bb_uij = tmp_b[7];
4270 IJK_Field_local_double& bb_vjj = tmp_b[8];
4271 IJK_Field_local_double& bb_vij = tmp_b[9];
4272 IJK_Field_local_double& bb_wkk = tmp_b[10];
4273 IJK_Field_local_double& bb_uik = tmp_b[11];
4274 IJK_Field_local_double& bb_vjk = tmp_b[12];
4275 IJK_Field_local_double& bb_wik = tmp_b[13];
4276 IJK_Field_local_double& bb_wjk = tmp_b[14];
4277
4278 IJK_Field_local_double& a_ii = tmp_a[0];
4279 IJK_Field_local_double& a_ij = tmp_a[1];
4280 IJK_Field_local_double& a_ik = tmp_a[2];
4281 IJK_Field_local_double& a_jj = tmp_a[3];
4282 IJK_Field_local_double& a_jk = tmp_a[4];
4283 IJK_Field_local_double& a_kk = tmp_a[5];
4284 IJK_Field_local_double& aa_uii = tmp_a[6];
4285 IJK_Field_local_double& aa_uij = tmp_a[7];
4286 IJK_Field_local_double& aa_vjj = tmp_a[8];
4287 IJK_Field_local_double& aa_vij = tmp_a[9];
4288 IJK_Field_local_double& aa_wkk = tmp_a[10];
4289 IJK_Field_local_double& aa_uik = tmp_a[11];
4290 IJK_Field_local_double& aa_vjk = tmp_a[12];
4291 IJK_Field_local_double& aa_wik = tmp_a[13];
4292 IJK_Field_local_double& aa_wjk = tmp_a[14];
4293
4294 const int ghost_size_filter = kernel->ghost_size();
4295 const int size_uniform = kernel->size_uniform();
4296 const int shift_uniform = kernel->shift_uniform();
4297 for (int k = 0; k < nk; k++)
4298 {
4299 const int kg = k + offset;
4300
4301 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
4302 const double dz_m1_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z[k-1];
4303 const double delta_m_glo = kg==0 ? 0.5*dz_glo : 0.5*(dz_glo + dz_m1_glo);
4304 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
4305 const double dz_m1_pour_delta_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1];
4306 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);
4307
4308 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
4309 const FixedVector<double, 21> filter_kernel_z_face = kernel->inhomogeneous(false, k, kg, nktot, delta_m_pour_delta_glo, delta_z);
4310 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
4311 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
4312 const int size_k_elem = kernel->size_k_elem(kg, nktot);
4313 const int size_k_face = kernel->size_k_face(kg, nktot);
4314 const int shift_k_elem = kernel->shift_k_elem(kg);
4315 const int shift_k_face = kernel->shift_k_face(kg);
4316 const bool ponderation_filter_kernel = kernel->ponderation();
4317 const bool normalisation_filter_kernel = kernel->normalisation();
4318
4319 double facteur_elem = 0.;
4320 if (ponderation_filter_kernel)
4321 {
4322 if (normalisation_filter_kernel)
4323 {
4324 double longueur_elem = 0.;
4325 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
4326 {
4327 const int kpg = kg + kp;
4328 if (kpg<-1 || kpg>nktot)
4329 {
4330 Cerr << "This should not happen." << finl;
4331 Process::exit();
4332 }
4333 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4334 const double filter_coef_z = filter_kernel_z[kp+10];
4335 longueur_elem += filter_coef_z * dz;
4336 }
4337 facteur_elem = 1./longueur_elem;
4338 }
4339 else
4340 {
4341 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
4342 }
4343 }
4344 double facteur_face = 0.;
4345 if (ponderation_filter_kernel)
4346 {
4347 if (normalisation_filter_kernel)
4348 {
4349 double longueur_face = 0.;
4350 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
4351 {
4352 const int kpg = kg + kp;
4353 if (kpg<0 || kpg>nktot)
4354 {
4355 Cerr << "This should not happen." << finl;
4356 Process::exit();
4357 }
4358 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4359 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
4360 const double dzf = 0.5*(dz + dz_m1);
4361 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
4362 longueur_face += filter_coef_z_face * dzf;
4363 }
4364 facteur_face = 1./longueur_face;
4365 }
4366 else
4367 {
4368 facteur_face = delta_m_glo==0. ? 0. : 1./delta_m_glo;
4369 }
4370 }
4371
4372 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
4373 {
4374 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
4375 {
4376 b_ii(i, j, 0) = 0.;
4377 bb_uii(i, j, 0) = 0.;
4378 bb_uij(i, j, 0) = 0.;
4379 b_ij(i, j, 0) = 0.;
4380 b_ik(i, j, 0) = 0.;
4381 b_jj(i, j, 0) = 0.;
4382 bb_vjj(i, j, 0) = 0.;
4383 bb_vij(i, j, 0) = 0.;
4384 b_jk(i, j, 0) = 0.;
4385 b_kk(i, j, 0) = 0.;
4386 bb_wkk(i, j, 0) = 0.;
4387 bb_uik(i, j, 0) = 0.;
4388 bb_vjk(i, j, 0) = 0.;
4389 bb_wik(i, j, 0) = 0.;
4390 bb_wjk(i, j, 0) = 0.;
4391 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
4392 {
4393 const int kpg = kg + kp;
4394 if (!(kernel->is_at_wall_elem(kpg, nktot)))
4395 {
4396 const double filter_coef_z = filter_kernel_z[kp+10];
4397
4398 const double rho_ijk = masse_vol_ijk(i,j,k+kp);
4399 const double uf_i = vitesse_i(i,j,k+kp);
4400 const double vf_j = vitesse_j(i,j,k+kp);
4401 const double wf_k = vitesse_k(i,j,k+kp);
4402
4403 const double uf_ip1 = vitesse_i(i+1,j,k+kp);
4404 const double vf_jp1 = vitesse_j(i,j+1,k+kp);
4405 const double wf_kp1 = kpg==(nktot-1) ? 0. : vitesse_k(i,j,k+1+kp);
4406
4407 const double uf_i_jm1 = vitesse_i(i,j-1,k+kp);
4408 const double vf_j_im1 = vitesse_j(i-1,j,k+kp);
4409
4410 const double u_ij = 0.5*(uf_i + uf_i_jm1);
4411 const double v_ij = 0.5*(vf_j + vf_j_im1);
4412
4413 const double ue = 0.5 * (uf_i + uf_ip1);
4414 const double ve = 0.5 * (vf_j + vf_jp1);
4415 const double we = 0.5 * (wf_k + wf_kp1);
4416
4417 if (ponderation_filter_kernel)
4418 {
4419 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4420 b_ii(i, j, 0) += rho_ijk*ue*ue * filter_coef_z * dz * facteur_elem;
4421 b_ij(i, j, 0) += rho_ijk*u_ij*v_ij * filter_coef_z * dz * facteur_elem;
4422 b_jj(i, j, 0) += rho_ijk*ve*ve * filter_coef_z * dz * facteur_elem;
4423 b_kk(i, j, 0) += rho_ijk*we*we * filter_coef_z * dz * facteur_elem;
4424 bb_uii(i, j, 0) += rho_ijk*ue * filter_coef_z * dz * facteur_elem;
4425 bb_uij(i, j, 0) += rho_ijk*u_ij * filter_coef_z * dz * facteur_elem;
4426 bb_vij(i, j, 0) += rho_ijk*v_ij * filter_coef_z * dz * facteur_elem;
4427 bb_vjj(i, j, 0) += rho_ijk*ve * filter_coef_z * dz * facteur_elem;
4428 bb_wkk(i, j, 0) += rho_ijk*we * filter_coef_z * dz * facteur_elem;
4429 masse_vol_ijk_filtre(i, j, 0) += rho_ijk * filter_coef_z * dz * facteur_elem;
4430 }
4431 else
4432 {
4433 b_ii(i, j, 0) += rho_ijk*ue*ue * filter_coef_z;
4434 b_ij(i, j, 0) += rho_ijk*u_ij*v_ij * filter_coef_z;
4435 b_jj(i, j, 0) += rho_ijk*ve*ve * filter_coef_z;
4436 b_kk(i, j, 0) += rho_ijk*we*we * filter_coef_z;
4437 bb_uii(i, j, 0) += rho_ijk*ue * filter_coef_z;
4438 bb_uij(i, j, 0) += rho_ijk*u_ij * filter_coef_z;
4439 bb_vij(i, j, 0) += rho_ijk*v_ij * filter_coef_z;
4440 bb_vjj(i, j, 0) += rho_ijk*ve * filter_coef_z;
4441 bb_wkk(i, j, 0) += rho_ijk*we * filter_coef_z;
4442 masse_vol_ijk_filtre(i, j, 0) += rho_ijk * filter_coef_z;
4443 }
4444 }
4445 }
4446 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
4447 {
4448 const int kpg = kg + kp;
4449 if (!(kernel->is_at_wall_face(kpg, nktot)))
4450 {
4451 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
4452
4453 const double rho_ijk = masse_vol_ijk(i,j,k+kp);
4454 const double uf_i = vitesse_i(i,j,k+kp);
4455 const double vf_j = vitesse_j(i,j,k+kp);
4456 const double wf_k = vitesse_k(i,j,k+kp);
4457
4458 const double uf_i_km1 = kpg==0 ? 0. : vitesse_i(i,j,k-1+kp);
4459 const double vf_j_km1 = kpg==0 ? 0. : vitesse_j(i,j,k-1+kp);
4460 const double wf_k_im1 = vitesse_k(i-1,j,k+kp);
4461 const double wf_k_jm1 = vitesse_k(i,j-1,k+kp);
4462
4463 const double u_ik = 0.5*(uf_i + uf_i_km1);
4464 const double v_jk = 0.5*(vf_j + vf_j_km1);
4465 const double w_ik = 0.5*(wf_k + wf_k_im1);
4466 const double w_jk = 0.5*(wf_k + wf_k_jm1);
4467
4468 if (ponderation_filter_kernel)
4469 {
4470 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4471 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
4472 const double dzf = 0.5*(dz + dz_m1);
4473 b_ik(i, j, 0) += rho_ijk*u_ik*w_ik * filter_coef_z_face * dzf * facteur_face;
4474 b_jk(i, j, 0) += rho_ijk*v_jk*w_jk * filter_coef_z_face * dzf * facteur_face;
4475 bb_uik(i, j, 0) += rho_ijk*u_ik * filter_coef_z_face * dzf * facteur_face;
4476 bb_vjk(i, j, 0) += rho_ijk*v_jk * filter_coef_z_face * dzf * facteur_face;
4477 bb_wik(i, j, 0) += rho_ijk*w_ik * filter_coef_z_face * dzf * facteur_face;
4478 bb_wjk(i, j, 0) += rho_ijk*w_jk * filter_coef_z_face * dzf * facteur_face;
4479 }
4480 else
4481 {
4482 b_ik(i, j, 0) += rho_ijk*u_ik*w_ik * filter_coef_z_face;
4483 b_jk(i, j, 0) += rho_ijk*v_jk*w_jk * filter_coef_z_face;
4484 bb_uik(i, j, 0) += rho_ijk*u_ik * filter_coef_z_face;
4485 bb_vjk(i, j, 0) += rho_ijk*v_jk * filter_coef_z_face;
4486 bb_wik(i, j, 0) += rho_ijk*w_ik * filter_coef_z_face;
4487 bb_wjk(i, j, 0) += rho_ijk*w_jk * filter_coef_z_face;
4488 }
4489 }
4490 }
4491 }
4492 }
4493 for (int j = 0; j < nj; j++)
4494 {
4495 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
4496 {
4497 a_ii(i, 0, 0) = 0.;
4498 aa_uii(i, 0, 0) = 0.;
4499 aa_uij(i, 0, 0) = 0.;
4500 a_ij(i, 0, 0) = 0.;
4501 a_ik(i, 0, 0) = 0.;
4502 a_jj(i, 0, 0) = 0.;
4503 aa_vjj(i, 0, 0) = 0.;
4504 aa_vij(i, 0, 0) = 0.;
4505 a_jk(i, 0, 0) = 0.;
4506 a_kk(i, 0, 0) = 0.;
4507 aa_wkk(i, 0, 0) = 0.;
4508 aa_uik(i, 0, 0) = 0.;
4509 aa_vjk(i, 0, 0) = 0.;
4510 aa_wik(i, 0, 0) = 0.;
4511 aa_wjk(i, 0, 0) = 0.;
4512 aa_rho_ijk_filtre(i, 0, 0) = 0.;
4513 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
4514 {
4515 const double filter_coef_y = filter_kernel_y[jp+10];
4516 a_ii(i, 0, 0) += b_ii(i, j+jp, 0) * filter_coef_y;
4517 aa_uii(i, 0, 0) += bb_uii(i, j+jp, 0) * filter_coef_y;
4518 aa_uij(i, 0, 0) += bb_uij(i, j+jp, 0) * filter_coef_y;
4519 a_ij(i, 0, 0) += b_ij(i, j+jp, 0) * filter_coef_y;
4520 a_ik(i, 0, 0) += b_ik(i, j+jp, 0) * filter_coef_y;
4521 a_jj(i, 0, 0) += b_jj(i, j+jp, 0) * filter_coef_y;
4522 aa_vjj(i, 0, 0) += bb_vjj(i, j+jp, 0) * filter_coef_y;
4523 aa_vij(i, 0, 0) += bb_vij(i, j+jp, 0) * filter_coef_y;
4524 a_jk(i, 0, 0) += b_jk(i, j+jp, 0) * filter_coef_y;
4525 a_kk(i, 0, 0) += b_kk(i, j+jp, 0) * filter_coef_y;
4526 aa_wkk(i, 0, 0) += bb_wkk(i, j+jp, 0) * filter_coef_y;
4527 aa_uik(i, 0, 0) += bb_uik(i, j+jp, 0) * filter_coef_y;
4528 aa_vjk(i, 0, 0) += bb_vjk(i, j+jp, 0) * filter_coef_y;
4529 aa_wik(i, 0, 0) += bb_wik(i, j+jp, 0) * filter_coef_y;
4530 aa_wjk(i, 0, 0) += bb_wjk(i, j+jp, 0) * filter_coef_y;
4531 aa_rho_ijk_filtre(i, 0, 0) += masse_vol_ijk_filtre(i, j+jp, 0)* filter_coef_y;
4532 }
4533 }
4534
4535 for (int i = 0; i < ni; i++)
4536 {
4537 double r_ii = 0.;
4538 double r_ij = 0.;
4539 double r_ik = 0.;
4540 double r_jj = 0.;
4541 double r_jk = 0.;
4542 double r_kk = 0.;
4543 double rho_ue = 0.;
4544 double rho_ve = 0.;
4545 double rho_we = 0.;
4546 double rho_uij = 0.;
4547 double rho_uik = 0.;
4548 double rho_vij = 0.;
4549 double rho_vjk = 0.;
4550 double rho_wik = 0.;
4551 double rho_wjk = 0.;
4552 double rho_filtre = 0.;
4553 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
4554 {
4555 const double filter_coef_x = filter_kernel_x[ip+10];
4556 r_ii += a_ii(i+ip, 0, 0) * filter_coef_x;
4557 r_ij += a_ij(i+ip, 0, 0) * filter_coef_x;
4558 r_ik += a_ik(i+ip, 0, 0) * filter_coef_x;
4559 r_jj += a_jj(i+ip, 0, 0) * filter_coef_x;
4560 r_jk += a_jk(i+ip, 0, 0) * filter_coef_x;
4561 r_kk += a_kk(i+ip, 0, 0) * filter_coef_x;
4562 rho_ue += aa_uii(i+ip, 0, 0) * filter_coef_x;
4563 rho_ve += aa_vjj(i+ip, 0, 0) * filter_coef_x;
4564 rho_we += aa_wkk(i+ip, 0, 0) * filter_coef_x;
4565 rho_uij += aa_uij(i+ip, 0, 0) * filter_coef_x;
4566 rho_uik += aa_uik(i+ip, 0, 0) * filter_coef_x;
4567 rho_vij += aa_vij(i+ip, 0, 0) * filter_coef_x;
4568 rho_vjk += aa_vjk(i+ip, 0, 0) * filter_coef_x;
4569 rho_wik += aa_wik(i+ip, 0, 0) * filter_coef_x;
4570 rho_wjk += aa_wjk(i+ip, 0, 0) * filter_coef_x;
4571 rho_filtre += aa_rho_ijk_filtre(i+ip, 0, 0)* filter_coef_x;
4572 }
4573
4574 const double c_ii = (r_ii)/rho_filtre - (rho_ue*rho_ue)/(rho_filtre*rho_filtre);
4575 const double c_ij = (r_ij)/rho_filtre - (rho_uij*rho_vij)/(rho_filtre*rho_filtre);
4576 const double c_ik = (r_ik)/rho_filtre - (rho_uik*rho_wik)/(rho_filtre*rho_filtre);
4577 const double c_jj = (r_jj)/rho_filtre - (rho_ve*rho_ve)/(rho_filtre*rho_filtre);
4578 const double c_jk = (r_jk)/rho_filtre - (rho_vjk*rho_wjk)/(rho_filtre*rho_filtre);
4579 const double c_kk = (r_kk)/rho_filtre - (rho_we*rho_we)/(rho_filtre*rho_filtre);
4580
4581 structural_uu_xx(i,j,k) = - coefficient_xx * structural_uu_model_constant * c_ii;
4582 structural_uu_xy(i,j,k) = - coefficient_xy * structural_uu_model_constant * c_ij;
4583 structural_uu_xz(i,j,k) = - coefficient_xz * structural_uu_model_constant * c_ik;
4584 structural_uu_yy(i,j,k) = - coefficient_yy * structural_uu_model_constant * c_jj;
4585 structural_uu_yz(i,j,k) = - coefficient_yz * structural_uu_model_constant * c_jk;
4586 structural_uu_zz(i,j,k) = - coefficient_zz * structural_uu_model_constant * c_kk;
4587 }
4588 }
4589 }
4590}
4591
4592template<class T>
4593void calculer_structural_uu_similarity(const double structural_uu_model_constant,
4594 const ArrOfDouble& structural_uu_tensor_coefficients,
4595 const IJK_Field_vector3_double& velocity,
4596 const IJK_Field_vector3_double& velocity_filtre,
4597 const ArrOfDouble_with_ghost& delta_z,
4598 const double facteur_delta_x,
4599 const double facteur_delta_y,
4600 const ArrOfDouble_with_ghost& delta_z_pour_delta,
4601 T& kernel,
4604 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
4605{
4606 const IJK_Field_double& vitesse_i = velocity[0];
4607 const IJK_Field_double& vitesse_j = velocity[1];
4608 const IJK_Field_double& vitesse_k = velocity[2];
4609
4610 const IJK_Field_double& vitesse_i_filtre = velocity_filtre[0];
4611 const IJK_Field_double& vitesse_j_filtre = velocity_filtre[1];
4612 const IJK_Field_double& vitesse_k_filtre = velocity_filtre[2];
4613
4614 IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
4615 IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
4616 IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
4617 IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
4618 IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
4619 IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
4620
4621 const double& coefficient_xx = structural_uu_tensor_coefficients[0];
4622 const double& coefficient_xy = structural_uu_tensor_coefficients[1];
4623 const double& coefficient_xz = structural_uu_tensor_coefficients[2];
4624 const double& coefficient_yy = structural_uu_tensor_coefficients[3];
4625 const double& coefficient_yz = structural_uu_tensor_coefficients[4];
4626 const double& coefficient_zz = structural_uu_tensor_coefficients[5];
4627
4628 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
4629 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
4630 const double dx_pour_delta = facteur_delta_x*dx;
4631 const double dy_pour_delta = facteur_delta_y*dy;
4632
4633 const int ni = vitesse_k.ni();
4634 const int nj = vitesse_k.nj();
4635 const int nk = vitesse_k.nk();
4636
4637 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
4638 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
4639
4640 IJK_Field_local_double& b_ii = tmp_b[0];
4641 IJK_Field_local_double& b_ij = tmp_b[1];
4642 IJK_Field_local_double& b_ik = tmp_b[2];
4643 IJK_Field_local_double& b_jj = tmp_b[3];
4644 IJK_Field_local_double& b_jk = tmp_b[4];
4645 IJK_Field_local_double& b_kk = tmp_b[5];
4646
4647 IJK_Field_local_double& a_ii = tmp_a[0];
4648 IJK_Field_local_double& a_ij = tmp_a[1];
4649 IJK_Field_local_double& a_ik = tmp_a[2];
4650 IJK_Field_local_double& a_jj = tmp_a[3];
4651 IJK_Field_local_double& a_jk = tmp_a[4];
4652 IJK_Field_local_double& a_kk = tmp_a[5];
4653
4654 const int ghost_size_filter = kernel->ghost_size();
4655 const int size_uniform = kernel->size_uniform();
4656 const int shift_uniform = kernel->shift_uniform();
4657 for (int k = 0; k < nk; k++)
4658 {
4659 const int kg = k + offset;
4660
4661 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
4662 const double dz_m1_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z[k-1];
4663 const double delta_m_glo = kg==0 ? 0.5*dz_glo : 0.5*(dz_glo + dz_m1_glo);
4664 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
4665 const double dz_m1_pour_delta_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1];
4666 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);
4667
4668 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
4669 const FixedVector<double, 21> filter_kernel_z_face = kernel->inhomogeneous(false, k, kg, nktot, delta_m_pour_delta_glo, delta_z);
4670 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
4671 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
4672 const int size_k_elem = kernel->size_k_elem(kg, nktot);
4673 const int size_k_face = kernel->size_k_face(kg, nktot);
4674 const int shift_k_elem = kernel->shift_k_elem(kg);
4675 const int shift_k_face = kernel->shift_k_face(kg);
4676 const bool ponderation_filter_kernel = kernel->ponderation();
4677 const bool normalisation_filter_kernel = kernel->normalisation();
4678
4679 double facteur_elem = 0.;
4680 if (ponderation_filter_kernel)
4681 {
4682 if (normalisation_filter_kernel)
4683 {
4684 double longueur_elem = 0.;
4685 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
4686 {
4687 const int kpg = kg + kp;
4688 if (kpg<-1 || kpg>nktot)
4689 {
4690 Cerr << "This should not happen." << finl;
4691 Process::exit();
4692 }
4693 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4694 const double filter_coef_z = filter_kernel_z[kp+10];
4695 longueur_elem += filter_coef_z * dz;
4696 }
4697 facteur_elem = 1./longueur_elem;
4698 }
4699 else
4700 {
4701 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
4702 }
4703 }
4704 double facteur_face = 0.;
4705 if (ponderation_filter_kernel)
4706 {
4707 if (normalisation_filter_kernel)
4708 {
4709 double longueur_face = 0.;
4710 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
4711 {
4712 const int kpg = kg + kp;
4713 if (kpg<0 || kpg>nktot)
4714 {
4715 Cerr << "This should not happen." << finl;
4716 Process::exit();
4717 }
4718 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4719 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
4720 const double dzf = 0.5*(dz + dz_m1);
4721 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
4722 longueur_face += filter_coef_z_face * dzf;
4723 }
4724 facteur_face = 1./longueur_face;
4725 }
4726 else
4727 {
4728 facteur_face = delta_m_glo==0. ? 0. : 1./delta_m_glo;
4729 }
4730 }
4731
4732 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
4733 {
4734 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
4735 {
4736 b_ii(i, j, 0) = 0.;
4737 b_ij(i, j, 0) = 0.;
4738 b_ik(i, j, 0) = 0.;
4739 b_jj(i, j, 0) = 0.;
4740 b_jk(i, j, 0) = 0.;
4741 b_kk(i, j, 0) = 0.;
4742 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
4743 {
4744 const int kpg = kg + kp;
4745 if (!(kernel->is_at_wall_elem(kpg, nktot)))
4746 {
4747 const double filter_coef_z = filter_kernel_z[kp+10];
4748
4749 const double uf_i = vitesse_i(i,j,k+kp);
4750 const double vf_j = vitesse_j(i,j,k+kp);
4751 const double wf_k = vitesse_k(i,j,k+kp);
4752
4753 const double uf_ip1 = vitesse_i(i+1,j,k+kp);
4754 const double vf_jp1 = vitesse_j(i,j+1,k+kp);
4755 const double wf_kp1 = kpg==(nktot-1) ? 0. : vitesse_k(i,j,k+1+kp);
4756
4757 const double uf_i_jm1 = vitesse_i(i,j-1,k+kp);
4758 const double vf_j_im1 = vitesse_j(i-1,j,k+kp);
4759
4760 const double u_ij = 0.5*(uf_i + uf_i_jm1);
4761 const double v_ij = 0.5*(vf_j + vf_j_im1);
4762
4763 const double ue = 0.5 * (uf_i + uf_ip1);
4764 const double ve = 0.5 * (vf_j + vf_jp1);
4765 const double we = 0.5 * (wf_k + wf_kp1);
4766
4767 if (ponderation_filter_kernel)
4768 {
4769 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4770 b_ii(i, j, 0) += ue*ue * filter_coef_z * dz * facteur_elem;
4771 b_ij(i, j, 0) += u_ij*v_ij * filter_coef_z * dz * facteur_elem;
4772 b_jj(i, j, 0) += ve*ve * filter_coef_z * dz * facteur_elem;
4773 b_kk(i, j, 0) += we*we * filter_coef_z * dz * facteur_elem;
4774 }
4775 else
4776 {
4777 b_ii(i, j, 0) += ue*ue * filter_coef_z;
4778 b_ij(i, j, 0) += u_ij*v_ij * filter_coef_z;
4779 b_jj(i, j, 0) += ve*ve * filter_coef_z;
4780 b_kk(i, j, 0) += we*we * filter_coef_z;
4781 }
4782 }
4783 }
4784 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
4785 {
4786 const int kpg = kg + kp;
4787 if (!(kernel->is_at_wall_face(kpg, nktot)))
4788 {
4789 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
4790
4791 const double uf_i = vitesse_i(i,j,k+kp);
4792 const double vf_j = vitesse_j(i,j,k+kp);
4793 const double wf_k = vitesse_k(i,j,k+kp);
4794
4795 const double uf_i_km1 = kpg==0 ? 0. : vitesse_i(i,j,k-1+kp);
4796 const double vf_j_km1 = kpg==0 ? 0. : vitesse_j(i,j,k-1+kp);
4797 const double wf_k_im1 = vitesse_k(i-1,j,k+kp);
4798 const double wf_k_jm1 = vitesse_k(i,j-1,k+kp);
4799
4800 const double u_ik = 0.5*(uf_i + uf_i_km1);
4801 const double v_jk = 0.5*(vf_j + vf_j_km1);
4802 const double w_ik = 0.5*(wf_k + wf_k_im1);
4803 const double w_jk = 0.5*(wf_k + wf_k_jm1);
4804
4805 if (ponderation_filter_kernel)
4806 {
4807 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
4808 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
4809 const double dzf = 0.5*(dz + dz_m1);
4810 b_ik(i, j, 0) += u_ik*w_ik * filter_coef_z_face * dzf * facteur_face;
4811 b_jk(i, j, 0) += v_jk*w_jk * filter_coef_z_face * dzf * facteur_face;
4812 }
4813 else
4814 {
4815 b_ik(i, j, 0) += u_ik*w_ik * filter_coef_z_face;
4816 b_jk(i, j, 0) += v_jk*w_jk * filter_coef_z_face;
4817 }
4818 }
4819 }
4820 }
4821 }
4822 for (int j = 0; j < nj; j++)
4823 {
4824 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
4825 {
4826 a_ii(i, 0, 0) = 0.;
4827 a_ij(i, 0, 0) = 0.;
4828 a_ik(i, 0, 0) = 0.;
4829 a_jj(i, 0, 0) = 0.;
4830 a_jk(i, 0, 0) = 0.;
4831 a_kk(i, 0, 0) = 0.;
4832 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
4833 {
4834 const double filter_coef_y = filter_kernel_y[jp+10];
4835 a_ii(i, 0, 0) += b_ii(i, j+jp, 0) * filter_coef_y;
4836 a_ij(i, 0, 0) += b_ij(i, j+jp, 0) * filter_coef_y;
4837 a_ik(i, 0, 0) += b_ik(i, j+jp, 0) * filter_coef_y;
4838 a_jj(i, 0, 0) += b_jj(i, j+jp, 0) * filter_coef_y;
4839 a_jk(i, 0, 0) += b_jk(i, j+jp, 0) * filter_coef_y;
4840 a_kk(i, 0, 0) += b_kk(i, j+jp, 0) * filter_coef_y;
4841 }
4842 }
4843
4844 for (int i = 0; i < ni; i++)
4845 {
4846 double r_ii = 0.;
4847 double r_ij = 0.;
4848 double r_ik = 0.;
4849 double r_jj = 0.;
4850 double r_jk = 0.;
4851 double r_kk = 0.;
4852 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
4853 {
4854 const double filter_coef_x = filter_kernel_x[ip+10];
4855 r_ii += a_ii(i+ip, 0, 0) * filter_coef_x;
4856 r_ij += a_ij(i+ip, 0, 0) * filter_coef_x;
4857 r_ik += a_ik(i+ip, 0, 0) * filter_coef_x;
4858 r_jj += a_jj(i+ip, 0, 0) * filter_coef_x;
4859 r_jk += a_jk(i+ip, 0, 0) * filter_coef_x;
4860 r_kk += a_kk(i+ip, 0, 0) * filter_coef_x;
4861 }
4862
4863 const double uf_i = vitesse_i_filtre(i,j,k);
4864 const double vf_j = vitesse_j_filtre(i,j,k);
4865 const double wf_k = vitesse_k_filtre(i,j,k);
4866
4867 const double uf_ip1 = vitesse_i_filtre(i+1,j,k);
4868 const double vf_jp1 = vitesse_j_filtre(i,j+1,k);
4869 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k_filtre(i,j,k+1);
4870
4871 const double uf_i_jm1 = vitesse_i_filtre(i,j-1,k);
4872 const double uf_i_km1 = kg==0 ? 0. : vitesse_i_filtre(i,j,k-1);
4873 const double vf_j_im1 = vitesse_j_filtre(i-1,j,k);
4874 const double vf_j_km1 = kg==0 ? 0. : vitesse_j_filtre(i,j,k-1);
4875 const double wf_k_im1 = vitesse_k_filtre(i-1,j,k);
4876 const double wf_k_jm1 = vitesse_k_filtre(i,j-1,k);
4877
4878 const double u_ij = 0.5*(uf_i + uf_i_jm1);
4879 const double u_ik = 0.5*(uf_i + uf_i_km1);
4880 const double v_ij = 0.5*(vf_j + vf_j_im1);
4881 const double v_jk = 0.5*(vf_j + vf_j_km1);
4882 const double w_ik = 0.5*(wf_k + wf_k_im1);
4883 const double w_jk = 0.5*(wf_k + wf_k_jm1);
4884
4885 const double ue = 0.5 * (uf_i + uf_ip1);
4886 const double ve = 0.5 * (vf_j + vf_jp1);
4887 const double we = 0.5 * (wf_k + wf_kp1);
4888
4889 const double c_ii = r_ii - ue*ue;
4890 const double c_ij = r_ij - u_ij*v_ij;
4891 const double c_ik = r_ik - u_ik*w_ik;
4892 const double c_jj = r_jj - ve*ve;
4893 const double c_jk = r_jk - v_jk*w_jk;
4894 const double c_kk = r_kk - we*we;
4895
4896 structural_uu_xx(i,j,k) = - coefficient_xx * structural_uu_model_constant * c_ii;
4897 structural_uu_xy(i,j,k) = - coefficient_xy * structural_uu_model_constant * c_ij;
4898 structural_uu_xz(i,j,k) = - coefficient_xz * structural_uu_model_constant * c_ik;
4899 structural_uu_yy(i,j,k) = - coefficient_yy * structural_uu_model_constant * c_jj;
4900 structural_uu_yz(i,j,k) = - coefficient_yz * structural_uu_model_constant * c_jk;
4901 structural_uu_zz(i,j,k) = - coefficient_zz * structural_uu_model_constant * c_kk;
4902 }
4903 }
4904 }
4905}
4906
4907
4908//#####################
4909//#####Martin 092021###
4910//#####################
4911
4912template<class T>
4913void calculer_structural_uu_similarity_Streher(const double structural_uu_model_constant,
4914 const IJK_Field_vector3_double& velocity,
4915 T& kernel,
4916 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
4917{
4918 const IJK_Field_double& vitesse_i = velocity[0];
4919 const IJK_Field_double& vitesse_j = velocity[1];
4920 const IJK_Field_double& vitesse_k = velocity[2];
4921
4922 const int ni = vitesse_k.ni();
4923 const int nj = vitesse_k.nj();
4924 const int nk = vitesse_k.nk();
4925
4926 IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
4927 IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
4928 IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
4929 IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
4930 IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
4931 IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
4932
4933 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
4934 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
4935
4936 for (int k = 0; k < nk; k++)
4937 {
4938 const int kg = k + offset;
4939 for (int j = 0; j < nj; j++)
4940 {
4941 for (int i = 0; i < ni; i++)
4942 {
4943 const double uf_im1 = vitesse_i(i-1,j,k);
4944 const double uf_i = vitesse_i(i,j,k);
4945 const double uf_i_jm2 = vitesse_i(i,j-2,k);
4946 const double uf_i_jm1 = vitesse_i(i,j-1,k);
4947 const double uf_i_jp1 = vitesse_i(i,j+1,k);
4948 const double uf_i_km2 = kg<=1 ? 0. : vitesse_i(i,j,k-2);
4949 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
4950 const double uf_i_kp1 = kg>=(nktot-1) ? 0. : vitesse_i(i,j,k+1);
4951 const double uf_ip1 = vitesse_i(i+1,j,k);
4952 const double uf_ip2 = vitesse_i(i+2,j,k);
4953
4954 const double vf_jm1 = vitesse_j(i,j-1,k);
4955 const double vf_j = vitesse_j(i,j,k);
4956 const double vf_j_im2 = vitesse_j(i-2,j,k);
4957 const double vf_j_im1 = vitesse_j(i-1,j,k);
4958 const double vf_j_ip1 = vitesse_j(i+1,j,k);
4959 const double vf_j_km2 = kg<=1 ? 0. : vitesse_j(i,j,k-2);
4960 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
4961 const double vf_j_kp1 = kg>=(nktot-1) ? 0. : vitesse_j(i,j,k+1);
4962 const double vf_jp1 = vitesse_j(i,j+1,k);
4963 const double vf_jp2 = vitesse_j(i,j+2,k);
4964
4965 const double wf_km1 = kg<=1 ? 0. : vitesse_k(i,j,k-1);
4966 const double wf_k = vitesse_k(i,j,k);
4967 const double wf_k_im2 = vitesse_k(i-2,j,k);
4968 const double wf_k_im1 = vitesse_k(i-1,j,k);
4969 const double wf_k_ip1 = vitesse_k(i+1,j,k);
4970 const double wf_k_jm2 = vitesse_k(i,j-2,k);
4971 const double wf_k_jm1 = vitesse_k(i,j-1,k);
4972 const double wf_k_jp1 = vitesse_k(i,j+1,k);
4973 const double wf_kp1 = kg>=(nktot-1) ? 0. : vitesse_k(i,j,k+1);
4974 const double wf_kp2 = kg>=(nktot-2) ? 0. : vitesse_k(i,j,k+2);
4975
4976 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.;
4977 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.;
4978 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.;
4979 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.;
4980 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.;
4981 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.;
4982
4983 structural_uu_xx(i,j,k) = - c_ii * structural_uu_model_constant;
4984 structural_uu_xy(i,j,k) = - c_ij * structural_uu_model_constant;
4985 structural_uu_xz(i,j,k) = - c_ik * structural_uu_model_constant;
4986 structural_uu_yy(i,j,k) = - c_jj * structural_uu_model_constant;
4987 structural_uu_yz(i,j,k) = - c_jk * structural_uu_model_constant;
4988 structural_uu_zz(i,j,k) = - c_kk * structural_uu_model_constant;
4989 }
4990 }
4991 }
4992}
4993
4994template<class T>
4995void calculer_structural_uu(const Nom& structural_uu_model,
4996 const double structural_uu_model_constant,
4997 const ArrOfDouble& structural_uu_tensor_coefficients,
4998 IJK_Field_double& rho,
4999 IJK_Field_vector3_double& velocity,
5000 IJK_Field_vector3_double& velocity_filtre,
5001 const ArrOfDouble_with_ghost& delta_z,
5002 const double facteur_delta_x,
5003 const double facteur_delta_y,
5004 const ArrOfDouble_with_ghost& delta_z_pour_delta,
5005 const double facteur_delta_filtre_x,
5006 const double facteur_delta_filtre_y,
5007 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
5008 T& kernel,
5011 FixedVector<IJK_Field_double, 6>& structural_uu_tmp_tensor,
5012 const bool flag_structural_uu_filtre,
5013 FixedVector<IJK_Field_double, 6>& structural_uu_filtre_tensor,
5014 FixedVector<IJK_Field_double, 6>& structural_uu_tensor)
5015{
5016 int ghost_size_filter;
5017 int ghost_size_velocity;
5018 int ghost_size_structural_uu_tmp;
5019
5020 if ( structural_uu_model == Nom("gradient") )
5021 {
5022 calculer_structural_uu_gradient(structural_uu_model_constant,
5023 structural_uu_tensor_coefficients,
5024 velocity,
5025 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
5026 structural_uu_tensor);
5027 }
5028 else if ( structural_uu_model == Nom("gradient_filtre") )
5029 {
5030 calculer_structural_uu_gradient(structural_uu_model_constant,
5031 structural_uu_tensor_coefficients,
5032 velocity,
5033 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
5034 structural_uu_tmp_tensor);
5035
5036 ghost_size_filter = 1 + kernel->ghost_size();
5037 ghost_size_structural_uu_tmp = max((int) 2, ghost_size_filter);
5038 structural_uu_tmp_tensor[0].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5039 structural_uu_tmp_tensor[1].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5040 structural_uu_tmp_tensor[2].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5041 structural_uu_tmp_tensor[3].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5042 structural_uu_tmp_tensor[4].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5043 structural_uu_tmp_tensor[5].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5044
5045 const int flag_add = 0;
5046 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]);
5047 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]);
5048 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]);
5049 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]);
5050 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]);
5051 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]);
5052 }
5053 else if ( structural_uu_model == Nom("su_laplacien_u") )
5054 {
5055 velocity[0].echange_espace_virtuel(2);
5056 velocity[1].echange_espace_virtuel(2);
5057 velocity[2].echange_espace_virtuel(2);
5058
5059 calculer_laplacien_u(velocity,
5060 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
5061 velocity_filtre);
5062
5063 velocity_filtre[0].echange_espace_virtuel(2);
5064 velocity_filtre[1].echange_espace_virtuel(2);
5065 velocity_filtre[2].echange_espace_virtuel(2);
5066
5067 calculer_structural_uu_su_laplacien_u(structural_uu_model_constant,
5068 structural_uu_tensor_coefficients,
5069 velocity,
5070 velocity_filtre,
5071 structural_uu_tensor);
5072 }
5073 else if ( structural_uu_model == Nom("convection") )
5074 {
5075 calculer_structural_uu_convection(structural_uu_model_constant,
5076 structural_uu_tensor_coefficients,
5077 velocity,
5078 structural_uu_tensor);
5079 }
5080 else if ( structural_uu_model == Nom("convection_filtre") )
5081 {
5082 calculer_structural_uu_convection(structural_uu_model_constant,
5083 structural_uu_tensor_coefficients,
5084 velocity,
5085 structural_uu_tmp_tensor);
5086
5087 ghost_size_filter = 1 + kernel->ghost_size();
5088 ghost_size_structural_uu_tmp = max((int) 2, ghost_size_filter);
5089 structural_uu_tmp_tensor[0].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5090 structural_uu_tmp_tensor[1].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5091 structural_uu_tmp_tensor[2].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5092 structural_uu_tmp_tensor[3].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5093 structural_uu_tmp_tensor[4].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5094 structural_uu_tmp_tensor[5].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5095
5096 const int flag_add = 0;
5097 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]);
5098 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]);
5099 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]);
5100 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]);
5101 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]);
5102 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]);
5103 }
5104 else if ( structural_uu_model == Nom("similarity") )
5105 {
5106 ghost_size_filter = 1 + kernel->ghost_size();
5107 ghost_size_velocity = max((int) 2, ghost_size_filter);
5108 velocity[0].echange_espace_virtuel(ghost_size_velocity);
5109 velocity[1].echange_espace_virtuel(ghost_size_velocity);
5110 velocity[2].echange_espace_virtuel(ghost_size_velocity);
5111
5112 const int flag_add = 0;
5113 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]);
5114 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]);
5115 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]);
5116
5117 velocity_filtre[0].echange_espace_virtuel(2);
5118 velocity_filtre[1].echange_espace_virtuel(2);
5119 velocity_filtre[2].echange_espace_virtuel(2);
5120
5121 calculer_structural_uu_similarity(structural_uu_model_constant,
5122 structural_uu_tensor_coefficients,
5123 velocity, velocity_filtre,
5124 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
5125 kernel, tmp_b, tmp_a,
5126 structural_uu_tensor);
5127 }
5128 else if ( structural_uu_model == Nom("similarity_comp") )
5129 {
5130 ghost_size_filter = 1 + kernel->ghost_size();
5131 ghost_size_velocity = max((int) 2, ghost_size_filter);
5132 velocity[0].echange_espace_virtuel(ghost_size_velocity);
5133 velocity[1].echange_espace_virtuel(ghost_size_velocity);
5134 velocity[2].echange_espace_virtuel(ghost_size_velocity);
5135
5136 const int flag_add = 0;
5137 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]);
5138 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]);
5139 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]);
5140
5141 velocity_filtre[0].echange_espace_virtuel(2);
5142 velocity_filtre[1].echange_espace_virtuel(2);
5143 velocity_filtre[2].echange_espace_virtuel(2);
5144
5145 calculer_structural_uu_similarity_comp(structural_uu_model_constant,
5146 structural_uu_tensor_coefficients,
5147 rho,
5148 velocity, velocity_filtre,
5149 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
5150 kernel, tmp_b, tmp_a,
5151 structural_uu_tensor);
5152 }
5153 else if ( structural_uu_model == Nom("similarity_streher") )
5154 {
5155 ghost_size_filter = 1 + kernel->ghost_size();
5156 ghost_size_velocity = max((int) 2, ghost_size_filter);
5157 velocity[0].echange_espace_virtuel(ghost_size_velocity);
5158 velocity[1].echange_espace_virtuel(ghost_size_velocity);
5159 velocity[2].echange_espace_virtuel(ghost_size_velocity);
5160
5161 const int flag_add = 0;
5162 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]);
5163 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]);
5164 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]);
5165
5166 velocity_filtre[0].echange_espace_virtuel(2);
5167 velocity_filtre[1].echange_espace_virtuel(2);
5168 velocity_filtre[2].echange_espace_virtuel(2);
5169
5170 calculer_structural_uu_similarity_Streher(structural_uu_model_constant,
5171 velocity,
5172 kernel,
5173 structural_uu_tensor);
5174 }
5175 else
5176 {
5177 Cerr << "The name of the structural model for uu is unknown." << finl;
5178 Process::exit();
5179 }
5180
5181 if (flag_structural_uu_filtre)
5182 {
5183 ghost_size_filter = 1 + kernel->ghost_size();
5184 ghost_size_velocity = max((int) 2, ghost_size_filter);
5185 velocity[0].echange_espace_virtuel(ghost_size_velocity);
5186 velocity[1].echange_espace_virtuel(ghost_size_velocity);
5187 velocity[2].echange_espace_virtuel(ghost_size_velocity);
5188
5189 const int flag_add = 0;
5190 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]);
5191 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]);
5192 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]);
5193
5194 velocity_filtre[0].echange_espace_virtuel(2);
5195 velocity_filtre[1].echange_espace_virtuel(2);
5196 velocity_filtre[2].echange_espace_virtuel(2);
5197
5198
5199 if ( structural_uu_model == Nom("gradient") )
5200 {
5201 calculer_structural_uu_gradient(structural_uu_model_constant,
5202 structural_uu_tensor_coefficients,
5203 velocity_filtre,
5204 delta_z, facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
5205 structural_uu_filtre_tensor);
5206 }
5207 else if ( structural_uu_model == Nom("gradient_filtre") )
5208 {
5209 calculer_structural_uu_gradient(structural_uu_model_constant,
5210 structural_uu_tensor_coefficients,
5211 velocity_filtre,
5212 delta_z, facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
5213 structural_uu_tmp_tensor);
5214
5215 ghost_size_filter = 1 + kernel->ghost_size();
5216 ghost_size_structural_uu_tmp = max((int) 2, ghost_size_filter);
5217 structural_uu_tmp_tensor[0].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5218 structural_uu_tmp_tensor[1].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5219 structural_uu_tmp_tensor[2].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5220 structural_uu_tmp_tensor[3].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5221 structural_uu_tmp_tensor[4].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5222 structural_uu_tmp_tensor[5].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5223
5224 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]);
5225 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]);
5226 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]);
5227 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]);
5228 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]);
5229 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]);
5230 }
5231 else if ( structural_uu_model == Nom("su_laplacien_u") )
5232 {
5233 calculer_laplacien_u(velocity_filtre,
5234 delta_z, facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
5235 velocity_filtre);
5236
5237 velocity_filtre[0].echange_espace_virtuel(2);
5238 velocity_filtre[1].echange_espace_virtuel(2);
5239 velocity_filtre[2].echange_espace_virtuel(2);
5240
5241 calculer_structural_uu_su_laplacien_u(structural_uu_model_constant,
5242 structural_uu_tensor_coefficients,
5243 velocity_filtre,
5244 velocity_filtre,
5245 structural_uu_filtre_tensor);
5246 }
5247 else if ( structural_uu_model == Nom("convection") )
5248 {
5249 calculer_structural_uu_convection(structural_uu_model_constant,
5250 structural_uu_tensor_coefficients,
5251 velocity_filtre,
5252 structural_uu_filtre_tensor);
5253 }
5254 else if ( structural_uu_model == Nom("convection_filtre") )
5255 {
5256 calculer_structural_uu_convection(structural_uu_model_constant,
5257 structural_uu_tensor_coefficients,
5258 velocity_filtre,
5259 structural_uu_tmp_tensor);
5260
5261 ghost_size_filter = 1 + kernel->ghost_size();
5262 ghost_size_structural_uu_tmp = max((int) 2, ghost_size_filter);
5263 structural_uu_tmp_tensor[0].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5264 structural_uu_tmp_tensor[1].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5265 structural_uu_tmp_tensor[2].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5266 structural_uu_tmp_tensor[3].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5267 structural_uu_tmp_tensor[4].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5268 structural_uu_tmp_tensor[5].echange_espace_virtuel(ghost_size_structural_uu_tmp);
5269
5270 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]);
5271 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]);
5272 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]);
5273 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]);
5274 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]);
5275 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]);
5276 }
5277 else if ( structural_uu_model == Nom("similarity") )
5278 {
5279 Cerr << "The use of a dynamic constant with the SIMILARITY structural model is not allowed." << finl;
5280 Process::exit();
5281 }
5282 }
5283}
5284
5285void calculer_structural_uscalar_gradient(const double structural_uscalar_model_constant,
5286 const ArrOfDouble& structural_uscalar_vector_coefficients,
5287 const IJK_Field_vector3_double& velocity,
5288 const IJK_Field_double& champ_scalar,
5289 double scalar_kmin, double scalar_kmax,
5290 const ArrOfDouble_with_ghost& delta_z_maillage,
5291 const double facteur_x_pour_delta,
5292 const double facteur_y_pour_delta,
5293 const ArrOfDouble_with_ghost& delta_z_pour_delta,
5294 IJK_Field_vector3_double& structural_uscalar_vector)
5295{
5296 const IJK_Field_double& vitesse_i = velocity[0];
5297 const IJK_Field_double& vitesse_j = velocity[1];
5298 const IJK_Field_double& vitesse_k = velocity[2];
5299
5300 IJK_Field_double& structural_uscalar_x = structural_uscalar_vector[0];
5301 IJK_Field_double& structural_uscalar_y = structural_uscalar_vector[1];
5302 IJK_Field_double& structural_uscalar_z = structural_uscalar_vector[2];
5303
5304 const double& coefficient_x = structural_uscalar_vector_coefficients[0];
5305 const double& coefficient_y = structural_uscalar_vector_coefficients[1];
5306 const double& coefficient_z = structural_uscalar_vector_coefficients[2];
5307
5308 const double deltaunsurdx = facteur_x_pour_delta;
5309 const double deltaunsurdy = facteur_y_pour_delta;
5310
5311 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
5312 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
5313
5314 const int ni = vitesse_k.ni();
5315 const int nj = vitesse_k.nj();
5316 const int nk = vitesse_k.nk();
5317
5318 for (int k = 0; k < nk; k++)
5319 {
5320 for (int j = 0; j < nj; j++)
5321 {
5322 for (int i = 0; i < ni; i++)
5323 {
5324 const int kg = k + offset;
5325
5326 const double dz = delta_z_maillage[k];
5327 const double dz_m1 = kg==0 ? 0. : delta_z_maillage[k-1];
5328 const double delta_m = kg==0 ? 0.5*dz : 0.5*(dz + delta_z_maillage[k-1]);
5329 const double delta_p = kg==(nktot-1) ? 0.5*dz : 0.5*(dz + delta_z_maillage[k+1]);
5330
5331 const double deltaunsurdz = delta_z_pour_delta[k] * 1./dz;
5332 const double deltaunsurdz_m1 = kg==0 ? 0. : delta_z_pour_delta[k-1] * 1./dz_m1;
5333 const double deltaunsurdelta_m = kg==0 ? 0. : 0.5*(delta_z_pour_delta[k] + delta_z_pour_delta[k-1]) * 1./delta_m;
5334 const double deltaunsurdelta_p = kg==(nktot-1) ? 0. : 0.5*(delta_z_pour_delta[k] + delta_z_pour_delta[k+1]) * 1./delta_p;
5335
5336 const double uf_i = vitesse_i(i,j,k);
5337 const double uf_ip1 = vitesse_i(i+1,j,k);
5338 const double uf_im1 = vitesse_i(i-1,j,k);
5339 const double uf_i_jm1 = vitesse_i(i,j-1,k);
5340 const double uf_i_jp1 = vitesse_i(i,j+1,k);
5341 const double uf_i_km1 = kg==0 ? 0. : vitesse_i(i,j,k-1);
5342 const double uf_i_kp1 = kg==(nktot-1) ? 0. : vitesse_i(i,j,k+1);
5343
5344 const double vf_j = vitesse_j(i,j,k);
5345 const double vf_j_im1 = vitesse_j(i-1,j,k);
5346 const double vf_j_ip1 = vitesse_j(i+1,j,k);
5347 const double vf_jp1 = vitesse_j(i,j+1,k);
5348 const double vf_jm1 = vitesse_j(i,j-1,k);
5349 const double vf_j_km1 = kg==0 ? 0. : vitesse_j(i,j,k-1);
5350 const double vf_j_kp1 = kg==(nktot-1) ? 0. : vitesse_j(i,j,k+1);
5351
5352 const double wf_k = vitesse_k(i,j,k);
5353 const double wf_k_im1 = vitesse_k(i-1,j,k);
5354 const double wf_k_ip1 = vitesse_k(i+1,j,k);
5355 const double wf_k_jm1 = vitesse_k(i,j-1,k);
5356 const double wf_k_jp1 = vitesse_k(i,j+1,k);
5357 const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
5358 const double wf_km1 = kg==0 ? 0. : vitesse_k(i,j,k-1);
5359
5360 const double duidx = deltaunsurdx * (uf_ip1 - uf_i);
5361 const double dujdy = deltaunsurdy * (vf_jp1 - vf_j);
5362 const double dukdz = deltaunsurdz * (wf_kp1 - wf_k);
5363
5364 const double duidx_im1 = deltaunsurdx * (uf_i - uf_im1);
5365 const double dujdy_jm1 = deltaunsurdy * (vf_j - vf_jm1);
5366 const double dukdz_km1 = deltaunsurdz_m1 * (wf_k - wf_km1);
5367
5368 const double duidy_ij = deltaunsurdy * (uf_i - uf_i_jm1);
5369 const double duidy_ijp1 = deltaunsurdy * (uf_i_jp1 - uf_i);
5370
5371 const double duidz_ik = deltaunsurdelta_m * (uf_i - uf_i_km1);
5372 const double duidz_ikp1 = deltaunsurdelta_p * (uf_i_kp1 - uf_i);
5373
5374 const double dujdx_ij = deltaunsurdx * (vf_j - vf_j_im1);
5375 const double dujdx_ip1j = deltaunsurdx * (vf_j_ip1 - vf_j);
5376
5377 const double dujdz_jk = deltaunsurdelta_m * (vf_j - vf_j_km1);
5378 const double dujdz_jkp1 = deltaunsurdelta_p * (vf_j_kp1 - vf_j);
5379
5380 const double dukdx_ik = deltaunsurdx * (wf_k - wf_k_im1);
5381 const double dukdx_ip1k = deltaunsurdx * (wf_k_ip1 - wf_k);
5382
5383 const double dukdy_jk = deltaunsurdy * (wf_k - wf_k_jm1);
5384 const double dukdy_jp1k = deltaunsurdy * (wf_k_jp1 - wf_k);
5385
5386 const double g_fi_ii = 0.5 * (duidx_im1 + duidx);
5387 const double g_fi_ij = 0.5 * (duidy_ijp1 + duidy_ij);
5388 const double g_fi_ik = 0.5 * (duidz_ikp1 + duidz_ik);
5389 const double g_fj_ji = 0.5 * (dujdx_ip1j + dujdx_ij);
5390 const double g_fj_jj = 0.5 * (dujdy_jm1 + dujdy);
5391 const double g_fj_jk = 0.5 * (dujdz_jkp1 + dujdz_jk);
5392 const double g_fk_ki = 0.5 * (dukdx_ip1k + dukdx_ik);
5393 const double g_fk_kj = 0.5 * (dukdy_jp1k + dukdy_jk);
5394 const double g_fk_kk = 0.5 * (dukdz_km1 + dukdz);
5395
5396 const double scalar = champ_scalar(i,j,k);
5397
5398 const double scalar_im1 = champ_scalar(i-1,j,k);
5399 const double scalar_ip1 = champ_scalar(i+1,j,k);
5400 const double scalar_im1_jm1 = champ_scalar(i-1,j-1,k);
5401 const double scalar_ip1_jm1 = champ_scalar(i+1,j-1,k);
5402 const double scalar_im1_km1 = kg==0 ? scalar_kmin : champ_scalar(i-1,j,k-1);
5403 const double scalar_ip1_km1 = kg==0 ? scalar_kmin : champ_scalar(i+1,j,k-1);
5404
5405 const double scalar_jm1 = champ_scalar(i,j-1,k);
5406 const double scalar_jp1 = champ_scalar(i,j+1,k);
5407 const double scalar_jm1_km1 = kg==0 ? scalar_kmin : champ_scalar(i,j-1,k-1);
5408 const double scalar_jp1_km1 = kg==0 ? scalar_kmin : champ_scalar(i,j+1,k-1);
5409
5410 const double scalar_km1 = kg==0 ? scalar_kmin : champ_scalar(i,j,k-1);
5411 const double scalar_kp1 = kg==(nktot-1) ? scalar_kmax : champ_scalar(i,j,k+1);
5412
5413 const double scalar_im1_jp1 = champ_scalar(i-1,j+1,k);
5414 const double scalar_im1_kp1 = kg==(nktot-1) ? scalar_kmax : champ_scalar(i-1,j,k+1);
5415 const double scalar_jm1_kp1 = kg==(nktot-1) ? scalar_kmax : champ_scalar(i,j-1,k+1);
5416
5417 const double dscalardxf_i = deltaunsurdx * (scalar - scalar_im1);
5418 const double dscalardxf_ip1 = deltaunsurdx * (scalar_ip1 - scalar);
5419 const double dscalardxf_i_jm1 = deltaunsurdx * (scalar_jm1 - scalar_im1_jm1);
5420 const double dscalardxf_ip1_jm1 = deltaunsurdx * (scalar_ip1_jm1 - scalar_jm1);
5421 const double dscalardxf_i_km1 = deltaunsurdx * (scalar_km1 - scalar_im1_km1);
5422 const double dscalardxf_ip1_km1 = deltaunsurdx * (scalar_ip1_km1 - scalar_km1);
5423
5424 const double dscalardyf_j = deltaunsurdy * (scalar - scalar_jm1);
5425 const double dscalardyf_jp1 = deltaunsurdy * (scalar_jp1 - scalar);
5426 const double dscalardyf_j_im1 = deltaunsurdy * (scalar_im1 - scalar_im1_jm1);
5427 const double dscalardyf_jp1_im1 = deltaunsurdy * (scalar_im1_jp1 - scalar_im1);
5428 const double dscalardyf_j_km1 = deltaunsurdy * (scalar_km1 - scalar_jm1_km1);
5429 const double dscalardyf_jp1_km1 = deltaunsurdy * (scalar_jp1_km1 - scalar_km1);
5430
5431 const double dscalardzf_k = deltaunsurdelta_m * (scalar - scalar_km1);
5432 const double dscalardzf_kp1 = deltaunsurdelta_p * (scalar_kp1 - scalar);
5433 const double dscalardzf_k_im1 = deltaunsurdelta_m * (scalar_im1 - scalar_im1_km1);
5434 const double dscalardzf_kp1_im1 = deltaunsurdelta_p * (scalar_im1_kp1 - scalar_im1);
5435 const double dscalardzf_k_jm1 = deltaunsurdelta_m * (scalar_jm1 - scalar_jm1_km1);
5436 const double dscalardzf_kp1_jm1 = deltaunsurdelta_p * (scalar_jm1_kp1 - scalar_jm1);
5437
5438 const double q_fi_i = dscalardxf_i;
5439 const double q_fi_j = 0.25 * (dscalardyf_jp1_im1 + dscalardyf_jp1 + dscalardyf_j_im1 + dscalardyf_j);
5440 const double q_fi_k = 0.25 * (dscalardzf_kp1_im1 + dscalardzf_kp1 + dscalardzf_k_im1 + dscalardzf_k);
5441
5442 const double q_fj_i = 0.25 * (dscalardxf_ip1_jm1 + dscalardxf_ip1 + dscalardxf_i_jm1 + dscalardxf_i);
5443 const double q_fj_j = dscalardyf_j;
5444 const double q_fj_k = 0.25 * (dscalardzf_kp1_jm1 + dscalardzf_kp1 + dscalardzf_k_jm1 + dscalardzf_k);
5445
5446 const double q_fk_i = 0.25 * (dscalardxf_ip1_km1 + dscalardxf_ip1 + dscalardxf_i_km1 + dscalardxf_i);
5447 const double q_fk_j = 0.25 * (dscalardyf_jp1_km1 + dscalardyf_jp1 + dscalardyf_j_km1 + dscalardyf_j);
5448 const double q_fk_k = dscalardzf_k;
5449
5450 const double c_i = g_fi_ii*q_fi_i + g_fi_ij*q_fi_j + g_fi_ik*q_fi_k;
5451 const double c_j = g_fj_ji*q_fj_i + g_fj_jj*q_fj_j + g_fj_jk*q_fj_k;
5452 const double c_k = g_fk_ki*q_fk_i + g_fk_kj*q_fk_j + g_fk_kk*q_fk_k;
5453
5454 structural_uscalar_x(i,j,k) = - coefficient_x * structural_uscalar_model_constant * c_i/12.;
5455 structural_uscalar_y(i,j,k) = - coefficient_y * structural_uscalar_model_constant * c_j/12.;
5456 structural_uscalar_z(i,j,k) = - coefficient_z * structural_uscalar_model_constant * c_k/12.;
5457 }
5458 }
5459 }
5460}
5461
5462
5463template<class T>
5464void calculer_structural_uscalar_similarity_comp(const double structural_uscalar_model_constant,
5465 const ArrOfDouble& structural_uscalar_vector_coefficients,
5466 const IJK_Field_double& rho,
5467 const IJK_Field_vector3_double& velocity,
5468 const IJK_Field_vector3_double& velocity_filtre,
5469 const IJK_Field_double& champ_scalar,
5470 const IJK_Field_double& champ_scalar_filtre,
5471 double scalar_kmin, double scalar_kmax,
5472 const ArrOfDouble_with_ghost& delta_z,
5473 const double facteur_delta_x,
5474 const double facteur_delta_y,
5475 const ArrOfDouble_with_ghost& delta_z_pour_delta,
5476 T& kernel,
5479 IJK_Field_vector3_double& structural_uscalar_vector)
5480{
5481 const IJK_Field_double& vitesse_i = velocity[0];
5482 const IJK_Field_double& vitesse_j = velocity[1];
5483 const IJK_Field_double& vitesse_k = velocity[2];
5484 const IJK_Field_double& masse_vol_ijk = rho;
5485 IJK_Field_local_double& masse_vol_ijk_filtre = tmp_b[9];
5486 IJK_Field_local_double& aa_rho_ijk_filtre = tmp_a[9];
5487
5488 // const IJK_Field_double& vitesse_i_filtre = velocity_filtre[0];
5489 // const IJK_Field_double& vitesse_j_filtre = velocity_filtre[1];
5490 // const IJK_Field_double& vitesse_k_filtre = velocity_filtre[2];
5491
5492 IJK_Field_double& structural_uscalar_x = structural_uscalar_vector[0];
5493 IJK_Field_double& structural_uscalar_y = structural_uscalar_vector[1];
5494 IJK_Field_double& structural_uscalar_z = structural_uscalar_vector[2];
5495
5496 const double& coefficient_x = structural_uscalar_vector_coefficients[0];
5497 const double& coefficient_y = structural_uscalar_vector_coefficients[1];
5498 const double& coefficient_z = structural_uscalar_vector_coefficients[2];
5499
5500 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
5501 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
5502 const double dx_pour_delta = facteur_delta_x*dx;
5503 const double dy_pour_delta = facteur_delta_y*dy;
5504
5505 const int ni = vitesse_k.ni();
5506 const int nj = vitesse_k.nj();
5507 const int nk = vitesse_k.nk();
5508
5509 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
5510 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
5511
5512 IJK_Field_local_double& b_is = tmp_b[0];
5513 IJK_Field_local_double& b_js = tmp_b[1];
5514 IJK_Field_local_double& b_ks = tmp_b[2];
5515 IJK_Field_local_double& bb_is = tmp_b[3];
5516 IJK_Field_local_double& bb_js = tmp_b[4];
5517 IJK_Field_local_double& bb_ks = tmp_b[5];
5518 IJK_Field_local_double& bbT_i = tmp_b[6];
5519 IJK_Field_local_double& bbT_j = tmp_b[7];
5520 IJK_Field_local_double& bbT_k = tmp_b[8];
5521
5522 IJK_Field_local_double& a_is = tmp_a[0];
5523 IJK_Field_local_double& a_js = tmp_a[1];
5524 IJK_Field_local_double& a_ks = tmp_a[2];
5525 IJK_Field_local_double& aa_is = tmp_a[3];
5526 IJK_Field_local_double& aa_js = tmp_a[4];
5527 IJK_Field_local_double& aa_ks = tmp_a[5];
5528 IJK_Field_local_double& aaT_i = tmp_a[6];
5529 IJK_Field_local_double& aaT_j = tmp_a[7];
5530 IJK_Field_local_double& aaT_k = tmp_a[8];
5531
5532 const int ghost_size_filter = kernel->ghost_size();
5533 const int size_uniform = kernel->size_uniform();
5534 const int shift_uniform = kernel->shift_uniform();
5535 for (int k = 0; k < nk; k++)
5536 {
5537 const int kg = k + offset;
5538
5539 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
5540 const double dz_m1_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z[k-1];
5541 const double delta_m_glo = kg==0 ? 0.5*dz_glo : 0.5*(dz_glo + dz_m1_glo);
5542
5543 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
5544 const double dz_m1_pour_delta_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1];
5545 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);
5546
5547 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
5548 const FixedVector<double, 21> filter_kernel_z_face = kernel->inhomogeneous(false, k, kg, nktot, delta_m_pour_delta_glo, delta_z);
5549 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
5550 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
5551 const int size_k_elem = kernel->size_k_elem(kg, nktot);
5552 const int size_k_face = kernel->size_k_face(kg, nktot);
5553 const int shift_k_elem = kernel->shift_k_elem(kg);
5554 const int shift_k_face = kernel->shift_k_face(kg);
5555 const bool ponderation_filter_kernel = kernel->ponderation();
5556 const bool normalisation_filter_kernel = kernel->normalisation();
5557
5558 double facteur_elem = 0.;
5559 if (ponderation_filter_kernel)
5560 {
5561 if (normalisation_filter_kernel)
5562 {
5563 double longueur_elem = 0.;
5564 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
5565 {
5566 const int kpg = kg + kp;
5567 if (kpg<-1 || kpg>nktot)
5568 {
5569 Cerr << "This should not happen." << finl;
5570 Process::exit();
5571 }
5572 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5573 const double filter_coef_z = filter_kernel_z[kp+10];
5574 longueur_elem += filter_coef_z * dz;
5575 }
5576 facteur_elem = 1./longueur_elem;
5577 }
5578 else
5579 {
5580 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
5581 }
5582 }
5583 double facteur_face = 0.;
5584 if (ponderation_filter_kernel)
5585 {
5586 if (normalisation_filter_kernel)
5587 {
5588 double longueur_face = 0.;
5589 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
5590 {
5591 const int kpg = kg + kp;
5592 if (kpg<0 || kpg>nktot)
5593 {
5594 Cerr << "This should not happen." << finl;
5595 Process::exit();
5596 }
5597 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5598 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
5599 const double dzf = 0.5*(dz + dz_m1);
5600 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
5601 longueur_face += filter_coef_z_face * dzf;
5602 }
5603 facteur_face = 1./longueur_face;
5604 }
5605 else
5606 {
5607 facteur_face = delta_m_glo==0. ? 0. : 1./delta_m_glo;
5608 }
5609 }
5610
5611 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
5612 {
5613 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
5614 {
5615 b_is(i, j, 0) = 0.;
5616 b_js(i, j, 0) = 0.;
5617 b_ks(i, j, 0) = 0.;
5618 bb_is(i, j, 0) = 0.;
5619 bb_js(i, j, 0) = 0.;
5620 bb_ks(i, j, 0) = 0.;
5621 bbT_i(i, j, 0) = 0.;
5622 bbT_j(i, j, 0) = 0.;
5623 bbT_k(i, j, 0) = 0.;
5624 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
5625 {
5626 const int kpg = kg + kp;
5627 if (!(kernel->is_at_wall_elem(kpg, nktot)))
5628 {
5629 const double filter_coef_z = filter_kernel_z[kp+10];
5630
5631 const double rho_ijk = masse_vol_ijk(i,j,k+kp);
5632 const double scalar = champ_scalar(i,j,k+kp);
5633 // const double scalar_im1 = champ_scalar(i-1,j,k+kp);
5634 // const double scalar_jm1 = champ_scalar(i,j-1,k+kp);
5635 const double scalarf_i = (scalar);
5636 const double scalarf_j = (scalar);
5637
5638 const double uf_i = 0.5*(vitesse_i(i,j,k+kp)+vitesse_i(i+1,j,k+kp));
5639 const double vf_j = 0.5*(vitesse_j(i,j,k+kp)+vitesse_j(i,j+1,k+kp));
5640
5641 if (ponderation_filter_kernel)
5642 {
5643 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5644 b_is(i, j, 0) += rho_ijk*uf_i*scalarf_i * filter_coef_z * dz * facteur_elem;
5645 b_js(i, j, 0) += rho_ijk*vf_j*scalarf_j * filter_coef_z * dz * facteur_elem;
5646 bb_is(i, j, 0) += rho_ijk*uf_i * filter_coef_z * dz * facteur_elem;
5647 bb_js(i, j, 0) += rho_ijk*vf_j * filter_coef_z * dz * facteur_elem;
5648 bbT_i(i, j, 0) += rho_ijk*scalarf_i * filter_coef_z * dz * facteur_elem;
5649 bbT_j(i, j, 0) += rho_ijk*scalarf_j * filter_coef_z * dz * facteur_elem;
5650 masse_vol_ijk_filtre(i, j, 0) += rho_ijk * filter_coef_z * dz * facteur_elem;
5651 }
5652 else
5653 {
5654 b_is(i, j, 0) += rho_ijk*uf_i*scalarf_i * filter_coef_z;
5655 b_js(i, j, 0) += rho_ijk*vf_j*scalarf_j * filter_coef_z;
5656 bb_is(i, j, 0) += rho_ijk*uf_i * filter_coef_z;
5657 bb_js(i, j, 0) += rho_ijk*vf_j * filter_coef_z;
5658 bbT_i(i, j, 0) += rho_ijk*scalarf_i * filter_coef_z;
5659 bbT_j(i, j, 0) += rho_ijk*scalarf_j * filter_coef_z;
5660 masse_vol_ijk_filtre(i, j, 0) += rho_ijk * filter_coef_z;
5661 }
5662 }
5663 }
5664 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
5665 {
5666 const int kpg = kg + kp;
5667 if (!(kernel->is_at_wall_face(kpg, nktot)))
5668 {
5669 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
5670
5671 const double rho_ijk = masse_vol_ijk(i,j,k+kp);
5672 const double scalar = champ_scalar(i,j,k+kp);
5673 // const double scalar_km1 = kpg==0 ? scalar_kmin : champ_scalar(i,j,k-1+kp);
5674 const double scalarf_k = (scalar);
5675
5676 const double wf_k = kpg==(nktot-1) ? 0. : 0.5*(vitesse_k(i,j,k+kp)+vitesse_k(i,j,k+kp+1));
5677
5678 if (ponderation_filter_kernel)
5679 {
5680 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5681 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
5682 const double dzf = 0.5*(dz + dz_m1);
5683 b_ks(i, j, 0) += rho_ijk*wf_k*scalarf_k * filter_coef_z_face * dzf * facteur_face;
5684 bb_ks(i, j, 0) += rho_ijk*wf_k*scalarf_k * filter_coef_z_face * dzf * facteur_face;
5685 bbT_k(i, j, 0) += rho_ijk*scalarf_k * filter_coef_z_face * dzf * facteur_face;
5686 }
5687 else
5688 {
5689 b_ks(i, j, 0) += rho_ijk*wf_k*scalarf_k * filter_coef_z_face;
5690 bb_ks(i, j, 0) += rho_ijk*wf_k*scalarf_k * filter_coef_z_face;
5691 bbT_k(i, j, 0) += rho_ijk*scalarf_k * filter_coef_z_face;
5692 }
5693 }
5694 }
5695 }
5696 }
5697 for (int j = 0; j < nj; j++)
5698 {
5699 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
5700 {
5701 a_is(i, 0, 0) = 0.;
5702 a_js(i, 0, 0) = 0.;
5703 a_ks(i, 0, 0) = 0.;
5704 aa_is(i, 0, 0) = 0.;
5705 aa_js(i, 0, 0) = 0.;
5706 aa_ks(i, 0, 0) = 0.;
5707 aaT_i(i, 0, 0) = 0.;
5708 aaT_j(i, 0, 0) = 0.;
5709 aaT_k(i, 0, 0) = 0.;
5710 aa_rho_ijk_filtre(i, 0, 0) = 0.;
5711 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
5712 {
5713 const double filter_coef_y = filter_kernel_y[jp+10];
5714 a_is(i, 0, 0) += b_is(i, j+jp, 0) * filter_coef_y;
5715 a_js(i, 0, 0) += b_js(i, j+jp, 0) * filter_coef_y;
5716 a_ks(i, 0, 0) += b_ks(i, j+jp, 0) * filter_coef_y;
5717 aa_is(i, 0, 0) += bb_is(i, j+jp, 0) * filter_coef_y;
5718 aa_js(i, 0, 0) += bb_js(i, j+jp, 0) * filter_coef_y;
5719 aa_ks(i, 0, 0) += bb_ks(i, j+jp, 0) * filter_coef_y;
5720 aaT_i(i, 0, 0) += bbT_i(i, j+jp, 0) * filter_coef_y;
5721 aaT_j(i, 0, 0) += bbT_j(i, j+jp, 0) * filter_coef_y;
5722 aaT_k(i, 0, 0) += bbT_k(i, j+jp, 0) * filter_coef_y;
5723 aa_rho_ijk_filtre(i, 0, 0) += masse_vol_ijk_filtre(i, j+jp, 0)* filter_coef_y;
5724 }
5725 }
5726
5727 for (int i = 0; i < ni; i++)
5728 {
5729 double r_is = 0.;
5730 double r_js = 0.;
5731 double r_ks = 0.;
5732 double rho_uf_i = 0.;
5733 double rho_vf_j = 0.;
5734 double rho_wf_k = 0.;
5735 double rho_scalarf_i = 0.;
5736 double rho_scalarf_j = 0.;
5737 double rho_scalarf_k = 0.;
5738 double rho_filtre = 0.;
5739 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
5740 {
5741 const double filter_coef_x = filter_kernel_x[ip+10];
5742 r_is += a_is(i+ip, 0, 0) * filter_coef_x;
5743 r_js += a_js(i+ip, 0, 0) * filter_coef_x;
5744 r_ks += a_ks(i+ip, 0, 0) * filter_coef_x;
5745 rho_uf_i += aa_is(i+ip, 0, 0) * filter_coef_x;
5746 rho_vf_j += aa_js(i+ip, 0, 0) * filter_coef_x;
5747 rho_wf_k += aa_ks(i+ip, 0, 0) * filter_coef_x;
5748 rho_scalarf_i += aaT_i(i+ip, 0, 0) * filter_coef_x;
5749 rho_scalarf_j += aaT_j(i+ip, 0, 0) * filter_coef_x;
5750 rho_scalarf_k += aaT_k(i+ip, 0, 0) * filter_coef_x;
5751 rho_filtre += aa_rho_ijk_filtre(i+ip, 0, 0)* filter_coef_x;
5752 }
5753
5754 Cerr << "i=" << i << finl;
5755 Cerr << "j=" << j << finl;
5756 Cerr << "k=" << k << finl;
5757 Cerr << "rho_filtre=" << rho_filtre << finl;
5758 Cerr << "r_is=" << r_is << finl;
5759 Cerr << "rho_uf_i=" << rho_uf_i << finl;
5760 Cerr << "rho_scalarf_i=" << rho_scalarf_i << finl;
5761 Cerr << "-----------------------" << finl;
5762
5763 const double c_is = (r_is)/rho_filtre - (rho_uf_i*rho_scalarf_i)/(rho_filtre*rho_filtre);
5764 const double c_js = (r_js)/rho_filtre - (rho_vf_j*rho_scalarf_j)/(rho_filtre*rho_filtre);
5765 const double c_ks = (r_ks)/rho_filtre - (rho_wf_k*rho_scalarf_k)/(rho_filtre*rho_filtre);
5766
5767 structural_uscalar_x(i,j,k) = - coefficient_x * structural_uscalar_model_constant * c_is;
5768 structural_uscalar_y(i,j,k) = - coefficient_y * structural_uscalar_model_constant * c_js;
5769 structural_uscalar_z(i,j,k) = - coefficient_z * structural_uscalar_model_constant * c_ks;
5770 }
5771 }
5772 }
5773}
5774
5775template<class T>
5776void calculer_structural_uscalar_similarity(const double structural_uscalar_model_constant,
5777 const ArrOfDouble& structural_uscalar_vector_coefficients,
5778 const IJK_Field_vector3_double& velocity,
5779 const IJK_Field_vector3_double& velocity_filtre,
5780 const IJK_Field_double& champ_scalar,
5781 const IJK_Field_double& champ_scalar_filtre,
5782 double scalar_kmin, double scalar_kmax,
5783 const ArrOfDouble_with_ghost& delta_z,
5784 const double facteur_delta_x,
5785 const double facteur_delta_y,
5786 const ArrOfDouble_with_ghost& delta_z_pour_delta,
5787 T& kernel,
5790 IJK_Field_vector3_double& structural_uscalar_vector)
5791{
5792 const IJK_Field_double& vitesse_i = velocity[0];
5793 const IJK_Field_double& vitesse_j = velocity[1];
5794 const IJK_Field_double& vitesse_k = velocity[2];
5795
5796 const IJK_Field_double& vitesse_i_filtre = velocity_filtre[0];
5797 const IJK_Field_double& vitesse_j_filtre = velocity_filtre[1];
5798 const IJK_Field_double& vitesse_k_filtre = velocity_filtre[2];
5799
5800 IJK_Field_double& structural_uscalar_x = structural_uscalar_vector[0];
5801 IJK_Field_double& structural_uscalar_y = structural_uscalar_vector[1];
5802 IJK_Field_double& structural_uscalar_z = structural_uscalar_vector[2];
5803
5804 const double& coefficient_x = structural_uscalar_vector_coefficients[0];
5805 const double& coefficient_y = structural_uscalar_vector_coefficients[1];
5806 const double& coefficient_z = structural_uscalar_vector_coefficients[2];
5807
5808 const double dx = vitesse_k.get_domaine().get_constant_delta(DIRECTION_I);
5809 const double dy = vitesse_k.get_domaine().get_constant_delta(DIRECTION_J);
5810 const double dx_pour_delta = facteur_delta_x*dx;
5811 const double dy_pour_delta = facteur_delta_y*dy;
5812
5813 const int ni = vitesse_k.ni();
5814 const int nj = vitesse_k.nj();
5815 const int nk = vitesse_k.nk();
5816
5817 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
5818 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
5819
5820 IJK_Field_local_double& b_is = tmp_b[0];
5821 IJK_Field_local_double& b_js = tmp_b[1];
5822 IJK_Field_local_double& b_ks = tmp_b[2];
5823
5824 IJK_Field_local_double& a_is = tmp_a[0];
5825 IJK_Field_local_double& a_js = tmp_a[1];
5826 IJK_Field_local_double& a_ks = tmp_a[2];
5827
5828 const int ghost_size_filter = kernel->ghost_size();
5829 const int size_uniform = kernel->size_uniform();
5830 const int shift_uniform = kernel->shift_uniform();
5831 for (int k = 0; k < nk; k++)
5832 {
5833 const int kg = k + offset;
5834
5835 const double dz_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z[k];
5836 const double dz_m1_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z[k-1];
5837 const double delta_m_glo = kg==0 ? 0.5*dz_glo : 0.5*(dz_glo + dz_m1_glo);
5838
5839 const double dz_pour_delta_glo = (kg<0 || kg>(nktot-1)) ? 0. : delta_z_pour_delta[k];
5840 const double dz_m1_pour_delta_glo = (kg-1<0 || kg-1>(nktot-1)) ? 0. : delta_z_pour_delta[k-1];
5841 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);
5842
5843 const FixedVector<double, 21> filter_kernel_z = kernel->inhomogeneous(true, k, kg, nktot, dz_pour_delta_glo, delta_z);
5844 const FixedVector<double, 21> filter_kernel_z_face = kernel->inhomogeneous(false, k, kg, nktot, delta_m_pour_delta_glo, delta_z);
5845 const FixedVector<double, 21> filter_kernel_x = kernel->uniform(dx_pour_delta, dx);
5846 const FixedVector<double, 21> filter_kernel_y = kernel->uniform(dy_pour_delta, dy);
5847 const int size_k_elem = kernel->size_k_elem(kg, nktot);
5848 const int size_k_face = kernel->size_k_face(kg, nktot);
5849 const int shift_k_elem = kernel->shift_k_elem(kg);
5850 const int shift_k_face = kernel->shift_k_face(kg);
5851 const bool ponderation_filter_kernel = kernel->ponderation();
5852 const bool normalisation_filter_kernel = kernel->normalisation();
5853
5854 double facteur_elem = 0.;
5855 if (ponderation_filter_kernel)
5856 {
5857 if (normalisation_filter_kernel)
5858 {
5859 double longueur_elem = 0.;
5860 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
5861 {
5862 const int kpg = kg + kp;
5863 if (kpg<-1 || kpg>nktot)
5864 {
5865 Cerr << "This should not happen." << finl;
5866 Process::exit();
5867 }
5868 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5869 const double filter_coef_z = filter_kernel_z[kp+10];
5870 longueur_elem += filter_coef_z * dz;
5871 }
5872 facteur_elem = 1./longueur_elem;
5873 }
5874 else
5875 {
5876 facteur_elem = dz_glo==0. ? 0. : 1./dz_glo;
5877 }
5878 }
5879 double facteur_face = 0.;
5880 if (ponderation_filter_kernel)
5881 {
5882 if (normalisation_filter_kernel)
5883 {
5884 double longueur_face = 0.;
5885 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
5886 {
5887 const int kpg = kg + kp;
5888 if (kpg<0 || kpg>nktot)
5889 {
5890 Cerr << "This should not happen." << finl;
5891 Process::exit();
5892 }
5893 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5894 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
5895 const double dzf = 0.5*(dz + dz_m1);
5896 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
5897 longueur_face += filter_coef_z_face * dzf;
5898 }
5899 facteur_face = 1./longueur_face;
5900 }
5901 else
5902 {
5903 facteur_face = delta_m_glo==0. ? 0. : 1./delta_m_glo;
5904 }
5905 }
5906
5907 for (int j = -ghost_size_filter; j < nj+ghost_size_filter; j++)
5908 {
5909 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
5910 {
5911 b_is(i, j, 0) = 0.;
5912 b_js(i, j, 0) = 0.;
5913 b_ks(i, j, 0) = 0.;
5914 for (int kp = -shift_k_elem; kp < size_k_elem-shift_k_elem; kp++)
5915 {
5916 const int kpg = kg + kp;
5917 if (!(kernel->is_at_wall_elem(kpg, nktot)))
5918 {
5919 const double filter_coef_z = filter_kernel_z[kp+10];
5920
5921 const double scalar = champ_scalar(i,j,k+kp);
5922 const double scalar_im1 = champ_scalar(i-1,j,k+kp);
5923 const double scalar_jm1 = champ_scalar(i,j-1,k+kp);
5924 const double scalarf_i = 0.5*(scalar + scalar_im1);
5925 const double scalarf_j = 0.5*(scalar + scalar_jm1);
5926
5927 const double uf_i = vitesse_i(i,j,k+kp);
5928 const double vf_j = vitesse_j(i,j,k+kp);
5929
5930 if (ponderation_filter_kernel)
5931 {
5932 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5933 b_is(i, j, 0) += uf_i*scalarf_i * filter_coef_z * dz * facteur_elem;
5934 b_js(i, j, 0) += vf_j*scalarf_j * filter_coef_z * dz * facteur_elem;
5935 }
5936 else
5937 {
5938 b_is(i, j, 0) += uf_i*scalarf_i * filter_coef_z;
5939 b_js(i, j, 0) += vf_j*scalarf_j * filter_coef_z;
5940 }
5941 }
5942 }
5943 for (int kp = -shift_k_face; kp < size_k_face-shift_k_face; kp++)
5944 {
5945 const int kpg = kg + kp;
5946 if (!(kernel->is_at_wall_face(kpg, nktot)))
5947 {
5948 const double filter_coef_z_face = filter_kernel_z_face[kp+10];
5949
5950 const double scalar = champ_scalar(i,j,k+kp);
5951 const double scalar_km1 = kpg==0 ? scalar_kmin : champ_scalar(i,j,k-1+kp);
5952 const double scalarf_k = 0.5*(scalar + scalar_km1);
5953
5954 const double wf_k = vitesse_k(i,j,k+kp);
5955
5956 if (ponderation_filter_kernel)
5957 {
5958 const double dz = (kpg<0 || kpg>(nktot-1)) ? 0. : delta_z[k+kp];
5959 const double dz_m1 = (kpg-1<0 || kpg-1>(nktot-1)) ? 0. : delta_z[k-1+kp];
5960 const double dzf = 0.5*(dz + dz_m1);
5961 b_ks(i, j, 0) += wf_k*scalarf_k * filter_coef_z_face * dzf * facteur_face;
5962 }
5963 else
5964 {
5965 b_ks(i, j, 0) += wf_k*scalarf_k * filter_coef_z_face;
5966 }
5967 }
5968 }
5969 }
5970 }
5971 for (int j = 0; j < nj; j++)
5972 {
5973 for (int i = -ghost_size_filter; i < ni+ghost_size_filter; i++)
5974 {
5975 a_is(i, 0, 0) = 0.;
5976 a_js(i, 0, 0) = 0.;
5977 a_ks(i, 0, 0) = 0.;
5978 for (int jp = -shift_uniform; jp < size_uniform-shift_uniform; jp++)
5979 {
5980 const double filter_coef_y = filter_kernel_y[jp+10];
5981 a_is(i, 0, 0) += b_is(i, j+jp, 0) * filter_coef_y;
5982 a_js(i, 0, 0) += b_js(i, j+jp, 0) * filter_coef_y;
5983 a_ks(i, 0, 0) += b_ks(i, j+jp, 0) * filter_coef_y;
5984 }
5985 }
5986
5987 for (int i = 0; i < ni; i++)
5988 {
5989 double r_is = 0.;
5990 double r_js = 0.;
5991 double r_ks = 0.;
5992 for (int ip = -shift_uniform; ip < size_uniform-shift_uniform; ip++)
5993 {
5994 const double filter_coef_x = filter_kernel_x[ip+10];
5995 r_is += a_is(i+ip, 0, 0) * filter_coef_x;
5996 r_js += a_js(i+ip, 0, 0) * filter_coef_x;
5997 r_ks += a_ks(i+ip, 0, 0) * filter_coef_x;
5998 }
5999
6000 const double scalar = champ_scalar_filtre(i,j,k);
6001 const double scalar_im1 = champ_scalar_filtre(i-1,j,k);
6002 const double scalar_jm1 = champ_scalar_filtre(i,j-1,k);
6003 const double scalar_km1 = kg==0 ? scalar_kmin : champ_scalar_filtre(i,j,k-1);
6004 const double scalarf_i = 0.5*(scalar + scalar_im1);
6005 const double scalarf_j = 0.5*(scalar + scalar_jm1);
6006 const double scalarf_k = 0.5*(scalar + scalar_km1);
6007
6008 const double uf_i = vitesse_i_filtre(i,j,k);
6009 const double vf_j = vitesse_j_filtre(i,j,k);
6010 const double wf_k = vitesse_k_filtre(i,j,k);
6011
6012 const double c_is = r_is - uf_i*scalarf_i;
6013 const double c_js = r_js - vf_j*scalarf_j;
6014 const double c_ks = r_ks - wf_k*scalarf_k;
6015
6016 structural_uscalar_x(i,j,k) = - coefficient_x * structural_uscalar_model_constant * c_is;
6017 structural_uscalar_y(i,j,k) = - coefficient_y * structural_uscalar_model_constant * c_js;
6018 structural_uscalar_z(i,j,k) = - coefficient_z * structural_uscalar_model_constant * c_ks;
6019 }
6020 }
6021 }
6022}
6023
6024void calculer_structural_uscalar_similarity_Streher(const double structural_uscalar_model_constant,
6025 const ArrOfDouble& structural_uscalar_vector_coefficients,
6026 const IJK_Field_vector3_double& velocity,
6027 const IJK_Field_double& champ_scalar,
6028 double scalar_kmin, double scalar_kmax,
6029 IJK_Field_vector3_double& structural_uscalar_vector)
6030{
6031 const IJK_Field_double& vitesse_i = velocity[0];
6032 const IJK_Field_double& vitesse_j = velocity[1];
6033 const IJK_Field_double& vitesse_k = velocity[2];
6034
6035 const int ni = vitesse_k.ni();
6036 const int nj = vitesse_k.nj();
6037 const int nk = vitesse_k.nk();
6038
6039 IJK_Field_double& structural_uscalar_x = structural_uscalar_vector[0];
6040 IJK_Field_double& structural_uscalar_y = structural_uscalar_vector[1];
6041 IJK_Field_double& structural_uscalar_z = structural_uscalar_vector[2];
6042
6043 const int nktot = vitesse_k.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
6044 const int offset = vitesse_k.get_domaine().get_offset_local(DIRECTION_K);
6045
6046 for (int k = 0; k < nk; k++)
6047 {
6048 const int kg = k + offset;
6049 for (int j = 0; j < nj; j++)
6050 {
6051 for (int i = 0; i < ni; i++)
6052 {
6053
6054 // const double uf_im1 = vitesse_i(i-1,j,k);
6055 const double uf_i = vitesse_i(i,j,k);
6056 // const double uf_ip1 = vitesse_i(i+1,j,k);
6057 // const double uf_ip2 = vitesse_i(i+2,j,k);
6058
6059 // const double vf_jm1 = vitesse_j(i,j-1,k);
6060 const double vf_j = vitesse_j(i,j,k);
6061 // const double vf_jp1 = vitesse_j(i,j+1,k);
6062 // const double vf_jp2 = vitesse_j(i,j+2,k);
6063
6064 // const double wf_km1 = kg<=1 ? 0. : vitesse_k(i,j,k-1);
6065 const double wf_k = vitesse_k(i,j,k);
6066 // const double wf_kp1 = kg==(nktot-1) ? 0. : vitesse_k(i,j,k+1);
6067 // const double wf_kp2 = kg>=(nktot-2) ? 0. : vitesse_k(i,j,k+2);
6068
6069 const double sf_im2 = champ_scalar(i-2,j,k);
6070 const double sf_im1 = champ_scalar(i-1,j,k);
6071 const double sf_i = champ_scalar(i,j,k);
6072 const double sf_ip1 = champ_scalar(i+1,j,k);
6073 // const double sf_ip2 = champ_scalar(i+2,j,k);
6074
6075 const double sf_jm2 = champ_scalar(i,j-2,k);
6076 const double sf_jm1 = champ_scalar(i,j-1,k);
6077 const double sf_j = champ_scalar(i,j,k);
6078 const double sf_jp1 = champ_scalar(i,j+1,k);
6079 // const double sf_jp2 = champ_scalar(i,j+2,k);
6080
6081 const double sf_km2 = kg<=1 ? scalar_kmin : champ_scalar(i,j,k-2);
6082 const double sf_km1 = kg==0 ? scalar_kmin : champ_scalar(i,j,k-1);
6083 const double sf_k = kg >=(nktot-1) ? scalar_kmax : champ_scalar(i,j,k);
6084 const double sf_kp1 = kg >=(nktot-2) ? scalar_kmax : champ_scalar(i,j,k+1);
6085 // const double sf_kp2 = kg >=(nktot-3) ? scalar_kmax : champ_scalar(i,j,k+2);
6086
6087
6088 const double c_is = uf_i*(sf_i+sf_im1)/2. - (uf_i)*(sf_im2+sf_im1+sf_i+sf_ip1)/4.;
6089 const double c_js = vf_j*(sf_j+sf_jm1)/2. - (vf_j)*(sf_jm2+sf_jm1+sf_j+sf_jp1)/4.;
6090 const double c_ks = wf_k*(sf_k+sf_km1)/2. - (wf_k)*(sf_km2+sf_km1+sf_k+sf_kp1)/4.;
6091
6092 structural_uscalar_x(i,j,k) = - structural_uscalar_model_constant * c_is;
6093 structural_uscalar_y(i,j,k) = - structural_uscalar_model_constant * c_js;
6094 structural_uscalar_z(i,j,k) = - structural_uscalar_model_constant * c_ks;
6095
6096 }
6097 }
6098 }
6099}
6100
6101template<class T>
6102void calculer_structural_uscalar(const Nom& structural_uscalar_model,
6103 const double structural_uscalar_model_constant,
6104 const ArrOfDouble& structural_uscalar_vector_coefficients,
6105 IJK_Field_double& rho,
6106 IJK_Field_vector3_double& velocity,
6107 IJK_Field_vector3_double& velocity_filtre,
6108 IJK_Field_double& scalar,
6109 IJK_Field_double& scalar_filtre,
6110 double scalar_kmin, double scalar_kmax,
6111 const ArrOfDouble_with_ghost& delta_z,
6112 const double facteur_delta_x,
6113 const double facteur_delta_y,
6114 const ArrOfDouble_with_ghost& delta_z_pour_delta,
6115 const double facteur_delta_filtre_x,
6116 const double facteur_delta_filtre_y,
6117 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
6118 T& kernel,
6121 IJK_Field_vector3_double& structural_uscalar_tmp_vector,
6122 const bool flag_structural_uscalar_filtre,
6123 IJK_Field_vector3_double& structural_uscalar_filtre_vector,
6124 IJK_Field_vector3_double& structural_uscalar_vector)
6125{
6126 int ghost_size_filter;
6127 int ghost_size_velocity;
6128 int ghost_size_scalar;
6129 int ghost_size_structural_uscalar_tmp;
6130
6131
6132 if ( structural_uscalar_model == Nom("gradient") )
6133 {
6134 calculer_structural_uscalar_gradient(structural_uscalar_model_constant,
6135 structural_uscalar_vector_coefficients,
6136 velocity, scalar, scalar_kmin, scalar_kmax,
6137 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6138 structural_uscalar_vector);
6139 }
6140 else if ( structural_uscalar_model == Nom("gradient_filtre") )
6141 {
6142 calculer_structural_uscalar_gradient(structural_uscalar_model_constant,
6143 structural_uscalar_vector_coefficients,
6144 velocity, scalar, scalar_kmin, scalar_kmax,
6145 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6146 structural_uscalar_tmp_vector);
6147
6148 ghost_size_filter = 1 + kernel->ghost_size();
6149 ghost_size_structural_uscalar_tmp = max((int) 2, ghost_size_filter);
6150 structural_uscalar_tmp_vector[0].echange_espace_virtuel(ghost_size_structural_uscalar_tmp);
6151 structural_uscalar_tmp_vector[1].echange_espace_virtuel(ghost_size_structural_uscalar_tmp);
6152 structural_uscalar_tmp_vector[2].echange_espace_virtuel(ghost_size_structural_uscalar_tmp);
6153
6154 const int flag_add = 0;
6155 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]);
6156 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]);
6157 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]);
6158 }
6159 else if ( structural_uscalar_model == Nom("similarity") )
6160 {
6161 ghost_size_filter = 1 + kernel->ghost_size();
6162 ghost_size_velocity = max((int) 2, ghost_size_filter);
6163 ghost_size_scalar = max((int) 2, ghost_size_filter);
6164 velocity[0].echange_espace_virtuel(ghost_size_velocity);
6165 velocity[1].echange_espace_virtuel(ghost_size_velocity);
6166 velocity[2].echange_espace_virtuel(ghost_size_velocity);
6167 scalar.echange_espace_virtuel(ghost_size_scalar);
6168
6169 const int flag_add = 0;
6170 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]);
6171 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]);
6172 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]);
6173 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);
6174
6175 velocity_filtre[0].echange_espace_virtuel(2);
6176 velocity_filtre[1].echange_espace_virtuel(2);
6177 velocity_filtre[2].echange_espace_virtuel(2);
6178 scalar_filtre.echange_espace_virtuel(2);
6179
6180 calculer_structural_uscalar_similarity(structural_uscalar_model_constant,
6181 structural_uscalar_vector_coefficients,
6182 velocity, velocity_filtre,
6183 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
6184 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6185 kernel, tmp_b, tmp_a,
6186 structural_uscalar_vector);
6187 }
6188 else if ( structural_uscalar_model == Nom("similarity_comp") )
6189 {
6190 ghost_size_filter = 1 + kernel->ghost_size();
6191 ghost_size_velocity = max((int) 2, ghost_size_filter);
6192 ghost_size_scalar = max((int) 2, ghost_size_filter);
6193 velocity[0].echange_espace_virtuel(ghost_size_velocity);
6194 velocity[1].echange_espace_virtuel(ghost_size_velocity);
6195 velocity[2].echange_espace_virtuel(ghost_size_velocity);
6196 scalar.echange_espace_virtuel(ghost_size_scalar);
6197
6198 const int flag_add = 0;
6199 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]);
6200 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]);
6201 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]);
6202 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);
6203
6204 velocity_filtre[0].echange_espace_virtuel(2);
6205 velocity_filtre[1].echange_espace_virtuel(2);
6206 velocity_filtre[2].echange_espace_virtuel(2);
6207 scalar_filtre.echange_espace_virtuel(2);
6208
6209 calculer_structural_uscalar_similarity_comp(structural_uscalar_model_constant,
6210 structural_uscalar_vector_coefficients,
6211 rho,
6212 velocity, velocity_filtre,
6213 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
6214 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6215 kernel, tmp_b, tmp_a,
6216 structural_uscalar_vector);
6217 }
6218 else if ( structural_uscalar_model == Nom("similarity_streher") )
6219 {
6220 ghost_size_filter = 1 + kernel->ghost_size();
6221 ghost_size_velocity = max((int) 2, ghost_size_filter);
6222 ghost_size_scalar = max((int) 2, ghost_size_filter);
6223 velocity[0].echange_espace_virtuel(ghost_size_velocity);
6224 velocity[1].echange_espace_virtuel(ghost_size_velocity);
6225 velocity[2].echange_espace_virtuel(ghost_size_velocity);
6226 scalar.echange_espace_virtuel(ghost_size_scalar);
6227
6228 const int flag_add = 0;
6229 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]);
6230 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]);
6231 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]);
6232 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);
6233
6234 velocity_filtre[0].echange_espace_virtuel(2);
6235 velocity_filtre[1].echange_espace_virtuel(2);
6236 velocity_filtre[2].echange_espace_virtuel(2);
6237 scalar_filtre.echange_espace_virtuel(2);
6238
6239 calculer_structural_uscalar_similarity_Streher(structural_uscalar_model_constant,
6240 structural_uscalar_vector_coefficients,
6241 velocity,
6242 scalar, scalar_kmin, scalar_kmax,
6243 structural_uscalar_vector);
6244 }
6245 else
6246 {
6247 Cerr << "The name of the structural model for uscalar is unknown." << finl;
6248 Process::exit();
6249 }
6250
6251 if (flag_structural_uscalar_filtre)
6252 {
6253 ghost_size_filter = 1 + kernel->ghost_size();
6254 ghost_size_velocity = max((int) 2, ghost_size_filter);
6255 ghost_size_scalar = max((int) 2, ghost_size_filter);
6256 velocity[0].echange_espace_virtuel(ghost_size_velocity);
6257 velocity[1].echange_espace_virtuel(ghost_size_velocity);
6258 velocity[2].echange_espace_virtuel(ghost_size_velocity);
6259 scalar.echange_espace_virtuel(ghost_size_scalar);
6260
6261 const int flag_add = 0;
6262 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]);
6263 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]);
6264 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]);
6265 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);
6266
6267 velocity_filtre[0].echange_espace_virtuel(2);
6268 velocity_filtre[1].echange_espace_virtuel(2);
6269 velocity_filtre[2].echange_espace_virtuel(2);
6270 scalar_filtre.echange_espace_virtuel(2);
6271
6272 if ( structural_uscalar_model == Nom("gradient") )
6273 {
6274 calculer_structural_uscalar_gradient(structural_uscalar_model_constant,
6275 structural_uscalar_vector_coefficients,
6276 velocity_filtre, scalar_filtre, scalar_kmin, scalar_kmax,
6277 delta_z, facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6278 structural_uscalar_filtre_vector);
6279 }
6280 else if ( structural_uscalar_model == Nom("gradient_filtre") )
6281 {
6282 calculer_structural_uscalar_gradient(structural_uscalar_model_constant,
6283 structural_uscalar_vector_coefficients,
6284 velocity_filtre, scalar_filtre, scalar_kmin, scalar_kmax,
6285 delta_z, facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6286 structural_uscalar_tmp_vector);
6287
6288 ghost_size_filter = 1 + kernel->ghost_size();
6289 ghost_size_structural_uscalar_tmp = max((int) 2, ghost_size_filter);
6290 structural_uscalar_tmp_vector[0].echange_espace_virtuel(ghost_size_structural_uscalar_tmp);
6291 structural_uscalar_tmp_vector[1].echange_espace_virtuel(ghost_size_structural_uscalar_tmp);
6292 structural_uscalar_tmp_vector[2].echange_espace_virtuel(ghost_size_structural_uscalar_tmp);
6293
6294 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]);
6295 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]);
6296 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]);
6297 }
6298 else if ( structural_uscalar_model == Nom("similarity") )
6299 {
6300 Cerr << "The use of a dynamic constant with the SIMILARITY structural model is not allowed." << finl;
6301 Process::exit();
6302 }
6303 }
6304}
6305
6306template<class T>
6307void modification_modele_dynamic_uu_scalar(const bool anisotropic,
6308 const Nom& turbulent_viscosity_dynamic_type,
6309 const Nom& structural_uu_dynamic_type,
6310 const IJK_Field_vector3_double& velocity,
6311 const IJK_Field_vector3_double& velocity_filtre,
6312 const IJK_Field_double& scalar,
6313 const IJK_Field_double& scalar_filtre,
6314 double scalar_kmin, double scalar_kmax,
6315 const ArrOfDouble_with_ghost& delta_z,
6316 const double facteur_delta_x,
6317 const double facteur_delta_y,
6318 const ArrOfDouble_with_ghost& delta_z_pour_delta,
6319 const double facteur_delta_filtre_x,
6320 const double facteur_delta_filtre_y,
6321 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
6322 T& kernel,
6325 ArrOfDouble_with_ghost& constante_modele,
6327 const int turbulent_viscosity,
6328 IJK_Field_double& turbulent_mu,
6329 IJK_Field_double& turbulent_mu_filtre,
6330 const int structural_uu,
6331 FixedVector<IJK_Field_double, 6>& structural_uu_tensor,
6332 FixedVector<IJK_Field_double, 6>& structural_uu_filtre_tensor)
6333{
6334 int ghost_size_filter;
6335 int ghost_size_turbulent_mu;
6336 int ghost_size_structural_uu;
6337 if ( turbulent_viscosity_dynamic_type == Nom("not_dynamic")
6338 && structural_uu_dynamic_type == Nom("not_dynamic") )
6339 {
6340 // do nothing
6341 }
6342 else
6343 {
6344 if (turbulent_viscosity)
6345 {
6346 ghost_size_filter = 1 + kernel->ghost_size();
6347 ghost_size_turbulent_mu = max((int) 2, ghost_size_filter);
6348 turbulent_mu.echange_espace_virtuel(ghost_size_turbulent_mu);
6349 turbulent_mu_filtre.echange_espace_virtuel(2);
6350 }
6351
6352 if (structural_uu)
6353 {
6354 for (int j=0 ; j<6 ; j++)
6355 {
6356 ghost_size_filter = 1 + kernel->ghost_size();
6357 ghost_size_structural_uu = max((int) 2, ghost_size_filter);
6358 structural_uu_tensor[j].echange_espace_virtuel(ghost_size_structural_uu);
6359 structural_uu_filtre_tensor[j].echange_espace_virtuel(2);
6360 }
6361 }
6362
6363 const bool tensorial_struct = structural_uu_dynamic_type.finit_par("tensorial");
6364
6365 calculer_ml_dynamic_uu_tensor(anisotropic, tensorial_struct,
6366 velocity, velocity_filtre,
6367 turbulent_viscosity,
6368 turbulent_mu,
6369 turbulent_mu,
6370 turbulent_mu,
6371 turbulent_mu,
6372 turbulent_mu,
6373 turbulent_mu,
6374 turbulent_mu_filtre,
6375 turbulent_mu_filtre,
6376 turbulent_mu_filtre,
6377 turbulent_mu_filtre,
6378 turbulent_mu_filtre,
6379 turbulent_mu_filtre,
6380 structural_uu,
6381 structural_uu_tensor,
6382 structural_uu_filtre_tensor,
6383 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6384 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6385 kernel, tmp_b, tmp_a,
6386 ml);
6387
6388 FixedVector<ArrOfDouble, 7>& lij = ml[0];
6389 FixedVector<ArrOfDouble, 7>& mij = ml[1];
6390 FixedVector<ArrOfDouble, 7>& hij = ml[2];
6391 FixedVector<ArrOfDouble, 7>& mijmij = ml[3];
6392 FixedVector<ArrOfDouble, 7>& hijhij = ml[4];
6393 FixedVector<ArrOfDouble, 7>& mijlij = ml[5];
6394 FixedVector<ArrOfDouble, 7>& hijlij = ml[6];
6395 FixedVector<ArrOfDouble, 7>& mijhij = ml[7];
6396
6397 ArrOfDouble& moy_lij = ml[0][6];
6398 ArrOfDouble& moy_mij = ml[1][6];
6399 ArrOfDouble& moy_hij = ml[2][6];
6400 ArrOfDouble& moy_mijmij = ml[3][6];
6401 ArrOfDouble& moy_hijhij = ml[4][6];
6402 ArrOfDouble& moy_mijlij = ml[5][6];
6403 ArrOfDouble& moy_hijlij = ml[6][6];
6404 ArrOfDouble& moy_mijhij = ml[7][6];
6405
6406 const bool visc_reconnu = calculer_constante_modele(turbulent_viscosity_dynamic_type,
6407 Nom("uu, viscosity"),
6408 moy_lij, moy_mij, moy_hij,
6409 moy_mijmij, moy_hijhij,
6410 moy_mijlij, moy_hijlij,
6411 moy_mijhij,
6412 velocity, delta_z,
6413 constante_modele);
6414 if (visc_reconnu)
6415 {
6416 const bool flag_face = false;
6417 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu);
6418 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_filtre);
6419 }
6420
6421 const bool struct_reconnu = calculer_constante_modele(structural_uu_dynamic_type,
6422 Nom("uu, structural"),
6423 moy_lij, moy_hij, moy_mij,
6424 moy_hijhij, moy_mijmij,
6425 moy_hijlij, moy_mijlij,
6426 moy_mijhij,
6427 velocity, delta_z,
6428 constante_modele);
6429 if (struct_reconnu)
6430 {
6431 for (int j=0 ; j<6 ; j++)
6432 {
6433 const bool flag_face = (j==2||j==4);
6434 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_tensor[j]);
6435 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_filtre_tensor[j]);
6436 }
6437 }
6438
6439 if (tensorial_struct)
6440 {
6441 Nom struct_dynamic_type = structural_uu_dynamic_type.getPrefix("tensorial");
6442 for (int j=0 ; j<6 ; j++)
6443 {
6444 const bool reconnu = calculer_constante_modele(struct_dynamic_type,
6445 Nom("uu, structural, tensorial, j= ") + Nom(j),
6446 lij[j], hij[j], mij[j],
6447 hijhij[j], mijmij[j],
6448 hijlij[j], mijlij[j],
6449 mijhij[j],
6450 velocity, delta_z,
6451 constante_modele);
6452 if (reconnu)
6453 {
6454 const bool flag_face = (j==2||j==4);
6455 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_tensor[j]);
6456 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_filtre_tensor[j]);
6457 }
6458 else
6459 {
6460 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6461 Process::exit();
6462 }
6463 }
6464 }
6465
6466 const bool twopass_visc = turbulent_viscosity_dynamic_type.finit_par("_twopass");
6467 const bool twopass_struct = structural_uu_dynamic_type.finit_par("_twopass");
6468 if (twopass_visc || twopass_struct)
6469 {
6470 if (!turbulent_viscosity)
6471 {
6472 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;
6473 Process::exit();
6474 }
6475 if (!structural_uu)
6476 {
6477 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;
6478 Process::exit();
6479 }
6480
6481 Nom visc_dynamic_type;
6482 Nom struct_dynamic_type;
6483 if (twopass_visc)
6484 {
6485 Cout << "Second pass, dynamic correction of constant: uu, viscosity" << finl;
6486 visc_dynamic_type = turbulent_viscosity_dynamic_type.getPrefix("_twopass");
6487 struct_dynamic_type = Nom("not_dynamic");
6488 }
6489 else
6490 {
6491 Cout << "Second pass, dynamic correction of constant: uu, structural" << finl;
6492 visc_dynamic_type = Nom("not_dynamic");
6493 struct_dynamic_type = structural_uu_dynamic_type.getPrefix("_twopass");
6494 }
6495
6496 modification_modele_dynamic_uu_scalar(anisotropic,
6497 visc_dynamic_type,
6498 struct_dynamic_type,
6499 velocity, velocity_filtre,
6500 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
6501 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6502 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6503 kernel, tmp_b, tmp_a,
6504 constante_modele, ml,
6505 turbulent_viscosity, turbulent_mu, turbulent_mu_filtre,
6506 structural_uu, structural_uu_tensor, structural_uu_filtre_tensor);
6507 }
6508
6509 if ((!visc_reconnu) && (!struct_reconnu) && (!twopass_visc) && (!tensorial_struct) && (!twopass_struct))
6510 {
6511 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6512 Process::exit();
6513 }
6514 }
6515}
6516
6517template<class T>
6518void modification_modele_dynamic_uu_tensor(const bool anisotropic,
6519 const Nom& turbulent_viscosity_dynamic_type,
6520 const Nom& structural_uu_dynamic_type,
6521 const IJK_Field_vector3_double& velocity,
6522 const IJK_Field_vector3_double& velocity_filtre,
6523 const IJK_Field_double& scalar,
6524 const IJK_Field_double& scalar_filtre,
6525 double scalar_kmin, double scalar_kmax,
6526 const ArrOfDouble_with_ghost& delta_z,
6527 const double facteur_delta_x,
6528 const double facteur_delta_y,
6529 const ArrOfDouble_with_ghost& delta_z_pour_delta,
6530 const double facteur_delta_filtre_x,
6531 const double facteur_delta_filtre_y,
6532 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
6533 T& kernel,
6536 ArrOfDouble_with_ghost& constante_modele,
6538 const int turbulent_viscosity,
6539 FixedVector<IJK_Field_double, 6>& turbulent_mu_tensor,
6540 FixedVector<IJK_Field_double, 6>& turbulent_mu_filtre_tensor,
6541 const int structural_uu,
6542 FixedVector<IJK_Field_double, 6>& structural_uu_tensor,
6543 FixedVector<IJK_Field_double, 6>& structural_uu_filtre_tensor)
6544{
6545 IJK_Field_double& turbulent_mu_xx = turbulent_mu_tensor[0];
6546 IJK_Field_double& turbulent_mu_xy = turbulent_mu_tensor[1];
6547 IJK_Field_double& turbulent_mu_xz = turbulent_mu_tensor[2];
6548 IJK_Field_double& turbulent_mu_yy = turbulent_mu_tensor[3];
6549 IJK_Field_double& turbulent_mu_yz = turbulent_mu_tensor[4];
6550 IJK_Field_double& turbulent_mu_zz = turbulent_mu_tensor[5];
6551
6552 IJK_Field_double& turbulent_mu_filtre_xx = turbulent_mu_filtre_tensor[0];
6553 IJK_Field_double& turbulent_mu_filtre_xy = turbulent_mu_filtre_tensor[1];
6554 IJK_Field_double& turbulent_mu_filtre_xz = turbulent_mu_filtre_tensor[2];
6555 IJK_Field_double& turbulent_mu_filtre_yy = turbulent_mu_filtre_tensor[3];
6556 IJK_Field_double& turbulent_mu_filtre_yz = turbulent_mu_filtre_tensor[4];
6557 IJK_Field_double& turbulent_mu_filtre_zz = turbulent_mu_filtre_tensor[5];
6558
6559 int ghost_size_filter, ghost_size_turbulent_mu, ghost_size_structural_uu;
6560
6561 if ( turbulent_viscosity_dynamic_type == Nom("not_dynamic")
6562 && structural_uu_dynamic_type == Nom("not_dynamic") )
6563 {
6564 // do nothing
6565 }
6566 else
6567 {
6568 if (turbulent_viscosity)
6569 {
6570 for (int j=0 ; j<6 ; j++)
6571 {
6572 ghost_size_filter = 1 + kernel->ghost_size();
6573 ghost_size_turbulent_mu = max((int) 2, ghost_size_filter);
6574 turbulent_mu_tensor[j].echange_espace_virtuel(ghost_size_turbulent_mu);
6575 turbulent_mu_filtre_tensor[j].echange_espace_virtuel(2);
6576 }
6577 }
6578
6579 if (structural_uu)
6580 {
6581 for (int j=0 ; j<6 ; j++)
6582 {
6583 ghost_size_filter = 1 + kernel->ghost_size();
6584 ghost_size_structural_uu = max((int) 2, ghost_size_filter);
6585 structural_uu_tensor[j].echange_espace_virtuel(ghost_size_structural_uu);
6586 structural_uu_filtre_tensor[j].echange_espace_virtuel(2);
6587 }
6588 }
6589
6590 const bool tensorial_visc = turbulent_viscosity_dynamic_type.finit_par("tensorial");
6591 const bool tensorial_struct = structural_uu_dynamic_type.finit_par("tensorial");
6592 const bool tensorial = tensorial_visc || tensorial_struct;
6593
6594 calculer_ml_dynamic_uu_tensor(anisotropic, tensorial,
6595 velocity, velocity_filtre,
6596 turbulent_viscosity,
6597 turbulent_mu_xx,
6598 turbulent_mu_xy,
6599 turbulent_mu_xz,
6600 turbulent_mu_yy,
6601 turbulent_mu_yz,
6602 turbulent_mu_zz,
6603 turbulent_mu_filtre_xx,
6604 turbulent_mu_filtre_xy,
6605 turbulent_mu_filtre_xz,
6606 turbulent_mu_filtre_yy,
6607 turbulent_mu_filtre_yz,
6608 turbulent_mu_filtre_zz,
6609 structural_uu,
6610 structural_uu_tensor,
6611 structural_uu_filtre_tensor,
6612 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6613 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6614 kernel, tmp_b, tmp_a,
6615 ml);
6616
6617 FixedVector<ArrOfDouble, 7>& lij = ml[0];
6618 FixedVector<ArrOfDouble, 7>& mij = ml[1];
6619 FixedVector<ArrOfDouble, 7>& hij = ml[2];
6620 FixedVector<ArrOfDouble, 7>& mijmij = ml[3];
6621 FixedVector<ArrOfDouble, 7>& hijhij = ml[4];
6622 FixedVector<ArrOfDouble, 7>& mijlij = ml[5];
6623 FixedVector<ArrOfDouble, 7>& hijlij = ml[6];
6624 FixedVector<ArrOfDouble, 7>& mijhij = ml[7];
6625
6626 ArrOfDouble& moy_lij = ml[0][6];
6627 ArrOfDouble& moy_mij = ml[1][6];
6628 ArrOfDouble& moy_hij = ml[2][6];
6629 ArrOfDouble& moy_mijmij = ml[3][6];
6630 ArrOfDouble& moy_hijhij = ml[4][6];
6631 ArrOfDouble& moy_mijlij = ml[5][6];
6632 ArrOfDouble& moy_hijlij = ml[6][6];
6633 ArrOfDouble& moy_mijhij = ml[7][6];
6634
6635 const bool visc_reconnu = calculer_constante_modele(turbulent_viscosity_dynamic_type,
6636 Nom("uu, viscosity"),
6637 moy_lij, moy_mij, moy_hij,
6638 moy_mijmij, moy_hijhij,
6639 moy_mijlij, moy_hijlij,
6640 moy_mijhij,
6641 velocity, delta_z,
6642 constante_modele);
6643 if (visc_reconnu)
6644 {
6645 for (int j=0 ; j<6 ; j++)
6646 {
6647 const bool flag_face = false;
6648 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_tensor[j]);
6649 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_filtre_tensor[j]);
6650 }
6651 }
6652
6653 const bool struct_reconnu = calculer_constante_modele(structural_uu_dynamic_type,
6654 Nom("uu, structural"),
6655 moy_lij, moy_hij, moy_mij,
6656 moy_hijhij, moy_mijmij,
6657 moy_hijlij, moy_mijlij,
6658 moy_mijhij,
6659 velocity, delta_z,
6660 constante_modele);
6661 if (struct_reconnu)
6662 {
6663 for (int j=0 ; j<6 ; j++)
6664 {
6665 const bool flag_face = (j==2||j==4);
6666 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_tensor[j]);
6667 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_filtre_tensor[j]);
6668 }
6669 }
6670
6671 if (tensorial_visc)
6672 {
6673 Nom visc_dynamic_type = turbulent_viscosity_dynamic_type.getPrefix("tensorial");
6674 for (int j=0 ; j<6 ; j++)
6675 {
6676 const bool reconnu = calculer_constante_modele(visc_dynamic_type,
6677 Nom("uu, viscosity, tensorial, j= ") + Nom(j),
6678 lij[j], mij[j], hij[j],
6679 mijmij[j], hijhij[j],
6680 mijlij[j], hijlij[j],
6681 mijhij[j],
6682 velocity, delta_z,
6683 constante_modele);
6684 if (reconnu)
6685 {
6686 const bool flag_face = false;
6687 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_tensor[j]);
6688 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_filtre_tensor[j]);
6689 }
6690 else
6691 {
6692 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6693 Process::exit();
6694 }
6695 }
6696 }
6697
6698 if (tensorial_struct)
6699 {
6700 Nom struct_dynamic_type = structural_uu_dynamic_type.getPrefix("tensorial");
6701 for (int j=0 ; j<6 ; j++)
6702 {
6703 const bool reconnu = calculer_constante_modele(struct_dynamic_type,
6704 Nom("uu, structural, tensorial, j= ") + Nom(j),
6705 lij[j], hij[j], mij[j],
6706 hijhij[j], mijmij[j],
6707 hijlij[j], mijlij[j],
6708 mijhij[j],
6709 velocity, delta_z,
6710 constante_modele);
6711 if (reconnu)
6712 {
6713 const bool flag_face = (j==2||j==4);
6714 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_tensor[j]);
6715 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uu_filtre_tensor[j]);
6716 }
6717 else
6718 {
6719 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6720 Process::exit();
6721 }
6722 }
6723 }
6724
6725 const bool twopass_visc = turbulent_viscosity_dynamic_type.finit_par("_twopass");
6726 const bool twopass_struct = structural_uu_dynamic_type.finit_par("_twopass");
6727 if (twopass_visc || twopass_struct)
6728 {
6729 if (!turbulent_viscosity)
6730 {
6731 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;
6732 Process::exit();
6733 }
6734 if (!structural_uu)
6735 {
6736 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;
6737 Process::exit();
6738 }
6739
6740 Nom visc_dynamic_type;
6741 Nom struct_dynamic_type;
6742 if (twopass_visc)
6743 {
6744 Cout << "Second pass, dynamic correction of constant: uu, viscosity" << finl;
6745 visc_dynamic_type = turbulent_viscosity_dynamic_type.getPrefix("_twopass");
6746 struct_dynamic_type = Nom("not_dynamic");
6747 }
6748 else
6749 {
6750 Cout << "Second pass, dynamic correction of constant: uu, structural" << finl;
6751 visc_dynamic_type = Nom("not_dynamic");
6752 struct_dynamic_type = structural_uu_dynamic_type.getPrefix("_twopass");
6753 }
6754
6755 modification_modele_dynamic_uu_tensor(anisotropic,
6756 visc_dynamic_type,
6757 struct_dynamic_type,
6758 velocity, velocity_filtre,
6759 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
6760 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6761 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6762 kernel, tmp_b, tmp_a,
6763 constante_modele, ml,
6764 turbulent_viscosity, turbulent_mu_tensor, turbulent_mu_filtre_tensor,
6765 structural_uu, structural_uu_tensor, structural_uu_filtre_tensor);
6766 }
6767
6768 if ((!visc_reconnu) && (!struct_reconnu) && (!tensorial_visc) && (!tensorial_struct) && (!twopass_visc) && (!twopass_struct))
6769 {
6770 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6771 Process::exit();
6772 }
6773 }
6774}
6775
6776template<class T>
6777void modification_modele_dynamic_uscalar_scalar(const bool anisotropic,
6778 const Nom& turbulent_viscosity_dynamic_type,
6779 const Nom& structural_uscalar_dynamic_type,
6780 const IJK_Field_vector3_double& velocity,
6781 const IJK_Field_vector3_double& velocity_filtre,
6782 const IJK_Field_double& scalar,
6783 const IJK_Field_double& scalar_filtre,
6784 double scalar_kmin, double scalar_kmax,
6785 const ArrOfDouble_with_ghost& delta_z,
6786 const double facteur_delta_x,
6787 const double facteur_delta_y,
6788 const ArrOfDouble_with_ghost& delta_z_pour_delta,
6789 const double facteur_delta_filtre_x,
6790 const double facteur_delta_filtre_y,
6791 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
6792 T& kernel,
6795 ArrOfDouble_with_ghost& constante_modele,
6797 const int turbulent_viscosity,
6798 IJK_Field_double& turbulent_mu,
6799 IJK_Field_double& turbulent_mu_filtre,
6800 const int structural_uscalar,
6801 IJK_Field_vector3_double& structural_uscalar_vector,
6802 IJK_Field_vector3_double& structural_uscalar_filtre_vector)
6803{
6804 int ghost_size_filter, ghost_size_turbulent_mu, ghost_size_structural_uu;
6805 if ( turbulent_viscosity_dynamic_type == Nom("not_dynamic")
6806 && structural_uscalar_dynamic_type == Nom("not_dynamic") )
6807 {
6808 // do nothing
6809 }
6810 else
6811 {
6812 if (turbulent_viscosity)
6813 {
6814 ghost_size_filter = 1 + kernel->ghost_size();
6815 ghost_size_turbulent_mu = max((int) 2, ghost_size_filter);
6816 turbulent_mu.echange_espace_virtuel(ghost_size_turbulent_mu);
6817 turbulent_mu_filtre.echange_espace_virtuel(2);
6818 }
6819
6820 if (structural_uscalar)
6821 {
6822 for (int j=0 ; j<3 ; j++)
6823 {
6824 ghost_size_filter = 1 + kernel->ghost_size();
6825 ghost_size_structural_uu = max((int) 2, ghost_size_filter);
6826 structural_uscalar_vector[j].echange_espace_virtuel(ghost_size_structural_uu);
6827 structural_uscalar_filtre_vector[j].echange_espace_virtuel(2);
6828 }
6829 }
6830
6831 const bool vectorial_struct = structural_uscalar_dynamic_type.finit_par("vectorial");
6832
6833 calculer_ml_dynamic_uscalar_vector(anisotropic, vectorial_struct,
6834 velocity, velocity_filtre,
6835 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
6836 turbulent_viscosity,
6837 turbulent_mu,
6838 turbulent_mu,
6839 turbulent_mu,
6840 turbulent_mu_filtre,
6841 turbulent_mu_filtre,
6842 turbulent_mu_filtre,
6843 structural_uscalar,
6844 structural_uscalar_vector,
6845 structural_uscalar_filtre_vector,
6846 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6847 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6848 kernel, tmp_b, tmp_a,
6849 ml);
6850
6851 FixedVector<ArrOfDouble, 7>& li = ml[0];
6852 FixedVector<ArrOfDouble, 7>& mi = ml[1];
6853 FixedVector<ArrOfDouble, 7>& hi = ml[2];
6854 FixedVector<ArrOfDouble, 7>& mimi = ml[3];
6855 FixedVector<ArrOfDouble, 7>& hihi = ml[4];
6856 FixedVector<ArrOfDouble, 7>& mili = ml[5];
6857 FixedVector<ArrOfDouble, 7>& hili = ml[6];
6858 FixedVector<ArrOfDouble, 7>& mihi = ml[7];
6859
6860 ArrOfDouble& moy_li = ml[0][6];
6861 ArrOfDouble& moy_mi = ml[1][6];
6862 ArrOfDouble& moy_hi = ml[2][6];
6863 ArrOfDouble& moy_mimi = ml[3][6];
6864 ArrOfDouble& moy_hihi = ml[4][6];
6865 ArrOfDouble& moy_mili = ml[5][6];
6866 ArrOfDouble& moy_hili = ml[6][6];
6867 ArrOfDouble& moy_mihi = ml[7][6];
6868
6869 const bool visc_reconnu = calculer_constante_modele(turbulent_viscosity_dynamic_type,
6870 Nom("uscalar, viscosity"),
6871 moy_li, moy_mi, moy_hi,
6872 moy_mimi, moy_hihi,
6873 moy_mili, moy_hili,
6874 moy_mihi,
6875 velocity, delta_z,
6876 constante_modele);
6877 if (visc_reconnu)
6878 {
6879 const bool flag_face = false;
6880 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu);
6881 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_filtre);
6882 }
6883
6884 const bool struct_reconnu = calculer_constante_modele(structural_uscalar_dynamic_type,
6885 Nom("uscalar, structural"),
6886 moy_li, moy_hi, moy_mi,
6887 moy_hihi, moy_mimi,
6888 moy_hili, moy_mili,
6889 moy_mihi,
6890 velocity, delta_z,
6891 constante_modele);
6892 if (struct_reconnu)
6893 {
6894 for (int j=0 ; j<3 ; j++)
6895 {
6896 const bool flag_face = (j==2);
6897 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_vector[j]);
6898 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_filtre_vector[j]);
6899 }
6900 }
6901
6902 if (vectorial_struct)
6903 {
6904 Nom struct_dynamic_type = structural_uscalar_dynamic_type.getPrefix("vectorial");
6905 for (int j=0 ; j<3 ; j++)
6906 {
6907 const bool reconnu = calculer_constante_modele(struct_dynamic_type,
6908 Nom("uscalar, structural, vectorial, j= ") + Nom(j),
6909 li[j], hi[j], mi[j],
6910 hihi[j], mimi[j],
6911 hili[j], mili[j],
6912 mihi[j],
6913 velocity, delta_z,
6914 constante_modele);
6915 if (reconnu)
6916 {
6917 const bool flag_face = (j==2);
6918 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_vector[j]);
6919 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_filtre_vector[j]);
6920 }
6921 else
6922 {
6923 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6924 Process::exit();
6925 }
6926 }
6927 }
6928
6929 const bool twopass_visc = turbulent_viscosity_dynamic_type.finit_par("_twopass");
6930 const bool twopass_struct = structural_uscalar_dynamic_type.finit_par("_twopass");
6931 if (twopass_visc || twopass_struct)
6932 {
6933 if (!turbulent_viscosity)
6934 {
6935 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;
6936 Process::exit();
6937 }
6938 if (!structural_uscalar)
6939 {
6940 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;
6941 Process::exit();
6942 }
6943
6944 Nom visc_dynamic_type;
6945 Nom struct_dynamic_type;
6946 if (twopass_visc)
6947 {
6948 Cout << "Second pass, dynamic correction of constant: uscalar, viscosity" << finl;
6949 visc_dynamic_type = turbulent_viscosity_dynamic_type.getPrefix("_twopass");
6950 struct_dynamic_type = Nom("not_dynamic");
6951 }
6952 else
6953 {
6954 Cout << "Second pass, dynamic correction of constant: uscalar, structural" << finl;
6955 visc_dynamic_type = Nom("not_dynamic");
6956 struct_dynamic_type = structural_uscalar_dynamic_type.getPrefix("_twopass");
6957 }
6958
6959 modification_modele_dynamic_uscalar_scalar(anisotropic,
6960 visc_dynamic_type,
6961 struct_dynamic_type,
6962 velocity, velocity_filtre,
6963 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
6964 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
6965 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
6966 kernel, tmp_b, tmp_a,
6967 constante_modele, ml,
6968 turbulent_viscosity, turbulent_mu, turbulent_mu_filtre,
6969 structural_uscalar, structural_uscalar_vector, structural_uscalar_filtre_vector);
6970 }
6971
6972 if ((!visc_reconnu) && (!struct_reconnu) && (!vectorial_struct) && (!twopass_visc) && (!twopass_struct))
6973 {
6974 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
6975 Process::exit();
6976 }
6977 }
6978}
6979
6980template<class T>
6981void modification_modele_dynamic_uscalar_vector(const bool anisotropic,
6982 const Nom& turbulent_viscosity_dynamic_type,
6983 const Nom& structural_uscalar_dynamic_type,
6984 const IJK_Field_vector3_double& velocity,
6985 const IJK_Field_vector3_double& velocity_filtre,
6986 const IJK_Field_double& scalar,
6987 const IJK_Field_double& scalar_filtre,
6988 double scalar_kmin, double scalar_kmax,
6989 const ArrOfDouble_with_ghost& delta_z,
6990 const double facteur_delta_x,
6991 const double facteur_delta_y,
6992 const ArrOfDouble_with_ghost& delta_z_pour_delta,
6993 const double facteur_delta_filtre_x,
6994 const double facteur_delta_filtre_y,
6995 const ArrOfDouble_with_ghost& delta_z_pour_delta_filtre,
6996 T& kernel,
6999 ArrOfDouble_with_ghost& constante_modele,
7001 const int turbulent_viscosity,
7002 IJK_Field_vector3_double& turbulent_mu_vector,
7003 IJK_Field_vector3_double& turbulent_mu_filtre_vector,
7004 const int structural_uscalar,
7005 IJK_Field_vector3_double& structural_uscalar_vector,
7006 IJK_Field_vector3_double& structural_uscalar_filtre_vector)
7007{
7008 IJK_Field_double& turbulent_mu_x = turbulent_mu_vector[0];
7009 IJK_Field_double& turbulent_mu_y = turbulent_mu_vector[1];
7010 IJK_Field_double& turbulent_mu_z = turbulent_mu_vector[2];
7011
7012 IJK_Field_double& turbulent_mu_filtre_x = turbulent_mu_filtre_vector[0];
7013 IJK_Field_double& turbulent_mu_filtre_y = turbulent_mu_filtre_vector[1];
7014 IJK_Field_double& turbulent_mu_filtre_z = turbulent_mu_filtre_vector[2];
7015
7016 if ( turbulent_viscosity_dynamic_type == Nom("not_dynamic")
7017 && structural_uscalar_dynamic_type == Nom("not_dynamic") )
7018 {
7019 // do nothing
7020 }
7021 else
7022 {
7023 int ghost_size_filter, ghost_size_turbulent_mu, ghost_size_structural_uu;
7024 if (turbulent_viscosity)
7025 {
7026 for (int j=0 ; j<3 ; j++)
7027 {
7028 ghost_size_filter = 1 + kernel->ghost_size();
7029 ghost_size_turbulent_mu = max((int) 2, ghost_size_filter);
7030 turbulent_mu_vector[j].echange_espace_virtuel(ghost_size_turbulent_mu);
7031 turbulent_mu_filtre_vector[j].echange_espace_virtuel(2);
7032 }
7033 }
7034
7035 if (structural_uscalar)
7036 {
7037 for (int j=0 ; j<3 ; j++)
7038 {
7039 ghost_size_filter = 1 + kernel->ghost_size();
7040 ghost_size_structural_uu = max((int) 2, ghost_size_filter);
7041 structural_uscalar_vector[j].echange_espace_virtuel(ghost_size_structural_uu);
7042 structural_uscalar_filtre_vector[j].echange_espace_virtuel(2);
7043 }
7044 }
7045
7046 const bool vectorial_visc = turbulent_viscosity_dynamic_type.finit_par("vectorial");
7047 const bool vectorial_struct = structural_uscalar_dynamic_type.finit_par("vectorial");
7048 const bool vectorial = vectorial_visc || vectorial_struct;
7049
7050 calculer_ml_dynamic_uscalar_vector(anisotropic, vectorial,
7051 velocity, velocity_filtre,
7052 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
7053 turbulent_viscosity,
7054 turbulent_mu_x,
7055 turbulent_mu_y,
7056 turbulent_mu_z,
7057 turbulent_mu_filtre_x,
7058 turbulent_mu_filtre_y,
7059 turbulent_mu_filtre_z,
7060 structural_uscalar,
7061 structural_uscalar_vector,
7062 structural_uscalar_filtre_vector,
7063 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
7064 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
7065 kernel, tmp_b, tmp_a,
7066 ml);
7067
7068 FixedVector<ArrOfDouble, 7>& li = ml[0];
7069 FixedVector<ArrOfDouble, 7>& mi = ml[1];
7070 FixedVector<ArrOfDouble, 7>& hi = ml[2];
7071 FixedVector<ArrOfDouble, 7>& mimi = ml[3];
7072 FixedVector<ArrOfDouble, 7>& hihi = ml[4];
7073 FixedVector<ArrOfDouble, 7>& mili = ml[5];
7074 FixedVector<ArrOfDouble, 7>& hili = ml[6];
7075 FixedVector<ArrOfDouble, 7>& mihi = ml[7];
7076
7077 ArrOfDouble& moy_li = ml[0][6];
7078 ArrOfDouble& moy_mi = ml[1][6];
7079 ArrOfDouble& moy_hi = ml[2][6];
7080 ArrOfDouble& moy_mimi = ml[3][6];
7081 ArrOfDouble& moy_hihi = ml[4][6];
7082 ArrOfDouble& moy_mili = ml[5][6];
7083 ArrOfDouble& moy_hili = ml[6][6];
7084 ArrOfDouble& moy_mihi = ml[7][6];
7085
7086 const bool visc_reconnu = calculer_constante_modele(turbulent_viscosity_dynamic_type,
7087 Nom("uscalar, viscosity"),
7088 moy_li, moy_mi, moy_hi,
7089 moy_mimi, moy_hihi,
7090 moy_mili, moy_hili,
7091 moy_mihi,
7092 velocity, delta_z,
7093 constante_modele);
7094 if (visc_reconnu)
7095 {
7096 for (int j=0 ; j<3 ; j++)
7097 {
7098 const bool flag_face = false;
7099 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_vector[j]);
7100 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_filtre_vector[j]);
7101 }
7102 }
7103
7104 const bool struct_reconnu = calculer_constante_modele(structural_uscalar_dynamic_type,
7105 Nom("uscalar, structural"),
7106 moy_li, moy_hi, moy_mi,
7107 moy_hihi, moy_mimi,
7108 moy_hili, moy_mili,
7109 moy_mihi,
7110 velocity, delta_z,
7111 constante_modele);
7112 if (struct_reconnu)
7113 {
7114 for (int j=0 ; j<3 ; j++)
7115 {
7116 const bool flag_face = (j==2);
7117 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_vector[j]);
7118 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_filtre_vector[j]);
7119 }
7120 }
7121
7122 if (vectorial_visc)
7123 {
7124 Nom visc_dynamic_type = turbulent_viscosity_dynamic_type.getPrefix("vectorial");
7125 for (int j=0 ; j<3 ; j++)
7126 {
7127 const bool reconnu = calculer_constante_modele(visc_dynamic_type,
7128 Nom("uscalar, viscosity, vectorial, j= ") + Nom(j),
7129 li[j], mi[j], hi[j],
7130 mimi[j], hihi[j],
7131 mili[j], hili[j],
7132 mihi[j],
7133 velocity, delta_z,
7134 constante_modele);
7135 if (reconnu)
7136 {
7137 const bool flag_face = false;
7138 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_vector[j]);
7139 multiplier_par_constante(flag_face, constante_modele, velocity, turbulent_mu_filtre_vector[j]);
7140 }
7141 else
7142 {
7143 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
7144 Process::exit();
7145 }
7146 }
7147 }
7148
7149 if (vectorial_struct)
7150 {
7151 Nom struct_dynamic_type = structural_uscalar_dynamic_type.getPrefix("vectorial");
7152 for (int j=0 ; j<3 ; j++)
7153 {
7154 const bool reconnu = calculer_constante_modele(struct_dynamic_type,
7155 Nom("uscalar, structural, vectorial, j= ") + Nom(j),
7156 li[j], hi[j], mi[j],
7157 hihi[j], mimi[j],
7158 hili[j], mili[j],
7159 mihi[j],
7160 velocity, delta_z,
7161 constante_modele);
7162 if (reconnu)
7163 {
7164 const bool flag_face = (j==2);
7165 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_vector[j]);
7166 multiplier_par_constante(flag_face, constante_modele, velocity, structural_uscalar_filtre_vector[j]);
7167 }
7168 else
7169 {
7170 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
7171 Process::exit();
7172 }
7173 }
7174 }
7175
7176 const bool twopass_visc = turbulent_viscosity_dynamic_type.finit_par("_twopass");
7177 const bool twopass_struct = structural_uscalar_dynamic_type.finit_par("_twopass");
7178 if (twopass_visc || twopass_struct)
7179 {
7180 if (!turbulent_viscosity)
7181 {
7182 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;
7183 Process::exit();
7184 }
7185 if (!structural_uscalar)
7186 {
7187 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;
7188 Process::exit();
7189 }
7190
7191 Nom visc_dynamic_type;
7192 Nom struct_dynamic_type;
7193 if (twopass_visc)
7194 {
7195 Cout << "Second pass, dynamic correction of constant: uscalar, viscosity" << finl;
7196 visc_dynamic_type = turbulent_viscosity_dynamic_type.getPrefix("_twopass");
7197 struct_dynamic_type = Nom("not_dynamic");
7198 }
7199 else
7200 {
7201 Cout << "Second pass, dynamic correction of constant: uscalar, structural" << finl;
7202 visc_dynamic_type = Nom("not_dynamic");
7203 struct_dynamic_type = structural_uscalar_dynamic_type.getPrefix("_twopass");
7204 }
7205
7206 modification_modele_dynamic_uscalar_vector(anisotropic,
7207 visc_dynamic_type,
7208 struct_dynamic_type,
7209 velocity, velocity_filtre,
7210 scalar, scalar_filtre, scalar_kmin, scalar_kmax,
7211 delta_z, facteur_delta_x, facteur_delta_y, delta_z_pour_delta,
7212 facteur_delta_filtre_x, facteur_delta_filtre_y, delta_z_pour_delta_filtre,
7213 kernel, tmp_b, tmp_a,
7214 constante_modele, ml,
7215 turbulent_viscosity, turbulent_mu_vector, turbulent_mu_filtre_vector,
7216 structural_uscalar, structural_uscalar_vector, structural_uscalar_filtre_vector);
7217 }
7218
7219 if ((!visc_reconnu) && (!struct_reconnu) && (!vectorial_visc) && (!vectorial_struct) && (!twopass_visc) && (!twopass_struct))
7220 {
7221 Cerr << "Error: The type of the dynamic correction of the constant is invalid." << finl;
7222 Process::exit();
7223 }
7224 }
7225}
7226
7227
7229{
7230 //M.D. 12-02-2019 ajout possibilite puit
7231 puit_ = 0.;
7232 fichier_reprise_rho_ = "??";
7236 expression_vitesse_initiale_.dimensionner(3);
7238 check_divergence_ = false;
7239 Param param(que_suis_je());
7240 Nom ijk_splitting_name;
7241 reprise_spectrale_ = false;
7242 dt_post_ = 2000000000; // jamais de post-traitement
7243 timestep_facsec_ = 1.;
7244 timestep_max_ = 1.;
7245 timestep_ = 1.e28;
7246 old_timestep_= 1.e28; // Evite la division par zero
7247 current_time_ = 0.;
7248 dt_sauvegarde_ = 2000000000; // jamais
7249 dt_raw_data_ = 2000000000; // jamais
7250 dt_stats_ = 2000000000; // jamais
7252 nom_sauvegarde_ = nom_du_cas() + ".sauv";
7253 nom_reprise_ = "??"; // pas de reprise
7256 calcul_2d_ = 0;
7258 // F.A 3/03/14 modification source
7259 dump_factor_ = 10./3.;
7260 // F.A 17/03/14 ajout diffs et convections negligeables
7265 // DD,2016-10-14: ajout disable_solveur_poisson_
7267 // F.A dt_start ajout possibilite de dt_start
7268 dt_start_ = 1.e28; // tres grand
7269
7270 //oscillating boundary condition
7273
7274 /* amplitude_oscillating_boundary_2_=0; */
7275 /* frequency_oscillating_boundary_2_=0; */
7276 /* flag_oscillating_boundary_2_=false; */
7277 /* statistiques spectrales */
7278 dt_post_spectral_ = -1;
7279 Nom post_splitting_name = "??";
7280
7281 /* sauvegarde des lata par plan */
7283
7284 // DD,2016-28-01: statistiques a partir de fichiers lata uniquement
7291
7292 // DD,2016-06-15: changement des pas de temps de stabilite,
7293 old_dtstab_ = false;
7294
7295 debit_cible_=0;
7296 aim_t_bulk_=-1;
7297 dump_factor_2_=3./100.;
7298
7299 convection_rho_amont_ = false;
7302
7306
7311
7315 Re_tau_fr_=1.;
7316 Re_tau_ch_=1.;
7317 pond_fr_=0.;
7318 pond_ch_=0.;
7320
7321 // DD,2017-04-27: diffusion modifie en vue de l'ajout de modeles
7322 type_velocity_diffusion_ = Nom("full");
7323
7326 turbulent_viscosity_dynamic_type_ = Nom("not_dynamic");
7330 turbulent_viscosity_ = false;
7331
7338 turbulent_diffusivity_ = false;
7339
7340 structural_uu_model_ = Nom("none");
7341 structural_uu_dynamic_type_ = Nom("not_dynamic");
7343 structural_uu_tensor_coefficients_.resize_array(6);
7345 structural_uu_ = false;
7346
7348 structural_uscalar_dynamic_type_ = Nom("not_dynamic");
7352 structural_uscalar_ = false;
7353
7354 filter_kernel_name_ = Nom("none");
7360
7362 Nom geom_name_pour_delta = Nom("__identique_au_maillage__");
7363 formulation_velocity_ = false;
7364 formulation_favre_ = false;
7365
7366 param.ajouter("ijk_splitting", &ijk_splitting_name, Param::REQUIRED); // XD_ADD_P chaine Name of the IJK_Splitting (mesh partitioning) object used for the computation.
7367 param.ajouter("tinit", &current_time_); // XD_ADD_P floattant Initial physical time of the computation.
7368 param.ajouter("timestep", &timestep_max_, Param::REQUIRED); // XD_ADD_P floattant Maximum time step.
7369 param.ajouter("timestep_facsec", &timestep_facsec_); // XD_ADD_P floattant Safety factor applied to the stability time step (facsec).
7370 param.ajouter("dt_start", &dt_start_); // XD_ADD_P floattant Imposed time step for the first iteration.
7371 param.ajouter("nb_pas_dt_max", &nb_timesteps_, Param::REQUIRED); // XD_ADD_P entier Maximum number of time steps to perform.
7372 param.ajouter("multigrid_solver", &poisson_solver_, Param::REQUIRED); // XD_ADD_P multigrid_solver Multigrid solver used for the pressure Poisson equation.
7373 param.ajouter_flag("check_divergence", &check_divergence_); // XD_ADD_P rien Flag to compute and print the velocity divergence.
7374
7375 param.ajouter("t_paroi_impose_kmin", &T_paroi_impose_kmin_, Param::REQUIRED); // XD_ADD_P floattant Imposed wall temperature on the kmin boundary.
7376 param.ajouter("t_paroi_impose_kmax", &T_paroi_impose_kmax_, Param::REQUIRED); // XD_ADD_P floattant Imposed wall temperature on the kmax boundary.
7377
7378 param.ajouter("p_thermo_init", &P_thermodynamique_, Param::REQUIRED); // XD_ADD_P floattant Initial thermodynamic pressure.
7379 param.ajouter("puit", &puit_); // XD_ADD_P floattant Volumetric heat sink term.
7380 param.ajouter("smoothing_center_fr", &smoothing_center_fr_); // XD_ADD_P floattant Two-layer mixed model: smoothing centre s_c of the hyperbolic-tangent law (cold side).
7381 param.ajouter("smoothing_factor_fr", &smoothing_factor_fr_); // XD_ADD_P floattant Two-layer mixed model: smoothing factor s_f of the hyperbolic-tangent law (cold side).
7382 param.ajouter("Re_tau_fr", &Re_tau_fr_); // XD_ADD_P floattant Two-layer mixed model: expected friction Reynolds number on the cold side.
7383 param.ajouter("Re_tau_ch", &Re_tau_ch_); // XD_ADD_P floattant Two-layer mixed model: expected friction Reynolds number on the hot side.
7384 param.ajouter("ponderation_fr", &pond_fr_); // XD_ADD_P floattant Two-layer mixed model: weighting between functional and structural models on the cold side.
7385 param.ajouter("ponderation_ch", &pond_ch_); // XD_ADD_P floattant Two-layer mixed model: weighting between functional and structural models on the hot side.
7386 param.ajouter("center_constant", &center_constant_); // XD_ADD_P floattant Two-layer mixed model: target model constant C_c at the channel centre.
7387 param.ajouter("cp", &Cp_gaz_, Param::REQUIRED); // XD_ADD_P floattant Specific heat capacity at constant pressure of the gas.
7388 param.ajouter("gamma", &gamma_, Param::REQUIRED); // XD_ADD_P floattant Heat capacity ratio (Cp/Cv) of the gas.
7389
7390
7391 param.ajouter("expression_vx_init", &expression_vitesse_initiale_[0]); // XD_ADD_P chaine Analytical expression (function of x,y,z) for the initial x-velocity.
7392 param.ajouter("expression_vy_init", &expression_vitesse_initiale_[1]); // XD_ADD_P chaine Analytical expression (function of x,y,z) for the initial y-velocity.
7393 param.ajouter("expression_vz_init", &expression_vitesse_initiale_[2]); // XD_ADD_P chaine Analytical expression (function of x,y,z) for the initial z-velocity.
7394 param.ajouter("expression_t_init", &expression_temperature_initiale_); // XD_ADD_P chaine Analytical expression for the initial temperature field.
7395 param.ajouter("fichier_reprise_vitesse", &fichier_reprise_vitesse_); // XD_ADD_P chaine Name of the .lata file to resume the velocity field from.
7396 param.ajouter("fichier_reprise_rho", &fichier_reprise_rho_); // XD_ADD_P chaine Name of the .lata file to resume the density field from.
7397 param.ajouter("timestep_reprise_vitesse", &timestep_reprise_vitesse_); // XD_ADD_P entier Time step index to read in the velocity resume file.
7398 param.ajouter("timestep_reprise_rho", &timestep_reprise_rho_); // XD_ADD_P entier Time step index to read in the density resume file.
7399
7400 // F.A on change la source utilisee
7401 param.ajouter("debit_massique", &debit_cible_); // XD_ADD_P floattant Target mass flow rate, imposed by a forcing term.
7402 // Y.Z. forcing T^b by changing H_s (heat sink)
7403 param.ajouter("t_bulk", &aim_t_bulk_); // XD_ADD_P floattant Target bulk temperature.
7404 param.ajouter("dump_factor_2", &dump_factor_2_); // XD_ADD_P floattant Secondary post-processing dump factor.
7405
7406 param.ajouter_flag("convection_rho_amont", &convection_rho_amont_); // XD_ADD_P rien Use the first-order upwind scheme for the density convection.
7407 param.ajouter_flag("convection_rho_centre2", &convection_rho_centre2_); // XD_ADD_P rien Use the 2nd-order centered scheme for the density convection.
7408 param.ajouter_flag("convection_rho_centre4", &convection_rho_centre4_); // XD_ADD_P rien Use the 4th-order centered scheme for the density convection.
7409
7410 param.ajouter_flag("convection_velocity_amont", &convection_velocity_amont_); // XD_ADD_P rien Use the first-order upwind scheme for the velocity convection.
7411 param.ajouter_flag("convection_velocity_quicksharp", &convection_velocity_quicksharp_); // XD_ADD_P rien Use the QUICK-SHARP scheme for the velocity convection.
7412 param.ajouter_flag("convection_velocity_centre2", &convection_velocity_centre2_); // XD_ADD_P rien Use the 2nd-order centered scheme for the velocity convection.
7413
7414 param.ajouter_flag("variation_cste_modele_fonctionnel", &variation_cste_modele_fonctionnel_); // XD_ADD_P rien Enable the two-layer mixed model (height-dependent variation of the functional model constant).
7415
7416 param.ajouter("dumping_factor", &dump_factor_); // XD_ADD_P floattant Damping factor applied to the forcing term.
7417
7418 // param.ajouter("terme_force_init", &terme_source_acceleration_, Param::REQUIRED);
7419 // param.ajouter("expression_derivee_force", &expression_derivee_acceleration_, Param::REQUIRED);
7420 param.ajouter("terme_source_acceleration_constant", &terme_source_acceleration_constant_); // XD_ADD_P floattant Constant acceleration source term (momentum forcing).
7421
7422 param.ajouter("dt_post", &dt_post_); // XD_ADD_P entier Number of time steps between two post-processing outputs.
7423 param.ajouter("champs_a_postraiter", &liste_post_instantanes_); // XD_ADD_P listchaine List of field names to post-process.
7424
7425 param.ajouter("dt_sauvegarde", &dt_sauvegarde_); // XD_ADD_P entier Number of time steps between two checkpoint (save) outputs.
7426 param.ajouter("dt_raw_data", &dt_raw_data_); // XD_ADD_P entier Number of time steps between two raw-data saves.
7427 param.ajouter("dt_stats", &dt_stats_); // XD_ADD_P entier Number of time steps between two statistics saves.
7428 param.ajouter("dt_save_oscillating_cycle_raw_data", &dt_save_oscillating_cycle_raw_data_); // XD_ADD_P floattant Time interval for saving raw data over the oscillating cycle.
7429
7430 param.ajouter_flag("postraiter_sous_pas_de_temps", &postraiter_sous_pas_de_temps_); // XD_ADD_P rien Flag to post-process at sub-time-steps.
7431 param.ajouter("nom_sauvegarde", &nom_sauvegarde_); // XD_ADD_P chaine Base name of the checkpoint (save) files.
7432 param.ajouter("nom_reprise", &nom_reprise_); // XD_ADD_P chaine Base name of the files to resume the computation from.
7433
7434 param.ajouter("t_debut_statistiques", &t_debut_statistiques_); // XD_ADD_P floattant Physical time at which statistics accumulation starts.
7435
7436 /* stats spectrales */
7437 param.ajouter("dt_post_spectral", &dt_post_spectral_); // XD_ADD_P entier Number of time steps between two spectral post-processing outputs.
7438 param.ajouter("spectral_splitting", &post_splitting_name); // XD_ADD_P chaine Name of the IJK_Splitting used for spectral post-processing.
7439 param.ajouter_flag("reprise_spectrale", &reprise_spectrale_); // XD_ADD_P rien Flag to resume spectral post-processing data.
7440 /* -------------------- */
7441
7442 /* sauvegarde des lata par plan */
7443 param.ajouter("sauvegarde_splitting", &sauvegarde_splitting_name_); // XD_ADD_P chaine Name of the IJK_Splitting used to write checkpoint files.
7444
7445 param.ajouter_flag("calcul_2d", &calcul_2d_); // XD_ADD_P rien Flag for a 2D computation.
7446 param.ajouter("check_stop_file", &check_stop_file_); // XD_ADD_P chaine Name of the stop file checked to interrupt the computation.
7447 param.ajouter_flag("projection_initiale", &projection_initiale_demandee_); // XD_ADD_P rien Flag to perform an initial projection of the velocity field.
7448
7449 // Ajout possibilite diffusion ou convection negligeable pour chaque equa (sauf celle de la chaleur !! ) !!
7450 param.ajouter_flag("convection_rho_negligeable", &conv_rho_negligeable_); // XD_ADD_P rien Neglect the density convection term.
7451 param.ajouter_flag("convection_qdm_negligeable", &conv_qdm_negligeable_); // XD_ADD_P rien Neglect the momentum convection term.
7452 param.ajouter_flag("diffusion_qdm_negligeable", &diff_qdm_negligeable_); // XD_ADD_P rien Neglect the momentum diffusion term.
7453 param.ajouter_flag("diffusion_temp_negligeable", &diff_temp_negligeable_); // XD_ADD_P rien Neglect the temperature diffusion term.
7454 // DD,2016-10-14: ajout disable_solveur_poisson_
7455 param.ajouter_flag("disable_solveur_poisson", &disable_solveur_poisson_); // XD_ADD_P rien Disable the pressure Poisson solver.
7456
7457 // DD,2017-04-27: diffusion modifie en vue de l'ajout de modeles
7458 param.ajouter("type_velocity_diffusion", &type_velocity_diffusion_); // XD_ADD_P chaine Form of the (molecular) velocity diffusion used for the shear-stress tensor: simple, simple_with_transpose, full or none.
7459
7460 param.ajouter("large_eddy_simulation_formulation", &large_eddy_simulation_formulation_); // XD_ADD_P chaine LES formulation of the filtered low-Mach equations: velocity (filtered velocity) or favre (Favre/density-weighted); none disables it.
7461 param.ajouter("ijk_grid_geometry_pour_delta", &geom_name_pour_delta); // XD_ADD_P chaine Name of the IJK grid geometry used to compute the LES filter width delta.
7462
7463 param.ajouter("type_velocity_turbulent_diffusion", &type_velocity_turbulent_diffusion_); // XD_ADD_P chaine Form of the turbulent velocity diffusion (shear-stress tensor model): simple, simple_with_transpose, full and their *_anisotropic variants.
7464 param.ajouter("turbulent_viscosity_model", &turbulent_viscosity_model_); // XD_ADD_P chaine Functional eddy-viscosity model: constant, unsrho, smagorinsky, vreman, sigma, wale, amd, amd_comp, amdnoclip, amdscalar, amdscalarnoclip, rds, vss or kobayashi.
7465 param.ajouter("turbulent_viscosity_dynamic_type", &turbulent_viscosity_dynamic_type_); // XD_ADD_P chaine Dynamic procedure for the functional eddy viscosity (e.g. dynamic_uu, dynamicglobal_uu).
7466 param.ajouter("turbulent_viscosity_model_constant", &turbulent_viscosity_model_constant_); // XD_ADD_P floattant Constant of the functional eddy-viscosity model.
7467 param.ajouter("turbulent_viscosity_tensor_coefficients", &turbulent_viscosity_tensor_coefficients_); // XD_ADD_P list Per-direction (anisotropic) coefficients of the functional eddy-viscosity tensor (count-prefixed list).
7468 param.ajouter_flag("turbulent_viscosity", &turbulent_viscosity_); // XD_ADD_P rien Enable the functional (eddy-viscosity) model for the momentum subgrid stress.
7469
7470 param.ajouter("type_scalar_turbulent_diffusion", &type_scalar_turbulent_diffusion_); // XD_ADD_P chaine Form of the turbulent scalar diffusion (heat-flux model): normal or anisotropic.
7471 param.ajouter("turbulent_diffusivity_model", &turbulent_diffusivity_model_); // XD_ADD_P chaine Functional eddy-diffusivity model for the scalar (same model set as turbulent_viscosity_model).
7472 param.ajouter("turbulent_diffusivity_dynamic_type", &turbulent_diffusivity_dynamic_type_); // XD_ADD_P chaine Dynamic procedure for the functional eddy diffusivity.
7473 param.ajouter("turbulent_diffusivity_model_constant", &turbulent_diffusivity_model_constant_); // XD_ADD_P floattant Constant of the functional eddy-diffusivity model.
7474 param.ajouter("turbulent_diffusivity_vector_coefficients", &turbulent_diffusivity_vector_coefficients_); // XD_ADD_P list Per-direction (anisotropic) coefficients of the functional eddy-diffusivity vector (count-prefixed list).
7475 param.ajouter_flag("turbulent_diffusivity", &turbulent_diffusivity_); // XD_ADD_P rien Enable the functional (eddy-diffusivity) model for the scalar subgrid flux.
7476
7477 param.ajouter("structural_uu_model", &structural_uu_model_); // XD_ADD_P chaine Structural model for the momentum subgrid (Reynolds) stress tensor.
7478 param.ajouter("structural_uu_dynamic_type", &structural_uu_dynamic_type_); // XD_ADD_P chaine Dynamic procedure for the structural momentum model.
7479 param.ajouter("structural_uu_model_constant", &structural_uu_model_constant_); // XD_ADD_P floattant Constant of the structural momentum model.
7480 param.ajouter("structural_uu_tensor_coefficients", &structural_uu_tensor_coefficients_); // XD_ADD_P list Per-direction coefficients of the structural momentum tensor (count-prefixed list).
7481 param.ajouter_flag("structural_uu", &structural_uu_); // XD_ADD_P rien Enable the structural model for the momentum subgrid stress.
7482
7483 param.ajouter("structural_uscalar_model", &structural_uscalar_model_); // XD_ADD_P chaine Structural model for the scalar subgrid flux.
7484 param.ajouter("structural_uscalar_dynamic_type", &structural_uscalar_dynamic_type_); // XD_ADD_P chaine Dynamic procedure for the structural scalar model.
7485 param.ajouter("structural_uscalar_model_constant", &structural_uscalar_model_constant_); // XD_ADD_P floattant Constant of the structural scalar model.
7486 param.ajouter("structural_uscalar_vector_coefficients", &structural_uscalar_vector_coefficients_); // XD_ADD_P list Per-direction coefficients of the structural scalar vector (count-prefixed list).
7487 param.ajouter_flag("structural_uscalar", &structural_uscalar_); // XD_ADD_P rien Enable the structural model for the scalar subgrid flux.
7488
7489 param.ajouter("filter_kernel_name", &filter_kernel_name_); // XD_ADD_P chaine Name of the filter kernel applied by the structural and dynamic LES models.
7490 param.ajouter_flag("filtrage_convection_qdm", &flag_filtrage_convection_qdm_); // XD_ADD_P rien Flag to filter the momentum convection term.
7491 param.ajouter_flag("filtrage_turbulent_diffusion_qdm", &flag_filtrage_turbulent_diffusion_qdm_); // XD_ADD_P rien Flag to filter the turbulent momentum diffusion term.
7492 param.ajouter_flag("filtrage_structural_diffusion_qdm", &flag_filtrage_structural_diffusion_qdm_); // XD_ADD_P rien Flag to filter the structural momentum diffusion term.
7493 param.ajouter_flag("convection_qdm_sans_rho", &flag_convection_qdm_sans_rho_); // XD_ADD_P rien Compute the momentum convection without the density factor.
7494 param.ajouter_flag("convection_qdm_sans_divergence", &flag_convection_qdm_sans_divergence_); // XD_ADD_P rien Compute the momentum convection in non-divergence form.
7495
7496 // DD,2016-28-01: statistiques a partir de fichiers lata uniquement
7497 param.ajouter("statlata_namelist", &statlata_namelist_); // XD_ADD_P listchaine List of fields for the statistics lata output.
7498 param.ajouter_flag("sauvegarde_post_instantanes", &sauvegarde_post_instantanes_); // XD_ADD_P rien Flag to save instantaneous post-processing fields.
7499 param.ajouter_flag("lecture_post_instantanes", &lecture_post_instantanes_); // XD_ADD_P rien Flag to read instantaneous post-processing fields.
7500 param.ajouter_flag("lecture_post_instantanes_filtrer_u", &lecture_post_instantanes_filtrer_u_); // XD_ADD_P rien On reading instantaneous fields, filter the velocity.
7501 param.ajouter_flag("lecture_post_instantanes_filtrer_rho", &lecture_post_instantanes_filtrer_rho_); // XD_ADD_P rien On reading instantaneous fields, filter the density.
7502 param.ajouter_flag("lecture_post_instantanes_filtrer_p", &lecture_post_instantanes_filtrer_p_); // XD_ADD_P rien On reading instantaneous fields, filter the pressure.
7503 param.ajouter_flag("lecture_post_instantanes_filtrer_tous", &lecture_post_instantanes_filtrer_tous_); // XD_ADD_P rien On reading instantaneous fields, filter all fields.
7504 param.ajouter("compteur_post_instantanes", &compteur_post_instantanes_); // XD_ADD_P entier Counter offset for instantaneous post-processing file numbering.
7505
7506 // DD,2016-06-15: changement des pas de temps de stabilite,
7507 param.ajouter_flag("old_dtstab", &old_dtstab_); // XD_ADD_P rien Flag to use the legacy stability time-step computation.
7508
7509 // Oscillating boundary condition expression
7510 // param.ajouter("expression_oscillating_boundary", &expression_oscillating_boundary);
7511 param.ajouter("amplitude_oscillating_boundary", &amplitude_oscillating_boundary_); // XD_ADD_P floattant Amplitude of the oscillating boundary forcing.
7512 param.ajouter("frequency_oscillating_boundary", &frequency_oscillating_boundary_); // XD_ADD_P floattant Frequency of the oscillating boundary forcing.
7513
7514 /* param.ajouter("amplitude_oscillating_boundary_2", &amplitude_oscillating_boundary_2_); */
7515 /* param.ajouter("frequency_oscillating_boundary_2", &frequency_oscillating_boundary_2_); */
7516
7517
7518 param.lire_avec_accolades(is);
7519
7520 // Recuperation des donnees de maillage
7521 domaine_ = ref_cast(Domaine_IJK, Interprete_bloc::objet_global(ijk_splitting_name));
7522 // Initialisation de delta_z_local_
7523 domaine_.get_local_mesh_delta(DIRECTION_K, 2 /* ghost cells */, delta_z_local_);
7524
7525 if (geom_name_pour_delta == Nom("__identique_au_maillage__"))
7526 {
7527 facteur_delta_x_ = 1.;
7528 facteur_delta_y_ = 1.;
7530 }
7531 else
7532 {
7533 Cerr << "Lecture de la taille du filtre depuis le Domaine_IJK " << geom_name_pour_delta << "." << finl;
7534 Domaine_IJK geom_pour_delta = ref_cast(Domaine_IJK, Interprete_bloc::objet_global(geom_name_pour_delta));
7535 const double dx_maillage = domaine_.get_constant_delta(DIRECTION_I);
7536 const double dy_maillage = domaine_.get_constant_delta(DIRECTION_J);
7537 const double dx_pour_delta = geom_pour_delta.get_constant_delta(DIRECTION_I);
7538 const double dy_pour_delta = geom_pour_delta.get_constant_delta(DIRECTION_J);
7539 facteur_delta_x_ = dx_pour_delta/dx_maillage;
7540 facteur_delta_y_ = dy_pour_delta/dy_maillage;
7541
7542 calculer_delta_z_pour_delta(domaine_, geom_pour_delta, 2, delta_z_local_pour_delta_);
7543 for (int i=-2 ; i<domaine_.get_nb_elem_local(DIRECTION_K)+2 ; i++)
7544 {
7545 Cerr << i << " " << delta_z_local_[i] << " " << delta_z_local_pour_delta_[i] << finl;
7546 }
7547 }
7548
7551 {
7552 Cerr << " Error: (Inconsistent parameters) The keyword DEBIT_MASSIQUE cannot be used with TERME_SOURCE_ACCELERATION_CONdoubleANT." << finl;
7553 Process::exit();
7554 }
7556 {
7557 Cerr << "Simulation en mode : TERME SOURCE IMPOSE." << finl;
7558 }
7559 else
7560 {
7561 Cerr << "Simulation en mode : DEBIT IMPOSE." << finl;
7562 }
7563
7564 if ( (post_splitting_name != "??") || ( dt_post_spectral_ != -1 ) )
7565 {
7566 if ( dt_post_spectral_ <= 0 )
7567 {
7568 Cerr << " You need to specify an dt_post_spectral X," <<
7569 " were X is the number of step between 2 post" << finl;
7570 Process::exit();
7571 }
7572 else if ( (post_splitting_name == "??") )
7573 {
7574 Cerr << " You need to specify an other splitting like : spectral_splitting post_splitting " << finl;
7575 Cerr << "in order to compute FFT on planes you must only split in z direction" << finl;
7576 Process::exit();
7577 }
7578 else
7579 {
7580#if defined(WITH_FFTW)
7581 post_splitting_ =ref_cast(Domaine_IJK, Interprete_bloc::objet_global(post_splitting_name));
7582
7583 const int decoupage_selon_x_ou_y = post_splitting_.get_nprocessor_per_direction(0)*post_splitting_.get_nprocessor_per_direction(1);
7584 if (decoupage_selon_x_ou_y > 1 )
7585 {
7586 Cerr << "In order to compute FFT on planes you must only split in z direction the spectral_splitting" << finl;
7587 Process::exit();
7588 }
7589#else
7590 Cerr << " Module FFTW desactive impossible de faire la FFT " << finl;
7591 Process::exit();
7592#endif
7593 }
7594 }
7595
7596 if (sauvegarde_splitting_name_ != "??")
7597 {
7599 const int decoupage_selon_x_ou_y = sauvegarde_splitting_.get_nprocessor_per_direction(0)*sauvegarde_splitting_.get_nprocessor_per_direction(1);
7600 // Modif Martin
7601 if (decoupage_selon_x_ou_y > 1 )
7602 {
7603 Cerr << "In order to save lata on planes you must only split in z direction the sauvegarde_splitting" << finl;
7604 Process::exit();
7605 }
7606 // Fin modif Martin
7607
7608 Cerr << "Initialisation de la sauvegarde des lata par plan" << finl;
7613 }
7614
7619 {
7620 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;
7621 Process::exit();
7622 }
7623
7624 if (turbulent_viscosity_tensor_coefficients_.size_array() != 6)
7625 {
7626 Cerr << "Erreur: TURBULENT_VISCOSITY_TENSOR_COEFFICIENTS doit etre un vecteur de 6 composantes (xx, xy, xz, yy, yz, zz)." << finl;
7627 Process::exit();
7628 }
7629 if (turbulent_diffusivity_vector_coefficients_.size_array() != 3)
7630 {
7631 Cerr << "Erreur: TURBULENT_VISCOSITY_TENSOR_COEFFICIENTS doit etre un vecteur de 3 composantes (x, y, z)." << finl;
7632 Process::exit();
7633 }
7634 if (structural_uu_tensor_coefficients_.size_array() != 6)
7635 {
7636 Cerr << "Erreur: sTRUCTURAL_UU_TENSOR_COEFFICIENTS doit etre un vecteur de 6 composantes (xx, xy, xz, yy, yz, zz)." << finl;
7637 Process::exit();
7638 }
7639 if (structural_uscalar_vector_coefficients_.size_array() != 3)
7640 {
7641 Cerr << "Erreur: sTRUCTURAL_USCALAR_VECTOR_COEFFICIENTS doit etre un vecteur de 3 composantes (x, y, z)." << finl;
7642 Process::exit();
7643 }
7644
7645 if ( large_eddy_simulation_formulation_ == Nom("favre") )
7646 {
7647 formulation_favre_ = true;
7648 }
7649 else if ( large_eddy_simulation_formulation_ == Nom("velocity") )
7650 {
7651 formulation_velocity_ = true;
7652 }
7653
7654 // DD,2017-04-27: diffusion modifie en vue de l'ajout de modeles
7655 if ( large_eddy_simulation_formulation_ == Nom("none") )
7656 {
7658 {
7659 Cerr << "Error: (Inconsistent parameters) "
7660 << "The TURBULENT_VISCOSITY flag was activated but no large eddy simulation formulation was specified. "
7661 << "To specify a large eddy simulation formulation, you may use the keyword LARGE_EDDY_SIMULATION_FORMULATION with the parameters FAVRE, VELOCITY or NONE." << finl;
7662 Process::exit();
7663 }
7664 else if (turbulent_diffusivity_)
7665 {
7666 Cerr << "Error: (Inconsistent parameters) "
7667 << "The TURBULENT_DIFFUSIVITY flag was activated but no large eddy simulation formulation was specified. "
7668 << "To specify a large eddy simulation formulation, you may use the keyword LARGE_EDDY_SIMULATION_FORMULATION with the parameters FAVRE, VELOCITY or NONE." << finl;
7669 Process::exit();
7670 }
7671 else if (structural_uu_)
7672 {
7673 Cerr << "Error: (Inconsistent parameters) "
7674 << "The sTRUCTURAL_UU flag was activated but no large eddy simulation formulation was specified. "
7675 << "To specify a large eddy simulation formulation, you may use the keyword LARGE_EDDY_SIMULATION_FORMULATION with the parameters FAVRE, VELOCITY or NONE." << finl;
7676 Process::exit();
7677 }
7678 else if (structural_uscalar_)
7679 {
7680 Cerr << "Error: (Inconsistent parameters) "
7681 << "The sTRUCTURAL_USCALAR flag was activated but no large eddy simulation formulation was specified. "
7682 << "To specify a large eddy simulation formulation, you may use the keyword LARGE_EDDY_SIMULATION_FORMULATION with the parameters FAVRE, VELOCITY or NONE." << finl;
7683 Process::exit();
7684 }
7685 }
7686 else
7687 {
7689 {
7690 Cerr << "Error: (Inconsistent parameters) "
7691 << "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. "
7692 << "" << finl;
7693 Process::exit();
7694 }
7695 }
7696
7698 {
7699 if ( type_velocity_turbulent_diffusion_ != Nom("none") )
7700 {
7701 Cerr << "Error: (Inconsistent parameters) "
7702 << "A velocity turbulent diffusion type was specified but the TURBULENT_VISCOSITY flag has not been activated. "
7703 << "" << finl;
7704 Process::exit();
7705 }
7706 else if ( turbulent_viscosity_model_ != Nom("none") )
7707 {
7708 Cerr << "Error: (Inconsistent parameters) "
7709 << "A subgrid viscosity model was specified but the TURBULENT_VISCOSITY flag has not been activated. "
7710 << "" << finl;
7711 Process::exit();
7712 }
7713 else if ( turbulent_viscosity_model_constant_ != -1 )
7714 {
7715 Cerr << "Error: (Inconsistent parameters) "
7716 << "A subgrid viscosity model constant was specified but the TURBULENT_VISCOSITY flag has not been activated. "
7717 << "" << finl;
7718 Process::exit();
7719 }
7720 }
7721 else
7722 {
7723 if ( type_velocity_turbulent_diffusion_ == Nom("none") )
7724 {
7725 Cerr << "Error: (Inconsistent parameters) "
7726 << "The TURBULENT_VISCOSITY flag expect a velocity turbulent diffusion type but no velocity turbulent diffusion type was specified. "
7727 << "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;
7728 Process::exit();
7729 }
7730 else if ( turbulent_viscosity_model_ == Nom("none") )
7731 {
7732 Cerr << "Error: (Inconsistent parameters) "
7733 << "The TURBULENT_VISCOSITY flag expect a subgrid viscosity model but no model was specified. "
7734 << "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;
7735 Process::exit();
7736 }
7737 else if ( turbulent_viscosity_model_constant_ == -1 )
7738 {
7739 Cerr << "Error: (Inconsistent parameters) "
7740 << "The TURBULENT_VISCOSITY flag expect a subgrid viscosity model constant but no constant was specified. "
7741 << "To specify a constant, you may use the keyword TURBULENT_VISCOSITY_MODEL_CONdoubleANT." << finl;
7742 Process::exit();
7743 }
7744 }
7745
7747 {
7748 if ( type_scalar_turbulent_diffusion_ != Nom("none") )
7749 {
7750 Cerr << "Error: (Inconsistent parameters) "
7751 << "A scalar turbulent diffusion type was specified but the TURBULENT_DIFFUSIVITY flag has not been activated. "
7752 << "" << finl;
7753 Process::exit();
7754 }
7755 if ( turbulent_diffusivity_model_ != Nom("none") )
7756 {
7757 Cerr << "Error: (Inconsistent parameters) "
7758 << "A subgrid diffusivity model was specified but the TURBULENT_DIFFUSIVITY flag has not been activated. "
7759 << "" << finl;
7760 Process::exit();
7761 }
7763 {
7764 Cerr << "Error: (Inconsistent parameters) "
7765 << "A subgrid diffusivity model constant was specified but the TURBULENT_DIFFUSIVITY flag has not been activated. "
7766 << "" << finl;
7767 Process::exit();
7768 }
7769 }
7770 else
7771 {
7772 if ( type_scalar_turbulent_diffusion_ == Nom("none") )
7773 {
7774 Cerr << "Error: (Inconsistent parameters) "
7775 << "The TURBULENT_DIFFUSIVITY flag expect a scalar turbulent diffusion type but no scalar turbulent diffusion type was specified. "
7776 << "To specify a scalar turbulent diffusion type, you may use the keyword TYPE_SCALAR_TURBULENT_DIFFUSION with the parameters NORMAL, ANISOTROPIC or NONE" << finl;
7777 Process::exit();
7778 }
7779 if ( turbulent_diffusivity_model_ == Nom("none") )
7780 {
7781 Cerr << "Error: (Inconsistent parameters) "
7782 << "The TURBULENT_DIFFUSIVITY flag expect a subgrid diffusivity model but no model was specified. "
7783 << "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;
7784 Process::exit();
7785 }
7787 {
7788 Cerr << "Error: (Inconsistent parameters) "
7789 << "The TURBULENT_DIFFUSIVITY flag expect a subgrid diffusivity model constant but no constant was specified. "
7790 << "To specify a constant, you may use the keyword TURBULENT_DIFFUSIVITY_MODEL_CONdoubleANT." << finl;
7791 Process::exit();
7792 }
7793 }
7794
7795 if (!structural_uu_)
7796 {
7797 if ( structural_uu_model_ != Nom("none") )
7798 {
7799 Cerr << "Error: (Inconsistent parameters) "
7800 << "A structural model for uu was specified but the sTRUCTURAL_UU flag has not been activated. "
7801 << "" << finl;
7802 Process::exit();
7803 }
7804 else if ( structural_uu_model_constant_ != -1 )
7805 {
7806 Cerr << "Error: (Inconsistent parameters) "
7807 << "A structural model for uu constant was specified but the sTRUCTURAL_UU flag has not been activated. "
7808 << "" << finl;
7809 Process::exit();
7810 }
7811 }
7812 else
7813 {
7814 if ( structural_uu_model_ == Nom("none") )
7815 {
7816 Cerr << "Error: (Inconsistent parameters) "
7817 << "The sTRUCTURAL_UU flag expect a structural model but no model was specified. "
7818 << "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;
7819 Process::exit();
7820 }
7821 else if ( structural_uu_model_constant_ == -1 )
7822 {
7823 Cerr << "Error: (Inconsistent parameters) "
7824 << "The sTRUCTURAL_UU flag expect a structural model constant but no constant was specified. "
7825 << "To specify a constant, you may use the keyword sTRUCTURAL_UU_MODEL_CONdoubleANT." << finl;
7826 Process::exit();
7827 }
7828 }
7829
7831 {
7832 if ( structural_uscalar_model_ != Nom("none") )
7833 {
7834 Cerr << "Error: (Inconsistent parameters) "
7835 << "A structural model for uscalar was specified but the sTRUCTURAL_USCALAR flag has not been activated. "
7836 << "" << finl;
7837 Process::exit();
7838 }
7840 {
7841 Cerr << "Error: (Inconsistent parameters) "
7842 << "A structural model for uscalar constant was specified but the sTRUCTURAL_USCALAR flag has not been activated. "
7843 << "" << finl;
7844 Process::exit();
7845 }
7846 }
7847 else
7848 {
7849 if ( structural_uscalar_model_ == Nom("none") )
7850 {
7851 Cerr << "Error: (Inconsistent parameters) "
7852 << "The sTRUCTURAL_USCALAR flag expect a subgrid diffusivity model but no model was specified. "
7853 << "To specify a model, you may use the keyword sTRUCTURAL_USCALAR_MODEL with the parameters GRADIENT, GRADIENT_FILTRE, SIMILARITY or NONE." << finl;
7854 Process::exit();
7855 }
7856 else if ( structural_uscalar_model_constant_ == -1 )
7857 {
7858 Cerr << "Error: (Inconsistent parameters) "
7859 << "The sTRUCTURAL_USCALAR flag expect a subgrid diffusivity model constant but no constant was specified. "
7860 << "To specify a constant, you may use the keyword sTRUCTURAL_USCALAR_MODEL_CONdoubleANT." << finl;
7861 Process::exit();
7862 }
7863 }
7864
7865 // Note :
7866 // 'dynamic_uu', 'dynamicglobal_uu', 'dynamic_urho', 'dynamicglobal_urho',
7867 // 'dynamic_ut' et 'dynamicglobal_ut' sont des options obsoletes
7868 // equivalentes a 'lilly' et 'lillyglobal'.
7869
7870 if (turbulent_viscosity_dynamic_type_ == Nom("dynamic_uu"))
7871 {
7873 }
7874 if (turbulent_viscosity_dynamic_type_ == Nom("dynamicglobal_uu"))
7875 {
7876 turbulent_viscosity_dynamic_type_ = Nom("lillyglobal");
7877 }
7878 if ( turbulent_diffusivity_dynamic_type_ == Nom("dynamic_urho")
7879 || turbulent_diffusivity_dynamic_type_ == Nom("dynamic_ut") )
7880 {
7882 }
7883 if ( turbulent_diffusivity_dynamic_type_ == Nom("dynamicglobal_urho")
7884 || turbulent_diffusivity_dynamic_type_ == Nom("dynamicglobal_ut") )
7885 {
7887 }
7888
7890 || (structural_uu_ && (structural_uu_model_ != Nom("gradient")) )
7891 || (structural_uscalar_ && (structural_uscalar_model_ != Nom("gradient")) )
7892 || (turbulent_viscosity_dynamic_type_ != Nom("not_dynamic"))
7893 || (turbulent_diffusivity_dynamic_type_ != Nom("not_dynamic"))
7894 || (structural_uu_dynamic_type_ != Nom("not_dynamic"))
7895 || (structural_uscalar_dynamic_type_ != Nom("not_dynamic"));
7898 || (turbulent_diffusivity_dynamic_type_ != Nom("not_dynamic"))
7899 || (turbulent_viscosity_dynamic_type_ != Nom("not_dynamic"))
7900 || (structural_uu_dynamic_type_ != Nom("not_dynamic"))
7901 || (structural_uscalar_dynamic_type_ != Nom("not_dynamic"));
7904 || (turbulent_viscosity_dynamic_type_ != Nom("not_dynamic"))
7905 || (turbulent_diffusivity_dynamic_type_ != Nom("not_dynamic"))
7906 || (structural_uu_dynamic_type_ != Nom("not_dynamic"))
7907 || (structural_uscalar_dynamic_type_ != Nom("not_dynamic"))
7908 );
7913
7914 flag_structural_uu_tmp_ = structural_uu_ && (structural_uu_model_ == Nom("gradient_filtre") || structural_uu_model_ == Nom("convection_filtre"));
7917
7918 flag_nu_anisotropic_ = ( (type_velocity_turbulent_diffusion_ == Nom("simple_anisotropic"))
7919 || (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose_anisotropic"))
7920 || (type_velocity_turbulent_diffusion_ == Nom("full_anisotropic")) );
7921 flag_nu_tensorial_ = ( turbulent_viscosity_dynamic_type_.finit_par("tensorial")
7922 || turbulent_viscosity_dynamic_type_.finit_par("tensorial_twopass")
7931 || turbulent_diffusivity_dynamic_type_.finit_par("vectorial_twopass")
7935
7936 // //3/03/14 changement de la source
7937 // // Preparation de l'expression derivee de l'acceleration
7938 // String2 tmpstring(expression_derivee_acceleration_);
7939 // parser_derivee_acceleration_.setString(tmpstring);
7940 // parser_derivee_acceleration_.setNbVar(3);
7941 // parser_derivee_acceleration_.addVar("force");
7942 // parser_derivee_acceleration_.addVar("v_moyen");
7943 // parser_derivee_acceleration_.addVar("rho_v_moyen");
7944 // parser_derivee_acceleration_.parseString();
7945 //
7946
7949 {
7950 Cerr <<
7951 "The boundary is oscillating at amplitude "
7953 << " and frequency "
7955 << finl;
7957 }
7958
7959
7960 flag_t_bulk_forced_=false;
7961 if(aim_t_bulk_ != -1)
7962 {
7963 Cerr <<
7964 "Simulation in forced T bulk mode with value "
7965 << aim_t_bulk_
7966 << " K"
7967 << finl;
7968 flag_t_bulk_forced_ = true;
7969 }
7970
7971 if (dt_post_ == 2000000000 && dt_raw_data_ == 2000000000 && dt_stats_ == 2000000000 && dt_save_oscillating_cycle_raw_data_== 0)
7972 dt_post_ = 100;
7973
7974 if (nom_reprise_ != "??")
7976
7977 dt_save_cycle_ = 2000000000;
7979 {
7981 dt_save_cycle_ = 0;
7984 Cerr << "Dt save cycle: " << dt_save_cycle_ << "dt_save_oscillating_cycle_raw_data_: " << dt_save_oscillating_cycle_raw_data_;
7985 }
7986
7987 run();
7988 return is;
7989}
7990
7991// Attention, il faut 1 epaisseur de joint valide sur rho
7992static 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)
7993{
7994 const int ni = vx.ni();
7995 const int nj = vx.nj();
7996 const int nk = vx.nk();
7997 const double dx = vx.get_domaine().get_constant_delta(DIRECTION_I);
7998 const double dy = vx.get_domaine().get_constant_delta(DIRECTION_J);
7999
8000 debit = 0.;
8001 // Ponderation par le volume des mailles pour traiter le cas ou le maillage est irregulier en k
8002 for (int k = 0; k < nk; k++)
8003 {
8004 double somme_rhov = 0;
8005 for (int j = 0; j < nj; j++)
8006 {
8007 for (int i = 0; i < ni; i++)
8008 {
8009 double rhov = vx(i,j,k) * (rho(i-1,j,k) + rho(i,j,k)) * 0.5; // rho moyen sur la face
8010 somme_rhov += rhov;
8011 //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;
8012 }
8013 }
8014 // volume d'une maille de ce plan
8015 double volume = dx * dy * delta_z[k];
8016 debit += volume * somme_rhov;
8017 }
8018 // somme sur tous les processeurs. On regroupe toutes les communications en un seul appel:
8019 ArrOfDouble tmp(1);
8020 tmp[0] = debit;
8022
8023 // ici on calcule la valeur moyenne sur le volume V = Lx * Ly * Lz et on multiplie par la surface debitante S = Ly * Lz
8024// on doit donc juste diviser par Lx
8025 debit = tmp[0] / longeur_Lx_tot;
8026}
8027
8028// Methode appelee dans run().
8029// Intialise toutes les variables et champs pour le demarrage du calcul
8030// (soit avec des valeurs du jdd, soit avec des valeurs lues dans le fichier de reprise)
8032{
8033 Cout << "DNS_QC_double::initialise()" << finl;
8034
8035 // precision de sortie du Cerr !!!
8036 Cerr.setf(ios::scientific);
8037 Cerr.precision(20);
8038 Cout.setf(ios::scientific);
8039 Cout.precision(20);
8040
8041 Cout << "precision de sortie du out et du err modifier" << finl;
8042
8043 // calcul de la constante specifique du gaz
8045 Cout << " Cp_gaz = " << Cp_gaz_
8046 << "\n constante_specifique_gaz = " << constante_specifique_gaz_ << finl;
8047
8048 // calcule les valeurs aux parois
8049 const double Pth_sur_R = P_thermodynamique_ / constante_specifique_gaz_;
8052 lambda_de_t_paroi_kmin_ = calculer_lambda_air(T_paroi_impose_kmin_);
8053 lambda_de_t_paroi_kmax_ = calculer_lambda_air(T_paroi_impose_kmax_);
8054 Cout << " T_paroi_impose_kmin_ = " << T_paroi_impose_kmin_
8055 << "\n T_paroi_impose_kmax_ = " << T_paroi_impose_kmax_
8056 << "\n lambda_de_t_paroi_kmin = " << lambda_de_t_paroi_kmin_
8057 << "\n lambda_de_t_paroi_kmax = " << lambda_de_t_paroi_kmax_ << finl;
8058
8059 // calcul du volume total du domaine
8060 const Nom& geom_name = domaine_.le_nom();
8061
8062 int Nx_tot = domaine_.get_nb_elem_tot(0) + 1;
8063 int Ny_tot = domaine_.get_nb_elem_tot(1) + 1;
8064 int Nz_tot = domaine_.get_nb_elem_tot(2) + 1;
8065 Lx_tot_ = domaine_.get_node_coordinates(0)[Nx_tot - 1] - domaine_.get_origin(0);
8066 Ly_tot_ = domaine_.get_node_coordinates(1)[Ny_tot - 1] - domaine_.get_origin(1);
8067 Lz_tot_ = domaine_.get_node_coordinates(2)[Nz_tot - 1] - domaine_.get_origin(2);
8069 Cout << " Volume total domaine = " << volume_total_domaine_ << finl;
8070
8071 if ( fichier_reprise_rho_ == "??" ) // si on ne fait pas une reprise on initialise T et rho suivant une methode
8072 {
8073 Cout << "Initialisation temperature, expression = " << expression_temperature_initiale_ << finl;
8075 // Calcul de rho_ fonction de la temperature:
8076 const int nk = temperature_.nk();
8077 const int nj = temperature_.nj();
8078 const int ni = temperature_.ni();
8079 for (int k = 0; k < nk; k++ )
8080 {
8081 for (int j = 0; j < nj; j++)
8082 {
8083 for (int i = 0; i < ni; i++)
8084 {
8085 double t = temperature_(i,j,k);
8086 rho_(i,j,k) = Pth_sur_R / t;
8087 }
8088 }
8089 }
8090 }
8091 else
8092 {
8093 Cout << "Lecture rho initial dans fichier " << fichier_reprise_rho_ << " timestep= " << timestep_reprise_rho_ << finl;
8094 lire_dans_lata(fichier_reprise_rho_, timestep_reprise_rho_, geom_name, "RHO", rho_);
8095 }
8096
8097 if (fichier_reprise_vitesse_ == "??") // si on ne fait pas une reprise on initialise V
8098 {
8099 if (expression_vitesse_initiale_.size() != 3)
8100 {
8101 Cerr << "Erreur dans l'initialisation: la vitesse initiale doit etre fournie avec trois expressions" << finl;
8102 Process::exit();
8103 }
8104 Cout << "Initialisation vitesse \nvx = " << expression_vitesse_initiale_[0]
8105 << "\nvy = " << expression_vitesse_initiale_[1]
8106 << "\nvz = " << expression_vitesse_initiale_[2] << finl;
8107 for (int i = 0; i < 3; i++)
8108 set_field_data(velocity_[i], expression_vitesse_initiale_[i]);
8109 }
8110 else
8111 {
8112 Cout << "Lecture vitesse initiale dans fichier " << fichier_reprise_vitesse_ << " timestep= " << timestep_reprise_vitesse_ << finl;
8113 lire_dans_lata(fichier_reprise_vitesse_, timestep_reprise_vitesse_, geom_name, "VELOCITY",
8114 velocity_[0], velocity_[1], velocity_[2]); // fonction qui lit un champ a partir d'un lata .
8115 }
8116
8117 // initialise temperature, lambda et mu
8118 // (on a besoin de mu(rho) initial pour l'operateur diffusion, voir rk3_sub_step()
8119 rho_.echange_espace_virtuel(1); // Nous avons besoin d'avoir rho a jour aux bord pour calculer le joints de mu et lambda !!
8121
8122 // statistiques...
8123 Cout << "Initialisation des statistiques. T_debut_statistiques=" << t_debut_statistiques_ << finl;
8125
8126 if ( dt_post_spectral_ > 0 ) // si on a un post traitement spectral
8127 {
8128 if (!statistiques_.is_converge())
8129 {
8130 Cerr << " les stats ne sont pas converger pas de productions spectrale allowed." << finl;
8131 Process::exit();
8132 }
8133
8134 partie_fourier_.initialize(domaine_ /* maillage de simu */
8135 ,post_splitting_ /* maillage de post traitement */
8136 ,statistiques_.vitesse_moyenne() /* vitesse moyenne utilisee dans les stats standart */
8137 ,statistiques_.masse_volumique_moyenne() /* masse volumique moyenne utilisee dans les stats standart */
8138 ,statistiques_.viscosite_cinematique_moyenne() /* viscosite cinematique moyenne utilisee dans les stats standart */
8142 }
8143
8144// pour source :
8146 if (debit_actuel_<0)
8147 {
8148 calculer_debit(velocity_[0], rho_, delta_z_local_, Lx_tot_, debit_actuel_);
8150 Cerr<< "debit "<<debit_actuel_<<finl;
8151 }
8152
8155}
8156
8157static void force_zero_normal_velocity_on_walls(IJK_Field_double& vz)
8158{
8159 const int nj = vz.nj();
8160 const int ni = vz.ni();
8161 const int kmin = vz.get_domaine().get_offset_local(DIRECTION_K);
8162 const int nktot = vz.get_domaine().get_nb_items_global(Domaine_IJK::FACES_K, DIRECTION_K);
8163 if (kmin == 0)
8164 {
8165 for (int j = 0; j < nj; j++)
8166 {
8167 for (int i = 0; i < ni; i++)
8168 {
8169 vz(i,j,0) = 0.;
8170 }
8171 }
8172 }
8173 if (kmin + vz.nk() == nktot)
8174 {
8175 const int k = vz.nk()-1;
8176 for (int j = 0; j < nj; j++)
8177 {
8178 for (int i = 0; i < ni; i++)
8179 {
8180 vz(i,j,k) = 0.;
8181 }
8182 }
8183 }
8184}
8185
8186static double calculer_dtstab_diffusion_temperature_local(const IJK_Field_double& lambda,
8187 const IJK_Field_double& rho,
8188 const double cp_gaz)
8189{
8190 const Domaine_IJK& geom = lambda.get_domaine();
8191 const int ni = geom.get_nb_elem_local(DIRECTION_I);
8192 const int nj = geom.get_nb_elem_local(DIRECTION_J);
8193 const int nk = geom.get_nb_elem_local(DIRECTION_K);
8194 const double dx = geom.get_constant_delta(DIRECTION_I);
8195 const double dy = geom.get_constant_delta(DIRECTION_J);
8196 const ArrOfDouble& delta_z = geom.get_delta(DIRECTION_K);
8197 const int k_offset = geom.get_offset_local(DIRECTION_K);
8198
8199 double inv_dtstab = 1e-20;
8200 for (int k = 0; k < nk; k++)
8201 {
8202 const double dz = delta_z[k + k_offset];
8203 const double coeff = 2. * (1./(dx*dx) + 1./(dy*dy) + 1./(dz*dz)) / cp_gaz;
8204 for (int j = 0; j < nj; j++)
8205 {
8206 for (int i = 0; i < ni; i++)
8207 {
8208 double dt = lambda(i,j,k) / rho(i,j,k) * coeff;
8209 inv_dtstab = max(dt, inv_dtstab);
8210 }
8211 }
8212 }
8213 return 1. / inv_dtstab;
8214}
8215
8216static double calculer_dtstab_diffusion_temperature_local_sans_rho(const bool anisotropic,
8217 const IJK_Field_double& lambda_x,
8218 const IJK_Field_double& lambda_y,
8219 const IJK_Field_double& lambda_z,
8220 const double cp_gaz)
8221{
8222 const Domaine_IJK& geom = lambda_x.get_domaine();
8223 const int ni = geom.get_nb_elem_local(DIRECTION_I);
8224 const int nj = geom.get_nb_elem_local(DIRECTION_J);
8225 const int nk = geom.get_nb_elem_local(DIRECTION_K);
8226 const double dx = geom.get_constant_delta(DIRECTION_I);
8227 const double dy = geom.get_constant_delta(DIRECTION_J);
8228 const ArrOfDouble& delta_z = geom.get_delta(DIRECTION_K);
8229 const int k_offset = geom.get_offset_local(DIRECTION_K);
8230
8231 double inv_dtstab = 1e-20;
8232 for (int k = 0; k < nk; k++)
8233 {
8234 const double dz = delta_z[k + k_offset];
8235 double coeff_x;
8236 double coeff_y;
8237 double coeff_z;
8238 if (anisotropic)
8239 {
8240 coeff_x = 2. * (1./(dx)) / cp_gaz;
8241 coeff_y = 2. * (1./(dy)) / cp_gaz;
8242 coeff_z = 2. * (1./(dz)) / cp_gaz;
8243 }
8244 else
8245 {
8246 coeff_x = 2. * (1./(dx*dx)) / cp_gaz;
8247 coeff_y = 2. * (1./(dy*dy)) / cp_gaz;
8248 coeff_z = 2. * (1./(dz*dz)) / cp_gaz;
8249 }
8250 for (int j = 0; j < nj; j++)
8251 {
8252 for (int i = 0; i < ni; i++)
8253 {
8254 double dt_x = lambda_x(i,j,k) * coeff_x;
8255 double dt_y = lambda_y(i,j,k) * coeff_y;
8256 double dt_z = lambda_z(i,j,k) * coeff_z;
8257 double dt = dt_x + dt_y + dt_z;
8258 inv_dtstab = max(dt, inv_dtstab);
8259 }
8260 }
8261 }
8262 return 1. / inv_dtstab;
8263}
8264
8265static double calculer_dtstab_diffusion_temperature_local_avec_turbulent_favre(const bool anisotropic,
8266 const IJK_Field_double& lambda,
8267 const IJK_Field_double& lambda_turbulent_xx,
8268 const IJK_Field_double& lambda_turbulent_xy,
8269 const IJK_Field_double& lambda_turbulent_xz,
8270 const IJK_Field_double& lambda_turbulent_yy,
8271 const IJK_Field_double& lambda_turbulent_yz,
8272 const IJK_Field_double& lambda_turbulent_zz,
8273 const IJK_Field_double& rho,
8274 const double cp_gaz)
8275{
8276 const IJK_Field_double& lambda_turbulent_yx = lambda_turbulent_xy;
8277 const IJK_Field_double& lambda_turbulent_zx = lambda_turbulent_xz;
8278 const IJK_Field_double& lambda_turbulent_zy = lambda_turbulent_yz;
8279
8280 const Domaine_IJK& geom = lambda.get_domaine();
8281 const int ni = geom.get_nb_elem_local(DIRECTION_I);
8282 const int nj = geom.get_nb_elem_local(DIRECTION_J);
8283 const int nk = geom.get_nb_elem_local(DIRECTION_K);
8284 const double dx = geom.get_constant_delta(DIRECTION_I);
8285 const double dy = geom.get_constant_delta(DIRECTION_J);
8286 const ArrOfDouble& delta_z = geom.get_delta(DIRECTION_K);
8287 const int k_offset = geom.get_offset_local(DIRECTION_K);
8288
8289 double inv_dtstab = 1e-20;
8290 for (int k = 0; k < nk; k++)
8291 {
8292 const double dz = delta_z[k + k_offset];
8293 const double coeff_x = 2. * (1./(dx*dx)) / cp_gaz;
8294 const double coeff_y = 2. * (1./(dy*dy)) / cp_gaz;
8295 const double coeff_z = 2. * (1./(dz*dz)) / cp_gaz;
8296 double fac_x;
8297 double fac_y;
8298 double fac_z;
8299 if (anisotropic)
8300 {
8301 fac_x = dx;
8302 fac_y = dy;
8303 fac_z = dz;
8304 }
8305 else
8306 {
8307 fac_x = 1.;
8308 fac_y = 1.;
8309 fac_z = 1.;
8310 }
8311 for (int j = 0; j < nj; j++)
8312 {
8313 for (int i = 0; i < ni; i++)
8314 {
8315 double dt_xx = ( lambda(i,j,k) + lambda_turbulent_xx(i,j,k)*fac_x ) / rho(i,j,k) * coeff_x;
8316 double dt_xy = ( lambda(i,j,k) + lambda_turbulent_xy(i,j,k)*fac_y ) / rho(i,j,k) * coeff_y;
8317 double dt_xz = ( lambda(i,j,k) + lambda_turbulent_xz(i,j,k)*fac_z ) / rho(i,j,k) * coeff_z;
8318 double dt_yx = ( lambda(i,j,k) + lambda_turbulent_yx(i,j,k)*fac_x ) / rho(i,j,k) * coeff_x;
8319 double dt_yy = ( lambda(i,j,k) + lambda_turbulent_yy(i,j,k)*fac_y ) / rho(i,j,k) * coeff_y;
8320 double dt_yz = ( lambda(i,j,k) + lambda_turbulent_yz(i,j,k)*fac_z ) / rho(i,j,k) * coeff_z;
8321 double dt_zx = ( lambda(i,j,k) + lambda_turbulent_zx(i,j,k)*fac_x ) / rho(i,j,k) * coeff_x;
8322 double dt_zy = ( lambda(i,j,k) + lambda_turbulent_zy(i,j,k)*fac_y ) / rho(i,j,k) * coeff_y;
8323 double dt_zz = ( lambda(i,j,k) + lambda_turbulent_zz(i,j,k)*fac_z ) / rho(i,j,k) * coeff_z;
8324 double dt_x = dt_xx + dt_xy + dt_xz;
8325 double dt_y = dt_yx + dt_yy + dt_yz;
8326 double dt_z = dt_zx + dt_zy + dt_zz;
8327 double dt = max(dt_x , max(dt_y, dt_z));
8328 inv_dtstab = max(dt, inv_dtstab);
8329 }
8330 }
8331 }
8332 return 1. / inv_dtstab;
8333}
8334
8335static double calculer_dtstab_diffusion_temperature_local_avec_turbulent_velocity(const bool anisotropic,
8336 const IJK_Field_double& lambda,
8337 const IJK_Field_double& lambda_turbulent_xx,
8338 const IJK_Field_double& lambda_turbulent_xy,
8339 const IJK_Field_double& lambda_turbulent_xz,
8340 const IJK_Field_double& lambda_turbulent_yy,
8341 const IJK_Field_double& lambda_turbulent_yz,
8342 const IJK_Field_double& lambda_turbulent_zz,
8343 const IJK_Field_double& rho,
8344 const double cp_gaz)
8345{
8346 const IJK_Field_double& lambda_turbulent_yx = lambda_turbulent_xy;
8347 const IJK_Field_double& lambda_turbulent_zx = lambda_turbulent_xz;
8348 const IJK_Field_double& lambda_turbulent_zy = lambda_turbulent_yz;
8349
8350 const Domaine_IJK& geom = lambda.get_domaine();
8351 const int ni = geom.get_nb_elem_local(DIRECTION_I);
8352 const int nj = geom.get_nb_elem_local(DIRECTION_J);
8353 const int nk = geom.get_nb_elem_local(DIRECTION_K);
8354 const double dx = geom.get_constant_delta(DIRECTION_I);
8355 const double dy = geom.get_constant_delta(DIRECTION_J);
8356 const ArrOfDouble& delta_z = geom.get_delta(DIRECTION_K);
8357 const int k_offset = geom.get_offset_local(DIRECTION_K);
8358
8359 double inv_dtstab = 1e-20;
8360 for (int k = 0; k < nk; k++)
8361 {
8362 const double dz = delta_z[k + k_offset];
8363 const double coeff_x = 2. * (1./(dx*dx)) / cp_gaz;
8364 const double coeff_y = 2. * (1./(dy*dy)) / cp_gaz;
8365 const double coeff_z = 2. * (1./(dz*dz)) / cp_gaz;
8366 double fac_x;
8367 double fac_y;
8368 double fac_z;
8369 if (anisotropic)
8370 {
8371 fac_x = dx;
8372 fac_y = dy;
8373 fac_z = dz;
8374 }
8375 else
8376 {
8377 fac_x = 1.;
8378 fac_y = 1.;
8379 fac_z = 1.;
8380 }
8381 for (int j = 0; j < nj; j++)
8382 {
8383 for (int i = 0; i < ni; i++)
8384 {
8385 double dt_xx = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_xx(i,j,k)*fac_x ) * coeff_x;
8386 double dt_xy = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_xy(i,j,k)*fac_y ) * coeff_y;
8387 double dt_xz = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_xz(i,j,k)*fac_z ) * coeff_z;
8388 double dt_yx = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_yx(i,j,k)*fac_x ) * coeff_x;
8389 double dt_yy = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_yy(i,j,k)*fac_y ) * coeff_y;
8390 double dt_yz = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_yz(i,j,k)*fac_z ) * coeff_z;
8391 double dt_zx = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_zx(i,j,k)*fac_x ) * coeff_x;
8392 double dt_zy = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_zy(i,j,k)*fac_y ) * coeff_y;
8393 double dt_zz = ( lambda(i,j,k)/rho(i,j,k) + lambda_turbulent_zz(i,j,k)*fac_z ) * coeff_z;
8394 double dt_x = dt_xx + dt_xy + dt_xz;
8395 double dt_y = dt_yx + dt_yy + dt_yz;
8396 double dt_z = dt_zx + dt_zy + dt_zz;
8397 double dt = max(dt_x , max(dt_y, dt_z));
8398 inv_dtstab = max(dt, inv_dtstab);
8399 }
8400 }
8401 }
8402 return 1. / inv_dtstab;
8403}
8404
8405// Impression dans cerr du flux vertical (direction K) conductif et
8407{
8408 const int ni = velocity_[2].ni();
8409 const int nj = velocity_[2].nj();
8410 const int nk = velocity_[2].nk();
8411
8412 const double dx = velocity_[2].get_domaine().get_constant_delta(DIRECTION_I);
8413 const double dy = velocity_[2].get_domaine().get_constant_delta(DIRECTION_J);
8414
8415 const double facteur = Cp_gaz_ * P_thermodynamique_ / constante_specifique_gaz_;
8416 const double surface = 1. / (ni*nj); // calcule directement la surface et la moyenne.
8417 const int offset = temperature_.get_domaine().get_offset_local(DIRECTION_K);
8418 const int nktot = velocity_[2].get_domaine().get_nb_items_global(Domaine_IJK::FACES_K, DIRECTION_K);
8419
8420 // tableau globaux plus facile pour faire un mp_sum.
8421 ArrOfDouble flux_cv(nktot);
8422 ArrOfDouble flux_cd(nktot);
8423
8424 flux_cv =0;
8425 flux_cd =0;
8426
8427 for (int k = 0; k < nk; k++)
8428 {
8429 double partiel_flux_cv = 0.;
8430 double partiel_flux_cd = 0.;
8431
8432 if ( (k + offset) == (nktot-1) )
8433 {
8434 partiel_flux_cv =0; // vitesse nulle a la paroi
8435 for (int j = 0; j < nj; j++)
8436 {
8437 for (int i = 0; i < ni; i++)
8438 {
8439 partiel_flux_cd += boundary_flux_kmax_(i,j,0)/ (dx* dy); // somme des flux de bord
8440 }
8441 }
8442 }
8443 else if ( (k + offset) == 0 )
8444 {
8445 partiel_flux_cv =0; // vitesse nulle a la paroi
8446 for (int j = 0; j < nj; j++)
8447 {
8448 for (int i = 0; i < ni; i++)
8449 {
8450 partiel_flux_cd += boundary_flux_kmin_(i,j,0) / (dx* dy); // somme des flux de bord
8451 }
8452 }
8453 }
8454 else
8455 {
8456 const double d0 = delta_z_local_[k-1] * 0.5;
8457 const double d1 = delta_z_local_[k] * 0.5;
8458 for (int j = 0; j < nj; j++)
8459 {
8460 for (int i = 0; i < ni; i++)
8461 {
8462 const double v = velocity_[2](i,j,k);
8463 const double L0 = molecular_lambda_(i,j,k-1);
8464 const double L1 = molecular_lambda_(i,j,k);
8465
8466 const double lambda_face = (L0 * L1) / ( d0 * L0 + d1 *L1);
8467 // mauvaise methode ici il faut utiliser la CL de flux bord.
8468 const double T_inf = temperature_(i,j,k-1);
8469 const double T_sup = temperature_(i,j,k);
8470
8471 double flux = lambda_face * ( T_inf - T_sup); // on calcule -L dT/dy
8472
8473 partiel_flux_cv += v * facteur;
8474 partiel_flux_cd += flux;
8475 }
8476 }
8477 }
8478 flux_cv[k+offset] = partiel_flux_cv;
8479 flux_cd[k+offset] = partiel_flux_cd;
8480 }
8481 flux_cv *= surface;
8482 flux_cd *= surface;
8483
8484 // communication
8485 // je veux ton recevoir sur le 0 pour ecrire.
8486 // pas besoin d'un envoi general.
8487 // bon pour le moment je m'en contente.
8488 mp_sum_for_each_item(flux_cv);
8489 mp_sum_for_each_item(flux_cd);
8490}
8491
8492
8493void DNS_QC_double::ecrire_fichier_sauv(const char *fichier_sauvegarde, const char *lata_name)
8494{
8496 {
8497 Cerr << "T= " << current_time_ << " Checkpointing dans le fichier " << fichier_sauvegarde << finl;
8498 SFichier fichier(fichier_sauvegarde);
8499 fichier.precision(17);
8500 fichier.setf(std::ios_base::scientific);
8501 fichier << "{\n"
8502 << " tinit " << current_time_ << "\n"
8503 << " terme_acceleration_init " << terme_source_acceleration_ << "\n"
8504 << " terme_acceleration_init_z " << terme_source_acceleration_z_ << "\n"
8505 << " p_thermo_init " << P_thermodynamique_ << "\n"
8506 << " fichier_reprise_vitesse " << lata_name << "\n";
8507 fichier << " fichier_reprise_rho " << lata_name << "\n"
8508 << " timestep_reprise_vitesse " << (int) 1 << "\n"
8509 << " timestep_reprise_rho " << (int) 1 << "\n";
8510 if (statistiques_.t_integration() > 0.)
8511 fichier << " statistiques " << statistiques_;
8512 fichier << "}\n";
8513 }
8514}
8515
8516void DNS_QC_double::sauvegarder_qc(const char *fichier_sauvegarde)
8517{
8518 Nom lata_name(fichier_sauvegarde);
8519 lata_name += ".lata";
8520
8521 ecrire_fichier_sauv(fichier_sauvegarde, lata_name);
8522 if (sauvegarde_splitting_name_ != "??")
8523 {
8524 for (int i = 0; i < 3; i++)
8525 {
8527 velocity_sauvegarde_[i].echange_espace_virtuel(velocity_sauvegarde_[i].ghost());
8528 }
8530 rho_sauvegarde_.echange_espace_virtuel(rho_sauvegarde_.ghost());
8531
8532 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8533 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8534 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8535
8536 if (ni > 0 || nj > 0 || nk > 0)
8537 {
8538 dumplata_header(lata_name, rho_sauvegarde_ /* on passe un champ pour ecrire la geometrie */);
8539 dumplata_newtime(lata_name, current_time_);
8540 dumplata_vector_parallele_plan(lata_name, "VELOCITY", velocity_sauvegarde_[0], velocity_sauvegarde_[1], velocity_sauvegarde_[2], 0);
8541 dumplata_scalar_parallele_plan(lata_name, "RHO", rho_sauvegarde_, 0);
8542 }
8543 }
8544 else
8545 {
8546 dumplata_header(lata_name, rho_ /* on passe un champ pour ecrire la geometrie */);
8547 dumplata_newtime(lata_name,current_time_);
8548 dumplata_vector(lata_name,"VELOCITY", velocity_[0], velocity_[1], velocity_[2], 0);
8549 dumplata_scalar(lata_name,"RHO", rho_, 0);
8550 }
8551
8552 if (dt_post_spectral_ > 0 )
8553 partie_fourier_.sauvegarde();
8554
8555}
8556
8557void DNS_QC_double::reprendre_qc(const char *fichier_reprise)
8558{
8559 Cerr << "Reprise du calcul dans le fichier " << fichier_reprise << finl;
8560 // Lecture par tous les processeurs, on retire les commentaires etc...
8561 LecFicDiffuse_JDD fichier(fichier_reprise);
8562 Param param(que_suis_je());
8563 param.ajouter("tinit", &current_time_);
8564 param.ajouter("terme_acceleration_init", &terme_source_acceleration_, Param::REQUIRED);
8565 param.ajouter("terme_acceleration_init_z", &terme_source_acceleration_z_, Param::REQUIRED);
8566 param.ajouter("p_thermo_init", &P_thermodynamique_, Param::REQUIRED);
8567 param.ajouter("fichier_reprise_vitesse", &fichier_reprise_vitesse_);
8568 param.ajouter("fichier_reprise_rho", &fichier_reprise_rho_);
8569 param.ajouter("timestep_reprise_vitesse", &timestep_reprise_vitesse_);
8570 param.ajouter("timestep_reprise_rho", &timestep_reprise_rho_);
8571 Cerr << "Avant ajout statistiques" << finl;
8572 param.ajouter("statistiques", &statistiques_);
8573 Cerr << "Apres ajout statistiques" << finl;
8574 param.lire_avec_accolades(fichier);
8575 // Appeler ensuite initialize() pour lire les fichiers lata etc...
8576 Cerr << "Reprise des donnees a t=" << current_time_ << "\n P_thermo=" << P_thermodynamique_ << finl;
8577}
8578
8579// MD 31/07/2019
8580// Calcul de la vitesse aux elements
8582{
8583 const int ni = velocity_elem_X_.ni();
8584 const int nj = velocity_elem_Y_.nj();
8585 const int nk = velocity_elem_Z_.nk();
8586
8587 for (int k = 0 ; k < nk ; k++)
8588 {
8589 for (int j = 0 ; j < nj ; j++)
8590 {
8591 for (int i = 0 ; i < ni ; i++)
8592 {
8593 velocity_elem_X_(i,j,k) = 0.5*(velocity_[0](i,j,k)+velocity_[0](i+1,j,k));
8594 velocity_elem_Y_(i,j,k) = 0.5*(velocity_[1](i,j,k)+velocity_[1](i,j+1,k));
8595 //if (kg == (nktot-1)) {
8596 // velocity_elem_Z_(i,j,k) = 0.5*(velocity_[2](i,j,k) + 0.);
8597 //} else {
8598 velocity_elem_Z_(i,j,k) = 0.5*(velocity_[2](i,j,k) + velocity_[2](i,j,k+1));
8599 //}
8600 }
8601 }
8602 }
8603 velocity_elem_X_.echange_espace_virtuel(1);
8604 velocity_elem_Y_.echange_espace_virtuel(1);
8605 velocity_elem_Z_.echange_espace_virtuel(1);
8606}
8607
8608void DNS_QC_double::posttraiter_champs_instantanes(const char *lata_name, double current_time)
8609{
8610 // DD,2016-28-01: statistiques a partir de fichiers lata uniquement
8612 {
8613 Nom nom_fichier_sauvegarde(lata_name);
8614 nom_fichier_sauvegarde += Nom(compteur_post_instantanes_);
8615 nom_fichier_sauvegarde += Nom(".sauv");
8616
8617 Nom lata_name_lata(nom_fichier_sauvegarde);
8618 lata_name_lata += ".lata";
8619
8620 ecrire_fichier_sauv(nom_fichier_sauvegarde, lata_name_lata);
8621
8622 dumplata_header(lata_name_lata, rho_ /* on passe un champ pour ecrire la geometrie */);
8623 dumplata_newtime(lata_name_lata, current_time_);
8624
8625 if (liste_post_instantanes_.contient_("TOUS"))
8626 {
8627 liste_post_instantanes_.dimensionner_force(0);
8628 liste_post_instantanes_.add("VELOCITY");
8629 liste_post_instantanes_.add("VELOCITY_ELEM_X");
8630 liste_post_instantanes_.add("VELOCITY_ELEM_Y");
8631 liste_post_instantanes_.add("VELOCITY_ELEM_Z");
8632 liste_post_instantanes_.add("D_VELOCITY");
8633 liste_post_instantanes_.add("PRESSURE");
8634 liste_post_instantanes_.add("TEMPERATURE");
8635 liste_post_instantanes_.add("RHO");
8636 liste_post_instantanes_.add("LAMBDA");
8637 liste_post_instantanes_.add("MU");
8638 liste_post_instantanes_.add("PRESSURE_RHS");
8639 liste_post_instantanes_.add("DIV_LAMBDA_GRAD_T_VOLUME");
8640 liste_post_instantanes_.add("U_DIV_RHO_U");
8641 liste_post_instantanes_.add("DRHO_DT");
8653 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_XX");
8654 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_XY");
8655 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_XZ");
8656 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_YY");
8657 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_YZ");
8658 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_ZZ");
8659 if (structural_uscalar_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_X");
8660 if (structural_uscalar_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_Y");
8661 if (structural_uscalar_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_Z");
8662 if (flag_u_filtre_) liste_post_instantanes_.add("VELOCITY_FILTRE");
8663 if (flag_rho_filtre_) liste_post_instantanes_.add("RHO_FILTRE");
8664 if (flag_temperature_filtre_) liste_post_instantanes_.add("TEMPERATURE_FILTRE");
8665 if (flag_turbulent_mu_filtre_ && (!flag_nu_tensorial_)) liste_post_instantanes_.add("TURBULENT_MU_FILTRE");
8667 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_XY");
8668 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_XZ");
8669 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_YY");
8670 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_YZ");
8671 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_ZZ");
8672 if (flag_turbulent_kappa_filtre_ && (!flag_kappa_vectorial_)) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE");
8673 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE_X");
8674 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE_Y");
8675 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE_Z");
8676 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_XX");
8677 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_XY");
8678 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_XZ");
8679 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_YY");
8680 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_YZ");
8681 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_ZZ");
8682 if (flag_structural_uscalar_filtre_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_FILTRE_X");
8683 if (flag_structural_uscalar_filtre_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_FILTRE_Y");
8684 if (flag_structural_uscalar_filtre_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_FILTRE_Z");
8685 }
8686 int n = liste_post_instantanes_.size();
8687 Cerr << " Martinn n= " << n << finl;
8688
8689 if (liste_post_instantanes_.contient_("VELOCITY"))
8690 {
8691 n=n-1;
8692 dumplata_vector(lata_name_lata,"VELOCITY", velocity_[0], velocity_[1], velocity_[2], 0);
8693 }
8694 if (liste_post_instantanes_.contient_("VELOCITY_ELEM_X"))
8695 {
8696 n=n-1;
8698 if (sauvegarde_splitting_name_ != "??")
8699 {
8701 velocity_elem_X_sauvegarde_.echange_espace_virtuel(velocity_elem_X_sauvegarde_.ghost());
8702
8703 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8704 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8705 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8706
8707 if (ni > 0 || nj > 0 || nk > 0)
8708 {
8709 dumplata_scalar_parallele_plan(lata_name_lata, "VELOCITY_ELEM_X", velocity_elem_X_sauvegarde_, 0);
8710 }
8711 }
8712 else
8713 {
8714 dumplata_scalar(lata_name_lata,"VELOCITY_ELEM_X", velocity_elem_X_, 0);
8715 }
8716 }
8717
8718 if (liste_post_instantanes_.contient_("VELOCITY_ELEM_Y"))
8719 {
8720 n=n-1;
8721 if (sauvegarde_splitting_name_ != "??")
8722 {
8724 velocity_elem_Y_sauvegarde_.echange_espace_virtuel(velocity_elem_Y_sauvegarde_.ghost());
8725
8726 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8727 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8728 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8729
8730 if (ni > 0 || nj > 0 || nk > 0)
8731 {
8732 dumplata_scalar_parallele_plan(lata_name_lata, "VELOCITY_ELEM_Y", velocity_elem_Y_sauvegarde_, 0);
8733 }
8734 }
8735 else
8736 {
8737 dumplata_scalar(lata_name_lata,"VELOCITY_ELEM_Y", velocity_elem_Y_, 0);
8738 }
8739 }
8740
8741 if (liste_post_instantanes_.contient_("VELOCITY_ELEM_Z"))
8742 {
8743 n=n-1;
8744 if (sauvegarde_splitting_name_ != "??")
8745 {
8747 velocity_elem_Z_sauvegarde_.echange_espace_virtuel(velocity_elem_Z_sauvegarde_.ghost());
8748
8749 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8750 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8751 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8752
8753 if (ni > 0 || nj > 0 || nk > 0)
8754 {
8755 dumplata_scalar_parallele_plan(lata_name_lata, "VELOCITY_ELEM_Z", velocity_elem_Z_sauvegarde_, 0);
8756 }
8757 }
8758 else
8759 {
8760 dumplata_scalar(lata_name_lata,"VELOCITY_ELEM_Z", velocity_elem_Z_, 0);
8761 }
8762 }
8763 if (liste_post_instantanes_.contient_("D_VELOCITY"))
8764 n--, dumplata_vector(lata_name_lata,"D_VELOCITY", d_velocity_[0], d_velocity_[1], d_velocity_[2], 0);
8765 if (liste_post_instantanes_.contient_("PRESSURE"))
8766 {
8767 n=n-1;
8768 if (sauvegarde_splitting_name_ != "??")
8769 {
8771 pressure_sauvegarde_.echange_espace_virtuel(pressure_sauvegarde_.ghost());
8772
8773 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8774 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8775 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8776
8777 if (ni > 0 || nj > 0 || nk > 0)
8778 {
8779 dumplata_scalar_parallele_plan(lata_name_lata, "PRESSURE", pressure_sauvegarde_, 0);
8780 }
8781 }
8782 else
8783 {
8784 dumplata_scalar(lata_name_lata,"PRESSURE", pressure_, 0);
8785 }
8786 }
8787 if (liste_post_instantanes_.contient_("TEMPERATURE"))
8788 {
8789 n=n-1;
8790 if (sauvegarde_splitting_name_ != "??")
8791 {
8793 temperature_sauvegarde_.echange_espace_virtuel(temperature_sauvegarde_.ghost());
8794
8795 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8796 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8797 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8798
8799 if (ni > 0 || nj > 0 || nk > 0)
8800 {
8801 dumplata_scalar_parallele_plan(lata_name_lata, "TEMPERATURE", temperature_sauvegarde_, 0);
8802 }
8803 }
8804 else
8805 {
8806 dumplata_scalar(lata_name_lata,"TEMPERATURE", temperature_, 0);
8807 }
8808 }
8809 if (liste_post_instantanes_.contient_("RHO"))
8810 {
8811 n=n-1;
8812 if (sauvegarde_splitting_name_ != "??")
8813 {
8815 rho_sauvegarde_.echange_espace_virtuel(rho_sauvegarde_.ghost());
8816
8817 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8818 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8819 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8820
8821 if (ni > 0 || nj > 0 || nk > 0)
8822 {
8823 dumplata_scalar_parallele_plan(lata_name_lata, "RHO", rho_sauvegarde_, 0);
8824 }
8825 }
8826 else
8827 {
8828 dumplata_scalar(lata_name_lata,"RHO", rho_, 0);
8829 }
8830 }
8831 if (liste_post_instantanes_.contient_("LAMBDA"))
8832 {
8833 n=n-1;
8834 if (sauvegarde_splitting_name_ != "??")
8835 {
8837 molecular_lambda_sauvegarde_.echange_espace_virtuel(molecular_lambda_sauvegarde_.ghost());
8838
8839 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8840 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8841 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8842
8843 if (ni > 0 || nj > 0 || nk > 0)
8844 {
8845 dumplata_scalar_parallele_plan(lata_name_lata, "LAMBDA", molecular_lambda_sauvegarde_, 0);
8846 }
8847 }
8848 else
8849 {
8850 dumplata_scalar(lata_name_lata,"LAMBDA", molecular_lambda_, 0);
8851 }
8852 }
8853 if (liste_post_instantanes_.contient_("MU"))
8854 {
8855 n=n-1;
8856 if (sauvegarde_splitting_name_ != "??")
8857 {
8859 molecular_mu_sauvegarde_.echange_espace_virtuel(molecular_mu_sauvegarde_.ghost());
8860
8861 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
8862 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
8863 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
8864
8865 if (ni > 0 || nj > 0 || nk > 0)
8866 {
8867 dumplata_scalar_parallele_plan(lata_name_lata, "MU", molecular_mu_sauvegarde_, 0);
8868 }
8869 }
8870 else
8871 {
8872 dumplata_scalar(lata_name_lata,"MU", molecular_mu_, 0);
8873 }
8874 }
8875 if (liste_post_instantanes_.contient_("PRESSURE_RHS"))
8876 n--,dumplata_scalar(lata_name_lata,"PRESSURE_RHS", pressure_rhs_, 0);
8877 if (liste_post_instantanes_.contient_("DIV_LAMBDA_GRAD_T_VOLUME"))
8878 n--,dumplata_scalar(lata_name_lata,"DIV_LAMBDA_GRAD_T_VOLUME", div_lambda_grad_T_volume_, 0);
8879 if (liste_post_instantanes_.contient_("U_DIV_RHO_U"))
8880 n--,dumplata_scalar(lata_name_lata,"U_DIV_RHO_U", u_div_rho_u_, 0);
8881 if (liste_post_instantanes_.contient_("DRHO_DT"))
8882 n--,dumplata_scalar(lata_name_lata,"DRHO_DT", d_rho_, 0);
8883 if (turbulent_viscosity_ && (!flag_nu_tensorial_) && liste_post_instantanes_.contient_("TURBULENT_MU"))
8884 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU", turbulent_mu_, 0);
8885 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_XX"))
8886 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_XX", turbulent_mu_tensor_[0], 0);
8887 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_XY"))
8888 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_XY", turbulent_mu_tensor_[1], 0);
8889 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_XZ"))
8890 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_XZ", turbulent_mu_tensor_[2], 0);
8891 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_YY"))
8892 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_YY", turbulent_mu_tensor_[3], 0);
8893 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_YZ"))
8894 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_YZ", turbulent_mu_tensor_[4], 0);
8895 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_ZZ"))
8896 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_ZZ", turbulent_mu_tensor_[5], 0);
8897 if (turbulent_diffusivity_ && (!flag_kappa_vectorial_) && liste_post_instantanes_.contient_("TURBULENT_KAPPA"))
8898 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA", turbulent_kappa_, 0);
8899 if (turbulent_diffusivity_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_X"))
8900 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_X", turbulent_kappa_vector_[0], 0);
8901 if (turbulent_diffusivity_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_Y"))
8902 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_Y", turbulent_kappa_vector_[1], 0);
8903 if (turbulent_diffusivity_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_Z"))
8904 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_Z", turbulent_kappa_vector_[2], 0);
8905 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_XX"))
8906 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_XX", structural_uu_tensor_[0], 0);
8907 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_XY"))
8908 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_XY", structural_uu_tensor_[1], 0);
8909 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_XZ"))
8910 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_XZ", structural_uu_tensor_[2], 0);
8911 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_YY"))
8912 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_YY", structural_uu_tensor_[3], 0);
8913 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_YZ"))
8914 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_YZ", structural_uu_tensor_[4], 0);
8915 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_ZZ"))
8916 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_ZZ", structural_uu_tensor_[5], 0);
8917 if (structural_uscalar_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_X"))
8918 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_X", structural_uscalar_vector_[0], 0);
8919 if (structural_uscalar_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_Y"))
8920 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_Y", structural_uscalar_vector_[1], 0);
8921 if (structural_uscalar_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_Z"))
8922 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_Z", structural_uscalar_vector_[2], 0);
8923 if (flag_u_filtre_ && liste_post_instantanes_.contient_("VELOCITY_FILTRE"))
8924 n--,dumplata_vector(lata_name_lata,"VELOCITY_FILTRE", velocity_filtre_[0], velocity_filtre_[1], velocity_filtre_[2], 0);
8925 if (flag_rho_filtre_ && liste_post_instantanes_.contient_("RHO_FILTRE"))
8926 n--,dumplata_scalar(lata_name_lata,"RHO_FILTRE", rho_filtre_, 0);
8927 if (flag_temperature_filtre_ && liste_post_instantanes_.contient_("TEMPERATURE_FILTRE"))
8928 n--,dumplata_scalar(lata_name_lata,"TEMPERATURE_FILTRE", temperature_filtre_, 0);
8929 if (flag_turbulent_mu_filtre_ && (!flag_nu_tensorial_) && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE"))
8930 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE", turbulent_mu_filtre_, 0);
8931 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_XX"))
8932 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_XX", turbulent_mu_filtre_tensor_[0], 0);
8933 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_XY"))
8934 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_XY", turbulent_mu_filtre_tensor_[1], 0);
8935 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_XZ"))
8936 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_XZ", turbulent_mu_filtre_tensor_[2], 0);
8937 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_YY"))
8938 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_YY", turbulent_mu_filtre_tensor_[3], 0);
8939 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_YZ"))
8940 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_YZ", turbulent_mu_filtre_tensor_[4], 0);
8941 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_ZZ"))
8942 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_ZZ", turbulent_mu_filtre_tensor_[5], 0);
8943 if (flag_turbulent_kappa_filtre_ && (!flag_kappa_vectorial_) && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE"))
8944 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE", turbulent_kappa_filtre_, 0);
8945 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE_X"))
8946 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE_X", turbulent_kappa_filtre_vector_[0], 0);
8947 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE_Y"))
8948 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE_Y", turbulent_kappa_filtre_vector_[1], 0);
8949 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE_Z"))
8950 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE_Z", turbulent_kappa_filtre_vector_[2], 0);
8951 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_XX"))
8952 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_XX", structural_uu_filtre_tensor_[0], 0);
8953 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_XY"))
8954 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_XY", structural_uu_filtre_tensor_[1], 0);
8955 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_XZ"))
8956 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_XZ", structural_uu_filtre_tensor_[2], 0);
8957 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_YY"))
8958 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_YY", structural_uu_filtre_tensor_[3], 0);
8959 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_YZ"))
8960 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_YZ", structural_uu_filtre_tensor_[4], 0);
8961 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_ZZ"))
8962 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_ZZ", structural_uu_filtre_tensor_[5], 0);
8963 if (flag_structural_uscalar_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_FILTRE_X"))
8964 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_FILTRE_X", structural_uscalar_filtre_vector_[0], 0);
8965 if (flag_structural_uscalar_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_FILTRE_Y"))
8966 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_FILTRE_Y", structural_uscalar_filtre_vector_[1], 0);
8967 if (flag_structural_uscalar_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_FILTRE_Z"))
8968 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_FILTRE_Z", structural_uscalar_filtre_vector_[2], 0);
8969 if (n>0)
8970 {
8971 Cerr << " Martinn n2= " << n << finl;
8972 Cerr << "Il y a des noms de champs a postraiter inconnus ou dupliques dans la liste de champs a postraiter"
8973 << finl << liste_post_instantanes_ << finl;
8974 Process::exit();
8975 }
8977 }
8978
8980 {
8981 Nom nom_fichier("moyenne_spatiale_");
8982 nom_fichier += Nom(current_time);
8983 nom_fichier += Nom(".txt");
8984 SFichier f(nom_fichier);
8985 // F.A modification de la precision pour allez chercher les 4 ordres
8986 f.setf(ios::scientific);
8987 f.precision(15);
8988 statistiques_.postraiter(f, 1 /* flag pour ecrire la moyenne instantanee */);
8989 // modif AT 20/06/2013
8990 if (statistiques_.check_converge())
8991 {
8992 Nom nom_fichier_ec("spatiale_ec_");
8993 nom_fichier_ec += Nom(current_time);
8994 nom_fichier_ec += Nom(".txt");
8995 SFichier fk(nom_fichier_ec);
8996 // F.A modification de la precision pour allez chercher les 4 ordres
8997 fk.setf(ios::scientific);
8998 fk.precision(15);
8999 statistiques_.postraiter_k(fk,1 /* valeur spatiale */);
9000 }
9001 }
9002
9003 if (Process::je_suis_maitre() && statistiques_.t_integration() > 0.)
9004 {
9005 Nom nom_fichier("statistiques_");
9006 nom_fichier += Nom(current_time);
9007 nom_fichier += Nom(".txt");
9008 SFichier fs(nom_fichier);
9009 // F.A modification de la precision pour allez chercher les 4 ordres
9010 fs.setf(ios::scientific);
9011 fs.precision(15);
9012 statistiques_.postraiter(fs,0 /* moyenne temporelle */);
9013 }
9014
9015 if (Process::je_suis_maitre() && statistiques_.t_integration_k() > 0. )
9016 {
9017 Nom nom_fichier("stat_ec_");
9018 nom_fichier += Nom(current_time);
9019 nom_fichier += Nom(".txt");
9020 SFichier fk(nom_fichier);
9021 // F.A modification de la precision pour allez chercher les 4 ordres
9022 fk.setf(ios::scientific);
9023 fk.precision(15);
9024 statistiques_.postraiter_k(fk,0 /* moyenne temporelle */);
9025 }
9026}
9027
9028
9029void DNS_QC_double::save_raw_data(const char *lata_name, double current_time)
9030{
9031 // DD,2016-28-01: statistiques a partir de fichiers lata uniquement
9033 {
9034 Nom nom_fichier_sauvegarde(lata_name);
9035 nom_fichier_sauvegarde += Nom(compteur_post_instantanes_);
9036 nom_fichier_sauvegarde += Nom(".sauv");
9037
9038 Nom lata_name_lata(nom_fichier_sauvegarde);
9039 lata_name_lata += ".lata";
9040
9041 ecrire_fichier_sauv(nom_fichier_sauvegarde, lata_name_lata);
9042
9043 dumplata_header(lata_name_lata, rho_ /* on passe un champ pour ecrire la geometrie */);
9044 dumplata_newtime(lata_name_lata, current_time_);
9045
9046 if (liste_post_instantanes_.contient_("TOUS"))
9047 {
9048 liste_post_instantanes_.dimensionner_force(0);
9049 liste_post_instantanes_.add("VELOCITY");
9050 liste_post_instantanes_.add("VELOCITY_ELEM_X");
9051 liste_post_instantanes_.add("VELOCITY_ELEM_Y");
9052 liste_post_instantanes_.add("VELOCITY_ELEM_Z");
9053 liste_post_instantanes_.add("D_VELOCITY");
9054 liste_post_instantanes_.add("PRESSURE");
9055 liste_post_instantanes_.add("TEMPERATURE");
9056 liste_post_instantanes_.add("RHO");
9057 liste_post_instantanes_.add("LAMBDA");
9058 liste_post_instantanes_.add("MU");
9059 liste_post_instantanes_.add("PRESSURE_RHS");
9060 liste_post_instantanes_.add("DIV_LAMBDA_GRAD_T_VOLUME");
9061 liste_post_instantanes_.add("U_DIV_RHO_U");
9062 liste_post_instantanes_.add("DRHO_DT");
9074 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_XX");
9075 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_XY");
9076 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_XZ");
9077 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_YY");
9078 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_YZ");
9079 if (structural_uu_) liste_post_instantanes_.add("sTRUCTURAL_UU_ZZ");
9080 if (structural_uscalar_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_X");
9081 if (structural_uscalar_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_Y");
9082 if (structural_uscalar_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_Z");
9083 if (flag_u_filtre_) liste_post_instantanes_.add("VELOCITY_FILTRE");
9084 if (flag_rho_filtre_) liste_post_instantanes_.add("RHO_FILTRE");
9085 if (flag_temperature_filtre_) liste_post_instantanes_.add("TEMPERATURE_FILTRE");
9086 if (flag_turbulent_mu_filtre_ && (!flag_nu_tensorial_)) liste_post_instantanes_.add("TURBULENT_MU_FILTRE");
9088 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_XY");
9089 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_XZ");
9090 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_YY");
9091 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_YZ");
9092 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_) liste_post_instantanes_.add("TURBULENT_MU_FILTRE_ZZ");
9093 if (flag_turbulent_kappa_filtre_ && (!flag_kappa_vectorial_)) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE");
9094 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE_X");
9095 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE_Y");
9096 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_) liste_post_instantanes_.add("TURBULENT_KAPPA_FILTRE_Z");
9097 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_XX");
9098 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_XY");
9099 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_XZ");
9100 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_YY");
9101 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_YZ");
9102 if (flag_structural_uu_filtre_) liste_post_instantanes_.add("sTRUCTURAL_UU_FILTRE_ZZ");
9103 if (flag_structural_uscalar_filtre_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_FILTRE_X");
9104 if (flag_structural_uscalar_filtre_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_FILTRE_Y");
9105 if (flag_structural_uscalar_filtre_) liste_post_instantanes_.add("sTRUCTURAL_USCALAR_FILTRE_Z");
9106 }
9107 int n = liste_post_instantanes_.size();
9108 Cerr << " Martinn n= " << n << finl;
9109
9110 if (liste_post_instantanes_.contient_("VELOCITY"))
9111 {
9112 n=n-1;
9113 dumplata_vector(lata_name_lata,"VELOCITY", velocity_[0], velocity_[1], velocity_[2], 0);
9114 }
9115 if (liste_post_instantanes_.contient_("VELOCITY_ELEM_X"))
9116 {
9117 n=n-1;
9119 if (sauvegarde_splitting_name_ != "??")
9120 {
9122 velocity_elem_X_sauvegarde_.echange_espace_virtuel(velocity_elem_X_sauvegarde_.ghost());
9123
9124 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9125 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9126 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9127
9128 if (ni > 0 || nj > 0 || nk > 0)
9129 {
9130 dumplata_scalar_parallele_plan(lata_name_lata, "VELOCITY_ELEM_X", velocity_elem_X_sauvegarde_, 0);
9131 }
9132 }
9133 else
9134 {
9135 dumplata_scalar(lata_name_lata,"VELOCITY_ELEM_X", velocity_elem_X_, 0);
9136 }
9137 }
9138
9139 if (liste_post_instantanes_.contient_("VELOCITY_ELEM_Y"))
9140 {
9141 n=n-1;
9142 if (sauvegarde_splitting_name_ != "??")
9143 {
9145 velocity_elem_Y_sauvegarde_.echange_espace_virtuel(velocity_elem_Y_sauvegarde_.ghost());
9146
9147 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9148 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9149 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9150
9151 if (ni > 0 || nj > 0 || nk > 0)
9152 {
9153 dumplata_scalar_parallele_plan(lata_name_lata, "VELOCITY_ELEM_Y", velocity_elem_Y_sauvegarde_, 0);
9154 }
9155 }
9156 else
9157 {
9158 dumplata_scalar(lata_name_lata,"VELOCITY_ELEM_Y", velocity_elem_Y_, 0);
9159 }
9160 }
9161
9162 if (liste_post_instantanes_.contient_("VELOCITY_ELEM_Z"))
9163 {
9164 n=n-1;
9165 if (sauvegarde_splitting_name_ != "??")
9166 {
9168 velocity_elem_Z_sauvegarde_.echange_espace_virtuel(velocity_elem_Z_sauvegarde_.ghost());
9169
9170 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9171 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9172 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9173
9174 if (ni > 0 || nj > 0 || nk > 0)
9175 {
9176 dumplata_scalar_parallele_plan(lata_name_lata, "VELOCITY_ELEM_Z", velocity_elem_Z_sauvegarde_, 0);
9177 }
9178 }
9179 else
9180 {
9181 dumplata_scalar(lata_name_lata,"VELOCITY_ELEM_Z", velocity_elem_Z_, 0);
9182 }
9183 }
9184 if (liste_post_instantanes_.contient_("D_VELOCITY"))
9185 n--, dumplata_vector(lata_name_lata,"D_VELOCITY", d_velocity_[0], d_velocity_[1], d_velocity_[2], 0);
9186 if (liste_post_instantanes_.contient_("PRESSURE"))
9187 {
9188 n=n-1;
9189 if (sauvegarde_splitting_name_ != "??")
9190 {
9192 pressure_sauvegarde_.echange_espace_virtuel(pressure_sauvegarde_.ghost());
9193
9194 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9195 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9196 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9197
9198 if (ni > 0 || nj > 0 || nk > 0)
9199 {
9200 dumplata_scalar_parallele_plan(lata_name_lata, "PRESSURE", pressure_sauvegarde_, 0);
9201 }
9202 }
9203 else
9204 {
9205 dumplata_scalar(lata_name_lata,"PRESSURE", pressure_, 0);
9206 }
9207 }
9208 if (liste_post_instantanes_.contient_("TEMPERATURE"))
9209 {
9210 n=n-1;
9211 if (sauvegarde_splitting_name_ != "??")
9212 {
9214 temperature_sauvegarde_.echange_espace_virtuel(temperature_sauvegarde_.ghost());
9215
9216 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9217 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9218 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9219
9220 if (ni > 0 || nj > 0 || nk > 0)
9221 {
9222 dumplata_scalar_parallele_plan(lata_name_lata, "TEMPERATURE", temperature_sauvegarde_, 0);
9223 }
9224 }
9225 else
9226 {
9227 dumplata_scalar(lata_name_lata,"TEMPERATURE", temperature_, 0);
9228 }
9229 }
9230 if (liste_post_instantanes_.contient_("RHO"))
9231 {
9232 n=n-1;
9233 if (sauvegarde_splitting_name_ != "??")
9234 {
9236 rho_sauvegarde_.echange_espace_virtuel(rho_sauvegarde_.ghost());
9237
9238 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9239 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9240 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9241
9242 if (ni > 0 || nj > 0 || nk > 0)
9243 {
9244 dumplata_scalar_parallele_plan(lata_name_lata, "RHO", rho_sauvegarde_, 0);
9245 }
9246 }
9247 else
9248 {
9249 dumplata_scalar(lata_name_lata,"RHO", rho_, 0);
9250 }
9251 }
9252 if (liste_post_instantanes_.contient_("LAMBDA"))
9253 {
9254 n=n-1;
9255 if (sauvegarde_splitting_name_ != "??")
9256 {
9258 molecular_lambda_sauvegarde_.echange_espace_virtuel(molecular_lambda_sauvegarde_.ghost());
9259
9260 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9261 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9262 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9263
9264 if (ni > 0 || nj > 0 || nk > 0)
9265 {
9266 dumplata_scalar_parallele_plan(lata_name_lata, "LAMBDA", molecular_lambda_sauvegarde_, 0);
9267 }
9268 }
9269 else
9270 {
9271 dumplata_scalar(lata_name_lata,"LAMBDA", molecular_lambda_, 0);
9272 }
9273 }
9274 if (liste_post_instantanes_.contient_("MU"))
9275 {
9276 n=n-1;
9277 if (sauvegarde_splitting_name_ != "??")
9278 {
9280 molecular_mu_sauvegarde_.echange_espace_virtuel(molecular_mu_sauvegarde_.ghost());
9281
9282 int ni = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_I);
9283 int nj = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_J);
9284 int nk = sauvegarde_splitting_.get_nb_elem_local(DIRECTION_K);
9285
9286 if (ni > 0 || nj > 0 || nk > 0)
9287 {
9288 dumplata_scalar_parallele_plan(lata_name_lata, "MU", molecular_mu_sauvegarde_, 0);
9289 }
9290 }
9291 else
9292 {
9293 dumplata_scalar(lata_name_lata,"MU", molecular_mu_, 0);
9294 }
9295 }
9296 if (liste_post_instantanes_.contient_("PRESSURE_RHS"))
9297 n--,dumplata_scalar(lata_name_lata,"PRESSURE_RHS", pressure_rhs_, 0);
9298 if (liste_post_instantanes_.contient_("DIV_LAMBDA_GRAD_T_VOLUME"))
9299 n--,dumplata_scalar(lata_name_lata,"DIV_LAMBDA_GRAD_T_VOLUME", div_lambda_grad_T_volume_, 0);
9300 if (liste_post_instantanes_.contient_("U_DIV_RHO_U"))
9301 n--,dumplata_scalar(lata_name_lata,"U_DIV_RHO_U", u_div_rho_u_, 0);
9302 if (liste_post_instantanes_.contient_("DRHO_DT"))
9303 n--,dumplata_scalar(lata_name_lata,"DRHO_DT", d_rho_, 0);
9304 if (turbulent_viscosity_ && (!flag_nu_tensorial_) && liste_post_instantanes_.contient_("TURBULENT_MU"))
9305 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU", turbulent_mu_, 0);
9306 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_XX"))
9307 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_XX", turbulent_mu_tensor_[0], 0);
9308 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_XY"))
9309 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_XY", turbulent_mu_tensor_[1], 0);
9310 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_XZ"))
9311 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_XZ", turbulent_mu_tensor_[2], 0);
9312 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_YY"))
9313 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_YY", turbulent_mu_tensor_[3], 0);
9314 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_YZ"))
9315 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_YZ", turbulent_mu_tensor_[4], 0);
9316 if (turbulent_viscosity_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_ZZ"))
9317 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_ZZ", turbulent_mu_tensor_[5], 0);
9318 if (turbulent_diffusivity_ && (!flag_kappa_vectorial_) && liste_post_instantanes_.contient_("TURBULENT_KAPPA"))
9319 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA", turbulent_kappa_, 0);
9320 if (turbulent_diffusivity_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_X"))
9321 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_X", turbulent_kappa_vector_[0], 0);
9322 if (turbulent_diffusivity_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_Y"))
9323 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_Y", turbulent_kappa_vector_[1], 0);
9324 if (turbulent_diffusivity_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_Z"))
9325 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_Z", turbulent_kappa_vector_[2], 0);
9326 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_XX"))
9327 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_XX", structural_uu_tensor_[0], 0);
9328 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_XY"))
9329 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_XY", structural_uu_tensor_[1], 0);
9330 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_XZ"))
9331 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_XZ", structural_uu_tensor_[2], 0);
9332 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_YY"))
9333 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_YY", structural_uu_tensor_[3], 0);
9334 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_YZ"))
9335 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_YZ", structural_uu_tensor_[4], 0);
9336 if (structural_uu_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_ZZ"))
9337 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_ZZ", structural_uu_tensor_[5], 0);
9338 if (structural_uscalar_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_X"))
9339 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_X", structural_uscalar_vector_[0], 0);
9340 if (structural_uscalar_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_Y"))
9341 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_Y", structural_uscalar_vector_[1], 0);
9342 if (structural_uscalar_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_Z"))
9343 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_Z", structural_uscalar_vector_[2], 0);
9344 if (flag_u_filtre_ && liste_post_instantanes_.contient_("VELOCITY_FILTRE"))
9345 n--,dumplata_vector(lata_name_lata,"VELOCITY_FILTRE", velocity_filtre_[0], velocity_filtre_[1], velocity_filtre_[2], 0);
9346 if (flag_rho_filtre_ && liste_post_instantanes_.contient_("RHO_FILTRE"))
9347 n--,dumplata_scalar(lata_name_lata,"RHO_FILTRE", rho_filtre_, 0);
9348 if (flag_temperature_filtre_ && liste_post_instantanes_.contient_("TEMPERATURE_FILTRE"))
9349 n--,dumplata_scalar(lata_name_lata,"TEMPERATURE_FILTRE", temperature_filtre_, 0);
9350 if (flag_turbulent_mu_filtre_ && (!flag_nu_tensorial_) && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE"))
9351 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE", turbulent_mu_filtre_, 0);
9352 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_XX"))
9353 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_XX", turbulent_mu_filtre_tensor_[0], 0);
9354 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_XY"))
9355 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_XY", turbulent_mu_filtre_tensor_[1], 0);
9356 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_XZ"))
9357 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_XZ", turbulent_mu_filtre_tensor_[2], 0);
9358 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_YY"))
9359 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_YY", turbulent_mu_filtre_tensor_[3], 0);
9360 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_YZ"))
9361 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_YZ", turbulent_mu_filtre_tensor_[4], 0);
9362 if (flag_turbulent_mu_filtre_ && flag_nu_tensorial_ && liste_post_instantanes_.contient_("TURBULENT_MU_FILTRE_ZZ"))
9363 n--,dumplata_scalar(lata_name_lata,"TURBULENT_MU_FILTRE_ZZ", turbulent_mu_filtre_tensor_[5], 0);
9364 if (flag_turbulent_kappa_filtre_ && (!flag_kappa_vectorial_) && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE"))
9365 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE", turbulent_kappa_filtre_, 0);
9366 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE_X"))
9367 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE_X", turbulent_kappa_filtre_vector_[0], 0);
9368 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE_Y"))
9369 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE_Y", turbulent_kappa_filtre_vector_[1], 0);
9370 if (flag_turbulent_kappa_filtre_ && flag_kappa_vectorial_ && liste_post_instantanes_.contient_("TURBULENT_KAPPA_FILTRE_Z"))
9371 n--,dumplata_scalar(lata_name_lata,"TURBULENT_KAPPA_FILTRE_Z", turbulent_kappa_filtre_vector_[2], 0);
9372 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_XX"))
9373 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_XX", structural_uu_filtre_tensor_[0], 0);
9374 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_XY"))
9375 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_XY", structural_uu_filtre_tensor_[1], 0);
9376 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_XZ"))
9377 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_XZ", structural_uu_filtre_tensor_[2], 0);
9378 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_YY"))
9379 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_YY", structural_uu_filtre_tensor_[3], 0);
9380 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_YZ"))
9381 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_YZ", structural_uu_filtre_tensor_[4], 0);
9382 if (flag_structural_uu_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_UU_FILTRE_ZZ"))
9383 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_UU_FILTRE_ZZ", structural_uu_filtre_tensor_[5], 0);
9384 if (flag_structural_uscalar_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_FILTRE_X"))
9385 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_FILTRE_X", structural_uscalar_filtre_vector_[0], 0);
9386 if (flag_structural_uscalar_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_FILTRE_Y"))
9387 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_FILTRE_Y", structural_uscalar_filtre_vector_[1], 0);
9388 if (flag_structural_uscalar_filtre_ && liste_post_instantanes_.contient_("sTRUCTURAL_USCALAR_FILTRE_Z"))
9389 n--,dumplata_scalar(lata_name_lata,"sTRUCTURAL_USCALAR_FILTRE_Z", structural_uscalar_filtre_vector_[2], 0);
9390 if (n>0)
9391 {
9392 Cerr << " Martinn n2= " << n << finl;
9393 Cerr << "Il y a des noms de champs a postraiter inconnus ou dupliques dans la liste de champs a postraiter"
9394 << finl << liste_post_instantanes_ << finl;
9395 Process::exit();
9396 }
9398 }
9399}
9400
9401
9402void DNS_QC_double::save_stats(double current_time)
9403{
9405 {
9406 Nom nom_fichier("moyenne_spatiale_");
9407 nom_fichier += Nom(current_time);
9408 nom_fichier += Nom(".txt");
9409 SFichier f(nom_fichier);
9410 // F.A modification de la precision pour allez chercher les 4 ordres
9411 f.setf(ios::scientific);
9412 f.precision(15);
9413 statistiques_.postraiter(f, 1 /* flag pour ecrire la moyenne instantanee */);
9414 // modif AT 20/06/2013
9415 if (statistiques_.check_converge())
9416 {
9417 Nom nom_fichier_ec("spatiale_ec_");
9418 nom_fichier_ec += Nom(current_time);
9419 nom_fichier_ec += Nom(".txt");
9420 SFichier fk(nom_fichier_ec);
9421 // F.A modification de la precision pour allez chercher les 4 ordres
9422 fk.setf(ios::scientific);
9423 fk.precision(15);
9424 statistiques_.postraiter_k(fk,1 /* valeur spatiale */);
9425 }
9426 }
9427
9428 if (Process::je_suis_maitre() && statistiques_.t_integration() > 0.)
9429 {
9430 Nom nom_fichier("statistiques_");
9431 nom_fichier += Nom(current_time);
9432 nom_fichier += Nom(".txt");
9433 SFichier fs(nom_fichier);
9434 // F.A modification de la precision pour allez chercher les 4 ordres
9435 fs.setf(ios::scientific);
9436 fs.precision(15);
9437 statistiques_.postraiter(fs,0 /* moyenne temporelle */);
9438 }
9439
9440 if (Process::je_suis_maitre() && statistiques_.t_integration_k() > 0. )
9441 {
9442 Nom nom_fichier("stat_ec_");
9443 nom_fichier += Nom(current_time);
9444 nom_fichier += Nom(".txt");
9445 SFichier fk(nom_fichier);
9446 // F.A modification de la precision pour allez chercher les 4 ordres
9447 fk.setf(ios::scientific);
9448 fk.precision(15);
9449 statistiques_.postraiter_k(fk,0 /* moyenne temporelle */);
9450 }
9451}
9452
9454{
9455 Cerr << "IJK_problem_double::run()" << finl;
9456
9457 if (dt_start_ == 1.e20)
9458 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;
9459
9461 Cerr << " Attention la convection de la vitesse est negligee " << finl;
9463 Cerr << " Attention la convection de la masse volumique est negligee " << finl;
9465 Cerr << " Attention la diffusion visqueuse est negligee " << finl;
9467 Cerr << " Attention la diffusion thermique est negligee " << finl;
9468
9469 kernel_ = nullptr;
9470 int ghost_size_filter = 0, ghost_size_d_velocity_tmp;
9476 {
9477 int ghost_size = 0;
9478
9479 choix_filter_kernel(ghost_size, filter_kernel_name_, kernel_);
9480 Cerr << "Filter: The ghost size is " << kernel_->ghost_size() << finl;
9481
9482 ghost_size_filter = 1 + kernel_->ghost_size();
9483 }
9484
9485 int ghost_size_velocity = flag_u_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9486 int ghost_size_rho = flag_rho_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9487 int ghost_size_temperature = flag_temperature_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9488 int ghost_size_pressure = (lecture_post_instantanes_filtrer_p_ || lecture_post_instantanes_filtrer_tous_) ? max((int) 1, ghost_size_filter) : 1;
9489
9490 /* allocation des tableaux */
9491 allocate_velocity(velocity_, domaine_, ghost_size_velocity);
9495 rho_.allocate(domaine_, Domaine_IJK::ELEM, ghost_size_rho);
9496 allocate_velocity(rho_v_, domaine_, 2);
9497 allocate_velocity(d_velocity_, domaine_, 1);
9498 allocate_velocity(RK3_F_velocity_, domaine_, 0);
9499 pressure_.allocate(domaine_, Domaine_IJK::ELEM, ghost_size_pressure);
9502 d_rho_.allocate(domaine_, Domaine_IJK::ELEM, 1);
9503 temperature_.allocate(domaine_, Domaine_IJK::ELEM, ghost_size_temperature);
9509
9510 //Modif Martin
9511 if (sauvegarde_splitting_name_ != "??")
9512 {
9513 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))
9514 {
9515 allocate_velocity(velocity_sauvegarde_, sauvegarde_splitting_, 1);
9524 }
9525 else
9526 {
9527 allocate_velocity(velocity_sauvegarde_, sauvegarde_splitting_, 0);
9536 }
9537 }
9538
9539 /* initialisation des tableaux */
9540 // Fill with valid floating point data in walls and ghost cells:
9541 velocity_[0].data() = 0.;
9542 velocity_[1].data() = 0.;
9543 velocity_[2].data() = 0.;
9544 velocity_elem_X_.data()=0.;
9545 velocity_elem_Y_.data()=0.;
9546 velocity_elem_Z_.data()=0.;
9547 rho_.data() = 1.; // not zero=> might want 1./rho and must not crash
9548 rho_v_[0].data() = 0.;
9549 rho_v_[1].data() = 0.;
9550 rho_v_[2].data() = 0.;
9551 d_velocity_[0].data() = 0.;
9552 d_velocity_[1].data() = 0.;
9553 d_velocity_[2].data() = 0.;
9554 RK3_F_velocity_[0].data() = 0.;
9555 RK3_F_velocity_[1].data() = 0.;
9556 RK3_F_velocity_[2].data() = 0.;
9557 pressure_.data() = 0.;
9558 molecular_mu_.data() = 0.;
9559 pressure_rhs_.data() = 0.;
9560 d_rho_.data() = 0.;
9561 temperature_.data() = 293.; // like rho: not zero
9562 RK3_F_rho_.data() = 0.;
9563 molecular_lambda_.data() = 0.;
9564 div_lambda_grad_T_volume_.data() = 0.;
9565 u_div_rho_u_.data() = 0.;
9566 divergence_.data() = 0.;
9567
9568
9569 // bool save_next_timestep=false;
9570 bool save_current_timestep=false;
9571
9572
9578 {
9579 if (filter_kernel_name_ == Nom("laplacian"))
9580 {
9581 Cerr << "Taille du filtre explicite identique a celle du filtre." << finl;
9585 calculer_delta_z_filtre_identique(domaine_, delta_z_local_pour_delta_, delta_z_local_pour_delta_filtre_);
9586 }
9587 else
9588 {
9589 const double n_mailles = kernel_->n_mailles();
9590 Cerr << "Taille du filtre explicite fixee a " << n_mailles << " mailles." << finl;
9591
9592 facteur_delta_filtre_x_ = sqrt(n_mailles*n_mailles + facteur_delta_x_*facteur_delta_x_);
9593 facteur_delta_filtre_y_ = sqrt(n_mailles*n_mailles + facteur_delta_y_*facteur_delta_y_);
9595 calculer_delta_z_filtre_n_mailles((int)n_mailles, domaine_, delta_z_local_, delta_z_local_pour_delta_, delta_z_local_pour_delta_filtre_);
9596 }
9598 for (int i=0 ; i<18 ; i++)
9599 {
9600 const int ni = velocity_[2].ni();
9601 const int nj = velocity_[2].nj();
9602
9603 // On voudrait
9604 // tmp_b_[i].allocate(ni, nj, 1, ghost_size_filter);
9605 // tmp_a_[i].allocate(ni, 1, 1, ghost_size_filter);
9606 // mais 'allocate' interdit ghost_size < ni, nj ou nk.
9607 tmp_b_[i].allocate(ni, nj, ghost_size_filter, ghost_size_filter);
9608 tmp_a_[i].allocate(ni, ghost_size_filter, ghost_size_filter, ghost_size_filter);
9609 }
9610 const int nktot = velocity_[2].get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
9611 for (int i=0; i<8; i++)
9612 {
9613 for (int j=0; j<7; j++)
9614 {
9615 ml_[i][j].resize_array(nktot+1);
9616 }
9617 }
9618 }
9619
9620 // DD,2017-04-27: diffusion modifie en vue de l'ajout de modeles
9622 {
9623 int ghost_size_turbulent_mu = flag_turbulent_mu_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9624
9626 {
9627 turbulent_mu_tensor_[0].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9628 turbulent_mu_tensor_[1].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9629 turbulent_mu_tensor_[2].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9630 turbulent_mu_tensor_[3].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9631 turbulent_mu_tensor_[4].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9632 turbulent_mu_tensor_[5].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9633 turbulent_mu_tensor_[0].data() = 0.;
9634 turbulent_mu_tensor_[1].data() = 0.;
9635 turbulent_mu_tensor_[2].data() = 0.;
9636 turbulent_mu_tensor_[3].data() = 0.;
9637 turbulent_mu_tensor_[4].data() = 0.;
9638 turbulent_mu_tensor_[5].data() = 0.;
9639 }
9640 else
9641 {
9642 turbulent_mu_.allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_mu);
9643 turbulent_mu_.data() = 0.;
9644 }
9645 }
9647 {
9648 int ghost_size_turbulent_kappa = flag_turbulent_kappa_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9649
9651 {
9652 allocate_cell_vector(turbulent_kappa_vector_, domaine_, ghost_size_turbulent_kappa);
9653 turbulent_kappa_vector_[0].data() = 0.;
9654 turbulent_kappa_vector_[1].data() = 0.;
9655 turbulent_kappa_vector_[2].data() = 0.;
9656 }
9657 else
9658 {
9659 turbulent_kappa_.allocate(domaine_, Domaine_IJK::ELEM, ghost_size_turbulent_kappa);
9660 turbulent_kappa_.data() = 0.;
9661 }
9662 }
9663
9664 if (flag_u_filtre_)
9665 {
9666 allocate_velocity(velocity_filtre_, domaine_, 2);
9667 velocity_filtre_[0].data() = 0.;
9668 velocity_filtre_[1].data() = 0.;
9669 velocity_filtre_[2].data() = 0.;
9670 }
9671 if (structural_uu_)
9672 {
9673 int ghost_size_structural_uu = flag_structural_uu_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9674
9675 structural_uu_tensor_[0].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu);
9676 structural_uu_tensor_[1].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu);
9677 structural_uu_tensor_[2].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu);
9678 structural_uu_tensor_[3].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu);
9679 structural_uu_tensor_[4].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu);
9680 structural_uu_tensor_[5].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu);
9681 structural_uu_tensor_[0].data() = 0.;
9682 structural_uu_tensor_[1].data() = 0.;
9683 structural_uu_tensor_[2].data() = 0.;
9684 structural_uu_tensor_[3].data() = 0.;
9685 structural_uu_tensor_[4].data() = 0.;
9686 structural_uu_tensor_[5].data() = 0.;
9687 }
9688
9689 if (flag_rho_filtre_)
9690 {
9692 rho_filtre_.data() = 1.; // not zero=> might want 1./rho and must not crash
9693 }
9695 {
9697 temperature_filtre_.data() = 293.; // like rho: not zero
9698 }
9700 {
9701 int ghost_size_structural_uscalar = flag_structural_uscalar_filtre_ ? max((int) 2, ghost_size_filter) : 2;
9702 allocate_cell_vector(structural_uscalar_vector_, domaine_,ghost_size_structural_uscalar );
9703 structural_uscalar_vector_[0].data() = 0.;
9704 structural_uscalar_vector_[1].data() = 0.;
9705 structural_uscalar_vector_[2].data() = 0.;
9706 }
9707
9709 {
9711 {
9718 turbulent_mu_filtre_tensor_[0].data() = 0.;
9719 turbulent_mu_filtre_tensor_[1].data() = 0.;
9720 turbulent_mu_filtre_tensor_[2].data() = 0.;
9721 turbulent_mu_filtre_tensor_[3].data() = 0.;
9722 turbulent_mu_filtre_tensor_[4].data() = 0.;
9723 turbulent_mu_filtre_tensor_[5].data() = 0.;
9724 }
9725 else
9726 {
9728 turbulent_mu_filtre_.data() = 0.;
9729 }
9730 }
9732 {
9734 {
9735 allocate_cell_vector(turbulent_kappa_filtre_vector_, domaine_,2 );
9736 turbulent_kappa_filtre_vector_[0].data() = 0.;
9737 turbulent_kappa_filtre_vector_[1].data() = 0.;
9738 turbulent_kappa_filtre_vector_[2].data() = 0.;
9739 }
9740 else
9741 {
9743 turbulent_kappa_filtre_.data() = 0.;
9744 }
9745 }
9746
9748 {
9755 structural_uu_filtre_tensor_[0].data() = 0.;
9756 structural_uu_filtre_tensor_[1].data() = 0.;
9757 structural_uu_filtre_tensor_[2].data() = 0.;
9758 structural_uu_filtre_tensor_[3].data() = 0.;
9759 structural_uu_filtre_tensor_[4].data() = 0.;
9760 structural_uu_filtre_tensor_[5].data() = 0.;
9761 }
9763 {
9767 structural_uscalar_filtre_vector_[0].data() = 0.;
9768 structural_uscalar_filtre_vector_[1].data() = 0.;
9769 structural_uscalar_filtre_vector_[2].data() = 0.;
9770 }
9771
9773 {
9774 int ghost_size_structural_uu_tmp = flag_structural_uu_tmp_ ? max((int) 2, ghost_size_filter) : 2;
9775
9776 structural_uu_tmp_tensor_[0].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu_tmp);
9777 structural_uu_tmp_tensor_[1].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu_tmp);
9778 structural_uu_tmp_tensor_[2].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu_tmp);
9779 structural_uu_tmp_tensor_[3].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu_tmp);
9780 structural_uu_tmp_tensor_[4].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu_tmp);
9781 structural_uu_tmp_tensor_[5].allocate(domaine_, Domaine_IJK::ELEM, ghost_size_structural_uu_tmp);
9782 structural_uu_tmp_tensor_[0].data() = 0.;
9783 structural_uu_tmp_tensor_[1].data() = 0.;
9784 structural_uu_tmp_tensor_[2].data() = 0.;
9785 structural_uu_tmp_tensor_[3].data() = 0.;
9786 structural_uu_tmp_tensor_[4].data() = 0.;
9787 structural_uu_tmp_tensor_[5].data() = 0.;
9788 }
9790 {
9791 int ghost_size_structural_uscalar_tmp = flag_structural_uscalar_tmp_ ? max((int) 2, ghost_size_filter) : 2;
9792
9793 allocate_cell_vector(structural_uscalar_tmp_vector_, domaine_, ghost_size_structural_uscalar_tmp);
9794 structural_uscalar_tmp_vector_[0].data() = 0.;
9795 structural_uscalar_tmp_vector_[1].data() = 0.;
9796 structural_uscalar_tmp_vector_[2].data() = 0.;
9797 }
9799 {
9800 ghost_size_d_velocity_tmp = flag_d_velocity_tmp_ ? max((int) 2, ghost_size_filter) : 2;
9801
9802 allocate_velocity(d_velocity_tmp_, domaine_, ghost_size_d_velocity_tmp);
9803 d_velocity_tmp_[0].data() = 0.;
9804 d_velocity_tmp_[1].data() = 0.;
9805 d_velocity_tmp_[2].data() = 0.;
9806 }
9807
9808 const int nb_allocated_arrays = 21;
9809 Cerr << " Allocating " << nb_allocated_arrays << " arrays, approx total size= "
9810 << (double)(unsigned long)molecular_mu_.data().size_array() * sizeof(double) * nb_allocated_arrays * 9.537E-07 << " MB per core" << finl;
9811
9812
9813 // DD,2017-04-27: diffusion modifie en vue de l'ajout de modeles
9814 if (type_velocity_diffusion_ == Nom("simple"))
9815 {
9816 Cerr << "The diffusion is 'simple': the flux is 'molecular_mu * grad u'" << finl;
9819 }
9820 else if (type_velocity_diffusion_ == Nom("simple_with_transpose"))
9821 {
9822 Cerr << "The diffusion is 'simple_with_transpose': the flux is 'molecular_mu * (grad u + grad^T u)'" << finl;
9825 }
9826 else if (type_velocity_diffusion_ == Nom("full"))
9827 {
9828 Cerr << "The diffusion is 'full': the flux is 'molecular_mu * (grad u + grad^T u - 2/3 * div u * Id)'" << finl;
9831 }
9832 else if (type_velocity_diffusion_ == Nom("none"))
9833 {
9834 Cerr << "The diffusion is 'none': no molecular diffusion" << finl;
9835 }
9836 else
9837 {
9838 Cerr << "Unknown velocity diffusion operator! " << finl;
9839 Process::exit();
9840 }
9841
9842 if (type_velocity_turbulent_diffusion_ == Nom("simple"))
9843 {
9844 Cerr << "The velocity turbulent diffusion is 'simple': the flux is 'turbulent_mu * grad u'" << finl;
9847 }
9848 else if (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose"))
9849 {
9850 Cerr << "The velocity turbulent diffusion is 'simple_with_transpose': the flux is 'turbulent_mu * (grad u + grad^T u)'" << finl;
9853 }
9854 else if (type_velocity_turbulent_diffusion_ == Nom("full"))
9855 {
9856 Cerr << "The velocity turbulent diffusion is 'full': the flux is 'turbulent_mu * (grad u + grad^T u - 2/3 * div u * Id)'" << finl;
9859 }
9860 else if (type_velocity_turbulent_diffusion_ == Nom("simple_anisotropic"))
9861 {
9862 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;
9865 }
9866 else if (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose_anisotropic"))
9867 {
9868 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;
9871 }
9872 else if (type_velocity_turbulent_diffusion_ == Nom("full_anisotropic"))
9873 {
9874 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;
9877 }
9878 else if (type_velocity_turbulent_diffusion_ == Nom("none"))
9879 {
9880 Cerr << "The velocity turbulent diffusion is 'none': no turbulent diffusion" << finl;
9881 }
9882 else
9883 {
9884 Cerr << "Unknown velocity turbulent diffusion operator! " << finl;
9885 Process::exit();
9886 }
9887
9888 if (structural_uu_)
9889 {
9890 Cerr << "A structural model will be added to the velocity turbulent diffusion. The structural uu tensor coefficients are:";
9891 Cerr << " xx: " << structural_uu_tensor_coefficients_[0];
9892 Cerr << " xy: " << structural_uu_tensor_coefficients_[1];
9893 Cerr << " xz: " << structural_uu_tensor_coefficients_[2];
9894 Cerr << " yy: " << structural_uu_tensor_coefficients_[3];
9895 Cerr << " yz: " << structural_uu_tensor_coefficients_[4];
9896 Cerr << " zz: " << structural_uu_tensor_coefficients_[5];
9897 Cerr << finl;
9900 }
9901
9903 {
9904 Cerr << "A structural model will be added to the scalar turbulent diffusion. The structural uscalar vector coefficients are:"
9908 << finl;
9910 }
9911
9912 if (type_scalar_turbulent_diffusion_ == Nom("normal"))
9913 {
9914 Cerr << "The scalar turbulent diffusion is 'normal': the flux is 'lambda * grad s'" << finl;
9916 }
9917 else if (type_scalar_turbulent_diffusion_ == Nom("anisotropic"))
9918 {
9919 Cerr << "The scalar turbulent diffusion is 'anisotropic': the flux is 'lambda^a * grad^a s' where (grad^a)_i = Delta_i (grad)_i" << finl;
9921 }
9922 else if (type_scalar_turbulent_diffusion_ == Nom("none"))
9923 {
9924 Cerr << "The scalar turbulent diffusion is 'none': no scalar turbulent diffusion" << finl;
9925 }
9926 else
9927 {
9928 Cerr << "Unknown scalar turbulent diffusion operator! " << finl;
9929 Process::exit();
9930 }
9931
9932 // On cree des variables ref_turbulent_mu_ij qui sont des references a
9933 // turbulent_mu_ij si la viscosite est tensorielle et
9934 // turbulent_mu_ si la viscosite n'est pas tensorielle.
9935 IJK_Field_double* ptr_turbulent_mu_xx;
9936 IJK_Field_double* ptr_turbulent_mu_xy;
9937 IJK_Field_double* ptr_turbulent_mu_xz;
9938 IJK_Field_double* ptr_turbulent_mu_yy;
9939 IJK_Field_double* ptr_turbulent_mu_yz;
9940 IJK_Field_double* ptr_turbulent_mu_zz;
9941
9943 {
9944 ptr_turbulent_mu_xx = &turbulent_mu_tensor_[0];
9945 ptr_turbulent_mu_xy = &turbulent_mu_tensor_[1];
9946 ptr_turbulent_mu_xz = &turbulent_mu_tensor_[2];
9947 ptr_turbulent_mu_yy = &turbulent_mu_tensor_[3];
9948 ptr_turbulent_mu_yz = &turbulent_mu_tensor_[4];
9949 ptr_turbulent_mu_zz = &turbulent_mu_tensor_[5];
9950 Cerr << "The turbulent viscosity is tensorial. The turbulent viscosity tensor coefficients are:"
9953 Cerr << " xz: " << turbulent_viscosity_tensor_coefficients_[2]
9956 Cerr << " zz: " << turbulent_viscosity_tensor_coefficients_[5]
9957 << finl;
9958 }
9959 else
9960 {
9961 ptr_turbulent_mu_xx = &turbulent_mu_;
9962 ptr_turbulent_mu_xy = &turbulent_mu_;
9963 ptr_turbulent_mu_xz = &turbulent_mu_;
9964 ptr_turbulent_mu_yy = &turbulent_mu_;
9965 ptr_turbulent_mu_yz = &turbulent_mu_;
9966 ptr_turbulent_mu_zz = &turbulent_mu_;
9967 Cerr << "The turbulent viscosity is not tensorial." << finl;
9968 }
9969
9970 IJK_Field_double& ref_turbulent_mu_xx = *ptr_turbulent_mu_xx;
9971 IJK_Field_double& ref_turbulent_mu_xy = *ptr_turbulent_mu_xy;
9972 IJK_Field_double& ref_turbulent_mu_xz = *ptr_turbulent_mu_xz;
9973 IJK_Field_double& ref_turbulent_mu_yy = *ptr_turbulent_mu_yy;
9974 IJK_Field_double& ref_turbulent_mu_yz = *ptr_turbulent_mu_yz;
9975 IJK_Field_double& ref_turbulent_mu_zz = *ptr_turbulent_mu_zz;
9976
9977 // On cree des variables ref_turbulent_kappa_i qui sont des references a
9978 // turbulent_kappa_i si la diffusivite est vectorielle et
9979 // turbulent_kappa_ si la diffusivite n'est pas vectorielle.
9980 IJK_Field_double* ptr_turbulent_kappa_x;
9981 IJK_Field_double* ptr_turbulent_kappa_y;
9982 IJK_Field_double* ptr_turbulent_kappa_z;
9983
9985 {
9986 ptr_turbulent_kappa_x = &turbulent_kappa_vector_[0];
9987 ptr_turbulent_kappa_y = &turbulent_kappa_vector_[1];
9988 ptr_turbulent_kappa_z = &turbulent_kappa_vector_[2];
9989 Cerr << "The turbulent diffusivity is vectorial. The turbulent diffusivity vector coefficients are:"
9993 << finl;
9994 }
9995 else
9996 {
9997 ptr_turbulent_kappa_x = &turbulent_kappa_;
9998 ptr_turbulent_kappa_y = &turbulent_kappa_;
9999 ptr_turbulent_kappa_z = &turbulent_kappa_;
10000 Cerr << "The turbulent diffusivity is not tensorial." << finl;
10001 }
10002
10003 IJK_Field_double& ref_turbulent_kappa_x = *ptr_turbulent_kappa_x;
10004 IJK_Field_double& ref_turbulent_kappa_y = *ptr_turbulent_kappa_y;
10005 IJK_Field_double& ref_turbulent_kappa_z = *ptr_turbulent_kappa_z;
10006
10007// velocity_convection_op_.initialize(splitting_);
10008
10010 {
10012 }
10014 {
10016 }
10018 {
10021 }
10022 else
10023 {
10024 // Schema centre4 (utilise par defaut)
10027 }
10028
10030 {
10032 }
10033 else if (convection_rho_amont_)
10034 {
10036 }
10037 else if (convection_rho_centre4_)
10038 {
10039 // ATTENTION le schema centre 4 OpCentre4IJK a ete modifie pour devenir un centre 2
10042 }
10043 else
10044 {
10045 // Schema quick (utilise par defaut)
10046 rho_convection_op_.initialize(domaine_);
10047 }
10050 {
10051 poisson_solver_.initialize(domaine_);
10052 }
10053
10054 initialise();
10055 force_zero_normal_velocity_on_walls(velocity_[2]);
10056
10057 statistics().create_custom_counter("calcul dtstab QC",2,"TrioCFD");
10058 statistics().create_custom_counter("update statistiques",2,"TrioCFD");
10059 statistics().create_custom_counter("calcul terme acceleration",2,"TrioCFD");
10060 statistics().create_custom_counter("checkpointing",2,"TrioCFD");
10061 statistics().create_custom_counter("TF update",2,"TrioCFD");
10062 // modif FA AT 16/07/2013 necessaire pour le calcul des derivees
10063 // dans statistiques_.update_stat_k(...)
10064 temperature_.echange_espace_virtuel(1);
10065 molecular_lambda_.echange_espace_virtuel(1);
10066 molecular_mu_.echange_espace_virtuel(1);
10067 pressure_.echange_espace_virtuel(1);
10068 rho_.echange_espace_virtuel(2); // rho est echange sur deux mailles en prevision de rk_step
10069 velocity_[0].echange_espace_virtuel(2); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
10070 velocity_[1].echange_espace_virtuel(2); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
10071 velocity_[2].echange_espace_virtuel(2); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
10072
10073 // Projection initiale sur div(u)=0, si demande: (attention, ne pas le faire en reprise)
10075 {
10077 {
10078 Cerr << "*****************************************************************************\n"
10079 << " Attention : projection du champ de vitesse initial sur div(u)=0\n"
10080 << "*****************************************************************************" << finl;
10081
10082 pressure_projection_with_rho(rho_,velocity_[0], velocity_[1], velocity_[2],
10083 pressure_, 1.0 /* dt */, pressure_rhs_,
10084 poisson_solver_,0);
10085 pressure_.data() = 0.;
10086 pressure_rhs_.data() = 0.;
10087 // Echange espace virtuel inutiles car deja fait dans pressure_projection_with_rho
10088 velocity_[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
10089 velocity_[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
10090 velocity_[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
10091 }
10092 }
10093
10094 const Nom lata_name = nom_du_cas() + Nom("_lata_");
10095
10096 ArrOfDouble tmp_size3(3);
10097 // Postraiter la condition initiale:
10098 // Calcul des moyennes spatiales sur la condition initiale:
10101 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,
10102 flag_kappa_anisotropic_, turbulent_diffusivity_, ref_turbulent_kappa_x, ref_turbulent_kappa_y, ref_turbulent_kappa_z,
10107 if (statistiques_.check_converge())
10108 {
10110 }
10112
10113 // ATTENTION PARTIE pour le test et debugage
10114 if ( 0 )
10115 {
10117 Cerr << " Post-traitement Spectral " << finl;
10118 Nom Nom_post_test = "Spectrale";
10119 partie_fourier_.postraiter(Nom_post_test);
10120 Process::exit();
10121 }
10122
10123 int stop = 0;
10124 double previous_time = 0;
10125
10126 // DD,2016-28-01: statistiques a partir de fichiers lata uniquement
10128 {
10130
10131 Cerr << "*****************************************************************************\n"
10132 << " Attention : On ne fait que postraiter les statistiques depuis les lata\n"
10133 << "*****************************************************************************" << finl;
10134 }
10135
10136 statistics().start_timeloop();
10137 for (int tstep = 0; tstep < nb_timesteps_ && stop == 0; tstep++)
10138 {
10139 statistics().start_time_step();
10140 statistics().begin_count(STD_COUNTERS::timeloop,statistics().get_last_opened_counter_level()+1);
10141 DebogIJK::verifier("Vitesse_X init", velocity_[0]);
10142 DebogIJK::verifier("Vitesse_Y init", velocity_[1]);
10143 DebogIJK::verifier("Vitesse_Z init", velocity_[2]);
10144 DebogIJK::verifier("rho init", rho_);
10145
10146 // DD,2016-28-01: statistiques a partir de fichiers lata uniquement
10148 {
10149 Nom statlata_fichier = Nom(statlata_namelist_[tstep]);
10150 statlata_fichier += Nom(".sauv");
10151
10152 previous_time = current_time_;
10153 reprendre_qc(statlata_fichier); // current_time_ mis a jour
10154 timestep_ = current_time_ - previous_time;
10155
10156 Cout << "T= " << current_time_
10157 << " timestep= " << timestep_ << finl;
10158
10159 const Nom& geom_name = domaine_.le_nom();
10160
10161 Cout << "Lecture rho dans fichier " << fichier_reprise_rho_ << " timestep= " << timestep_reprise_rho_ << finl;
10162 lire_dans_lata(fichier_reprise_rho_, timestep_reprise_rho_, geom_name, "RHO", rho_);
10163
10164 Cout << "Lecture pression dans fichier " << fichier_reprise_rho_ << " timestep= " << timestep_reprise_rho_ << finl;
10165 lire_dans_lata(fichier_reprise_rho_, timestep_reprise_rho_, geom_name, "PRESSURE", pressure_);
10166
10167 Cout << "Lecture vitesse dans fichier " << fichier_reprise_vitesse_ << " timestep= " << timestep_reprise_vitesse_ << finl;
10168 lire_dans_lata(fichier_reprise_vitesse_, timestep_reprise_vitesse_, geom_name, "VELOCITY",
10169 velocity_[0], velocity_[1], velocity_[2]);
10170
10172 {
10173 const int flag_add = 0;
10174 velocity_[0].echange_espace_virtuel(ghost_size_velocity);
10175 velocity_[1].echange_espace_virtuel(ghost_size_velocity);
10176 velocity_[2].echange_espace_virtuel(ghost_size_velocity);
10180 }
10181
10183 {
10184 const int flag_add = 0;
10185 rho_.echange_espace_virtuel(ghost_size_rho);
10187 }
10188
10190 {
10191 const int flag_add = 0;
10192 pressure_.echange_espace_virtuel(ghost_size_pressure);
10194 }
10195
10196 rho_.echange_espace_virtuel(1);
10198
10199 temperature_.echange_espace_virtuel(1);
10200 molecular_lambda_.echange_espace_virtuel(1);
10201 molecular_mu_.echange_espace_virtuel(1);
10202 pressure_.echange_espace_virtuel(1);
10203 rho_.echange_espace_virtuel(2);
10204 velocity_[0].echange_espace_virtuel(2);
10205 velocity_[1].echange_espace_virtuel(2);
10206 velocity_[2].echange_espace_virtuel(2);
10207 }
10208 else
10209 {
10210 // Calcul du pas de temps:
10211
10212 velocity_[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
10213 velocity_[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
10214 velocity_[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
10215
10216 statistics().begin_count("calcul dtstab QC",statistics().get_last_opened_counter_level()+1);
10218
10219 double dt_conv = conv_qdm_negligeable_ ? 1.e20 : velocity_convection_op_.compute_dtstab_convection_local(velocity_[0], velocity_[1], velocity_[2]);
10220 double dt_diff = 1.e20;
10221 double dt_diff_mu = 1.e20;
10222 if (old_dtstab_)
10223 {
10224 dt_diff_mu = diff_qdm_negligeable_ ? 1.e20 : calculer_dtstab_diffusion_temperature_local(molecular_mu_, rho_, 1.);
10225 dt_diff = diff_temp_negligeable_ ? 1.e20 : calculer_dtstab_diffusion_temperature_local(molecular_lambda_, rho_, Cp_gaz_);
10226 }
10227 else
10228 {
10232 {
10233 dt_diff_mu = diff_qdm_negligeable_ ? 1.e20 : calculer_dtstab_diffusion_temperature_local(molecular_mu_, rho_, 1.);
10234 dt_diff = dt_diff_mu;
10235 }
10237 {
10238 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.);
10239 dt_diff = dt_diff_mu;
10240 }
10242 {
10243 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.);
10244 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.);
10245 dt_diff = min(dt_diff_mu, dt_diff_kappa);
10246 }
10248 {
10249 dt_diff_mu = diff_qdm_negligeable_ ? 1.e20 : calculer_dtstab_diffusion_temperature_local(molecular_mu_, rho_, 1.);
10250 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.);
10251 dt_diff = min(dt_diff_mu, dt_diff_kappa);
10252 }
10254 {
10255 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.);
10256 dt_diff = dt_diff_mu;
10257 }
10258 else
10259 {
10260 Cerr << "This should not happen." << finl;
10261 Process::exit();
10262 }
10263 }
10264
10265 statistics().end_count("calcul dtstab QC");
10266 tmp_size3[0] = dt_conv;
10267 tmp_size3[1] = dt_diff;
10268 tmp_size3[2] = dt_diff_mu;
10269 mp_min_for_each_item(tmp_size3);
10270 dt_conv = tmp_size3[0];
10271 dt_diff = tmp_size3[1];
10272 dt_diff_mu = tmp_size3[2];
10273
10274 // ajouter ici methode de non progression du dt si trop faible. (stats plus stables => plus precise).
10275 const double dt_theorique = 1. / (1./dt_conv + 1./dt_diff);
10276 double dt_regule = min(dt_theorique * timestep_facsec_, timestep_max_);
10277
10278 // FA 17/03/14 amelioration pour le pas de temps !
10279 if (tstep == 0 ) /* au cas ou on a un dt_start */
10280 timestep_ = min(dt_regule,dt_start_);
10281 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
10282 {
10283 timestep_ = dt_regule;
10284 }
10285 // We want to save each delta_t
10287 {
10288 // If the stability timestep makes us go beyond
10289 // the desired next timestep
10290 // change the timestep to match the next point
10292 {
10293 assert(timestep_ >= dt_save_cycle_ - current_time_ && "Something went wrong while trying to adapt the delta_t timestep");
10295 /* save_next_timestep = true; */
10296 save_current_timestep = true;
10297 }
10298 assert(timestep_ > 0 && "You can't have a null timestep");
10299 }
10300
10301 Cout << "T= " << current_time_
10302 << " dtconv= " << dt_conv
10303 << " dtdiff_t= " << dt_diff
10304 << " dtdiff_v= " << dt_diff_mu;
10305 Cout << " theorique_dt= " << dt_theorique
10306 << " dt_limited " << dt_regule
10307 << " timestep= " << timestep_ << finl;
10308
10309 // // F.A 3 /04/2014 changement de la source est maintenant calculee au debut de rk_sub_step
10310 // double v_moy, rho_v_moy;
10311 // calculer_v_et_rhov_moyen(velocity_[0], rho_, delta_z_local_, volume_total_domaine_, v_moy, rho_v_moy);
10312 // double derivee_acceleration;
10313 // if (Process::je_suis_maitre()) {
10314 // // Mise a jour de l'acceleration
10315 // parser_derivee_acceleration_.setVar("force", terme_source_acceleration_);
10316 // parser_derivee_acceleration_.setVar("v_moyen", v_moy);
10317 // parser_derivee_acceleration_.setVar("rho_v_moyen", rho_v_moy);
10318 // derivee_acceleration = parser_derivee_acceleration_.eval();
10319 // terme_source_acceleration_ += derivee_acceleration * timestep_;
10320 // }
10321 //
10322
10323 // F.A 16/04/14 changement de source (encore ...)
10324 // calcul de la force de recirculation avant modification des tableaux
10325
10326 statistics().begin_count("calcul terme acceleration",statistics().get_last_opened_counter_level()+1);
10327 double debit_old = debit_actuel_;
10328 calculer_debit(velocity_[0], rho_, delta_z_local_, Lx_tot_, debit_actuel_);
10329 double old_t_bulk = actual_t_bulk_;
10332 {
10333 double acceleration_du_dt = 0.;
10335 {
10337 }
10338 else
10339 {
10340 double ecart_debit = (debit_cible_ - debit_actuel_);
10341 double ecart_ancien = (debit_actuel_ - debit_old);
10342 acceleration_du_dt = ecart_debit - ecart_ancien;
10343 acceleration_du_dt /= dump_factor_ * Ly_tot_ * Lz_tot_ * timestep_;
10344
10345 terme_source_acceleration_ += acceleration_du_dt;
10346 }
10347
10349 {
10350 /* double derivative_flux = (sum_entering_flux_ - old_entering_hf)/Lz_tot_; */
10351 double derivative_2nd_order_t = aim_t_bulk_ - 2 * actual_t_bulk_ + old_t_bulk;
10352 double d = derivative_2nd_order_t / timestep_;
10353 /* double fac = dump_factor_2_ *( rho_bulk_ * constante_specifique_gaz_ * d / (gamma_ - 1) - derivative_flux); */
10354 double fac = dump_factor_2_ * rho_bulk_ * constante_specifique_gaz_ * d / (gamma_ - 1);
10355 puit_ -= fac;
10356 Cout << "Current heat sink: " << puit_
10357 << " Current T_bulk: " << actual_t_bulk_
10358 << " Aim T_bulk: " << aim_t_bulk_
10359 << " Old T_bulk: " << old_t_bulk
10360 << " factor " << fac
10361 << " Timestep " << timestep_
10362 << " rho bulk " << rho_bulk_
10363 /* << " sum_fluxes: " << sum_entering_flux_ */
10364 /* << " old_sum_fluxes: " << old_entering_hf */
10365 << finl;
10366 }
10367
10368
10369 // la derivee_acceleration n'est connue que sur le maitre
10370 Cout << "T= " << current_time_
10371 << " debit cible= " << debit_cible_
10372 << " debit actuel= " << debit_actuel_
10373 << " acceleration= " << terme_source_acceleration_
10374 << " da/dt= " << acceleration_du_dt << finl;
10375
10376
10377 }
10378 envoyer_broadcast(terme_source_acceleration_, 0);
10379 envoyer_broadcast(puit_, 0);
10380
10381
10382 // // F.A 3 /04/2014 changement de la source
10383 // if (Process::je_suis_maitre()) {
10384 // // la derivee_acceleration n'est connue que sur le maitre
10385 // Cout << "T= " << current_time_
10386 // << " Vx_moyen= " << v_moy
10387 // << " rho_vx_moyen= " << rho_v_moy
10388 // << " acceleration= " << terme_source_acceleration_
10389 // << " da/dt= " << derivee_acceleration << finl;
10390 // }
10391 //
10392
10393 statistics().end_count("calcul terme acceleration");
10394
10395 //////////////////////////
10396 for (int rk_step = 0; rk_step < 3; rk_step++)
10397 {
10398 rk3_sub_step(rk_step, timestep_);
10400 {
10401 statistics().begin_count(STD_COUNTERS::postreatment,statistics().get_last_opened_counter_level()+1);
10402 posttraiter_champs_instantanes(lata_name, current_time_ + timestep_ * rk_step / 3.0);
10403 statistics().end_count(STD_COUNTERS::postreatment);
10404 }
10405 }
10406 }
10407 // on s'assure que la force est la meme entre chaque pas de temps.
10408 // if (Process::je_suis_maitre())
10409 // envoyer_broadcast(terme_source_acceleration_, 0);
10410
10412 {
10413 statistics().begin_count(STD_COUNTERS::postreatment,statistics().get_last_opened_counter_level()+1);
10414 statistics().begin_count("update statistiques",statistics().get_last_opened_counter_level()+1);
10417 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,
10418 flag_kappa_anisotropic_, turbulent_diffusivity_, ref_turbulent_kappa_x, ref_turbulent_kappa_y, ref_turbulent_kappa_z,
10422 Cp_gaz_, P_thermodynamique_, timestep_); // stats standard
10423 if (statistiques_.check_converge())
10425 statistics().end_count("update statistiques");
10426 statistics().begin_count("TF update",statistics().get_last_opened_counter_level()+1);
10427 if ( dt_post_spectral_ > 0 )
10428 {
10429 int un_sur_20 = tstep%20;
10430 if ( !un_sur_20 )
10432 }
10433 statistics().end_count("TF update");
10434 statistics().end_count(STD_COUNTERS::postreatment);
10435 }
10436
10438 {
10439 // do nothing
10440 }
10441 else
10442 {
10444 }
10445 // verification du fichier stop
10446 stop = 0;
10447 if (check_stop_file_ != "??")
10448 {
10449 if (je_suis_maitre())
10450 {
10451 EFichier f;
10452 stop = f.ouvrir(check_stop_file_);
10453 if (stop)
10454 {
10455 // file exists, check if it contains 1:
10456 f >> stop;
10457 }
10458 }
10459 envoyer_broadcast(stop, 0);
10460 }
10461 if (tstep == nb_timesteps_ - 1)
10462 stop = true;
10463
10464 if (tstep % dt_sauvegarde_ == dt_sauvegarde_-1 || stop)
10465 {
10466 statistics().begin_count("checkpointing",statistics().get_last_opened_counter_level()+1);
10468 statistics().end_count("checkpointing");
10469 }
10470
10471 if (tstep % dt_post_ == dt_post_-1 || stop)
10472 {
10473 statistics().end_count(STD_COUNTERS::timeloop,0,0);
10475 statistics().begin_count(STD_COUNTERS::timeloop,statistics().get_last_opened_counter_level()+1);
10476 }
10477
10478 if (save_current_timestep)
10479 {
10480 save_current_timestep=false;
10481 // save_next_timestep=false;
10482 Cerr << "Yanis: Raw data cycle " << finl;
10484 statistics().end_count(STD_COUNTERS::timeloop,0,0);
10485 save_raw_data(lata_name, current_time_);
10486 statistics().begin_count(STD_COUNTERS::timeloop,statistics().get_last_opened_counter_level()+1);
10487 }
10488
10489 /*
10490 if (current_time_ > dt_save_cycle_)
10491 {
10492 Cerr << "Yanis: Raw data cycle " << finl;
10493 dt_save_cycle_ += dt_save_oscillating_cycle_raw_data_;
10494 save_raw_data(lata_name, current_time_);
10495 }
10496 */
10497 if (tstep % dt_raw_data_ == dt_raw_data_-1)
10498 {
10499 Cerr << "Yanis: Raw data " << finl;
10500 statistics().end_count(STD_COUNTERS::timeloop,0,0);
10501 save_raw_data(lata_name, current_time_);
10502 statistics().begin_count(STD_COUNTERS::timeloop,statistics().get_last_opened_counter_level()+1);
10503 }
10504 if (tstep % dt_stats_ == dt_stats_-1)
10505 {
10506 Cerr << "Yanis: Stats " << finl;
10508 }
10509 if ((tstep % dt_post_spectral_ == dt_post_-1 || stop) && (dt_post_spectral_ != -1))
10510 {
10511 statistics().end_count(STD_COUNTERS::timeloop,0,0);
10512 Nom Nom_post = "Spectrale_";
10513 Nom_post += Nom(current_time_);
10514 partie_fourier_.postraiter(Nom_post);
10515 statistics().begin_count(STD_COUNTERS::timeloop,statistics().get_last_opened_counter_level()+1);
10516 }
10517 // calculer_moyennes_flux();
10518
10520 {
10521 Cerr << "tstep " << tstep
10522 << " currenttime " << current_time_
10523 << " cpu_time " << statistics().get_time_since_last_open(STD_COUNTERS::timeloop) << finl;
10524 }
10525 statistics().end_count(STD_COUNTERS::timeloop);
10526 statistics().end_time_step(tstep);
10527 }
10528 statistics().end_timeloop();
10529 statistics().print_TU_files("Time loop statistics");
10530 delete kernel_;
10531}
10532
10533
10534int calculer_k_pour_bord(const IJK_Field_double& temperature, const bool bord_kmax)
10535{
10536 const int kmin = temperature.get_domaine().get_offset_local(DIRECTION_K);
10537 const int nktot = temperature.get_domaine().get_nb_items_global(Domaine_IJK::ELEM, DIRECTION_K);
10538 int k;
10539 // calcul l'indice k de la couche de mailles voisine du bord. Si je n'ai pas de bord, on met k = -1
10540 if (!bord_kmax)
10541 {
10542 // on veut le bord "k_global = 0"
10543 if (kmin == 0)
10544 {
10545 // ce bord est chez moi... et il est en k=0
10546 k = 0;
10547 }
10548 else
10549 {
10550 // ce bord n'est pas chez moi
10551 k = -1;
10552 }
10553 }
10554 else
10555 {
10556 // on veut le bord kmax
10557 if (kmin + temperature.nk() == nktot)
10558 {
10559 // ce bord est chez moi... et il est en k= truc...
10560 k = temperature.nk() - 1;
10561 }
10562 else
10563 {
10564 k = -1;
10565 }
10566 }
10567 return k;
10568}
10569
10570// valeur de retour: indice local du plan de temperature voisin utilise,
10571// -1 si on n'a pas le bord sur ce processeur
10572// Calcule l'integrale sur chaque face du bord demande du flux de chaleur a travers la face
10573// positif si le flux va vers les k positifs.
10574int calculer_flux_thermique_bord(const IJK_Field_double& temperature,
10575 const double lambda_de_t_paroi,
10576 const int turbulent_diffusivity,
10577 const IJK_Field_double& lambda_turbulent,
10578 const int flag_lambda_anisotropic,
10579 const int structural_uscalar,
10580 const IJK_Field_double& structural_uscalar_z,
10581 const double T_paroi_impose,
10582 IJK_Field_local_double& flux_bord,
10583 const bool bord_kmax)
10584{
10585 const int kmin = temperature.get_domaine().get_offset_local(DIRECTION_K);
10586 int k = calculer_k_pour_bord(temperature, bord_kmax);
10587 if (k == -1)
10588 return k;
10589
10590 // redimensionne flux_bord avec ni * nj:
10591 const int ni = temperature.ni(); // nombre d'element local sur ce processeur
10592 const int nj = temperature.nj();
10593 flux_bord.allocate(ni, nj, 1, 0);
10594
10595 const Domaine_IJK& geometry = temperature.get_domaine();
10596 const double delta_k = geometry.get_delta(DIRECTION_K)[k + kmin]; // k+kmin est l'indice global de la maille locale k
10597 const ArrOfDouble& coord_z = geometry.get_node_coordinates(DIRECTION_K);
10598
10599 for (int j = 0; j < nj; j++)
10600 {
10601 for (int i = 0; i < ni; i++)
10602 {
10603 const int sens = bord_kmax ? -1 : 1;
10604
10605 // si bord bas: x_p=coord_z[p]; y_k=velocity_k(i,j,p)
10606 // si bord haut: x_p=coord_z[k+kmin+1-p]; y_k=velocity_k(i,j,k+1-p)
10607 const double xf_0 = coord_z[k+kmin+bord_kmax];
10608 const double xf_1 = coord_z[k+kmin+bord_kmax+sens*1];
10609 const double xf_2 = coord_z[k+kmin+bord_kmax+sens*2];
10610
10611 const double x_p = xf_0;
10612 const double x_0 = 0.5*(xf_0+xf_1);
10613 const double x_1 = 0.5*(xf_1+xf_2);
10614
10615 double T_p = T_paroi_impose;
10616
10617 const double T_0 = temperature(i,j,k);
10618 const double T_1 = temperature(i,j,k+sens*1);
10619 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))));
10620
10621 double l;
10622 double flux;
10623 if (turbulent_diffusivity && (!flag_lambda_anisotropic))
10624 {
10625 l = lambda_turbulent(i,j,k) + lambda_de_t_paroi;
10626 }
10627 else if (turbulent_diffusivity && flag_lambda_anisotropic)
10628 {
10629 l = delta_k*lambda_turbulent(i,j,k) + lambda_de_t_paroi;
10630 }
10631 else
10632 {
10633 l = lambda_de_t_paroi;
10634 }
10635 /*
10636 // Faut-il ajouter ce if ? Si oui ou ajouter s ?
10637 if (structural_uscalar) {
10638 const double s = structural_uscalar_z(i,j,k);
10639 flux = ((T_paroi_impose - t) * l + s) * facteur;
10640 } else {
10641 // le flux est positif s'il va vers les k croissants
10642 flux = (T_paroi_impose - t) * l * facteur;
10643 }
10644 */
10645 if (structural_uscalar)
10646 {
10647 const double s = structural_uscalar_z(i,j,k);
10648 flux = -( derivee_premiere * l + s ) * geometry.get_constant_delta(DIRECTION_I) * geometry.get_constant_delta(DIRECTION_J);
10649 }
10650 else
10651 {
10652 flux = -( derivee_premiere * l ) * geometry.get_constant_delta(DIRECTION_I) * geometry.get_constant_delta(DIRECTION_J);
10653 }
10654 flux_bord(i,j,0) = flux;
10655 }
10656 }
10657 return k;
10658}
10659
10660
10661// p_thermo = pression thermodynamique
10662void DNS_QC_double::calcul_p_thermo_et_bilan(const IJK_Field_double& rho,
10663 IJK_Field_double& temperature,
10664 const int turbulent_diffusivity,
10665 const IJK_Field_double& lambda_turbulent,
10666 const int flag_lambda_anisotropic,
10667 const int structural_uscalar,
10668 const IJK_Field_double& structural_uscalar_z,
10669 const double P_th_initial,
10670 double& P_th_final,
10671 const double fractionnal_timestep,
10672 double& d_Pth_divise_par_gammamoins1) const
10673{
10674 IJK_Field_local_double flux_bord;
10675
10676 const int imax = temperature.ni();
10677 const int jmax = temperature.nj();
10678
10679 double P_th = P_th_initial;
10680 // Boucle point fixe:
10681 const int max_point_fixe = 3;
10682 double somme_flux_entrants;
10683
10684 for (int point_fixe_iter = 0; point_fixe_iter < max_point_fixe; point_fixe_iter++)
10685 {
10686 // Calcul t_star a partir de rho et de la valeur courante de pthermo
10687 // boucle sur les deux plans conditions aux limites:
10688 double somme_flux_kmin = 0.;
10689 double somme_flux_kmax = 0.;
10690 for (int plan_cl = 0; plan_cl < 2; plan_cl++)
10691 {
10692 double somme_flux = 0.;
10693 // indice local du plan de mailles voisin de ce bord:
10694 int k = calculer_k_pour_bord(temperature, plan_cl);
10695 if (k > -1)
10696 {
10697 for (int j = 0; j < jmax; j++)
10698 {
10699 for (int i = 0; i < imax; i++)
10700 {
10701 temperature(i,j,k) = P_th / (constante_specifique_gaz_ * rho(i,j,k));
10702 }
10703 }
10704 const double lambda_de_t_paroi = (plan_cl ? lambda_de_t_paroi_kmax_ : lambda_de_t_paroi_kmin_);
10705 const double T_paroi_impose = (plan_cl ? T_paroi_impose_kmax_ : T_paroi_impose_kmin_);
10706
10707 calculer_flux_thermique_bord(temperature, lambda_de_t_paroi,
10708 0, lambda_turbulent, flag_lambda_anisotropic,
10709 0, structural_uscalar_z,
10710 T_paroi_impose, flux_bord, plan_cl);
10711 // integrale du flux:
10712 for (int j = 0; j < jmax; j++)
10713 {
10714 for (int i = 0; i < imax; i++)
10715 {
10716 somme_flux += flux_bord(i,j,0);
10717 }
10718 }
10719 }
10720 // le flux est positif si la chaleur va vers les k croissants:
10721 if (plan_cl)
10722 somme_flux_kmax = somme_flux;
10723 else
10724 somme_flux_kmin = somme_flux;
10725 }
10726 // Reduce 2 mp_sum calls to 1 by using mp_sum_for_each
10727 mp_sum_for_each(somme_flux_kmin, somme_flux_kmax);
10728 // Somme des flux entrants dans le domaine:
10729 if ( diff_temp_negligeable_ && !(formulation_favre_ && turbulent_diffusivity) && !(formulation_favre_ && structural_uscalar) ) // si diffusion negligable
10730 somme_flux_entrants =0;
10731 else
10732 somme_flux_entrants = somme_flux_kmin - somme_flux_kmax;
10733 P_th = P_th_initial / (1. - (gamma_ - 1) * fractionnal_timestep / P_th * ( somme_flux_entrants / volume_total_domaine_ - puit_ ));
10734
10735 assert_parallel(P_th);
10736 if (point_fixe_iter== max_point_fixe-1)
10737 {
10738 Cout << "calcul_p_thermo iter " << point_fixe_iter << " flux k=0: " << somme_flux_kmin
10739 << " flux k=kmax: " << somme_flux_kmax << " P_th: " << P_th << " ";
10740 }
10741 }
10742 P_th_final = P_th;
10743
10744 d_Pth_divise_par_gammamoins1 = somme_flux_entrants / volume_total_domaine_ - puit_;
10745 Cout << "dP_th/dt= " << d_Pth_divise_par_gammamoins1 * (gamma_ - 1) << finl;
10746}
10747
10748static void force_2d(IJK_Field_double& f)
10749{
10750 const int ni = f.ni();
10751 const int nj = f.nj();
10752 const int nk = f.nk();
10753 for (int k = 0; k < nk; k++)
10754 {
10755 for (int j = 1; j < nj; j++)
10756 {
10757 for (int i = 0; i < ni; i++)
10758 {
10759 f(i, j, k) = f(i, 0, k);
10760 }
10761 }
10762 }
10763}
10764
10765template<class T>
10766void DNS_QC_double::calculer_convection_vitesse(IJK_Field_vector3_double& rho_v,
10767 IJK_Field_vector3_double& velocity,
10768 const ArrOfDouble_with_ghost& delta_z,
10769 const double facteur_delta_x,
10770 const double facteur_delta_y,
10771 const ArrOfDouble_with_ghost& delta_z_pour_delta,
10772 T& kernel,
10775 IJK_Field_vector3_double& d_velocity_tmp,
10776 IJK_Field_vector3_double& d_velocity,
10777 IJK_Field_double& u_div_rho_u)
10778{
10779 int ghost_size_filter;
10780 int ghost_size_d_velocity_tmp;
10782 {
10784 {
10785 rho_v[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
10786 rho_v[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
10787 rho_v[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
10788 compute_divergence_times_constant(rho_v[0], rho_v[1], rho_v[2], 1., u_div_rho_u);
10789 u_div_rho_u.echange_espace_virtuel(1);
10790
10791 multiplier_champ_rho_face_i(false, u_div_rho_u, 1., velocity[0], d_velocity_tmp[0]);
10792 multiplier_champ_rho_face_j(false, u_div_rho_u, 1., velocity[1], d_velocity_tmp[1]);
10793 multiplier_champ_rho_face_k(false, u_div_rho_u, 1., 0., velocity[2], d_velocity_tmp[2]);
10794
10795 ghost_size_filter = 1 + kernel->ghost_size();
10796 ghost_size_d_velocity_tmp = max((int) 2, ghost_size_filter);
10797 d_velocity_tmp[0].echange_espace_virtuel(ghost_size_d_velocity_tmp);
10798 d_velocity_tmp[1].echange_espace_virtuel(ghost_size_d_velocity_tmp);
10799 d_velocity_tmp[2].echange_espace_virtuel(ghost_size_d_velocity_tmp);
10800
10801 const int flag_add = 1;
10802 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]);
10803 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]);
10804 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]);
10805 }
10806 else
10807 {
10808 rho_v[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
10809 rho_v[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
10810 rho_v[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
10811 compute_divergence_times_constant(rho_v[0], rho_v[1], rho_v[2], 1., u_div_rho_u);
10812 u_div_rho_u.echange_espace_virtuel(1);
10813
10814 multiplier_champ_rho_face_i(true, u_div_rho_u, 1., velocity[0], d_velocity[0]);
10815 multiplier_champ_rho_face_j(true, u_div_rho_u, 1., velocity[1], d_velocity[1]);
10816 multiplier_champ_rho_face_k(true, u_div_rho_u, 1., 0., velocity[2], d_velocity[2]);
10817 }
10818 }
10819 else
10820 {
10822 {
10824 {
10825 velocity_convection_op_amont_.calculer(rho_v[0], rho_v[1], rho_v[2],
10826 velocity[0], velocity[1], velocity[2],
10827 d_velocity[0], d_velocity[1], d_velocity[2]);
10828
10829 }
10831 {
10832 velocity_convection_op_quicksharp_.calculer(rho_v[0], rho_v[1], rho_v[2],
10833 velocity[0], velocity[1], velocity[2],
10834 d_velocity[0], d_velocity[1], d_velocity[2]);
10835 }
10837 {
10838 velocity_convection_op_centre_2_.ajouter_avec_u_div_rhou(rho_v[0], rho_v[1], rho_v[2],
10839 velocity[0], velocity[1], velocity[2],
10840 d_velocity[0], d_velocity[1], d_velocity[2],
10841 u_div_rho_u);
10842 }
10843 else
10844 {
10845 // Schema centre4 (utilise par defaut)
10846 velocity_convection_op_.ajouter_avec_u_div_rhou(rho_v[0], rho_v[1], rho_v[2],
10847 velocity[0], velocity[1], velocity[2],
10848 d_velocity[0], d_velocity[1], d_velocity[2],
10849 u_div_rho_u);
10850 }
10851
10852 ghost_size_filter = 1 + kernel->ghost_size();
10853 ghost_size_d_velocity_tmp = max((int) 2, ghost_size_filter);
10854 d_velocity_tmp[0].echange_espace_virtuel(ghost_size_d_velocity_tmp);
10855 d_velocity_tmp[1].echange_espace_virtuel(ghost_size_d_velocity_tmp);
10856 d_velocity_tmp[2].echange_espace_virtuel(ghost_size_d_velocity_tmp);
10857
10858 const int flag_add = 1;
10859 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]);
10860 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]);
10861 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]);
10862 }
10863 else
10864 {
10866 {
10867 velocity_convection_op_amont_.calculer(rho_v[0], rho_v[1], rho_v[2],
10868 velocity[0], velocity[1], velocity[2],
10869 d_velocity[0], d_velocity[1], d_velocity[2]);
10870 }
10872 {
10873 velocity_convection_op_quicksharp_.calculer(rho_v[0], rho_v[1], rho_v[2],
10874 velocity[0], velocity[1], velocity[2],
10875 d_velocity[0], d_velocity[1], d_velocity[2]);
10876 }
10878 {
10879 velocity_convection_op_centre_2_.ajouter_avec_u_div_rhou(rho_v[0], rho_v[1], rho_v[2],
10880 velocity[0], velocity[1], velocity[2],
10881 d_velocity[0], d_velocity[1], d_velocity[2],
10882 u_div_rho_u);
10883 }
10884 else
10885 {
10886 // Schema centre4 (utilise par defaut)
10887 velocity_convection_op_.ajouter_avec_u_div_rhou(rho_v[0], rho_v[1], rho_v[2],
10888 velocity[0], velocity[1], velocity[2],
10889 d_velocity[0], d_velocity[1], d_velocity[2],
10890 u_div_rho_u);
10891 }
10892 }
10893 }
10894}
10895
10896template<class T>
10897void DNS_QC_double::calculer_turbulent_diffusion_vitesse(IJK_Field_vector3_double& velocity,
10898 const IJK_Field_double& turbulent_mu_xx,
10899 const IJK_Field_double& turbulent_mu_xy,
10900 const IJK_Field_double& turbulent_mu_xz,
10901 const IJK_Field_double& turbulent_mu_yy,
10902 const IJK_Field_double& turbulent_mu_yz,
10903 const IJK_Field_double& turbulent_mu_zz,
10904 const ArrOfDouble_with_ghost& delta_z,
10905 const double facteur_delta_x,
10906 const double facteur_delta_y,
10907 const ArrOfDouble_with_ghost& delta_z_pour_delta,
10908 T& kernel,
10911 IJK_Field_vector3_double& d_velocity_tmp,
10912 IJK_Field_vector3_double& d_velocity)
10913{
10914 const IJK_Field_double& turbulent_mu_yx = turbulent_mu_xy;
10915 const IJK_Field_double& turbulent_mu_zx = turbulent_mu_xz;
10916 const IJK_Field_double& turbulent_mu_zy = turbulent_mu_yz;
10917 int ghost_size_filter;
10918 int ghost_size_d_velocity_tmp;
10920 {
10921 if (type_velocity_turbulent_diffusion_ == Nom("simple"))
10922 {
10923 velocity_turbulent_diffusion_op_simple_.set_coeff_x_y_z(turbulent_mu_xx,
10924 turbulent_mu_xy,
10925 turbulent_mu_xz,
10926 turbulent_mu_yx,
10927 turbulent_mu_yy,
10928 turbulent_mu_yz,
10929 turbulent_mu_zx,
10930 turbulent_mu_zy,
10931 turbulent_mu_zz);
10932 velocity_turbulent_diffusion_op_simple_.calculer(velocity[0], velocity[1], velocity[2],
10933 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
10934 }
10935 else if (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose"))
10936 {
10937 velocity_turbulent_diffusion_op_simple_with_transpose_.set_coeff_x_y_z(turbulent_mu_xx,
10938 turbulent_mu_xy,
10939 turbulent_mu_xz,
10940 turbulent_mu_yx,
10941 turbulent_mu_yy,
10942 turbulent_mu_yz,
10943 turbulent_mu_zx,
10944 turbulent_mu_zy,
10945 turbulent_mu_zz);
10946 velocity_turbulent_diffusion_op_simple_with_transpose_.calculer(velocity[0], velocity[1], velocity[2],
10947 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
10948 }
10949 else if (type_velocity_turbulent_diffusion_ == Nom("full"))
10950 {
10951 velocity[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
10952 velocity[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
10953 velocity[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
10954 compute_divergence(velocity[0], velocity[1], velocity[2], divergence_);
10955 divergence_.echange_espace_virtuel(1);
10956 velocity_turbulent_diffusion_op_full_.set_coeff_x_y_z(turbulent_mu_xx,
10957 turbulent_mu_xy,
10958 turbulent_mu_xz,
10959 turbulent_mu_yx,
10960 turbulent_mu_yy,
10961 turbulent_mu_yz,
10962 turbulent_mu_zx,
10963 turbulent_mu_zy,
10964 turbulent_mu_zz);
10966 velocity_turbulent_diffusion_op_full_.calculer(velocity[0], velocity[1], velocity[2],
10967 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
10968 }
10969 else if (type_velocity_turbulent_diffusion_ == Nom("simple_anisotropic"))
10970 {
10971 velocity_turbulent_diffusion_op_simple_anisotropic_.set_coeff_x_y_z(turbulent_mu_xx,
10972 turbulent_mu_xy,
10973 turbulent_mu_xz,
10974 turbulent_mu_yx,
10975 turbulent_mu_yy,
10976 turbulent_mu_yz,
10977 turbulent_mu_zx,
10978 turbulent_mu_zy,
10979 turbulent_mu_zz);
10980 velocity_turbulent_diffusion_op_simple_anisotropic_.calculer(velocity[0], velocity[1], velocity[2],
10981 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
10982 }
10983 else if (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose_anisotropic"))
10984 {
10986 turbulent_mu_xy,
10987 turbulent_mu_xz,
10988 turbulent_mu_yx,
10989 turbulent_mu_yy,
10990 turbulent_mu_yz,
10991 turbulent_mu_zx,
10992 turbulent_mu_zy,
10993 turbulent_mu_zz);
10994 velocity_turbulent_diffusion_op_simple_with_transpose_anisotropic_.calculer(velocity[0], velocity[1], velocity[2],
10995 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
10996 }
10997 else if (type_velocity_turbulent_diffusion_ == Nom("full_anisotropic"))
10998 {
10999 velocity[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
11000 velocity[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
11001 velocity[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
11002 compute_divergence(velocity[0], velocity[1], velocity[2], divergence_);
11003 divergence_.echange_espace_virtuel(1);
11004 velocity_turbulent_diffusion_op_full_anisotropic_.set_coeff_x_y_z(turbulent_mu_xx,
11005 turbulent_mu_xy,
11006 turbulent_mu_xz,
11007 turbulent_mu_yx,
11008 turbulent_mu_yy,
11009 turbulent_mu_yz,
11010 turbulent_mu_zx,
11011 turbulent_mu_zy,
11012 turbulent_mu_zz);
11014 velocity_turbulent_diffusion_op_full_anisotropic_.calculer(velocity[0], velocity[1], velocity[2],
11015 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
11016 }
11017 else
11018 {
11019 Cerr << "Unknown velocity turbulent diffusion operator! " << finl;
11020 Process::exit();
11021 }
11022
11023 ghost_size_filter = 1 + kernel->ghost_size();
11024 ghost_size_d_velocity_tmp = max((int) 2, ghost_size_filter);
11025 d_velocity_tmp[0].echange_espace_virtuel(ghost_size_d_velocity_tmp);
11026 d_velocity_tmp[1].echange_espace_virtuel(ghost_size_d_velocity_tmp);
11027 d_velocity_tmp[2].echange_espace_virtuel(ghost_size_d_velocity_tmp);
11028
11029 const int flag_add = 1;
11030 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]);
11031 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]);
11032 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]);
11033 }
11034 else
11035 {
11036 if (type_velocity_turbulent_diffusion_ == Nom("simple"))
11037 {
11038 velocity_turbulent_diffusion_op_simple_.set_coeff_x_y_z(turbulent_mu_xx,
11039 turbulent_mu_xy,
11040 turbulent_mu_xz,
11041 turbulent_mu_yx,
11042 turbulent_mu_yy,
11043 turbulent_mu_yz,
11044 turbulent_mu_zx,
11045 turbulent_mu_zy,
11046 turbulent_mu_zz);
11047 velocity_turbulent_diffusion_op_simple_.ajouter(velocity[0], velocity[1], velocity[2],
11048 d_velocity[0], d_velocity[1], d_velocity[2]);
11049 }
11050 else if (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose"))
11051 {
11052 velocity_turbulent_diffusion_op_simple_with_transpose_.set_coeff_x_y_z(turbulent_mu_xx,
11053 turbulent_mu_xy,
11054 turbulent_mu_xz,
11055 turbulent_mu_yx,
11056 turbulent_mu_yy,
11057 turbulent_mu_yz,
11058 turbulent_mu_zx,
11059 turbulent_mu_zy,
11060 turbulent_mu_zz);
11061 velocity_turbulent_diffusion_op_simple_with_transpose_.ajouter(velocity[0], velocity[1], velocity[2],
11062 d_velocity[0], d_velocity[1], d_velocity[2]);
11063 }
11064 else if (type_velocity_turbulent_diffusion_ == Nom("full"))
11065 {
11066 velocity[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
11067 velocity[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
11068 velocity[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
11069 compute_divergence(velocity[0], velocity[1], velocity[2], divergence_);
11070 divergence_.echange_espace_virtuel(1);
11071 velocity_turbulent_diffusion_op_full_.set_coeff_x_y_z(turbulent_mu_xx,
11072 turbulent_mu_xy,
11073 turbulent_mu_xz,
11074 turbulent_mu_yx,
11075 turbulent_mu_yy,
11076 turbulent_mu_yz,
11077 turbulent_mu_zx,
11078 turbulent_mu_zy,
11079 turbulent_mu_zz);
11081 velocity_turbulent_diffusion_op_full_.ajouter(velocity[0], velocity[1], velocity[2],
11082 d_velocity[0], d_velocity[1], d_velocity[2]);
11083 }
11084 else if (type_velocity_turbulent_diffusion_ == Nom("simple_anisotropic"))
11085 {
11086 velocity_turbulent_diffusion_op_simple_anisotropic_.set_coeff_x_y_z(turbulent_mu_xx,
11087 turbulent_mu_xy,
11088 turbulent_mu_xz,
11089 turbulent_mu_yx,
11090 turbulent_mu_yy,
11091 turbulent_mu_yz,
11092 turbulent_mu_zx,
11093 turbulent_mu_zy,
11094 turbulent_mu_zz);
11095 velocity_turbulent_diffusion_op_simple_anisotropic_.ajouter(velocity[0], velocity[1], velocity[2],
11096 d_velocity[0], d_velocity[1], d_velocity[2]);
11097 }
11098 else if (type_velocity_turbulent_diffusion_ == Nom("simple_with_transpose_anisotropic"))
11099 {
11101 turbulent_mu_xy,
11102 turbulent_mu_xz,
11103 turbulent_mu_yx,
11104 turbulent_mu_yy,
11105 turbulent_mu_yz,
11106 turbulent_mu_zx,
11107 turbulent_mu_zy,
11108 turbulent_mu_zz);
11109 velocity_turbulent_diffusion_op_simple_with_transpose_anisotropic_.ajouter(velocity[0], velocity[1], velocity[2],
11110 d_velocity[0], d_velocity[1], d_velocity[2]);
11111 }
11112 else if (type_velocity_turbulent_diffusion_ == Nom("full_anisotropic"))
11113 {
11114 velocity[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
11115 velocity[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
11116 velocity[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
11117 compute_divergence(velocity[0], velocity[1], velocity[2], divergence_);
11118 divergence_.echange_espace_virtuel(1);
11119 velocity_turbulent_diffusion_op_full_anisotropic_.set_coeff_x_y_z(turbulent_mu_xx,
11120 turbulent_mu_xy,
11121 turbulent_mu_xz,
11122 turbulent_mu_yx,
11123 turbulent_mu_yy,
11124 turbulent_mu_yz,
11125 turbulent_mu_zx,
11126 turbulent_mu_zy,
11127 turbulent_mu_zz);
11129 velocity_turbulent_diffusion_op_full_anisotropic_.ajouter(velocity[0], velocity[1], velocity[2],
11130 d_velocity[0], d_velocity[1], d_velocity[2]);
11131 }
11132 else
11133 {
11134 Cerr << "Unknown velocity turbulent diffusion operator! " << finl;
11135 Process::exit();
11136 }
11137 }
11138}
11139
11140template<class T>
11141void DNS_QC_double::calculer_structural_diffusion_vitesse(IJK_Field_vector3_double& velocity,
11142 const FixedVector<IJK_Field_double, 6>& structural_uu_tensor,
11143 const ArrOfDouble_with_ghost& delta_z,
11144 const double facteur_delta_x,
11145 const double facteur_delta_y,
11146 const ArrOfDouble_with_ghost& delta_z_pour_delta,
11147 T& kernel,
11150 IJK_Field_vector3_double& d_velocity_tmp,
11151 IJK_Field_vector3_double& d_velocity)
11152{
11153 const IJK_Field_double& structural_uu_xx = structural_uu_tensor[0];
11154 const IJK_Field_double& structural_uu_xy = structural_uu_tensor[1];
11155 const IJK_Field_double& structural_uu_xz = structural_uu_tensor[2];
11156 const IJK_Field_double& structural_uu_yx = structural_uu_tensor[1];
11157 const IJK_Field_double& structural_uu_yy = structural_uu_tensor[3];
11158 const IJK_Field_double& structural_uu_yz = structural_uu_tensor[4];
11159 const IJK_Field_double& structural_uu_zx = structural_uu_tensor[2];
11160 const IJK_Field_double& structural_uu_zy = structural_uu_tensor[4];
11161 const IJK_Field_double& structural_uu_zz = structural_uu_tensor[5];
11162 int ghost_size_filter;
11163 int ghost_size_d_velocity_tmp;
11165 {
11166 velocity_turbulent_diffusion_op_structural_.set_coeff_x_y_z(structural_uu_xx,
11167 structural_uu_xy,
11168 structural_uu_xz,
11169 structural_uu_yx,
11170 structural_uu_yy,
11171 structural_uu_yz,
11172 structural_uu_zx,
11173 structural_uu_zy,
11174 structural_uu_zz);
11175 velocity_turbulent_diffusion_op_structural_.calculer(velocity[0], velocity[1], velocity[2],
11176 d_velocity_tmp[0], d_velocity_tmp[1], d_velocity_tmp[2]);
11177
11178 ghost_size_filter = 1 + kernel->ghost_size();
11179 ghost_size_d_velocity_tmp = max((int) 2, ghost_size_filter);
11180 d_velocity_tmp[0].echange_espace_virtuel(ghost_size_d_velocity_tmp);
11181 d_velocity_tmp[1].echange_espace_virtuel(ghost_size_d_velocity_tmp);
11182 d_velocity_tmp[2].echange_espace_virtuel(ghost_size_d_velocity_tmp);
11183
11184 const int flag_add = 1;
11185 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]);
11186 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]);
11187 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]);
11188 }
11189 else
11190 {
11191 velocity_turbulent_diffusion_op_structural_.set_coeff_x_y_z(structural_uu_xx,
11192 structural_uu_xy,
11193 structural_uu_xz,
11194 structural_uu_yx,
11195 structural_uu_yy,
11196 structural_uu_yz,
11197 structural_uu_zx,
11198 structural_uu_zy,
11199 structural_uu_zz);
11200 velocity_turbulent_diffusion_op_structural_.ajouter(velocity[0], velocity[1], velocity[2],
11201 d_velocity[0], d_velocity[1], d_velocity[2]);
11202 }
11203}
11204
11205void DNS_QC_double::calculer_diffusion_scalar(const IJK_Field_double& rho,
11206 const IJK_Field_double& turbulent_kappa_x,
11207 const IJK_Field_double& turbulent_kappa_y,
11208 const IJK_Field_double& turbulent_kappa_z,
11209 IJK_Field_double& d_rho,
11210 const IJK_Field_local_double& boundary_flux_kmin,
11211 const IJK_Field_local_double& boundary_flux_kmax)
11212{
11213 if (type_scalar_turbulent_diffusion_ == Nom("normal"))
11214 {
11215 operateur_diffusion_turbulent_scalar_.set_coeff_x_y_z(turbulent_kappa_x,
11216 turbulent_kappa_y,
11217 turbulent_kappa_z);
11219 d_rho,
11220 boundary_flux_kmin, boundary_flux_kmax);
11221 }
11222 else if (type_scalar_turbulent_diffusion_ == Nom("anisotropic"))
11223 {
11224 operateur_diffusion_turbulent_scalar_anisotropic_.set_coeff_x_y_z(turbulent_kappa_x,
11225 turbulent_kappa_y,
11226 turbulent_kappa_z);
11228 d_rho,
11229 boundary_flux_kmin, boundary_flux_kmax);
11230 }
11231 else
11232 {
11233 Cerr << "Unknown scalar turbulent diffusion operator! " << finl;
11234 Process::exit();
11235 }
11236}
11237
11238// Perform one sub-step of rk3 for QC algorithm, called 3 times per time step.
11239// rk_step = 0, 1 or 2
11240// total_timestep = not the fractionnal timestep !
11241void DNS_QC_double::rk3_sub_step(const int rk_step, const double total_timestep)
11242{
11243 statistics().create_custom_counter("qc convection rho",2,"TrioCFD");
11244 statistics().create_custom_counter("qc calcul pthermo,t,rho_v,etc",2,"TrioCFD");
11245 statistics().create_custom_counter("qc diffusion vitesse",2,"TrioCFD");
11246 statistics().create_custom_counter("qc diffusion turbulente vitesse",2,"TrioCFD");
11247 statistics().create_custom_counter("qc diffusion vitesse modele structurel",2,"TrioCFD");
11248 statistics().create_custom_counter("qc convection vitesse",2,"TrioCFD");
11249 statistics().create_custom_counter("qc rk3 update",2,"TrioCFD");
11250 statistics().create_custom_counter("qc diffusion temperature",2,"TrioCFD");
11251 statistics().create_custom_counter("qc turbulent diffusivity",2,"TrioCFD");
11252 statistics().create_custom_counter("qc turbulent diffusivity structurel",2,"TrioCFD");
11253 statistics().create_custom_counter("qc prepare rhs",2,"TrioCFD");
11254 statistics().create_custom_counter("qc resoudre systeme",2,"TrioCFD");
11255 statistics().create_custom_counter("qc ajouter grad p",2,"TrioCFD");
11256
11257
11258 const double fractionnal_timestep = compute_fractionnal_timestep_rk3(total_timestep, rk_step);
11259
11260 if (calcul_2d_)
11261 {
11262 velocity_[1].data() = 0;
11263 force_2d(rho_);
11264 force_2d(velocity_[0]);
11265 force_2d(velocity_[2]);
11266 }
11267
11268 assert(rk_step>=0 && rk_step<3);
11269 // 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.
11270 // rho_.echange_espace_virtuel(2);
11271 // velocity_[0].echange_espace_virtuel(1);
11272 // velocity_[1].echange_espace_virtuel(1);
11273 // velocity_[2].echange_espace_virtuel(1);
11274
11275 //
11276 // Convection du champ de masse volumique
11277 //
11278 // L'operateur de convection calcule drho/dt integre sur le volume de controle:
11279 statistics().begin_count("qc convection rho",statistics().get_last_opened_counter_level()+1);
11280 if (conv_rho_negligeable_) // cas ou la convection de rho serait negligeable
11281 {
11282 d_rho_.data()=0;
11283 }
11284 else
11285 {
11287 {
11289 }
11290 else if (convection_rho_amont_)
11291 {
11293 }
11294 else if (convection_rho_centre4_)
11295 {
11297 }
11298 else
11299 {
11300 // Schema quick (utilise par defaut)
11302 }
11303 }
11304 statistics().end_count("qc convection rho");
11305
11306 DebogIJK::verifier("op_conv(rho)", d_rho_);
11307
11309 {
11311 {
11312 statistics().begin_count("qc turbulent diffusivity",statistics().get_last_opened_counter_level()+1);
11314 {
11315 calculer_turbulent_mu_vector(flag_kappa_anisotropic_,
11327 }
11328 else
11329 {
11330 calculer_turbulent_mu_scalar(flag_kappa_anisotropic_,
11340 }
11341 statistics().end_count("qc turbulent diffusivity");
11342 }
11343
11345 {
11346 statistics().begin_count("qc turbulent diffusivity structurel",statistics().get_last_opened_counter_level()+1);
11349 rho_,
11357
11358 statistics().end_count("qc turbulent diffusivity structurel");
11359 }
11360
11362 {
11363 modification_modele_dynamic_uscalar_vector(flag_kappa_anisotropic_,
11373 }
11374 else
11375 {
11376 modification_modele_dynamic_uscalar_scalar(flag_kappa_anisotropic_,
11386 }
11387
11389 {
11390 statistics().begin_count("qc turbulent diffusivity",statistics().get_last_opened_counter_level()+1);
11392 {
11393 turbulent_kappa_vector_[0].echange_espace_virtuel(1);
11394 turbulent_kappa_vector_[1].echange_espace_virtuel(1);
11395 turbulent_kappa_vector_[2].echange_espace_virtuel(1);
11396
11397 // on impose le flux au bord a zero dans tous les cas
11398 calculer_flux_thermique_bord(rho_, 0.,
11401 rho_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
11402 calculer_flux_thermique_bord(rho_, 0.,
11405 rho_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
11406
11407 rho_.echange_espace_virtuel(1);
11408 turbulent_kappa_vector_[0].echange_espace_virtuel(1);
11409 turbulent_kappa_vector_[1].echange_espace_virtuel(1);
11410 turbulent_kappa_vector_[2].echange_espace_virtuel(1);
11411
11416 d_rho_,
11418 }
11419 else
11420 {
11421 turbulent_kappa_.echange_espace_virtuel(1);
11422
11423 // on impose le flux au bord a zero dans tous les cas
11424 calculer_flux_thermique_bord(rho_, 0.,
11427 rho_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
11428 calculer_flux_thermique_bord(rho_, 0.,
11431 rho_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
11432
11433 rho_.echange_espace_virtuel(1);
11434 turbulent_kappa_.echange_espace_virtuel(1);
11435
11440 d_rho_,
11442 }
11443 statistics().end_count("qc turbulent diffusivity");
11444 DebogIJK::verifier("rho", rho_);
11445 DebogIJK::verifier("op_conv(rho)_kappa", d_rho_);
11446 }
11447
11449 {
11450 statistics().begin_count("qc turbulent diffusivity structurel",statistics().get_last_opened_counter_level()+1);
11451
11452 structural_uscalar_vector_[0].echange_espace_virtuel(1);
11453 structural_uscalar_vector_[1].echange_espace_virtuel(1);
11454 structural_uscalar_vector_[2].echange_espace_virtuel(1);
11455
11456 // on impose le flux au bord a zero dans tous les cas
11457 calculer_flux_thermique_bord(rho_, 0.,
11460 rho_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
11461 calculer_flux_thermique_bord(rho_, 0.,
11464 rho_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
11465
11466 rho_.echange_espace_virtuel(1);
11467 structural_uscalar_vector_[0].echange_espace_virtuel(1);
11468 structural_uscalar_vector_[1].echange_espace_virtuel(1);
11469 structural_uscalar_vector_[2].echange_espace_virtuel(1);
11470
11471 DebogIJK::verifier("rho", rho_);
11472 DebogIJK::verifier("structural_uscalar_x", structural_uscalar_vector_[0]);
11473 DebogIJK::verifier("structural_uscalar_y", structural_uscalar_vector_[1]);
11474 DebogIJK::verifier("structural_uscalar_z", structural_uscalar_vector_[2]);
11479 d_rho_,
11481
11482 statistics().end_count("qc turbulent diffusivity structurel");
11483
11484 DebogIJK::verifier("op_conv(rho)_struct", d_rho_);
11485 }
11486 }
11487
11488 {
11489 const int kmax = d_rho_.nk();
11490 for (int k = 0; k < kmax; k++)
11491 {
11492 // division par le volume de controle
11493 mass_solver_scalar(d_rho_, delta_z_local_, k);
11494 // calcul de rho_ au sous-pas de temps suivant, et mise a jour F_rho_ (valeur intermediaire de l'algo rk3)
11495 runge_kutta3_update(d_rho_, RK3_F_rho_, rho_, rk_step, k, total_timestep);
11496 }
11497 }
11498 DebogIJK::verifier("rk3 update rho", rho_);
11499
11500 // On a besoin d'une epaisseur de 1 sur rho (pour calculer rho aux faces et ensuite
11501 // pour calculer l'epaisseur 1 de la temperature et de mu/lambda.
11502 rho_.echange_espace_virtuel(1);
11503
11504 statistics().begin_count("qc calcul pthermo,t,rho_v,etc",statistics().get_last_opened_counter_level()+1);
11505 // Resoudre EDO Pthermo: calcul de P_th_final et de la temperature en fonction de rho_
11506 const double P_th_initial = P_thermodynamique_;
11507 double P_th_final;
11508 double d_Pth_divise_par_gammamoins1;
11509
11511 {
11513 {
11514 statistics().begin_count("qc turbulent diffusivity",statistics().get_last_opened_counter_level()+1);
11516 {
11517 calculer_turbulent_mu_vector(flag_kappa_anisotropic_,
11529 }
11530 else
11531 {
11532 calculer_turbulent_mu_scalar(flag_kappa_anisotropic_,
11542 }
11543 statistics().end_count("qc turbulent diffusivity");
11544 }
11545
11547 {
11548 statistics().begin_count("qc turbulent diffusivity structurel",statistics().get_last_opened_counter_level()+1);
11551 rho_,
11559
11560 statistics().end_count("qc turbulent diffusivity structurel");
11561 }
11562
11564 {
11565 modification_modele_dynamic_uscalar_vector(flag_kappa_anisotropic_,
11575 }
11576 else
11577 {
11578 modification_modele_dynamic_uscalar_scalar(flag_kappa_anisotropic_,
11588 }
11589
11591 {
11592 statistics().begin_count("qc turbulent diffusivity",statistics().get_last_opened_counter_level()+1);
11594 {
11595 // we multiply by rho cp = rho (r/Pth) (Pth CP/r):
11596 // * r/Pth: because we use grad T instead of grad 1/rho
11597 // * Pth Cp/r: because div_lambda_grad_T will be multiplied by r/Cp/Pth
11598 // but this should not
11599 // * rho: required in the favre formulation
11600 multiplier_champ(rho_, Cp_gaz_, turbulent_kappa_vector_[0]);
11601 multiplier_champ(rho_, Cp_gaz_, turbulent_kappa_vector_[1]);
11602 multiplier_champ(rho_, Cp_gaz_, turbulent_kappa_vector_[2]);
11603
11604 turbulent_kappa_vector_[0].echange_espace_virtuel(1);
11605 turbulent_kappa_vector_[1].echange_espace_virtuel(1);
11606 turbulent_kappa_vector_[2].echange_espace_virtuel(1);
11607 }
11608 else
11609 {
11610 // we multiply by rho cp = rho (r/Pth) (Pth CP/r):
11611 // * r/Pth: because we use grad T instead of grad 1/rho
11612 // * Pth Cp/r: because div_lambda_grad_T will be multiplied by r/Cp/Pth
11613 // but this should not
11614 // * rho: required in the favre formulation
11615 multiplier_champ(rho_, Cp_gaz_, turbulent_kappa_);
11616
11617 turbulent_kappa_.echange_espace_virtuel(1);
11618 }
11619 statistics().end_count("qc turbulent diffusivity");
11620 }
11621
11623 {
11624 statistics().begin_count("qc turbulent diffusivity structurel",statistics().get_last_opened_counter_level()+1);
11625 // we multiply by rho cp = rho (r/Pth) (Pth CP/r):
11626 // * r/Pth: because we use grad T instead of grad 1/rho
11627 // * Pth Cp/r: because div_lambda_grad_T will be multiplied by r/Cp/Pth
11628 // but this should not
11629 // * rho: required in the favre formulation
11630 multiplier_champ_rho_face_i(rho_, Cp_gaz_, structural_uscalar_vector_[0]);
11631 multiplier_champ_rho_face_j(rho_, Cp_gaz_, structural_uscalar_vector_[1]);
11632 multiplier_champ_rho_face_k(rho_, Cp_gaz_, rho_paroi_impose_kmin_, structural_uscalar_vector_[2]);
11633
11634 structural_uscalar_vector_[0].echange_espace_virtuel(1);
11635 structural_uscalar_vector_[1].echange_espace_virtuel(1);
11636 structural_uscalar_vector_[2].echange_espace_virtuel(1);
11637
11638 statistics().end_count("qc turbulent diffusivity structurel");
11639 }
11640 }
11641
11643 {
11644 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);
11645 }
11646 else
11647 {
11648 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);
11649 }
11650 P_thermodynamique_ = P_th_final;
11651
11652 const double Pth_sur_R = P_thermodynamique_ / constante_specifique_gaz_;
11655
11656 // Mise a jour de temperature, mu et lambda en fonction de rho, sur une epaisseur de 1
11657 calculer_temperature_mu_lambda_air(P_th_final, constante_specifique_gaz_,
11658 rho_, temperature_, molecular_mu_, molecular_lambda_, 1 /* epaisseur de joint */);
11659
11660 DebogIJK::verifier("temperature", temperature_);
11661
11662 // derivee_en_temps_impl_p1 Navier Stokes
11663 calculer_rho_v(rho_, velocity_, rho_v_);
11664 DebogIJK::verifier("rho_v_X", rho_v_[0]);
11665 DebogIJK::verifier("rho_v_Y", rho_v_[1]);
11666 DebogIJK::verifier("rho_v_Z", rho_v_[2]);
11667 statistics().end_count("qc calcul pthermo,t,rho_v,etc");
11668
11669 // Pour l'operateur de convection, on a besoin d'une epaisseur 2 sur la quantite convectee:
11670 rho_v_[0].echange_espace_virtuel(2);
11671 rho_v_[1].echange_espace_virtuel(2);
11672 rho_v_[2].echange_espace_virtuel(2);
11673 // on a besoin de l'epaisseur 1 sur mu et lambda
11674
11675 // Le coefficient de diffusion est mu => resultat homogene a d(rho_v)/dt
11676 statistics().begin_count("qc diffusion vitesse",statistics().get_last_opened_counter_level()+1);
11677 if(diff_qdm_negligeable_) // si la diffusion est negligable
11678 {
11679 d_velocity_[0].data()=0;
11680 d_velocity_[1].data()=0;
11681 d_velocity_[2].data()=0;
11682 }
11683 else
11684 {
11685 if (type_velocity_diffusion_ == Nom("simple"))
11686 {
11690 }
11691 else if (type_velocity_diffusion_ == Nom("simple_with_transpose"))
11692 {
11696 }
11697 else if (type_velocity_diffusion_ == Nom("full"))
11698 {
11699 velocity_[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
11700 velocity_[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
11701 velocity_[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
11702 compute_divergence(velocity_[0], velocity_[1], velocity_[2], divergence_);
11703 divergence_.echange_espace_virtuel(1);
11708 }
11709 else if (type_velocity_diffusion_ == Nom("none"))
11710 {
11711 d_velocity_[0].data()=0;
11712 d_velocity_[1].data()=0;
11713 d_velocity_[2].data()=0;
11714 }
11715 else
11716 {
11717 Cerr << "Unknown velocity diffusion operator! " << finl;
11718 Process::exit();
11719 }
11720 }
11721 statistics().end_count("qc diffusion vitesse");
11722 DebogIJK::verifier("op_diff(velocity)X", d_velocity_[0]);
11723 DebogIJK::verifier("op_diff(velocity)Y", d_velocity_[1]);
11724 DebogIJK::verifier("op_diff(velocity)Z", d_velocity_[2]);
11725
11727 {
11729 {
11730 statistics().begin_count("qc diffusion turbulente vitesse",statistics().get_last_opened_counter_level()+1);
11731
11733 {
11734 calculer_turbulent_mu_tensor(flag_nu_anisotropic_,
11746 }
11747 else
11748 {
11749 calculer_turbulent_mu_scalar(flag_nu_anisotropic_,
11759 }
11760 statistics().end_count("qc diffusion turbulente vitesse");
11761 }
11762
11763 if (structural_uu_)
11764 {
11765 statistics().begin_count("qc diffusion vitesse modele structurel",statistics().get_last_opened_counter_level()+1);
11768 rho_,
11775 statistics().end_count("qc diffusion vitesse modele structurel");
11776 }
11777
11779 {
11780 modification_modele_dynamic_uu_tensor(flag_nu_anisotropic_,
11790 }
11791 else
11792 {
11793 modification_modele_dynamic_uu_scalar(flag_nu_anisotropic_,
11803 }
11804
11806 {
11807 statistics().begin_count("qc diffusion turbulente vitesse",statistics().get_last_opened_counter_level()+1);
11808
11810 {
11811 multiplier_champ(rho_, turbulent_mu_tensor_[0]);
11812 multiplier_champ(rho_, turbulent_mu_tensor_[1]);
11813 multiplier_champ(rho_, turbulent_mu_tensor_[2]);
11814 multiplier_champ(rho_, turbulent_mu_tensor_[3]);
11815 multiplier_champ(rho_, turbulent_mu_tensor_[4]);
11816 multiplier_champ(rho_, turbulent_mu_tensor_[5]);
11817
11818 turbulent_mu_tensor_[0].echange_espace_virtuel(1);
11819 turbulent_mu_tensor_[1].echange_espace_virtuel(1);
11820 turbulent_mu_tensor_[2].echange_espace_virtuel(1);
11821 turbulent_mu_tensor_[3].echange_espace_virtuel(1);
11822 turbulent_mu_tensor_[4].echange_espace_virtuel(1);
11823 turbulent_mu_tensor_[5].echange_espace_virtuel(1);
11824
11835 d_velocity_);
11836 }
11837 else
11838 {
11839 multiplier_champ(rho_, turbulent_mu_);
11840
11841 turbulent_mu_.echange_espace_virtuel(1);
11842
11853 d_velocity_);
11854 }
11855 statistics().end_count("qc diffusion turbulente vitesse");
11856
11857 DebogIJK::verifier("op_difft(velocity)X", d_velocity_[0]);
11858 DebogIJK::verifier("op_difft(velocity)Y", d_velocity_[1]);
11859 DebogIJK::verifier("op_difft(velocity)Z", d_velocity_[2]);
11860 }
11861
11862 if (structural_uu_)
11863 {
11864 statistics().begin_count("qc diffusion vitesse modele structurel",statistics().get_last_opened_counter_level()+1);
11865
11866 multiplier_champ(rho_, structural_uu_tensor_[0]);
11867 multiplier_champ_rho_arete_ij(rho_, structural_uu_tensor_[1]);
11868 multiplier_champ_rho_arete_ik(rho_, rho_paroi_impose_kmin_, structural_uu_tensor_[2]);
11869 multiplier_champ(rho_, structural_uu_tensor_[3]);
11870 multiplier_champ_rho_arete_jk(rho_, rho_paroi_impose_kmin_, structural_uu_tensor_[4]);
11871 multiplier_champ(rho_, structural_uu_tensor_[5]);
11872
11873 structural_uu_tensor_[0].echange_espace_virtuel(1);
11874 structural_uu_tensor_[1].echange_espace_virtuel(1);
11875 structural_uu_tensor_[2].echange_espace_virtuel(1);
11876 structural_uu_tensor_[3].echange_espace_virtuel(1);
11877 structural_uu_tensor_[4].echange_espace_virtuel(1);
11878 structural_uu_tensor_[5].echange_espace_virtuel(1);
11879
11885 d_velocity_);
11886
11887 statistics().end_count("qc diffusion vitesse modele structurel");
11888 DebogIJK::verifier("op_diffstruct(velocity)X", d_velocity_[0]);
11889 DebogIJK::verifier("op_diffstruct(velocity)Y", d_velocity_[1]);
11890 DebogIJK::verifier("op_diffstruct(velocity)Z", d_velocity_[2]);
11891 }
11892 }
11893
11894 // On transporte le champ rho_v par le champ v
11895 statistics().begin_count("qc convection vitesse",statistics().get_last_opened_counter_level()+1);
11897 {
11898 u_div_rho_u_.data()=0;
11899 }
11900 else // sinon on calcule rho u div(u) comme div(rho u u) - u div(rho u)
11901 {
11903 velocity_,
11908 u_div_rho_u_);
11909 }
11910 statistics().end_count("qc convection vitesse");
11911 DebogIJK::verifier("op_conv(velocity)X", d_velocity_[0]);
11912 DebogIJK::verifier("op_conv(velocity)Y", d_velocity_[1]);
11913 DebogIJK::verifier("op_conv(velocity)Z", d_velocity_[2]);
11914
11915
11917 {
11918 int dir = DIRECTION_J;
11919 IJK_Field_double& dv = d_velocity_[dir];
11920 const int ni = dv.ni();
11921 const int nj = dv.nj();
11922 const int kmax = d_velocity_[dir].nk();
11924 for(int k = 0; k < kmax; k++)
11925 {
11926 for (int j = 0; j < nj; j++)
11927 {
11928 for (int i = 0; i < ni; i++)
11929 {
11930 const double volume = get_channel_control_volume(dv, k, delta_z_local_);
11931 const double force = volumic_force * volume * (rho_(i, j, k) + rho_(i, j-1, k))*0.5;
11932 dv(i, j, k) += force;
11933 }
11934 }
11935 }
11936 /* Cout << "Volumic force at edge: " << volumic_force * get_channel_control_volume(dv, 0, delta_z_local_) */
11937 /* << " Volumic force at middle: " << volumic_force * get_channel_control_volume(dv, kmax/2, delta_z_local_) */
11938 /* << finl; */
11939 }
11940
11941
11942
11943
11944 // force_oscillating_boundary(
11945 // velocity_[DIRECTION_J],
11946 // current_time_,
11947 // amplitude_oscillating_boundary_2_,
11948 // frequency_oscillating_boundary_2_
11949 // );
11950 statistics().begin_count("qc rk3 update",statistics().get_last_opened_counter_level()+1);
11951 for (int dir = 0; dir < 3; dir++)
11952 {
11953 const int kmax = d_velocity_[dir].nk();
11954 for (int k = 0; k < kmax; k++)
11955 {
11956 // Le terme source est ajouter avant solveur masse, donc homogene a des Newton:
11957 if (dir == DIRECTION_I)
11958 {
11959 const double force_volumique = terme_source_acceleration_;
11960 IJK_Field_double& dvx = d_velocity_[dir];
11961 const double volume = get_channel_control_volume(dvx, k, delta_z_local_);
11962 const double f = force_volumique * volume;
11963 const int ni = dvx.ni();
11964 const int nj = dvx.nj();
11965
11966 for (int j = 0; j < nj; j++)
11967 {
11968 for (int i = 0; i < ni; i++)
11969 {
11970 dvx(i,j,k) += f;
11971 }
11972 }
11973 }
11974
11975 if (dir == DIRECTION_K)
11976 {
11977 const double force_volumique = terme_source_acceleration_z_;
11978 IJK_Field_double& dvx = d_velocity_[dir];
11979 const double volume = get_channel_control_volume(dvx, k, delta_z_local_);
11980 const double f = force_volumique * volume;
11981 const int ni = dvx.ni();
11982 const int nj = dvx.nj();
11983
11984 for (int j = 0; j < nj; j++)
11985 {
11986 for (int i = 0; i < ni; i++)
11987 {
11988 dvx(i,j,k) += f;
11989 }
11990 }
11991 }
11992
11993 density_solver_with_rho(d_velocity_[dir], rho_, delta_z_local_, k);
11994 }
11995 }
11996
11997 // On transporte le champ v par le champ v
11998 statistics().begin_count("qc convection vitesse",statistics().get_last_opened_counter_level()+1);
12000 {
12001 // on calcule u div(u) comme div(u u) - u div(u)
12003 velocity_,
12008 u_div_rho_u_);
12009 }
12010 statistics().end_count("qc convection vitesse");
12011 DebogIJK::verifier("op_conv(velocity)X", d_velocity_[0]);
12012 DebogIJK::verifier("op_conv(velocity)Y", d_velocity_[1]);
12013 DebogIJK::verifier("op_conv(velocity)Z", d_velocity_[2]);
12014
12016 {
12018 {
12019 statistics().begin_count("qc diffusion turbulente vitesse",statistics().get_last_opened_counter_level()+1);
12020
12022 {
12023 calculer_turbulent_mu_tensor(flag_nu_anisotropic_,
12035 }
12036 else
12037 {
12038 calculer_turbulent_mu_scalar(flag_nu_anisotropic_,
12048 }
12049
12050 statistics().end_count("qc diffusion turbulente vitesse");
12051 }
12052
12053 if (structural_uu_)
12054 {
12055 statistics().begin_count("qc diffusion vitesse modele structurel",statistics().get_last_opened_counter_level()+1);
12056 Cerr << "avant calculer_structural_uu" << finl;
12059 rho_,
12066 statistics().end_count("qc diffusion vitesse modele structurel");
12067 }
12068
12070 {
12071 modification_modele_dynamic_uu_tensor(flag_nu_anisotropic_,
12081 }
12082 else
12083 {
12084 modification_modele_dynamic_uu_scalar(flag_nu_anisotropic_,
12094 }
12095
12097 {
12098 statistics().begin_count("qc diffusion turbulente vitesse",statistics().get_last_opened_counter_level()+1);
12100 {
12101 turbulent_mu_tensor_[0].echange_espace_virtuel(1);
12102 turbulent_mu_tensor_[1].echange_espace_virtuel(1);
12103 turbulent_mu_tensor_[2].echange_espace_virtuel(1);
12104 turbulent_mu_tensor_[3].echange_espace_virtuel(1);
12105 turbulent_mu_tensor_[4].echange_espace_virtuel(1);
12106 turbulent_mu_tensor_[5].echange_espace_virtuel(1);
12107
12118 d_velocity_);
12119 }
12120 else
12121 {
12122 turbulent_mu_.echange_espace_virtuel(1);
12123
12134 d_velocity_);
12135 }
12136
12137 statistics().end_count("qc diffusion turbulente vitesse");
12138
12139 DebogIJK::verifier("op_difft(velocity)X", d_velocity_[0]);
12140 DebogIJK::verifier("op_difft(velocity)Y", d_velocity_[1]);
12141 DebogIJK::verifier("op_difft(velocity)Z", d_velocity_[2]);
12142 }
12143
12144 if (structural_uu_)
12145 {
12146 statistics().begin_count("qc diffusion vitesse modele structurel",statistics().get_last_opened_counter_level()+1);
12147
12148 structural_uu_tensor_[0].echange_espace_virtuel(1);
12149 structural_uu_tensor_[1].echange_espace_virtuel(1);
12150 structural_uu_tensor_[2].echange_espace_virtuel(1);
12151 structural_uu_tensor_[3].echange_espace_virtuel(1);
12152 structural_uu_tensor_[4].echange_espace_virtuel(1);
12153 structural_uu_tensor_[5].echange_espace_virtuel(1);
12154
12160 d_velocity_);
12161
12162 statistics().end_count("qc diffusion vitesse modele structurel");
12163 DebogIJK::verifier("op_diffstruct(velocity)X", d_velocity_[0]);
12164 DebogIJK::verifier("op_diffstruct(velocity)Y", d_velocity_[1]);
12165 DebogIJK::verifier("op_diffstruct(velocity)Z", d_velocity_[2]);
12166 }
12167 }
12168
12169 // diffusion creates non zero velocity at walls, restore zero
12170 force_zero_normal_velocity_on_walls(d_velocity_[2]);
12171
12172 for (int dir = 0; dir < 3; dir++)
12173 {
12174 const int kmax = d_velocity_[dir].nk();
12175 for (int k = 0; k < kmax; k++)
12176 {
12177 mass_solver_scalar(d_velocity_[dir], delta_z_local_, k);
12178
12179 runge_kutta3_update(d_velocity_[dir], RK3_F_velocity_[dir], velocity_[dir], rk_step, k, total_timestep);
12180 }
12181 }
12182 statistics().end_count("qc rk3 update");
12183 DebogIJK::verifier("rk3update(velocity)X", velocity_[0]);
12184 DebogIJK::verifier("rk3update(velocity)Y", velocity_[1]);
12185 DebogIJK::verifier("rk3update(velocity)Z", velocity_[2]);
12186 // --------------------------------------
12187 // Projection sur div(u)=quelque chose
12188 // --------------------------------------
12189 // vpoint -= gradP / rho
12190 // secmem = - R / (Cp * Pth) * (div((lambda*grad(T))*volume+source) - dpth2 / gamma_moins1 * volume)
12191
12192
12193 // B secmem = [ ( ( R/(Cp*Pth)*(tab_W(i) + dpth2/gamma_moins_1*volumes(i) )) - div(v)) / dt - div(vpoint) ]
12194
12195 // trouver P tel que div ( v + dt * vpoint - dt * 1/rho*grad(P) ) = (R/(cp*Pth)...)
12196 // equivalent a
12197 // trouver P tel que div ( dt * 1/rho*gradP ) = div( v + dt * vpoint - (R/(cp*Pth)...) )
12198 // A trouver P tel que div ( 1/rho*gradP ) = div( v/dt + vpoint - (R/(cp*Pth)...)/dt )
12199
12200 // calculer ici div(lambda*grad(T))*volume)
12201
12202 calculer_flux_thermique_bord(temperature_, lambda_de_t_paroi_kmin_,
12205 T_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
12206 calculer_flux_thermique_bord(temperature_, lambda_de_t_paroi_kmax_,
12209 T_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
12210
12211 temperature_.echange_espace_virtuel(1);
12212 molecular_lambda_.echange_espace_virtuel(1);
12215
12216 statistics().begin_count("qc diffusion temperature",statistics().get_last_opened_counter_level()+1);
12217 if (diff_temp_negligeable_) // si diffusion negligeable
12218 {
12220 }
12221 else
12222 {
12227 }
12228 statistics().end_count("qc diffusion temperature");
12229
12230 DebogIJK::verifier("div_lambda_grad_T_volume", div_lambda_grad_T_volume_);
12231
12233 {
12235 {
12236 statistics().begin_count("qc turbulent diffusivity",statistics().get_last_opened_counter_level()+1);
12238 {
12239 calculer_flux_thermique_bord(temperature_, 0.,
12242 T_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
12243 calculer_flux_thermique_bord(temperature_, 0.,
12246 T_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
12247
12248 temperature_.echange_espace_virtuel(1);
12249 turbulent_kappa_vector_[0].echange_espace_virtuel(1);
12250 turbulent_kappa_vector_[1].echange_espace_virtuel(1);
12251 turbulent_kappa_vector_[2].echange_espace_virtuel(1);
12252
12259 }
12260 else
12261 {
12262 calculer_flux_thermique_bord(temperature_, 0.,
12265 T_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
12266 calculer_flux_thermique_bord(temperature_, 0.,
12269 T_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
12270
12271 temperature_.echange_espace_virtuel(1);
12272 turbulent_kappa_.echange_espace_virtuel(1);
12273
12280 }
12281 statistics().end_count("qc turbulent diffusivity");
12283 DebogIJK::verifier("div_lambda_grad_T_volume_kappa", div_lambda_grad_T_volume_);
12284 }
12285
12287 {
12288 statistics().begin_count("qc turbulent diffusivity structurel",statistics().get_last_opened_counter_level()+1);
12289
12290 calculer_flux_thermique_bord(temperature_, 0.,
12293 T_paroi_impose_kmin_, boundary_flux_kmin_, 0 /* boundary kmin */);
12294 calculer_flux_thermique_bord(temperature_, 0.,
12297 T_paroi_impose_kmax_, boundary_flux_kmax_, 1 /* boundary kmax */);
12298
12299 temperature_.echange_espace_virtuel(1);
12300 structural_uscalar_vector_[0].echange_espace_virtuel(1);
12301 structural_uscalar_vector_[1].echange_espace_virtuel(1);
12302 structural_uscalar_vector_[2].echange_espace_virtuel(1);
12303
12305 DebogIJK::verifier("structural_uscalar_x", structural_uscalar_vector_[0]);
12306 DebogIJK::verifier("structural_uscalar_y", structural_uscalar_vector_[1]);
12307 DebogIJK::verifier("structural_uscalar_z", structural_uscalar_vector_[2]);
12314
12315 statistics().end_count("qc turbulent diffusivity structurel");
12316 DebogIJK::verifier("div_lambda_grad_T_volume_kappa_struct", div_lambda_grad_T_volume_);
12317 }
12318 }
12319
12320 // Pour calculer la divergence, il faut les valeurs sur les faces de "droite" des elements, qui sont
12321 // des faces virtuelles a l'extremite du domaine, donc mettre a jour les faces de droite
12322 // A ete modifie lors de l'ajout de la source !!!!!
12323 velocity_[0].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/
12324 velocity_[1].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/
12325 velocity_[2].echange_espace_virtuel(1); /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/
12326
12327 statistics().begin_count("qc prepare rhs",statistics().get_last_opened_counter_level()+1);
12328
12329 compute_divergence_times_constant(velocity_[0], velocity_[1], velocity_[2],
12330 - 1. / fractionnal_timestep, pressure_rhs_);
12331 DebogIJK::verifier("-div(u)/dt", pressure_rhs_);
12332 {
12333// Modif Martin 28-05-2019
12334 const int ni = rho_.ni();
12335 const int nj = rho_.nj();
12336 const int nk = rho_.nk();
12337 const double R_divise_par_Cp_Pth = constante_specifique_gaz_ / (Cp_gaz_ * P_th_final);
12338 const Domaine_IJK& geom = rho_.get_domaine();
12339// On a besoin de vx et rho pour la pondération du terme source par la vitesse
12340 IJK_Field_double& vx = velocity_[0];
12341 IJK_Field_double& rho = rho_;
12342 const double delta_x = geom.get_constant_delta(0);
12343 const double delta_y = geom.get_constant_delta(1);
12344 for (int k = 0; k < nk; k++)
12345 {
12346 const double delta_z = delta_z_local_[k];
12347 const double volume_maille = delta_x * delta_y * delta_z;
12348 const double facteur = d_Pth_divise_par_gammamoins1 * volume_maille;
12349// S il n y a pas d'ecoulement dans le canal, la source n'est pas ponderee par la vitesse
12350 if (debit_actuel_ < 0.0000001)
12351 {
12352 for (int j = 0; j < nj; j++)
12353 {
12354 for (int i = 0; i < ni; i++)
12355 {
12356 pressure_rhs_(i,j,k) += R_divise_par_Cp_Pth * (div_lambda_grad_T_volume_(i,j,k) - facteur - puit_ * volume_maille) / fractionnal_timestep;
12357 }
12358 }
12359 }
12360 else
12361 {
12362 for (int j = 0; j < nj; j++)
12363 {
12364 for (int i = 0; i < ni; i++)
12365 {
12366 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;
12367 }
12368 }
12369 }
12370 }
12371 }
12372 DebogIJK::verifier("pressure_rhs", pressure_rhs_);
12373 statistics().end_count("qc prepare rhs");
12374 // Appel au solveur multigrille:
12376 {
12377 statistics().begin_count("qc resoudre systeme",statistics().get_last_opened_counter_level()+1);
12378 poisson_solver_.set_rho(rho_);
12379 poisson_solver_.resoudre_systeme_IJK(pressure_rhs_, pressure_);
12380 statistics().end_count("qc resoudre systeme");
12381 DebogIJK::verifier("pressure", pressure_);
12382
12383// pressure gradient requires the "left" value in all directions:
12384 pressure_.echange_espace_virtuel(1 /*, IJK_Field_double::EXCHANGE_GET_AT_LEFT_IJK*/);
12385 statistics().begin_count("qc ajouter grad p",statistics().get_last_opened_counter_level()+1);
12386 add_gradient_times_constant_over_rho(pressure_, rho_, -fractionnal_timestep,
12387 velocity_[0], velocity_[1], velocity_[2]);
12388 statistics().end_count("qc ajouter grad p");
12389 }
12390
12391 // DD,2016-01-20: decalage de la pression en prenant comme reference la moyenne de la pression sur le volume.
12392 double reference_pression = 0;
12393 fixer_reference_pression(reference_pression);
12394 Cout << "reference_pression= " << reference_pression << finl;
12395 translation_pression(reference_pression);
12396
12397 // Mise a jour des stats en prevision du prochain rk_step et du post_traitement. !!! (positionement optimum !!)
12398 rho_.echange_espace_virtuel(2);
12399 velocity_[0].echange_espace_virtuel(2);
12400 velocity_[1].echange_espace_virtuel(2);
12401 velocity_[2].echange_espace_virtuel(2);
12402}
12403
12404void DNS_QC_double::fixer_reference_pression(double& reference_pression)
12405{
12406 const int ni = pressure_.ni();
12407 const int nj = pressure_.nj();
12408 const int nk = pressure_.nk();
12409 const double dx = pressure_.get_domaine().get_constant_delta(DIRECTION_I);
12410 const double dy = pressure_.get_domaine().get_constant_delta(DIRECTION_J);
12411
12412 double integrale_pression = 0.;
12413 for (int k = 0; k < nk; k++)
12414 {
12415 for (int j = 0; j < nj; j++)
12416 {
12417 for (int i = 0; i < ni; i++)
12418 {
12419 integrale_pression += pressure_(i,j,k) * dx * dy * delta_z_local_[k];
12420 }
12421 }
12422 }
12423 ArrOfDouble tmp(1);
12424 tmp[0] = integrale_pression;
12426
12427 reference_pression = tmp[0] / (Lx_tot_*Ly_tot_*Lz_tot_);
12428}
12429void DNS_QC_double::translation_pression(const double& reference_pression)
12430{
12431 const int ni = pressure_.ni();
12432 const int nj = pressure_.nj();
12433 const int nk = pressure_.nk();
12434 for (int k = 0; k < nk; k++)
12435 {
12436 for (int j = 0; j < nj; j++)
12437 {
12438 for (int i = 0; i < ni; i++)
12439 {
12440 pressure_(i,j,k) -= reference_pression;
12441 }
12442 }
12443 }
12444}
12445
12447{
12448 const int ni = rho_.ni();
12449 const int nj = rho_.nj();
12450 const int nk = rho_.nk();
12451 const double dx = rho_.get_domaine().get_constant_delta(DIRECTION_I);
12452 const double dy = rho_.get_domaine().get_constant_delta(DIRECTION_J);
12453
12454 double integral_rho = 0.;
12455 for (int k = 0; k < nk; k++)
12456 {
12457 for (int j = 0; j < nj; j++)
12458 {
12459 for (int i = 0; i < ni; i++)
12460 {
12461 integral_rho += rho_(i,j,k) * dx * dy * delta_z_local_[k];
12462 }
12463 }
12464 }
12465 ArrOfDouble tmp(1);
12466 tmp[0] = integral_rho;
12468
12469 rho_bulk = tmp[0] / (Lx_tot_*Ly_tot_*Lz_tot_);
12470}
12471
12472
12474{
12475 const int ni = temperature_.ni();
12476 const int nj = temperature_.nj();
12477 const int nk = temperature_.nk();
12478 const double dx = temperature_.get_domaine().get_constant_delta(DIRECTION_I);
12479 const double dy = temperature_.get_domaine().get_constant_delta(DIRECTION_J);
12480
12481 double integral_t = 0.;
12482 for (int k = 0; k < nk; k++)
12483 {
12484 for (int j = 0; j < nj; j++)
12485 {
12486 for (int i = 0; i < ni; i++)
12487 {
12488 integral_t += temperature_(i,j,k) * dx * dy * delta_z_local_[k];
12489 }
12490 }
12491 }
12492 ArrOfDouble tmp(1);
12493 tmp[0] = integral_t;
12495
12496 t_bulk = tmp[0] / (Lx_tot_*Ly_tot_*Lz_tot_);
12497}
12498
12499void DNS_QC_double::compute_rho_t_bulk(double& rho_bulk, double& t_bulk)
12500{
12501 const int ni = rho_.ni();
12502 const int nj = rho_.nj();
12503 const int nk = rho_.nk();
12504 const double dx = rho_.get_domaine().get_constant_delta(DIRECTION_I);
12505 const double dy = rho_.get_domaine().get_constant_delta(DIRECTION_J);
12506
12507 double integral_t = 0.;
12508 double integral_rho = 0.;
12509 for (int k = 0; k < nk; k++)
12510 {
12511 for (int j = 0; j < nj; j++)
12512 {
12513 for (int i = 0; i < ni; i++)
12514 {
12515 integral_t += temperature_(i,j,k) * dx * dy * delta_z_local_[k];
12516 integral_rho += rho_(i,j,k) * dx * dy * delta_z_local_[k];
12517 }
12518 }
12519 }
12520 ArrOfDouble tmp(1);
12521 tmp[0] = integral_t;
12523
12524 t_bulk = tmp[0] / (Lx_tot_*Ly_tot_*Lz_tot_);
12525
12526 ArrOfDouble tmp2(1);
12527 tmp2[0] = integral_rho;
12529
12530 rho_bulk = tmp2[0] / (Lx_tot_*Ly_tot_*Lz_tot_);
12531}
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:9453
Entree & interpreter(Entree &) override
Definition DNS.cpp:7228
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:8581
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:12446
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:10766
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:11205
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:8406
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:9402
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:8031
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:8493
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:8516
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:12499
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:9029
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:10897
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:11141
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:12473
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:12404
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:12429
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:11241
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:10662
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:8608
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:8557
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