CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   what does the function min() do??? (https://www.cfd-online.com/Forums/openfoam/69934-what-does-function-min-do.html)

sven November 9, 2009 19:54

what does the function min() do???
 
Somewhere in the source Code of a turbulence model I found something which I dont understand. Unfortunately the understanding of this line is crucial to what I am doing. The line I am talking about is

Code:

P[faceCelli] *=
                    min(G[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL), 1.0);

What I dont understand are the following things:

  • what is SMALL? A variable a function??
  • what does the function min do? Does it select eitherG[faceCelli]/(0.5*mag(tr(P[faceCelli])) + SMALL) or 1.0, depending on which value is the smaller one
If I do some more source Code searching, I find


Code:

inline retType min(const type1 s1, const type2 s2) \
{                                                  \
    return (s1 < s2)? s1: s2;                      \
}

Can someone understand this?

Thank you very much!

Simon Lapointe November 9, 2009 21:41

Hi,

min(a,b) returns the smallest value between a and b. SMALL stands for a small finite value, in this case it is used to avoid a possible division by 0.


All times are GMT -4. The time now is 14:07.