7.0
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-2021 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  * BFT library headers
32  *----------------------------------------------------------------------------*/
33 
34 #include <bft_printf.h>
35 
36 /*----------------------------------------------------------------------------
37  * Local headers
38  *----------------------------------------------------------------------------*/
39 
40 #include "cs_base.h"
41 #include "cs_math.h"
42 #include "cs_turbulence_model.h"
43 
44 /*----------------------------------------------------------------------------*/
45 
47 
48 /*=============================================================================
49  * Local Macro definitions
50  *============================================================================*/
51 
52 /*============================================================================
53  * Type definition
54  *============================================================================*/
55 
56 /* Wall function type */
57 /*--------------------*/
58 
59 typedef enum {
60 
70 
72 
73 typedef enum {
74 
80  CS_WALL_F_S_SMOOTH_ROUGH = 4,//TODO merge with MO ?
81 
83 
84 /* Wall functions descriptor */
85 /*---------------------------*/
86 
87 typedef struct {
88 
89  cs_wall_f_type_t iwallf; /* wall function type */
90 
91  cs_wall_f_s_type_t iwalfs; /* wall function type for scalars */
92 
93  int iwallt; /* exchange coefficient correlation
94  - 0: not used by default
95  - 1: exchange coefficient computed with a
96  correlation */
97 
98  double ypluli; /* limit value of y+ for the viscous
99  sublayer */
100 
102 
103 /*============================================================================
104  * Global variables
105  *============================================================================*/
106 
107 /* Pointer to wall functions descriptor structure */
108 
110 
111 /*============================================================================
112  * Private function definitions
113  *============================================================================*/
114 
115 /*----------------------------------------------------------------------------*/
132 /*----------------------------------------------------------------------------*/
133 
134 inline static void
135 cs_wall_functions_1scale_power(cs_real_t l_visc,
136  cs_real_t vel,
137  cs_real_t y,
138  int *iuntur,
139  cs_lnum_t *nsubla,
140  cs_lnum_t *nlogla,
141  cs_real_t *ustar,
142  cs_real_t *uk,
143  cs_real_t *yplus,
144  cs_real_t *ypup,
145  cs_real_t *cofimp)
146 {
147  const double ypluli = cs_glob_wall_functions->ypluli;
148 
149  const double ydvisc = y / l_visc;
150 
151  /* Compute the friction velocity ustar */
152 
153  *ustar = pow((vel/(cs_turb_apow * pow(ydvisc, cs_turb_bpow))), cs_turb_dpow);
154  *uk = *ustar;
155  *yplus = *ustar * ydvisc;
156 
157  /* In the viscous sub-layer: U+ = y+ */
158  if (*yplus <= ypluli) {
159 
160  *ustar = sqrt(vel / ydvisc);
161  *yplus = *ustar * ydvisc;
162  *uk = *ustar;
163  *ypup = 1.;
164  *cofimp = 0.;
165 
166  /* Disable the wall funcion count the cell in the viscous sub-layer */
167  *iuntur = 0;
168  *nsubla += 1;
169 
170  /* In the log layer */
171  } else {
172  *ypup = pow(vel, 2. * cs_turb_dpow-1.)
173  / pow(cs_turb_apow, 2. * cs_turb_dpow);
174  *cofimp = 1. + cs_turb_bpow
175  * pow(*ustar, cs_turb_bpow + 1. - 1./cs_turb_dpow)
176  * (pow(2., cs_turb_bpow - 1.) - 2.);
177 
178  /* Count the cell in the log layer */
179  *nlogla += 1;
180 
181  }
182 }
183 
184 /*----------------------------------------------------------------------------*/
203 /*----------------------------------------------------------------------------*/
204 
205 inline static void
206 cs_wall_functions_1scale_log(cs_lnum_t ifac,
207  cs_real_t l_visc,
208  cs_real_t vel,
209  cs_real_t y,
210  int *iuntur,
211  cs_lnum_t *nsubla,
212  cs_lnum_t *nlogla,
213  cs_real_t *ustar,
214  cs_real_t *uk,
215  cs_real_t *yplus,
216  cs_real_t *ypup,
217  cs_real_t *cofimp)
218 {
219  const double ypluli = cs_glob_wall_functions->ypluli;
220 
221  double ustarwer, ustarmin, ustaro, ydvisc;
222  double eps = 0.001;
223  int niter_max = 100;
224  int iter = 0;
225  double reynolds;
226 
227  /* Compute the local Reynolds number */
228 
229  ydvisc = y / l_visc;
230  reynolds = vel * ydvisc;
231 
232  /*
233  * Compute the friction velocity ustar
234  */
235 
236  /* In the viscous sub-layer: U+ = y+ */
237  if (reynolds <= ypluli * ypluli) {
238 
239  *ustar = sqrt(vel / ydvisc);
240  *yplus = *ustar * ydvisc;
241  *uk = *ustar;
242  *ypup = 1.;
243  *cofimp = 0.;
244 
245  /* Disable the wall funcion count the cell in the viscous sub-layer */
246  *iuntur = 0;
247  *nsubla += 1;
248 
249  /* In the log layer */
250  } else {
251 
252  /* The initial value is Wener or the minimun ustar to ensure convergence */
253  ustarwer = pow(fabs(vel) / cs_turb_apow / pow(ydvisc, cs_turb_bpow),
254  cs_turb_dpow);
255  ustarmin = exp(-cs_turb_cstlog * cs_turb_xkappa)/ydvisc;
256  ustaro = CS_MAX(ustarwer, ustarmin);
257  *ustar = (cs_turb_xkappa * vel + ustaro)
258  / (log(ydvisc * ustaro) + cs_turb_xkappa * cs_turb_cstlog + 1.);
259 
260  /* Iterative solving */
261  for (iter = 0; iter < niter_max
262  && fabs(*ustar - ustaro) >= eps * ustaro; iter++) {
263  ustaro = *ustar;
264  *ustar = (cs_turb_xkappa * vel + ustaro)
265  / (log(ydvisc * ustaro) + cs_turb_xkappa * cs_turb_cstlog + 1.);
266  }
267 
268  if (iter >= niter_max) {
269  bft_printf(_("WARNING: non-convergence in the computation\n"
270  "******** of the friction velocity\n\n"
271  "face id: %ld \n"
272  "friction vel: %f \n" ), (long)ifac, *ustar);
273  }
274 
275  *uk = *ustar;
276  *yplus = *ustar * ydvisc;
277  *ypup = *yplus / (log(*yplus) / cs_turb_xkappa + cs_turb_cstlog);
278  *cofimp = 1. - *ypup / cs_turb_xkappa * 1.5 / *yplus;
279 
280  /* Count the cell in the log layer */
281  *nlogla += 1;
282 
283  }
284 
285 }
286 
287 /*----------------------------------------------------------------------------
288  * Compute du+/dy+ for a given yk+.
289  *
290  * parameters:
291  * yplus <-- dimensionless distance
292  *
293  * returns:
294  * the resulting dimensionless velocity.
295  *----------------------------------------------------------------------------*/
296 
297 inline static cs_real_t
298 _uplus(cs_real_t yp,
299  cs_real_t ka,
300  cs_real_t B,
301  cs_real_t cuv,
302  cs_real_t y0,
303  cs_real_t n)
304 {
305  cs_real_t uplus, f_blend;
306 
307  f_blend = exp(-0.25*cuv*pow(yp,3));
308  uplus = f_blend*yp + (log(yp)/ka +B)*(1.-exp(-pow(yp/y0,n)))*(1-f_blend);
309 
310  return uplus;
311 }
312 
313 /*----------------------------------------------------------------------------
314  * Compute du+/dy+ for a given yk+.
315  * parameters:
316  * yplus <-- dimensionless distance
317  * returns:
318  * the resulting dimensionless velocity gradient.
319  *----------------------------------------------------------------------------*/
320 
321 inline static cs_real_t
322 _dupdyp(cs_real_t yp,
323  cs_real_t ka,
324  cs_real_t B,
325  cs_real_t cuv,
326  cs_real_t y0,
327  cs_real_t n)
328 {
329  cs_real_t dupdyp;
330 
331  dupdyp = exp(-0.25*cuv*pow(yp,3))
332  - 0.75*cuv*pow(yp,3.)*exp(-0.25*cuv*pow(yp,3.))
333  + n*(1.-exp(-0.25*cuv*pow(yp,3.)))*(pow(yp,n-1.)/pow(y0,n))
334  *exp(-pow(yp/y0,n))*((1./ka)*log(yp)+B)
335  + 0.75*cuv*pow(yp,2.)*exp(-0.25*cuv*pow(yp,3.))
336  *(1.-exp(-pow(yp/y0,n)))*((1./ka)*log(yp)+B)
337  + (1./ka/yp)*(1.-exp(-pow(yp/y0,n)))*(1-exp(-0.25*cuv*pow(yp,3.)));
338 
339  return dupdyp;
340 }
341 
342 /*----------------------------------------------------------------------------*/
365 /*----------------------------------------------------------------------------*/
366 
367 inline static void
368 cs_wall_functions_2scales_continuous(cs_real_t rnnb,
369  cs_real_t l_visc,
370  cs_real_t t_visc,
371  cs_real_t vel,
372  cs_real_t y,
373  cs_real_t kinetic_en,
374  int *iuntur,
375  cs_lnum_t *nsubla,
376  cs_lnum_t *nlogla,
377  cs_real_t *ustar,
378  cs_real_t *uk,
379  cs_real_t *yplus,
380  cs_real_t *ypup,
381  cs_real_t *cofimp)
382 {
383  const double ypluli = cs_glob_wall_functions->ypluli;
384  double Re, g, t_visc_durb;
385  cs_real_t cstcuv, csty0, cstN;
386  cs_real_t dup1, dup2, uplus;
387 
388  /* Local constants */
389  cstcuv = 1.0674e-3;
390  csty0 = 14.5e0;
391  cstN = 2.25e0;
392 
393  /* Iterative process to determine uk through TKE law */
394  Re = sqrt(kinetic_en) * y / l_visc;
395  g = exp(-Re/11.);
396 
397  /* Comutation of uk*/
398  *uk = sqrt( (1.-g) * cs_turb_cmu025 * cs_turb_cmu025 * kinetic_en
399  + g * l_visc * vel/y);
400 
401  /* Local value of y+, estimated U+ */
402  *yplus = *uk * y / l_visc;
403  uplus = _uplus( *yplus, cs_turb_xkappa, cs_turb_cstlog, cstcuv, csty0, cstN);
404  /* Deduced velocity sclale uet*/
405  *ustar = vel / uplus;
406 
407  if (*yplus < 1.e-1) {
408 
409  *ypup = 1.0;
410  *cofimp = 0.0;
411 
412  *iuntur = 0;
413  *nsubla += 1;
414 
415  }
416  else {
417 
418  /* Dimensionless velocity gradient in y+ */
419  dup1 = _dupdyp(*yplus, cs_turb_xkappa, cs_turb_cstlog,
420  cstcuv, csty0, cstN);
421  /* Dimensionless velocity gradient in 2 x y+ */
422  dup2 = _dupdyp(2.0 * *yplus, cs_turb_xkappa,
423  cs_turb_cstlog, cstcuv, csty0, cstN);
424 
425  *ypup = *yplus / uplus;
426 
427  /* ------------------------------------------------------------
428  * Cofimp = U,F/U,I is built so that the theoretical expression
429  * of the production P_theo = dup1 * (1.0 - dup1) is equal to
430  * P_calc = mu_t,I * ((U,I - U,F + IF*dup2)/(2IF) )^2
431  * This is a generalization of the process implemented in the 2
432  * scales wall function (iwallf = 3).
433  * ------------------------------------------------------------*/
434 
435  /* Turbulent viscocity is modified for RSM so that its expression
436  * remain valid down to the wall, according to Durbin :
437  * nu_t = 0.22 * v'2 * k / eps */
438  const cs_turb_model_t *turb_model = cs_get_glob_turb_model();
439  assert(turb_model != NULL);
440  if (turb_model->itytur == 3)
441  t_visc_durb = t_visc / (kinetic_en * cs_turb_cmu ) * rnnb * 0.22;
442  else
443  t_visc_durb = t_visc;
444 
445  *cofimp
446  = 1. - *ypup * (2. * sqrt(l_visc / t_visc_durb * dup1 * (1. - dup1))
447  - dup2);
448 
449  /* log layer */
450  if (*yplus > ypluli) {
451  *nlogla += 1;
452  /* viscous sub-layer or buffer layer*/
453  } else {
454  *iuntur = 0;
455  *nsubla += 1;
456  }
457  }
458 }
459 
460 /*----------------------------------------------------------------------------*/
480 /*----------------------------------------------------------------------------*/
481 
482 inline static void
483 cs_wall_functions_2scales_log(cs_real_t l_visc,
484  cs_real_t t_visc,
485  cs_real_t vel,
486  cs_real_t y,
487  cs_real_t kinetic_en,
488  int *iuntur,
489  cs_lnum_t *nsubla,
490  cs_lnum_t *nlogla,
491  cs_real_t *ustar,
492  cs_real_t *uk,
493  cs_real_t *yplus,
494  cs_real_t *ypup,
495  cs_real_t *cofimp)
496 {
497  const double ypluli = cs_glob_wall_functions->ypluli;
498 
499  double rcprod, ml_visc, Re, g;
500 
501  /* Compute the friction velocity ustar */
502 
503  /* Blending for very low values of k */
504  Re = sqrt(kinetic_en) * y / l_visc;
505  g = exp(-Re/11.);
506 
507  *uk = sqrt( (1.-g) * cs_turb_cmu025 * cs_turb_cmu025 * kinetic_en
508  + g * l_visc * vel / y);
509 
510  *yplus = *uk * y / l_visc;
511 
512  /* log layer */
513  if (*yplus > ypluli) {
514 
515  *ustar = vel / (log(*yplus) / cs_turb_xkappa + cs_turb_cstlog);
516  *ypup = *yplus / (log(*yplus) / cs_turb_xkappa + cs_turb_cstlog);
517  /* Mixing length viscosity */
518  ml_visc = cs_turb_xkappa * l_visc * *yplus;
519  rcprod = CS_MIN(cs_turb_xkappa, CS_MAX(1., sqrt(ml_visc / t_visc)) / *yplus);
520  *cofimp = 1. - *ypup / cs_turb_xkappa * ( 2. * rcprod - 1. / (2. * *yplus));
521 
522  *nlogla += 1;
523 
524  /* viscous sub-layer */
525  } else {
526 
527  if (*yplus > 1.e-12) {
528  *ustar = fabs(vel / *yplus); /* FIXME remove that: its is here only to
529  be fully equivalent to the former code. */
530  } else {
531  *ustar = 0.;
532  }
533  *ypup = 1.;
534  *cofimp = 0.;
535 
536  *iuntur = 0;
537  *nsubla += 1;
538 
539  }
540 }
541 
542 /*----------------------------------------------------------------------------*/
563 /*----------------------------------------------------------------------------*/
564 
565 inline static void
566 cs_wall_functions_2scales_scalable(cs_real_t l_visc,
567  cs_real_t t_visc,
568  cs_real_t vel,
569  cs_real_t y,
570  cs_real_t kinetic_en,
571  int *iuntur,
572  cs_lnum_t *nsubla,
573  cs_lnum_t *nlogla,
574  cs_real_t *ustar,
575  cs_real_t *uk,
576  cs_real_t *yplus,
577  cs_real_t *dplus,
578  cs_real_t *ypup,
579  cs_real_t *cofimp)
580 {
581  CS_UNUSED(iuntur);
582 
583  const double ypluli = cs_glob_wall_functions->ypluli;
584 
585  double rcprod, ml_visc, Re, g;
586  /* Compute the friction velocity ustar */
587 
588  /* Blending for very low values of k */
589  Re = sqrt(kinetic_en) * y / l_visc;
590  g = exp(-Re/11.);
591 
592  *uk = sqrt( (1.-g) * cs_turb_cmu025 * cs_turb_cmu025 * kinetic_en
593  + g * l_visc * vel / y);
594 
595  *yplus = *uk * y / l_visc;
596 
597  /* Compute the friction velocity ustar */
598  *uk = cs_turb_cmu025 * sqrt(kinetic_en);//FIXME
599  *yplus = *uk * y / l_visc;//FIXME
600 
601  /* Log layer */
602  if (*yplus > ypluli) {
603 
604  *dplus = 0.;
605 
606  *nlogla += 1;
607 
608  /* Viscous sub-layer and therefore shift */
609  } else {
610 
611  *dplus = ypluli - *yplus;
612 
613  /* Count the cell as if it was in the viscous sub-layer */
614  *nsubla += 1;
615 
616  }
617 
618  /* Mixing length viscosity */
619  ml_visc = cs_turb_xkappa * l_visc * (*yplus + *dplus);
620  rcprod = CS_MIN(cs_turb_xkappa, CS_MAX(1., sqrt(ml_visc / t_visc)) / (*yplus + *dplus));
621 
622  *ustar = vel / (log(*yplus + *dplus) / cs_turb_xkappa + cs_turb_cstlog);
623  *ypup = *yplus / (log(*yplus + *dplus) / cs_turb_xkappa + cs_turb_cstlog);
624  *cofimp = 1. - *ypup
625  / cs_turb_xkappa * (2. * rcprod - 1. / (2. * *yplus + *dplus));
626 }
627 
628 /*----------------------------------------------------------------------------
629  * Compute u+ for a given yk+ between 0.1 and 200 according to the two
630  * scales wall functions using Van Driest mixing length.
631  * This function holds the coefficients of the polynome fitting log(u+).
632  *
633  * parameters:
634  * yplus <-- dimensionless distance
635  *
636  * returns:
637  * the resulting dimensionless velocity.
638  *----------------------------------------------------------------------------*/
639 
640 inline static cs_real_t
641 _vdriest_dupdyp_integral(cs_real_t yplus)
642 {
643  /* Coefficients of the polynome fitting log(u+) for yk < 200 */
644  static double aa[11] = {-0.0091921, 3.9577, 0.031578,
645  -0.51013, -2.3254, -0.72665,
646  2.969, 0.48506, -1.5944,
647  0.087309, 0.1987 };
648 
649  cs_real_t y1,y2,y3,y4,y5,y6,y7,y8,y9,y10, uplus;
650 
651  y1 = 0.25 * log(yplus);
652  y2 = y1 * y1;
653  y3 = y2 * y1;
654  y4 = y3 * y1;
655  y5 = y4 * y1;
656  y6 = y5 * y1;
657  y7 = y6 * y1;
658  y8 = y7 * y1;
659  y9 = y8 * y1;
660  y10 = y9 * y1;
661 
662  uplus = aa[0]
663  + aa[1] * y1
664  + aa[2] * y2
665  + aa[3] * y3
666  + aa[4] * y4
667  + aa[5] * y5
668  + aa[6] * y6
669  + aa[7] * y7
670  + aa[8] * y8
671  + aa[9] * y9
672  + aa[10] * y10;
673 
674  return exp(uplus);
675 }
676 
677 /*----------------------------------------------------------------------------*/
712 /*----------------------------------------------------------------------------*/
713 
714 inline static void
715 cs_wall_functions_2scales_vdriest(cs_real_t rnnb,
716  cs_real_t l_visc,
717  cs_real_t vel,
718  cs_real_t y,
719  cs_real_t kinetic_en,
720  int *iuntur,
721  cs_lnum_t *nsubla,
722  cs_lnum_t *nlogla,
723  cs_real_t *ustar,
724  cs_real_t *uk,
725  cs_real_t *yplus,
726  cs_real_t *ypup,
727  cs_real_t *cofimp,
728  cs_real_t *lmk,
729  cs_real_t kr,
730  bool wf)
731 {
732  double urplus, d_up, lmk15;
733 
734  if (wf)
735  *uk = sqrt(sqrt((1.-cs_turb_crij2)/cs_turb_crij1 * rnnb * kinetic_en));
736 
737  /* Set a low threshold value in case tangential velocity is zero */
738  *yplus = CS_MAX(*uk * y / l_visc, 1.e-4);
739 
740  /* Dimensionless roughness */
741  cs_real_t krp = *uk * kr / l_visc;
742 
743  /* Extension of Van Driest mixing length according to Rotta (1962) with
744  Cebeci & Chang (1978) correlation */
745  cs_real_t dyrp = 0.9 * (sqrt(krp) - krp * exp(-krp / 6.));
746  cs_real_t yrplus = *yplus + dyrp;
747 
748  if (dyrp <= 1.e-1)
749  d_up = dyrp;
750  else if (dyrp <= 200.)
751  d_up = _vdriest_dupdyp_integral(dyrp);
752  else
753  d_up = 16.088739022054590 + log(dyrp/200.) / cs_turb_xkappa;
754 
755  if (yrplus <= 1.e-1) {
756 
757  urplus = yrplus;
758 
759  if (wf) {
760  *iuntur = 0;
761  *nsubla += 1;
762 
763  *lmk = 0.;
764 
765  *ypup = 1.;
766 
767  *cofimp = 0.;
768  }
769 
770  } else if (yrplus <= 200.) {
771 
772  urplus = _vdriest_dupdyp_integral(yrplus);
773 
774  if (wf) {
775  *nlogla += 1;
776 
777  *ypup = *yplus / (urplus-d_up);
778 
779  /* Mixing length in y+ */
780  *lmk = cs_turb_xkappa * (*yplus) *(1-exp(- (*yplus) / cs_turb_vdriest));
781 
782  /* Mixing length in 3/2*y+ */
783  lmk15 = cs_turb_xkappa * 1.5 * (*yplus) *(1-exp(- 1.5 * (*yplus)
784  / cs_turb_vdriest));
785 
786  *cofimp = 1. - (2. / (1. + *lmk) - 1. / (1. + lmk15)) * *ypup;
787  }
788 
789  } else {
790 
791  urplus = 16.088739022054590 + log(yrplus/200) / cs_turb_xkappa;
792 
793  if (wf) {
794  *nlogla += 1;
795 
796  *ypup = *yplus / (urplus-d_up);
797 
798  /* Mixing length in y+ */
799  *lmk = cs_turb_xkappa * (*yplus) *(1-exp(- (*yplus) / cs_turb_vdriest));
800 
801  /* Mixing length in 3/2*y+ */
802  lmk15 = cs_turb_xkappa * 1.5 * (*yplus) *(1-exp(- 1.5 * (*yplus)
803  / cs_turb_vdriest));
804 
805  *cofimp = 1. - (2. / *lmk - 1. / lmk15) * *ypup;
806  }
807 
808  }
809 
810  *ustar = vel / (urplus-d_up);
811 }
812 
813 /*----------------------------------------------------------------------------*/
846 /*----------------------------------------------------------------------------*/
847 
848 inline static void
849 cs_wall_functions_2scales_smooth_rough(cs_real_t l_visc,
850  cs_real_t t_visc,
851  cs_real_t vel,
852  cs_real_t y,
853  cs_real_t rough_d,
854  cs_real_t kinetic_en,
855  int *iuntur,
856  cs_lnum_t *nsubla,
857  cs_lnum_t *nlogla,
858  cs_real_t *ustar,
859  cs_real_t *uk,
860  cs_real_t *yplus,
861  cs_real_t *dplus,
862  cs_real_t *ypup,
863  cs_real_t *cofimp)
864 {
865  CS_UNUSED(iuntur);
866 
867  const double ypluli = cs_glob_wall_functions->ypluli;
868 
869  double rcprod, ml_visc, Re, g;
870 
871  /* Compute the friction velocity ustar */
872 
873  /* Shifting of the wall distance to be consistant with
874  * the fully rough wall function
875  *
876  * ln((y+y0)/y0) = ln((y+y0)/alpha xi) + kappa * 5.2
877  *
878  * y0 = xi * exp(-kappa * 8.5)
879  * where xi is the sand grain roughness here
880  * y0 = alpha * xi * exp(-kappa * 5.2)
881  *
882  * so:
883  * alpha = exp(-kappa * (8.5 - 5.2)) = 0.25
884  *
885  */
886  cs_real_t y0 = rough_d;
887  /* Sand grain roughness */
888  cs_real_t sg_rough = rough_d * exp(cs_turb_xkappa*cs_turb_cstlog_rough);
889 
890  /* Blending for very low values of k */
891  Re = sqrt(kinetic_en) * (y + y0) / l_visc;
892  g = exp(-Re/11.);
893 
894  *uk = sqrt( (1.-g) * cs_turb_cmu025 * cs_turb_cmu025 * kinetic_en
895  + g * l_visc * vel / (y + y0));
896 
897 
898  *yplus = *uk * y / l_visc;
899 
900  /* As for scalable wall functions, yplus is shifted of "dplus" */
901  *dplus = *uk * y0 / l_visc;
902 
903  /* Shift of the velocity profile due to roughness */
904  cs_real_t shift_vel = -log(1. + cs_turb_cstlog_alpha * sg_rough * *uk/l_visc)
905  / cs_turb_xkappa;
906 
907  /* Log layer and shifted with the roughness */
908  if (*yplus > ypluli) {
909 
910  *nlogla += 1;
911 
912  }
913 
914  /* Viscous sub-layer and therefore shift again */
915  else {
916 
917  *dplus = ypluli - *yplus;
918  /* Count the cell as if it was in the viscous sub-layer */
919  *nsubla += 1;
920 
921  }
922 
923  cs_real_t uplus = log(*yplus + *dplus) / cs_turb_xkappa + cs_turb_cstlog + shift_vel;
924  *ustar = vel / uplus;
925 #if 0
926  bft_printf("uet=%f, u=%f, uplus=%f, yk=%f, vel=%f, duplus=%f\n", *ustar, vel, uplus, *yplus, vel, 1./uplus);
927 #endif
928  *ypup = *yplus / uplus;
929 
930  /* Mixing length viscosity, compatible with both regimes */
931  ml_visc = cs_turb_xkappa * *uk * (y + y0);
932  rcprod = CS_MIN(cs_turb_xkappa, CS_MAX(1., sqrt(ml_visc / t_visc)) / *yplus);
933  *cofimp = 1. - *yplus / uplus
934  / cs_turb_xkappa * ( 2. * rcprod - 1. / (2. * *yplus + *dplus));
935 
936 }
937 
938 /*----------------------------------------------------------------------------*/
958 /*----------------------------------------------------------------------------*/
959 
960 inline static void
961 cs_wall_functions_disabled(cs_real_t l_visc,
962  cs_real_t t_visc,
963  cs_real_t vel,
964  cs_real_t y,
965  int *iuntur,
966  cs_lnum_t *nsubla,
967  cs_lnum_t *nlogla,
968  cs_real_t *ustar,
969  cs_real_t *uk,
970  cs_real_t *yplus,
971  cs_real_t *dplus,
972  cs_real_t *ypup,
973  cs_real_t *cofimp)
974 {
975  CS_UNUSED(t_visc);
976  CS_UNUSED(nlogla);
977  CS_UNUSED(dplus);
978 
979  const double ypluli = cs_glob_wall_functions->ypluli;
980 
981  /* Compute the friction velocity ustar */
982 
983  *ustar = sqrt(vel * l_visc / y);
984  *yplus = *ustar * y / l_visc;
985  *uk = *ustar;
986  *ypup = 1.;
987  *cofimp = 0.;
988  *iuntur = 0;
989 
990  if (*yplus <= ypluli) {
991 
992  /* Disable the wall funcion count the cell in the viscous sub-layer */
993  *nsubla += 1;
994 
995  } else {
996 
997  /* Count the cell as if it was in the viscous sub-layer */
998  *nsubla += 1;
999 
1000  }
1001 }
1002 
1003 /*----------------------------------------------------------------------------*/
1033 /*----------------------------------------------------------------------------*/
1034 
1035 inline static void
1036 cs_wall_functions_s_arpaci_larsen(cs_real_t l_visc,
1037  cs_real_t prl,
1038  cs_real_t prt,
1039  cs_real_t rough_t,
1040  cs_real_t uk,
1041  cs_real_t yplus,
1042  cs_real_t dplus,
1043  cs_real_t *htur,
1044  cs_real_t *yplim)
1045 {
1046  /* Local variables */
1047  double tplus;
1048  double beta2,a2;
1049  double yp2;
1050  double prlm1;
1051 
1052  const double epzero = cs_math_epzero;
1053 
1054  /*==========================================================================
1055  1. Initializations
1056  ==========================================================================*/
1057 
1058  (*htur) = CS_MAX(yplus,epzero)/CS_MAX(yplus+dplus,epzero);
1059 
1060  prlm1 = 0.1;
1061 
1062  /* Sand grain roughness is:
1063  * zeta = z0 * exp(kappa 8.5)
1064  * Then:
1065  * hp = zeta uk / nu * exp( -kappa(8.5 - 5.2))
1066  * = z0 * uk / nu * exp(kappa * 5.2)
1067  * where 5.2 is the smooth log constant, and 8.5 the rough one
1068  *
1069  * FIXME check if we should use a molecular Schmidt number
1070  */
1071  cs_real_t hp = rough_t *uk / l_visc * exp(cs_turb_xkappa*cs_turb_cstlog);
1072 
1073  /* Shift of the temperature profile due to roughness */
1074  cs_real_t shift_temp = -log(1. + hp);
1075 
1076  /*==========================================================================
1077  2. Compute htur for small Prandtl numbers
1078  ==========================================================================*/
1079 
1080  if (prl <= prlm1) {
1081  (*yplim) = prt/(prl*cs_turb_xkappa);
1082  if (yplus > (*yplim)) {
1083  tplus = prl*(*yplim) + prt/cs_turb_xkappa * (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 
1137 inline static void
1138 cs_wall_functions_s_vdriest(cs_real_t prl,
1139  cs_real_t prt,
1140  cs_real_t yplus,
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_MIN(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_MAX((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 
1202 inline static void
1203 cs_wall_functions_s_smooth_rough(cs_real_t l_visc,
1204  cs_real_t prl,
1205  cs_real_t prt,
1206  cs_real_t rough_t,
1207  cs_real_t uk,
1208  cs_real_t yplus,
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 
1227  (*htur) = CS_MAX(yplus,epzero)/CS_MAX(yplus+dplus,epzero);
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 + cs_turb_cstlog);
1234  (*htur) = prl * yplus / tplus;
1235  }
1236 }
1237 
1238 /*============================================================================
1239  * Public function definitions for Fortran API
1240  *============================================================================*/
1241 
1242 /*----------------------------------------------------------------------------
1243  * Wrapper to cs_wall_functions_velocity.
1244  *----------------------------------------------------------------------------*/
1245 
1246 void CS_PROCF (wallfunctions, WALLFUNCTIONS)
1247 (
1248  const int *const iwallf,
1249  const cs_lnum_t *const ifac,
1250  const cs_real_t *const viscosity,
1251  const cs_real_t *const t_visc,
1252  const cs_real_t *const vel,
1253  const cs_real_t *const y,
1254  const cs_real_t *const rough_d,
1255  const cs_real_t *const rnnb,
1256  const cs_real_t *const kinetic_en,
1257  int *iuntur,
1258  cs_lnum_t *nsubla,
1259  cs_lnum_t *nlogla,
1260  cs_real_t *ustar,
1261  cs_real_t *uk,
1262  cs_real_t *yplus,
1263  cs_real_t *ypup,
1264  cs_real_t *cofimp,
1265  cs_real_t *dplus
1266 );
1267 
1268 /*----------------------------------------------------------------------------
1269  * Wrapper to cs_wall_functions_scalar.
1270  *----------------------------------------------------------------------------*/
1271 
1272 void CS_PROCF (hturbp, HTURBP)
1273 (
1274  const int *const iwalfs,
1275  const cs_real_t *const l_visc,
1276  const cs_real_t *const prl,
1277  const cs_real_t *const prt,
1278  const cs_real_t *const rough_t,
1279  const cs_real_t *const uk,
1280  const cs_real_t *const yplus,
1281  const cs_real_t *const dplus,
1282  cs_real_t *htur,
1283  cs_real_t *yplim
1284 );
1285 
1286 /*=============================================================================
1287  * Public function prototypes
1288  *============================================================================*/
1289 
1290 /*----------------------------------------------------------------------------
1291  *! \brief Provide access to cs_glob_wall_functions
1292  *----------------------------------------------------------------------------*/
1293 
1296 
1297 /*----------------------------------------------------------------------------*/
1325 /*----------------------------------------------------------------------------*/
1326 
1327 void
1329  cs_lnum_t ifac,
1330  cs_real_t l_visc,
1331  cs_real_t t_visc,
1332  cs_real_t vel,
1333  cs_real_t y,
1334  cs_real_t rough_d,
1335  cs_real_t rnnb,
1336  cs_real_t kinetic_en,
1337  int *iuntur,
1338  cs_lnum_t *nsubla,
1339  cs_lnum_t *nlogla,
1340  cs_real_t *ustar,
1341  cs_real_t *uk,
1342  cs_real_t *yplus,
1343  cs_real_t *ypup,
1344  cs_real_t *cofimp,
1345  cs_real_t *dplus);
1346 
1347 /*----------------------------------------------------------------------------*/
1372 /*----------------------------------------------------------------------------*/
1373 
1374 void
1376  cs_real_t l_visc,
1377  cs_real_t prl,
1378  cs_real_t prt,
1379  cs_real_t rough_t,
1380  cs_real_t uk,
1381  cs_real_t yplus,
1382  cs_real_t dplus,
1383  cs_real_t *htur,
1384  cs_real_t *yplim);
1385 
1386 /*----------------------------------------------------------------------------*/
1387 
1389 
1390 #endif /* __CS_WALL_FUNCTIONS_H__ */
const double cs_turb_cstlog_rough
Definition: cs_turbulence_model.c:418
const double cs_turb_xkappa
Definition: cs_turbulence_model.c:387
int itytur
Definition: cs_turbulence_model.h:138
double precision epzero
epsilon
Definition: cstnum.f90:40
Definition: cs_wall_functions.h:75
cs_wall_f_type_t iwallf
Definition: cs_wall_functions.h:89
cs_turb_model_t * cs_get_glob_turb_model(void)
Provide write access to turbulence model structure.
Definition: cs_turbulence_model.c:1432
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
integer(c_int), pointer, save iwalfs
Wall functions for scalar.
Definition: optcal.f90:567
const cs_real_t cs_math_epzero
Turbulence model general options descriptor.
Definition: cs_turbulence_model.h:114
#define CS_UNUSED(x)
Definition: cs_defs.h:481
double cs_turb_cmu025
Definition: cs_turbulence_model.c:449
cs_wall_functions_t * cs_get_glob_wall_functions(void)
Definition: cs_wall_functions.c:306
Definition: cs_wall_functions.h:76
Definition: cs_wall_functions.h:63
double precision, dimension(ncharm), save a2
Definition: cpincl.f90:233
double cs_turb_cmu
Definition: cs_turbulence_model.c:446
Definition: cs_wall_functions.h:79
Definition: cs_wall_functions.h:62
double cs_turb_dpow
Definition: cs_turbulence_model.c:438
double cs_real_t
Floating-point value.
Definition: cs_defs.h:307
const double cs_turb_bpow
Definition: cs_turbulence_model.c:435
Definition: cs_field_pointer.h:68
Definition: cs_wall_functions.h:64
void hturbp(const int *const iwalfs, const cs_real_t *const l_visc, const cs_real_t *const prl, const cs_real_t *const prt, const cs_real_t *const rough_t, const cs_real_t *const uk, const cs_real_t *const yplus, const cs_real_t *const dplus, cs_real_t *htur, cs_real_t *yplim)
Definition: cs_wall_functions.c:270
double cs_turb_crij2
Definition: cs_turbulence_model.c:486
cs_wall_f_s_type_t
Definition: cs_wall_functions.h:73
Definition: cs_wall_functions.h:66
const double cs_turb_vdriest
Definition: cs_turbulence_model.c:396
Definition: cs_wall_functions.h:61
Definition: cs_wall_functions.h:78
double cs_turb_cstlog_alpha
Definition: cs_turbulence_model.c:429
#define CS_MIN(a, b)
Definition: cs_defs.h:458
real(c_double), pointer, save ypluli
limit value of for the viscous sublayer. ypluli depends on the chosen wall function: it is initializ...
Definition: cstphy.f90:303
integer(c_int), pointer, save iwallf
Wall functions Indicates the type of wall function used for the velocity boundary conditions on a fri...
Definition: optcal.f90:562
Definition: cs_wall_functions.h:65
double cs_turb_crij1
Definition: cs_turbulence_model.c:480
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:301
Definition: cs_wall_functions.h:69
#define END_C_DECLS
Definition: cs_defs.h:496
wall functions descriptor.
Definition: cs_wall_functions.h:87
#define _(String)
Definition: cs_defs.h:66
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.c:540
Definition: cs_wall_functions.h:80
Definition: cs_wall_functions.h:68
const double cs_turb_cstlog
Definition: cs_turbulence_model.c:407
#define CS_PROCF(x, y)
Definition: cs_defs.h:509
#define CS_MAX(a, b)
Definition: cs_defs.h:459
int iwallt
Definition: cs_wall_functions.h:93
int bft_printf(const char *const format,...)
Replacement for printf() with modifiable behavior.
Definition: bft_printf.c:140
cs_wall_f_s_type_t iwalfs
Definition: cs_wall_functions.h:91
double precision, dimension(4, npot), save ka
Definition: ppcpfu.f90:159
Definition: cs_field_pointer.h:71
double ypluli
Definition: cs_wall_functions.h:98
cs_wall_f_type_t
Definition: cs_wall_functions.h:59
Definition: cs_wall_functions.h:77
void cs_wall_functions_velocity(cs_wall_f_type_t iwallf, cs_lnum_t ifac, 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, int *iuntur, cs_lnum_t *nsubla, cs_lnum_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)
Compute the friction velocity and / .
Definition: cs_wall_functions.c:340
const cs_wall_functions_t * cs_glob_wall_functions
void wallfunctions(const int *const iwallf, const cs_lnum_t *const ifac, const cs_real_t *const viscosity, const cs_real_t *const t_visc, const cs_real_t *const vel, const cs_real_t *const y, const cs_real_t *const rough_d, const cs_real_t *const rnnb, const cs_real_t *const kinetic_en, int *iuntur, cs_lnum_t *nsubla, cs_lnum_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)
Definition: cs_wall_functions.c:222
Definition: cs_field_pointer.h:242
Definition: cs_wall_functions.h:67
const double cs_turb_apow
Definition: cs_turbulence_model.c:432