The UDF interpreter supports C preprocessor directives including
#define and #include.
When you use the #define macro substitution
directive, the C preprocessor (for example, cpp) performs a simple substitution and expands the occurrence of each
argument in macro using the replacement-text.
#define macro replacement-text
For example, the macro substitution directive given by
#define RAD 1.2345
will cause the preprocessor to replace all instances of the
variable RAD in your UDF with the number
1.2345. There may be many references to
the variable RAD in your function, but you
only have to define it once in the macro directive; the preprocessor
does the work of performing the substitution throughout your code.
In another example
#define AREA_RECTANGLE(X,Y) ((X)*(Y))
all of the references to AREA_RECTANGLE(X,Y) in your UDF are replaced by the product of (X) and (Y).
When you use the #include file inclusion
directive, the C preprocessor replaces the line #include filename with the contents of the named file.
#include "filename"The file you name must reside in your current folder. The only
exception to this rule is the udf.h file,
which is read automatically by the Ansys Fluent solver.
For example, the file inclusion directive given by
#include "udf.h"
will cause the udf.h file to be included with your source code.
The Ansys Fluent solver automatically reads the udf.h file from the following folder:
path\ANSYS
Inc\v242\fluent\fluent24.2.0\src\udf\udf.h
where
path
is
the folder in which you have installed Ansys Fluent (by default, the
path is C:\Program Files).