CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

what does the function min() do???

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 9, 2009, 19:54
Default what does the function min() do???
  #1
Member
 
Sven Winkler
Join Date: May 2009
Posts: 70
Rep Power: 16
sven is on a distinguished road
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!
sven is offline   Reply With Quote

Old   November 9, 2009, 21:41
Default
  #2
Member
 
Simon Lapointe
Join Date: May 2009
Location: Québec, Qc, Canada
Posts: 33
Rep Power: 16
Simon Lapointe is on a distinguished road
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.
Simon Lapointe is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 09:31
[blockMesh] BlockMesh FOAM warning gaottino OpenFOAM Meshing & Mesh Conversion 7 July 19, 2010 14:11
Error with Wmake skabilan OpenFOAM Installation 3 July 28, 2009 00:35
On the damBreak4phaseFine cases paean OpenFOAM Running, Solving & CFD 0 November 14, 2008 21:14
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 14:00


All times are GMT -4. The time now is 02:18.