TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
LoiParUtil.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 <LoiParUtil.h>
16#include <Double.h>
17
18
19static double valmin_ss_couche_log=20;
20static double valmax_ss_couche_log=100;
21
22static inline double fn_uplus(double dplus)
23{
24 static double chi=1./0.41;
25 static double beta=5.5;
26 // if(dplus<valmin_ss_couche_log)
27 // return dplus;
28 // else
29 // if(dplus>valmax_ss_couche_log)
30 // // WARNING max depasse ...
31 return chi*log(dplus)+beta;
32 // else
33 // return chi*log(dplus)+beta;
34}
35static inline double fn_uplus_dplus(double dplus)
36{
37 return dplus*fn_uplus(dplus);
38}
39static double fn_uplus_dplus_inv(double uplusdplus)
40{
41 double b=(fn_uplus_dplus(valmax_ss_couche_log)-fn_uplus_dplus(valmin_ss_couche_log))/(valmax_ss_couche_log-valmin_ss_couche_log);
42 static double a=fn_uplus_dplus(0.5*(valmin_ss_couche_log+valmax_ss_couche_log))-b*0.5*(valmin_ss_couche_log+valmax_ss_couche_log);
43 static double seuil=1.e-12;
44 double x=(uplusdplus-a)/b;
45 double err=uplusdplus-fn_uplus_dplus(x);
46 double fx=fn_uplus_dplus(x);
47 while(std::fabs(err/b)>seuil*x)
48 {
49 b=fn_uplus_dplus(x+1)-fx;
50 x+=err/b;
51 fx=fn_uplus_dplus(x);
52 err=uplusdplus-fx;
53 }
54 return x;
55}
56
57
58
59//
60//
61//
62//
63
64double calculer_u_tau(double nu, double us, double delta, int& type_couche)
65{
66 double uplusdplus=us*delta/nu;
67 //if(fn_uplus_dplus(valmin_ss_couche_log)>=uplusdplus)
68 if(0)
69 {
70 // sous couche visqueuse :
71 type_couche=0;
72 double dplus=sqrt(uplusdplus);
73 // if(dplus > valmin_ss_couche_log)
74 // {
75 // Cerr << "PB .... " << finl;
76 // Process::exit();
77 // }
78 double uplus=uplusdplus/dplus;
79 return us/uplus;
80 }
81 else
82 //if(fn_uplus_dplus(valmax_ss_couche_log)>=uplusdplus)
83 if(1)
84 {
85 double dplus=fn_uplus_dplus_inv(uplusdplus);
86 //Cerr << "y+ = " << dplus << finl;
87 // if( (dplus < valmin_ss_couche_log) || (dplus > valmax_ss_couche_log) )
88 // {
89 // Cerr << "PB .... " << finl;
90 // Process::exit();
91 // }
92 type_couche=1;
93 double uplus=uplusdplus/dplus;
94 return us/uplus;
95 }
96 else
97 {
98 type_couche=2;
99 }
100 return -1;
101}