Using Tools > Working with User Code > User Function Interface Reference (C) > Specifying the Precision of Floating-Point Variables in C

Your Ad Here




Specifying the Precision of Floating-Point Variables in C

STAR-CCM+ simulations may be run in single- or double-precision. This defines whether generic floating-point variables are float or double, in C terms. Coordinates, such as centroid positions, are always double-precision. The implication of this for user functions is that floating-point arguments which are exchanged with STAR-CCM+ must be declared with the correct precision. The convention in this documentation is that generic floating-point variables are declared Real and strictly double-precision variables are declared CoordReal. These two types are defined in the header file Real.h:

  #ifndef REAL_H
  #define REAL_H
  
  #if DOUBLE_PRECISION
  typedef double Real;
  #else
  typedef float Real;
  #endif
  
  typedef double CoordReal;
  #endif

The file should be created in the same directory as the user functions. For double-precision simulations, the macro DOUBLE_PRECISION should be defined in the compilation flags.

Return to CD-adapco STAR-CCM+ Index


Your Ad Here