CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Speed difference of "scalar, label" with"double, int" (https://www.cfd-online.com/Forums/openfoam-programming-development/159562-speed-difference-scalar-label-double-int.html)

sharonyue September 18, 2015 04:31

Speed difference of "scalar, label" with"double, int"
 
Hi guys,

We know that in OpenFOAM we can use label instead of int and scalar instead of double. If we just wanna to use the simple mathematical manipulation.

Is the code using double or int faster than scalar of label?

Or...std::cout is faster than Info?

Cause for now Im solving population balance model. For a mesh with 17m cells. It uses 3.12s to calculate the source term(only some tedious algebraic manipulation). 1.29 to solve NS equations. 0.29s to solve moments equations.

Thanks,

lukas.lebo April 25, 2017 07:04

Hey did you ever find out more about this? Label/Scalar vs Int/Double?

GerhardHolzinger April 25, 2017 08:00

Quote:

Originally Posted by sharonyue (Post 564548)
Hi guys,

We know that in OpenFOAM we can use label instead of int and scalar instead of double. If we just wanna to use the simple mathematical manipulation.

Is the code using double or int faster than scalar of label?

Or...std::cout is faster than Info?

Thanks,

The data type label is an int, depending on your settings either 32 or 64 bit long.
The data type scalar is a floating point number, depending on your compiler settings, either a float (32bit) or double (64bit).

Study the source code in $FOAM_SRC/OpenFOAM/primitives/ints and $FOAM_SRC/OpenFOAM/primitives/Scalar

The Info keyword, widely used in OpenFOAM, at some point will use std::cout.

So, label, scalar and Info is there for our convenience. There should be no performance penalty.


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