CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   atan(s) function. openFoam (

lulo October 7, 2011 08:23

atan(s) function. openFoam

I can see that the function atan(s) in openFoam can only give results in the 1st and 4th quadrant. (angles between -pi and +pi)

My angle can variate between 0 and 2pi.
Is there any function in openFoam which can give the right result?
I know in Matlab is called atan2(s) but openFoam does not recognise that.

Any idea???


wyldckat October 7, 2011 08:41

Hi Luca,

When in doubt about some detail like this, check the code documentation:

Here's the proof that atan2 does exist in OpenFOAM: - AFAIK it's the standard C/C++ libraries that don't have atan2.

To use it, you might need to call it by the full path name:

value = Foam::atan2(x,y);
Instead of:

value = atan2(x,y);
This last one will most likely assume that the function is a global one, i.e. if available it would be the standard C/C++ one.

Best regards,

lulo October 7, 2011 08:59

Thanks a lot.

I was trying atan2(s) but of course it needs 2 variables atan2(x,y).

Henning86 August 11, 2016 08:35

in doubleScalar it is

atan (y,x)

All times are GMT -4. The time now is 19:30.