UDFs are defined using ANSYS Fluent-supplied function declarations.
These function declarations are implemented in the code as macros,
and are referred to in this document as DEFINE (all capitals) macros. Definitions for DEFINE macros are contained in the udf.h header file
(see Appendix B: DEFINE Macro Definitions for a listing). For a complete
description of each DEFINE macro and an example
of its usage, refer to
DEFINE Macros.
The general format of a DEFINE macro
is:
DEFINE_MACRONAME(udf_name, passed-in variables)
where the first argument in the parentheses is the name of the
UDF that you supply. Name arguments are case-sensitive and must be specified in lowercase. After the function has
been interpreted or compiled, the name that you choose for your UDF
will become visible and selectable in drop-down lists in ANSYS Fluent.
The second set of input arguments to the DEFINE macro are variables that are passed into your function from the ANSYS Fluent solver.
For example, the macro:
DEFINE_PROFILE(inlet_x_velocity, thread, index)
defines a boundary profile function named inlet_x_velocity with two variables, thread and index, that are passed into the function from ANSYS Fluent.
These passed-in variables are the boundary condition zone ID (as a
pointer to the thread) and the index identifying the variable that is to be stored.
After the UDF has been interpreted or compiled, its name (inlet_x_velocity) will become visible and selectable
in drop-down lists in the appropriate boundary condition dialog box
(for example, Velocity Inlet) in ANSYS Fluent.
Important: When using UDFs:
All of the arguments to a DEFINE macro need to be placed on the same line in your source code. Splitting
the DEFINE statement onto several lines will
result in a compilation error.
There must be no spaces between the macro (for example, DEFINE_PROFILE) and the first parenthesis of the arguments,
as this will cause an error in Windows.
Do not include a DEFINE macro
statement (such as DEFINE_PROFILE) within
a comment in your source code. This will cause a compilation error.