9.1
general documentation
cs_wall_functions.h
Go to the documentation of this file.
1#ifndef __CS_WALL_FUNCTIONS_H__
2#define __CS_WALL_FUNCTIONS_H__
3
4/*============================================================================
5 * Wall functions
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2025 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------*/
29
30/*----------------------------------------------------------------------------
31 * Local headers
32 *----------------------------------------------------------------------------*/
33
34#include "bft/bft_printf.h"
35#include "base/cs_base.h"
36#include "base/cs_math.h"
38
39/*----------------------------------------------------------------------------*/
40
42
43/*=============================================================================
44 * Local Macro definitions
45 *============================================================================*/
46
47/*============================================================================
48 * Type definition
49 *============================================================================*/
50
51/* Wall function type */
52/*--------------------*/
53
54typedef enum {
55
65
67
68typedef enum {
69
75 CS_WALL_F_S_SMOOTH_ROUGH = 4,//TODO merge with MO ?
76
78
79/* Wall functions descriptor */
80/*---------------------------*/
81
82typedef struct {
83
84 cs_wall_f_type_t iwallf; /* wall function type */
85
86 cs_wall_f_s_type_t iwalfs; /* wall function type for scalars */
87
88 double ypluli; /* limit value of y+ for the viscous
89 sublayer */
90
92
93/*============================================================================
94 * Global variables
95 *============================================================================*/
96
97/* Pointer to wall functions descriptor structure */
98
100
101/*============================================================================
102 * Private function definitions
103 *============================================================================*/
104
105/*----------------------------------------------------------------------------*/
122/*----------------------------------------------------------------------------*/
123
124inline static void
127 cs_real_t y,
128 int *iuntur,
129 cs_gnum_t *nsubla,
130 cs_gnum_t *nlogla,
131 cs_real_t *ustar,
132 cs_real_t *uk,
134 cs_real_t *ypup,
135 cs_real_t *cofimp)
136{
137 const double ypluli = cs_glob_wall_functions->ypluli;
138
139 const double ydvisc = y / l_visc;
140
141 /* Compute the friction velocity ustar */
142
143 *ustar = pow((vel/(cs_turb_apow * pow(ydvisc, cs_turb_bpow))), cs_turb_dpow);
144 *uk = *ustar;
145 *yplus = *ustar * ydvisc;
146
147 /* In the viscous sub-layer: U+ = y+ */
148 if (*yplus <= ypluli) {
149
150 *ustar = sqrt(vel / ydvisc);
151 *yplus = *ustar * ydvisc;
152 *uk = *ustar;
153 *ypup = 1.;
154 *cofimp = 0.;
155
156 /* Disable the wall funcion count the cell in the viscous sub-layer */
157 *iuntur = 0;
158 *nsubla += 1;
159
160 /* In the log layer */
161 } else {
162 *ypup = pow(vel, 2. * cs_turb_dpow-1.)
163 / pow(cs_turb_apow, 2. * cs_turb_dpow);
164 *cofimp = 1. + cs_turb_bpow
165 * pow(*ustar, cs_turb_bpow + 1. - 1./cs_turb_dpow)
166 * (pow(2., cs_turb_bpow - 1.) - 2.);
167
168 /* Count the cell in the log layer */
169 *nlogla += 1;
170
171 }
172}
173
174/*----------------------------------------------------------------------------*/
193/*----------------------------------------------------------------------------*/
194
195inline static void
198 cs_real_t y,
199 int *iuntur,
200 cs_gnum_t *nsubla,
201 cs_gnum_t *nlogla,
202 cs_real_t *ustar,
203 cs_real_t *uk,
205 cs_real_t *ypup,
206 cs_real_t *cofimp)
207{
208 const double ypluli = cs_glob_wall_functions->ypluli;
209
210 double ustarwer, ustarmin, ustaro, ydvisc;
211 double eps = 0.001;
212 int niter_max = 100;
213 int iter = 0;
214 double reynolds;
215
216 /* Compute the local Reynolds number */
217
218 ydvisc = y / l_visc;
219 reynolds = vel * ydvisc;
220
221 /*
222 * Compute the friction velocity ustar
223 */
224
225 /* In the viscous sub-layer: U+ = y+ */
226 if (reynolds <= ypluli * ypluli) {
227
228 *ustar = sqrt(vel / ydvisc);
229 *yplus = *ustar * ydvisc;
230 *uk = *ustar;
231 *ypup = 1.;
232 *cofimp = 0.;
233
234 /* Disable the wall funcion count the cell in the viscous sub-layer */
235 *iuntur = 0;
236 *nsubla += 1;
237
238 /* In the log layer */
239 } else {
240
241 /* The initial value is Wener or the minimun ustar to ensure convergence */
242 ustarwer = pow(fabs(vel) / cs_turb_apow / pow(ydvisc, cs_turb_bpow),
244 ustarmin = exp(-cs_turb_cstlog * cs_turb_xkappa)/ydvisc;
245 ustaro = cs_math_fmax(ustarwer, ustarmin);
246 *ustar = (cs_turb_xkappa * vel + ustaro)
247 / (log(ydvisc * ustaro) + cs_turb_xkappa * cs_turb_cstlog + 1.);
248
249 /* Iterative solving */
250 for (iter = 0; iter < niter_max
251 && fabs(*ustar - ustaro) >= eps * ustaro; iter++) {
252 ustaro = *ustar;
253 *ustar = (cs_turb_xkappa * vel + ustaro)
254 / (log(ydvisc * ustaro) + cs_turb_xkappa * cs_turb_cstlog + 1.);
255 }
256
257 if (iter >= niter_max) {
258 bft_printf(_("WARNING: non-convergence in the computation\n"
259 "******** of the friction velocity\n\n"
260 "friction vel: %f \n" ), *ustar);
261 }
262
263 *uk = *ustar;
264 *yplus = *ustar * ydvisc;
265 *ypup = *yplus / (log(*yplus) / cs_turb_xkappa + cs_turb_cstlog);
266 *cofimp = 1. - *ypup / cs_turb_xkappa * 1.5 / *yplus;
267
268 /* Count the cell in the log layer */
269 *nlogla += 1;
270
271 }
272
273}
274
275/*----------------------------------------------------------------------------
276 * Compute du+/dy+ for a given yk+.
277 *
278 * parameters:
279 * yplus <-- dimensionless distance
280 *
281 * returns:
282 * the resulting dimensionless velocity.
283 *----------------------------------------------------------------------------*/
284
285inline static cs_real_t
287 cs_real_t ka,
288 cs_real_t B,
289 cs_real_t cuv,
290 cs_real_t y0,
291 cs_real_t n)
292{
293 cs_real_t uplus, f_blend;
294
295 f_blend = exp(-0.25*cuv*pow(yp,3));
296 uplus = f_blend*yp + (log(yp)/ka +B)*(1.-exp(-pow(yp/y0,n)))*(1-f_blend);
297
298 return uplus;
299}
300
301/*----------------------------------------------------------------------------
302 * Compute du+/dy+ for a given yk+.
303 * parameters:
304 * yplus <-- dimensionless distance
305 * returns:
306 * the resulting dimensionless velocity gradient.
307 *----------------------------------------------------------------------------*/
308
309inline static cs_real_t
311 cs_real_t ka,
312 cs_real_t B,
313 cs_real_t cuv,
314 cs_real_t y0,
315 cs_real_t n)
316{
317 cs_real_t dupdyp;
318
319 dupdyp = exp(-0.25*cuv*pow(yp,3))
320 - 0.75*cuv*pow(yp,3.)*exp(-0.25*cuv*pow(yp,3.))
321 + n*(1.-exp(-0.25*cuv*pow(yp,3.)))*(pow(yp,n-1.)/pow(y0,n))
322 *exp(-pow(yp/y0,n))*((1./ka)*log(yp)+B)
323 + 0.75*cuv*pow(yp,2.)*exp(-0.25*cuv*pow(yp,3.))
324 *(1.-exp(-pow(yp/y0,n)))*((1./ka)*log(yp)+B)
325 + (1./ka/yp)*(1.-exp(-pow(yp/y0,n)))*(1-exp(-0.25*cuv*pow(yp,3.)));
326
327 return dupdyp;
328}
329
330/*----------------------------------------------------------------------------*/
353/*----------------------------------------------------------------------------*/
354
355inline static void
357 cs_real_t l_visc,
358 cs_real_t t_visc,
360 cs_real_t y,
361 cs_real_t kinetic_en,
362 int *iuntur,
363 cs_gnum_t *nsubla,
364 cs_gnum_t *nlogla,
365 cs_real_t *ustar,
366 cs_real_t *uk,
368 cs_real_t *ypup,
369 cs_real_t *cofimp)
370{
371 const double ypluli = cs_glob_wall_functions->ypluli;
372 double Re, g, t_visc_durb;
373 cs_real_t cstcuv, csty0, cstN;
374 cs_real_t dup1, dup2, uplus;
375
376 /* Local constants */
377 cstcuv = 1.0674e-3;
378 csty0 = 14.5e0;
379 cstN = 2.25e0;
380
381 /* Iterative process to determine uk through TKE law */
382 Re = sqrt(kinetic_en) * y / l_visc;
383 g = exp(-Re/11.);
384
385 /* Comutation of uk*/
386 *uk = sqrt( (1.-g) * sqrt(cs_turb_cmu) * kinetic_en
387 + g * l_visc * vel/y);
388
389 /* Local value of y+, estimated U+ */
390 *yplus = *uk * y / l_visc;
391 uplus = _uplus( *yplus, cs_turb_xkappa, cs_turb_cstlog, cstcuv, csty0, cstN);
392 /* Deduced velocity sclale uet*/
393 *ustar = vel / uplus;
394
395 if (*yplus < 1.e-1) {
396
397 *ypup = 1.0;
398 *cofimp = 0.0;
399
400 *iuntur = 0;
401 *nsubla += 1;
402
403 }
404 else {
405
406 /* Dimensionless velocity gradient in y+ */
408 cstcuv, csty0, cstN);
409 /* Dimensionless velocity gradient in 2 x y+ */
410 dup2 = _dupdyp(2.0 * *yplus, cs_turb_xkappa,
411 cs_turb_cstlog, cstcuv, csty0, cstN);
412
413 *ypup = *yplus / uplus;
414
415 /* ------------------------------------------------------------
416 * Cofimp = U,F/U,I is built so that the theoretical expression
417 * of the production P_theo = dup1 * (1.0 - dup1) is equal to
418 * P_calc = mu_t,I * ((U,I - U,F + IF*dup2)/(2IF) )^2
419 * This is a generalization of the process implemented in the 2
420 * scales wall function (iwallf = 3).
421 * ------------------------------------------------------------*/
422
423 /* Turbulent viscocity is modified for RSM so that its expression
424 * remain valid down to the wall, according to Durbin :
425 * nu_t = 0.22 * v'2 * k / eps */
426 const cs_turb_model_t *turb_model = cs_get_glob_turb_model();
427 assert(turb_model != NULL);
428 if (turb_model->itytur == 3)
429 t_visc_durb = t_visc / (kinetic_en * cs_turb_cmu ) * rnnb * 0.22;
430 else
431 t_visc_durb = t_visc;
432
433 *cofimp
434 = 1. - *ypup * (2. * sqrt(l_visc / t_visc_durb * dup1 * (1. - dup1))
435 - dup2);
436
437 /* log layer */
438 if (*yplus > ypluli) {
439 *nlogla += 1;
440 /* viscous sub-layer or buffer layer*/
441 } else {
442 *iuntur = 0;
443 *nsubla += 1;
444 }
445 }
446}
447
448/*----------------------------------------------------------------------------*/
468/*----------------------------------------------------------------------------*/
469
470inline static void
472 cs_real_t t_visc,
474 cs_real_t y,
475 cs_real_t kinetic_en,
476 int *iuntur,
477 cs_gnum_t *nsubla,
478 cs_gnum_t *nlogla,
479 cs_real_t *ustar,
480 cs_real_t *uk,
482 cs_real_t *ypup,
483 cs_real_t *cofimp)
484{
485 const double ypluli = cs_glob_wall_functions->ypluli;
486
487 double rcprod, ml_visc, Re, g;
488
489 /* Compute the friction velocity ustar */
490
491 /* Blending for very low values of k */
492 Re = sqrt(kinetic_en) * y / l_visc;
493 g = exp(-Re/11.);
494
495 *uk = sqrt( (1.-g) * sqrt(cs_turb_cmu) * kinetic_en
496 + g * l_visc * vel / y);
497
498 *yplus = *uk * y / l_visc;
499
500 /* log layer */
501 if (*yplus > ypluli) {
502
503 cs_real_t uplus = log(*yplus)
505 *ustar = vel / uplus;
506 *ypup = *yplus / uplus;
507
508 /* Mixing length viscosity */
509 ml_visc = cs_turb_xkappa * l_visc * *yplus;
511 cs_math_fmax(1., sqrt(ml_visc / t_visc)) / *yplus);
512
513 *cofimp = 1. - *ypup / cs_turb_xkappa
514 * ( 2. * rcprod - 1. / (2. * *yplus));
515 *nlogla += 1;
516
517 }
518
519 /* Viscous sub-layer */
520 else {
521
522 if (*yplus > 1.e-12) {
523 *ustar = fabs(vel / *yplus); /* FIXME remove that: its is here only to
524 be fully equivalent to the former code. */
525 }
526 else {
527 *ustar = 0.;
528 }
529 *ypup = 1.;
530 *cofimp = 0.;
531
532 *iuntur = 0;
533 *nsubla += 1;
534
535 }
536}
537
538/*----------------------------------------------------------------------------*/
559/*----------------------------------------------------------------------------*/
560
561inline static void
563 cs_real_t t_visc,
565 cs_real_t y,
566 cs_real_t kinetic_en,
567 int *iuntur,
568 cs_gnum_t *nsubla,
569 cs_gnum_t *nlogla,
570 cs_real_t *ustar,
571 cs_real_t *uk,
573 cs_real_t *dplus,
574 cs_real_t *ypup,
575 cs_real_t *cofimp)
576{
577 CS_UNUSED(iuntur);
578
579 const double ypluli = cs_glob_wall_functions->ypluli;
580
581 double rcprod, ml_visc, Re, g;
582 /* Compute the friction velocity ustar */
583
584 /* Blending for very low values of k */
585 Re = sqrt(kinetic_en) * y / l_visc;
586 g = exp(-Re/11.);
587
588 *uk = sqrt( (1.-g) * sqrt(cs_turb_cmu) * kinetic_en
589 + g * l_visc * vel / y);
590
591 *yplus = *uk * y / l_visc;
592
593 /* Compute the friction velocity ustar */
594 *uk = sqrt(sqrt(cs_turb_cmu) *kinetic_en);//FIXME
595 *yplus = *uk * y / l_visc;//FIXME
596
597 /* Log layer */
598 if (*yplus > ypluli) {
599
600 *dplus = 0.;
601
602 *nlogla += 1;
603
604 /* Viscous sub-layer and therefore shift */
605 } else {
606
607 *dplus = ypluli - *yplus;
608
609 /* Count the cell as if it was in the viscous sub-layer */
610 *nsubla += 1;
611
612 }
613
614 /* Mixing length viscosity */
615 ml_visc = cs_turb_xkappa * l_visc * (*yplus + *dplus);
617 cs_math_fmax(1., sqrt(ml_visc / t_visc))
618 / (*yplus + *dplus));
619
620 *ustar = vel / (log(*yplus + *dplus) / cs_turb_xkappa + cs_turb_cstlog);
621 *ypup = *yplus / (log(*yplus + *dplus) / cs_turb_xkappa + cs_turb_cstlog);
622 *cofimp = 1. - *ypup
623 / cs_turb_xkappa * (2. * rcprod - 1. / (2. * *yplus + *dplus));
624}
625
626/*----------------------------------------------------------------------------
627 * Compute u+ for a given yk+ between 0.1 and 200 according to the two
628 * scales wall functions using Van Driest mixing length.
629 * This function holds the coefficients of the polynome fitting log(u+).
630 *
631 * parameters:
632 * yplus <-- dimensionless distance
633 *
634 * returns:
635 * the resulting dimensionless velocity.
636 *----------------------------------------------------------------------------*/
637
638inline static cs_real_t
640{
641 /* Coefficients of the polynome fitting log(u+) for yk < 200 */
642 static double aa[11] = {-0.0091921, 3.9577, 0.031578,
643 -0.51013, -2.3254, -0.72665,
644 2.969, 0.48506, -1.5944,
645 0.087309, 0.1987 };
646
647 cs_real_t y1,y2,y3,y4,y5,y6,y7,y8,y9,y10, uplus;
648
649 y1 = 0.25 * log(yplus);
650 y2 = y1 * y1;
651 y3 = y2 * y1;
652 y4 = y3 * y1;
653 y5 = y4 * y1;
654 y6 = y5 * y1;
655 y7 = y6 * y1;
656 y8 = y7 * y1;
657 y9 = y8 * y1;
658 y10 = y9 * y1;
659
660 uplus = aa[0]
661 + aa[1] * y1
662 + aa[2] * y2
663 + aa[3] * y3
664 + aa[4] * y4
665 + aa[5] * y5
666 + aa[6] * y6
667 + aa[7] * y7
668 + aa[8] * y8
669 + aa[9] * y9
670 + aa[10] * y10;
671
672 return exp(uplus);
673}
674
675/*----------------------------------------------------------------------------*/
710/*----------------------------------------------------------------------------*/
711
712inline static void
714 cs_real_t l_visc,
716 cs_real_t y,
717 cs_real_t kinetic_en,
718 int *iuntur,
719 cs_gnum_t *nsubla,
720 cs_gnum_t *nlogla,
721 cs_real_t *ustar,
722 cs_real_t *uk,
724 cs_real_t *ypup,
725 cs_real_t *cofimp,
726 cs_real_t *lmk,
727 cs_real_t kr,
728 bool wf)
729{
730 double urplus, d_up, lmk15;
731
732 if (wf)
733 *uk = sqrt(sqrt((1.-cs_turb_crij2)/cs_turb_crij1 * rnnb * kinetic_en));
734
735 /* Set a low threshold value in case tangential velocity is zero */
736 *yplus = cs_math_fmax(*uk * y / l_visc, 1.e-4);
737
738 /* Dimensionless roughness */
739 cs_real_t krp = *uk * kr / l_visc;
740
741 /* Extension of Van Driest mixing length according to Rotta (1962) with
742 Cebeci & Chang (1978) correlation */
743 cs_real_t dyrp = 0.9 * (sqrt(krp) - krp * exp(-krp / 6.));
744 cs_real_t yrplus = *yplus + dyrp;
745
746 if (dyrp <= 1.e-1)
747 d_up = dyrp;
748 else if (dyrp <= 200.)
749 d_up = _vdriest_dupdyp_integral(dyrp);
750 else
751 d_up = 16.088739022054590 + log(dyrp/200.) / cs_turb_xkappa;
752
753 if (yrplus <= 1.e-1) {
754
755 urplus = yrplus;
756
757 if (wf) {
758 *iuntur = 0;
759 *nsubla += 1;
760
761 *lmk = 0.;
762
763 *ypup = 1.;
764
765 *cofimp = 0.;
766 }
767
768 } else if (yrplus <= 200.) {
769
770 urplus = _vdriest_dupdyp_integral(yrplus);
771
772 if (wf) {
773 *nlogla += 1;
774
775 *ypup = *yplus / (urplus-d_up);
776
777 /* Mixing length in y+ */
778 *lmk = cs_turb_xkappa * (*yplus) *(1-exp(- (*yplus) / cs_turb_vdriest));
779
780 /* Mixing length in 3/2*y+ */
781 lmk15 = cs_turb_xkappa * 1.5 * (*yplus) *(1-exp(- 1.5 * (*yplus)
782 / cs_turb_vdriest));
783
784 *cofimp = 1. - (2. / (1. + *lmk) - 1. / (1. + lmk15)) * *ypup;
785 }
786
787 } else {
788
789 urplus = 16.088739022054590 + log(yrplus/200) / cs_turb_xkappa;
790
791 if (wf) {
792 *nlogla += 1;
793
794 *ypup = *yplus / (urplus-d_up);
795
796 /* Mixing length in y+ */
797 *lmk = cs_turb_xkappa * (*yplus) *(1-exp(- (*yplus) / cs_turb_vdriest));
798
799 /* Mixing length in 3/2*y+ */
800 lmk15 = cs_turb_xkappa * 1.5 * (*yplus) *(1-exp(- 1.5 * (*yplus)
801 / cs_turb_vdriest));
802
803 *cofimp = 1. - (2. / *lmk - 1. / lmk15) * *ypup;
804 }
805
806 }
807
808 *ustar = vel / (urplus-d_up);
809}
810
811/*----------------------------------------------------------------------------*/
843/*----------------------------------------------------------------------------*/
844
845inline static void
847 cs_real_t t_visc,
849 cs_real_t y,
850 cs_real_t rough_d,
851 cs_real_t kinetic_en,
852 int *iuntur,
853 cs_gnum_t *nsubla,
854 cs_gnum_t *nlogla,
855 cs_real_t *ustar,
856 cs_real_t *uk,
858 cs_real_t *dplus,
859 cs_real_t *ypup,
860 cs_real_t *cofimp)
861{
862 CS_UNUSED(iuntur);
863
864 const double ypluli = cs_glob_wall_functions->ypluli;
865
866 double rcprod, ml_visc, Re, g;
867
868 /* Compute the friction velocity ustar */
869
870 /* Shifting of the wall distance to be consistant with
871 * the fully rough wall function
872 *
873 * ln((y+y0)/y0) = ln((y+y0)/alpha xi) + kappa * 5.2
874 *
875 * y0 = xi * exp(-kappa * 8.5)
876 * where xi is the sand grain roughness here
877 * y0 = alpha * xi * exp(-kappa * 5.2)
878 *
879 * so:
880 * alpha = exp(-kappa * (8.5 - 5.2)) = 0.25
881 *
882 */
883 cs_real_t y0 = rough_d;
884 /* Note : Sand grain roughness given by:
885 cs_real_t sg_rough = rough_d * exp(cs_turb_xkappa*cs_turb_cstlog_rough);
886 */
887
888 /* Blending for very low values of k */
889 Re = sqrt(kinetic_en) * (y + y0) / l_visc;
890 g = exp(-Re/11.);
891
892 *uk = sqrt( (1.-g) * sqrt(cs_turb_cmu) * kinetic_en
893 + g * l_visc * vel / (y + y0));
894
895
896 *yplus = *uk * y / l_visc;
897
898 /* As for scalable wall functions, yplus is shifted of "dplus" */
899 *dplus = *uk * y0 / l_visc;
900
901 /* Shift of the velocity profile due to roughness */
902 cs_real_t shift_vel = -log(1. + y0 * exp(cs_turb_xkappa * cs_turb_cstlog) * *uk/l_visc)
904
905 /* Log layer and shifted with the roughness */
906 if (*yplus > ypluli) {
907
908 cs_real_t uplus = log(*yplus + *dplus)
909 / cs_turb_xkappa + cs_turb_cstlog + shift_vel;
910 *ustar = vel / uplus;
911 *ypup = *yplus / uplus;
912#if 0
913 bft_printf("uet=%f, u=%f, uplus=%f, yk=%f, duplus=%f\n",
914 *ustar, vel, uplus, *yplus, 1./uplus);
915#endif
916
917 /* Mixing length viscosity, compatible with both regimes */
918 ml_visc = cs_turb_xkappa * l_visc * (*yplus + *dplus);
920 cs_math_fmax(1., sqrt(ml_visc / t_visc))
921 / (*yplus + *dplus));
922 *cofimp = 1. - *ypup / cs_turb_xkappa
923 * ( 2. * rcprod - 1. / (2. * *yplus + *dplus));
924 *nlogla += 1;
925
926 }
927
928 /* Viscous sub-layer and therefore shift again */
929 else {
930
931 if (*yplus > 1.e-12) {
932 *ustar = fabs(vel / *yplus); /* FIXME remove that: its is here only to
933 be fully equivalent to the former code. */
934 }
935 else {
936 *ustar = 0.;
937 }
938 *ypup = 1.;
939 *cofimp = 0.;
940
941 *iuntur = 0;
942 /* Count the cell as if it was in the viscous sub-layer */
943 *nsubla += 1;
944
945 }
946}
947
948/*----------------------------------------------------------------------------*/
968/*----------------------------------------------------------------------------*/
969
970inline static void
972 cs_real_t t_visc,
974 cs_real_t y,
975 int *iuntur,
976 cs_gnum_t *nsubla,
977 cs_gnum_t *nlogla,
978 cs_real_t *ustar,
979 cs_real_t *uk,
981 cs_real_t *dplus,
982 cs_real_t *ypup,
983 cs_real_t *cofimp)
984{
985 CS_UNUSED(t_visc);
986 CS_UNUSED(nlogla);
987 CS_UNUSED(dplus);
988
989 /* Compute the friction velocity ustar */
990
991 *ustar = sqrt(vel * l_visc / y);
992 *yplus = *ustar * y / l_visc;
993 *uk = *ustar;
994 *ypup = 1.;
995 *cofimp = 0.;
996 *iuntur = 0;
997
998 /* Count the cell as if it was in the viscous sub-layer */
999 *nsubla += 1;
1000}
1001
1002/*----------------------------------------------------------------------------*/
1032/*----------------------------------------------------------------------------*/
1033
1034inline static void
1036 cs_real_t prl,
1037 cs_real_t prt,
1038 cs_real_t rough_t,
1039 cs_real_t uk,
1041 cs_real_t dplus,
1042 cs_real_t *htur,
1043 cs_real_t *yplim)
1044{
1045 /* Local variables */
1046 double tplus;
1047 double beta2,a2;
1048 double yp2;
1049 double prlm1;
1050
1051 const double epzero = cs_math_epzero;
1052
1053 /*==========================================================================
1054 1. Initializations
1055 ==========================================================================*/
1056
1057 (*htur) = cs_math_fmax(yplus, epzero) / cs_math_fmax(yplus+dplus, epzero);
1058
1059 prlm1 = 0.1;
1060
1061 /* Sand grain roughness is:
1062 * zeta = z0 * exp(kappa 8.5)
1063 * Then:
1064 * hp = zeta uk / nu * exp( -kappa(8.5 - 5.2))
1065 * = z0 * uk / nu * exp(kappa * 5.2)
1066 * where 5.2 is the smooth log constant, and 8.5 the rough one
1067 *
1068 * FIXME check if we should use a molecular Schmidt number
1069 */
1070 cs_real_t hp = rough_t *uk / l_visc * exp(cs_turb_xkappa*cs_turb_cstlog);
1071
1072 /* Shift of the temperature profile due to roughness */
1073 cs_real_t shift_temp = -log(1. + hp);
1074
1075 /*==========================================================================
1076 2. Compute htur for small Prandtl numbers
1077 ==========================================================================*/
1078
1079 if (prl <= prlm1) {
1080 (*yplim) = prt/(prl*cs_turb_xkappa);
1081 if (yplus > (*yplim)) {
1082 tplus = prl*(*yplim) + prt/cs_turb_xkappa
1083 * (log((yplus+dplus)/(*yplim)) + shift_temp);
1084 (*htur) = prl * yplus / tplus;
1085 }
1086
1087 /*========================================================================
1088 3. Compute htur for the model with three sub-layers
1089 ========================================================================*/
1090
1091 } else {
1092 yp2 = sqrt(cs_turb_xkappa*1000./prt);
1093 (*yplim) = pow(1000./prl, 1./3.);
1094
1095 a2 = 15.*pow(prl, 2./3.);
1096
1097 if (yplus >= (*yplim) && yplus < yp2) {
1098 tplus = a2 - 500./((yplus+dplus)*(yplus+dplus));
1099 (*htur) = prl * yplus / tplus;
1100 }
1101
1102 if (yplus >= yp2) {
1103 beta2 = a2 - 0.5 * prt /cs_turb_xkappa;
1104 tplus = beta2 + prt/cs_turb_xkappa*log((yplus+dplus)/yp2);
1105 (*htur) = prl * yplus / tplus;
1106 }
1107
1108 }
1109}
1110
1111/*----------------------------------------------------------------------------*/
1135/*----------------------------------------------------------------------------*/
1136
1137inline static void
1139 cs_real_t prt,
1141 cs_real_t *htur)
1142{
1143 cs_real_t prlrat = prl / prt;
1144
1145 /* Parameters of the numerical quadrature */
1146 const int ninter_max = 100;
1147 const cs_real_t ypmax = 1.e2;
1148
1149 /* No correction for very small yplus */
1150 if (yplus <= 0.1)
1151 *htur = 1.;
1152 else {
1153 cs_real_t ypint = cs_math_fmin(yplus, ypmax);
1154
1155 /* The number of sub-intervals is taken proportional to yplus and equal to
1156 * ninter_max if yplus=ypmax */
1157
1158 int npeff = cs_math_fmax((int)(ypint / ypmax * (double)(ninter_max)), 1);
1159
1160 double dy = ypint / (double)(npeff);
1161 cs_real_t stplus = 0.;
1162 cs_real_t nut1 = 0.;
1163 cs_real_t nut2 = 0.;
1164
1165 for (int ip = 1; ip <= npeff; ip++) {
1166 double yp = ypint * (double)(ip) / (double)(npeff);
1167 nut2 = cs_turb_xkappa * yp * (1. - exp(-yp / cs_turb_vdriest));
1168 stplus += dy / (1. + prlrat * 0.5 * (nut1 + nut2));
1169 nut1 = nut2;
1170 }
1171
1172 if (yplus > ypint) {
1173 cs_real_t r = prlrat * cs_turb_xkappa;
1174 stplus += log( (1. + r*yplus) / (1. + r*ypint)) / r;
1175 }
1176
1177 if (stplus >= 1.e-6)
1178 *htur = yplus / stplus;
1179 else
1180 *htur = 1.;
1181 }
1182}
1183
1184/*----------------------------------------------------------------------------*/
1200/*----------------------------------------------------------------------------*/
1201
1202inline static void
1204 cs_real_t prl,
1205 cs_real_t prt,
1206 cs_real_t rough_t,
1207 cs_real_t uk,
1209 cs_real_t dplus,
1210 cs_real_t *htur)
1211{
1212 CS_UNUSED(prt);
1213
1214 /* Sand grain roughness is:
1215 * zeta = z0 * exp(kappa 8.5)
1216 * Then:
1217 * hp = zeta uk / nu * exp( -kappa(8.5 - 5.2))
1218 * = z0 * uk / nu * exp(kappa * 5.2)
1219 * where 5.2 is the smooth log constant, and 8.5 the rough one
1220 *
1221 * FIXME check if we should use a molecular Schmidt number
1222 */
1223 cs_real_t hp = rough_t *uk / l_visc * exp(cs_turb_xkappa*cs_turb_cstlog);
1224 const double ypluli = cs_glob_wall_functions->ypluli;
1225 const double epzero = cs_math_epzero;
1226
1228
1229 /* Shift of the temperature profile due to roughness */
1230 cs_real_t shift_temp = -log(1. + hp);
1231
1232 if (yplus > ypluli) {
1233 cs_real_t tplus = prt * ( (log(yplus+dplus) + shift_temp)/cs_turb_xkappa
1234 + cs_turb_cstlog);
1235 (*htur) = prl * yplus / tplus;
1236 }
1237}
1238
1239/*============================================================================
1240 * Public function definitions for Fortran API
1241 *============================================================================*/
1242
1243/*=============================================================================
1244 * Public function prototypes
1245 *============================================================================*/
1246
1247/*----------------------------------------------------------------------------
1248 *! \brief Provide access to cs_glob_wall_functions
1249 *----------------------------------------------------------------------------*/
1250
1253
1254/*----------------------------------------------------------------------------*/
1289/*----------------------------------------------------------------------------*/
1290
1291void
1293 cs_real_t l_visc,
1294 cs_real_t t_visc,
1295 cs_real_t vel,
1296 cs_real_t y,
1297 cs_real_t rough_d,
1298 cs_real_t rnnb,
1299 cs_real_t kinetic_en,
1300 cs_real_t rough_t,
1301 cs_real_t buoyant_param,
1302 cs_real_t delta_t,
1303 cs_real_t turb_prandtl,
1304 int icodcl_th_fid,
1305 cs_real_t flux,
1306 cs_field_t *f_th,
1307 int *iuntur,
1308 cs_gnum_t *nsubla,
1309 cs_gnum_t *nlogla,
1310 cs_real_t *ustar,
1311 cs_real_t *uk,
1313 cs_real_t *ypup,
1314 cs_real_t *cofimp,
1315 cs_real_t *dplus,
1316 cs_real_t *cfnns,
1317 cs_real_t *cfnnk,
1318 cs_real_t *cfnne,
1319 cs_real_t *dlmo);
1320
1321/*----------------------------------------------------------------------------*/
1346/*----------------------------------------------------------------------------*/
1347
1348void
1350 cs_real_t l_visc,
1351 cs_real_t prl,
1352 cs_real_t prt,
1353 cs_real_t rough_t,
1354 cs_real_t uk,
1356 cs_real_t dplus,
1357 cs_real_t *htur,
1358 cs_real_t *yplim);
1359
1360/*----------------------------------------------------------------------------*/
1361
1363
1364#endif /* __CS_WALL_FUNCTIONS_H__ */
int bft_printf(const char *const format,...)
Replacement for printf() with modifiable behavior.
Definition: bft_printf.cpp:140
#define BEGIN_C_DECLS
Definition: cs_defs.h:554
double cs_real_t
Floating-point value.
Definition: cs_defs.h:357
#define _(String)
Definition: cs_defs.h:67
unsigned cs_gnum_t
global mesh entity number
Definition: cs_defs.h:342
#define CS_UNUSED(x)
Definition: cs_defs.h:543
#define END_C_DECLS
Definition: cs_defs.h:555
@ eps
Definition: cs_field_pointer.h:73
@ vel
Definition: cs_field_pointer.h:70
@ yplus
Definition: cs_field_pointer.h:217
const cs_real_t cs_math_epzero
static CS_F_HOST_DEVICE cs_real_t cs_math_fmin(cs_real_t x, cs_real_t y)
Compute the min value of two real values.
Definition: cs_math.h:710
static CS_F_HOST_DEVICE cs_real_t cs_math_fmax(cs_real_t x, cs_real_t y)
Compute the max value of two real values.
Definition: cs_math.h:729
double cs_turb_vdriest
Definition: cs_turbulence_model.cpp:443
double cs_turb_crij2
Definition: cs_turbulence_model.cpp:549
double cs_turb_crij1
Definition: cs_turbulence_model.cpp:543
cs_turb_model_t * cs_get_glob_turb_model(void)
Provide write access to turbulence model structure.
Definition: cs_turbulence_model.cpp:1209
double cs_turb_cstlog
Definition: cs_turbulence_model.cpp:455
double cs_turb_dpow
Definition: cs_turbulence_model.cpp:488
double cs_turb_apow
Definition: cs_turbulence_model.cpp:482
double cs_turb_cmu
Definition: cs_turbulence_model.cpp:496
double cs_turb_bpow
Definition: cs_turbulence_model.cpp:485
double cs_turb_xkappa
Definition: cs_turbulence_model.cpp:434
cs_wall_f_s_type_t
Definition: cs_wall_functions.h:68
@ CS_WALL_F_S_SMOOTH_ROUGH
Definition: cs_wall_functions.h:75
@ CS_WALL_F_S_MONIN_OBUKHOV
Definition: cs_wall_functions.h:74
@ CS_WALL_F_S_VDRIEST
Definition: cs_wall_functions.h:72
@ CS_WALL_F_S_ARPACI_LARSEN
Definition: cs_wall_functions.h:71
@ CS_WALL_F_S_UNSET
Definition: cs_wall_functions.h:70
@ CS_WALL_F_S_LOUIS
Definition: cs_wall_functions.h:73
static cs_real_t _dupdyp(cs_real_t yp, cs_real_t ka, cs_real_t B, cs_real_t cuv, cs_real_t y0, cs_real_t n)
Definition: cs_wall_functions.h:310
void cs_wall_functions_scalar(cs_wall_f_s_type_t iwalfs, cs_real_t l_visc, cs_real_t prl, cs_real_t prt, cs_real_t rough_t, cs_real_t uk, cs_real_t yplus, cs_real_t dplus, cs_real_t *htur, cs_real_t *yplim)
Compute the correction of the exchange coefficient between the fluid and the wall for a turbulent flo...
Definition: cs_wall_functions.cpp:716
static void cs_wall_functions_2scales_continuous(cs_real_t rnnb, cs_real_t l_visc, cs_real_t t_visc, cs_real_t vel, cs_real_t y, cs_real_t kinetic_en, int *iuntur, cs_gnum_t *nsubla, cs_gnum_t *nlogla, cs_real_t *ustar, cs_real_t *uk, cs_real_t *yplus, cs_real_t *ypup, cs_real_t *cofimp)
Continuous law of the wall between the linear and log law, with two velocity scales based on the fric...
Definition: cs_wall_functions.h:356
static void cs_wall_functions_1scale_log(cs_real_t l_visc, cs_real_t vel, cs_real_t y, int *iuntur, cs_gnum_t *nsubla, cs_gnum_t *nlogla, cs_real_t *ustar, cs_real_t *uk, cs_real_t *yplus, cs_real_t *ypup, cs_real_t *cofimp)
Log law: piecewise linear and log, with one velocity scale based on the friction.
Definition: cs_wall_functions.h:196
static void cs_wall_functions_2scales_smooth_rough(cs_real_t l_visc, cs_real_t t_visc, cs_real_t vel, cs_real_t y, cs_real_t rough_d, cs_real_t kinetic_en, int *iuntur, cs_gnum_t *nsubla, cs_gnum_t *nlogla, cs_real_t *ustar, cs_real_t *uk, cs_real_t *yplus, cs_real_t *dplus, cs_real_t *ypup, cs_real_t *cofimp)
Two velocity scales wall function with automatic switch from rough to smooth.
Definition: cs_wall_functions.h:846
static void cs_wall_functions_s_smooth_rough(cs_real_t l_visc, cs_real_t prl, cs_real_t prt, cs_real_t rough_t, cs_real_t uk, cs_real_t yplus, cs_real_t dplus, cs_real_t *htur)
Rough Smooth Thermal Wall Function - Prototype.
Definition: cs_wall_functions.h:1203
static void cs_wall_functions_1scale_power(cs_real_t l_visc, cs_real_t vel, cs_real_t y, int *iuntur, cs_gnum_t *nsubla, cs_gnum_t *nlogla, cs_real_t *ustar, cs_real_t *uk, cs_real_t *yplus, cs_real_t *ypup, cs_real_t *cofimp)
Power law: Werner & Wengle.
Definition: cs_wall_functions.h:125
const cs_wall_functions_t * cs_glob_wall_functions
static cs_real_t _vdriest_dupdyp_integral(cs_real_t yplus)
Definition: cs_wall_functions.h:639
static void cs_wall_functions_s_arpaci_larsen(cs_real_t l_visc, cs_real_t prl, cs_real_t prt, cs_real_t rough_t, cs_real_t uk, cs_real_t yplus, cs_real_t dplus, cs_real_t *htur, cs_real_t *yplim)
The correction of the exchange coefficient is computed thanks to a similarity model between dynamic v...
Definition: cs_wall_functions.h:1035
static void cs_wall_functions_disabled(cs_real_t l_visc, cs_real_t t_visc, cs_real_t vel, cs_real_t y, int *iuntur, cs_gnum_t *nsubla, cs_gnum_t *nlogla, cs_real_t *ustar, cs_real_t *uk, cs_real_t *yplus, cs_real_t *dplus, cs_real_t *ypup, cs_real_t *cofimp)
No wall function.
Definition: cs_wall_functions.h:971
cs_wall_functions_t * cs_get_glob_wall_functions(void)
Definition: cs_wall_functions.cpp:185
static void cs_wall_functions_2scales_vdriest(cs_real_t rnnb, cs_real_t l_visc, cs_real_t vel, cs_real_t y, cs_real_t kinetic_en, int *iuntur, cs_gnum_t *nsubla, cs_gnum_t *nlogla, cs_real_t *ustar, cs_real_t *uk, cs_real_t *yplus, cs_real_t *ypup, cs_real_t *cofimp, cs_real_t *lmk, cs_real_t kr, bool wf)
Two velocity scales wall function using Van Driest mixing length.
Definition: cs_wall_functions.h:713
static void cs_wall_functions_s_vdriest(cs_real_t prl, cs_real_t prt, cs_real_t yplus, cs_real_t *htur)
The correction of the exchange coefficient is computed thanks to a numerical integration of:
Definition: cs_wall_functions.h:1138
cs_wall_f_type_t
Definition: cs_wall_functions.h:54
@ CS_WALL_F_1SCALE_LOG
Definition: cs_wall_functions.h:59
@ CS_WALL_F_1SCALE_POWER
Definition: cs_wall_functions.h:58
@ CS_WALL_F_2SCALES_SMOOTH_ROUGH
Definition: cs_wall_functions.h:63
@ CS_WALL_F_2SCALES_LOG
Definition: cs_wall_functions.h:60
@ CS_WALL_F_2SCALES_VDRIEST
Definition: cs_wall_functions.h:62
@ CS_WALL_F_DISABLED
Definition: cs_wall_functions.h:57
@ CS_WALL_F_UNSET
Definition: cs_wall_functions.h:56
@ CS_WALL_F_2SCALES_CONTINUOUS
Definition: cs_wall_functions.h:64
@ CS_WALL_F_SCALABLE_2SCALES_LOG
Definition: cs_wall_functions.h:61
static void cs_wall_functions_2scales_scalable(cs_real_t l_visc, cs_real_t t_visc, cs_real_t vel, cs_real_t y, cs_real_t kinetic_en, int *iuntur, cs_gnum_t *nsubla, cs_gnum_t *nlogla, cs_real_t *ustar, cs_real_t *uk, cs_real_t *yplus, cs_real_t *dplus, cs_real_t *ypup, cs_real_t *cofimp)
Scalable wall function: shift the wall if .
Definition: cs_wall_functions.h:562
static void cs_wall_functions_2scales_log(cs_real_t l_visc, cs_real_t t_visc, cs_real_t vel, cs_real_t y, cs_real_t kinetic_en, int *iuntur, cs_gnum_t *nsubla, cs_gnum_t *nlogla, cs_real_t *ustar, cs_real_t *uk, cs_real_t *yplus, cs_real_t *ypup, cs_real_t *cofimp)
Log law: piecewise linear and log, with two velocity scales based on the friction and the turbulent k...
Definition: cs_wall_functions.h:471
void cs_wall_functions_velocity(cs_wall_f_type_t iwallf, cs_real_t l_visc, cs_real_t t_visc, cs_real_t vel, cs_real_t y, cs_real_t rough_d, cs_real_t rnnb, cs_real_t kinetic_en, cs_real_t rough_t, cs_real_t buoyant_param, cs_real_t delta_t, cs_real_t turb_prandtl, int icodcl_th_fid, cs_real_t flux, cs_field_t *f_th, int *iuntur, cs_gnum_t *nsubla, cs_gnum_t *nlogla, cs_real_t *ustar, cs_real_t *uk, cs_real_t *yplus, cs_real_t *ypup, cs_real_t *cofimp, cs_real_t *dplus, cs_real_t *cfnns, cs_real_t *cfnnk, cs_real_t *cfnne, cs_real_t *dlmo)
Compute the friction velocity and / .
Definition: cs_wall_functions.cpp:345
static cs_real_t _uplus(cs_real_t yp, cs_real_t ka, cs_real_t B, cs_real_t cuv, cs_real_t y0, cs_real_t n)
Definition: cs_wall_functions.h:286
double precision epzero
epsilon
Definition: cstnum.f90:40
Field descriptor.
Definition: cs_field.h:156
Turbulence model general options descriptor.
Definition: cs_turbulence_model.h:130
int itytur
Definition: cs_turbulence_model.h:157
wall functions descriptor.
Definition: cs_wall_functions.h:82
double ypluli
Definition: cs_wall_functions.h:88
cs_wall_f_s_type_t iwalfs
Definition: cs_wall_functions.h:86
cs_wall_f_type_t iwallf
Definition: cs_wall_functions.h:84