[ANSYS, Inc. Logo] return to home search
next up previous contents index

1.4 Defining Your UDF Using DEFINE Macros

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 for a listing). For a complete description of each DEFINE macro and an example of its usage, refer to Chapter  2.

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. The name that you choose for your UDF will become visible and selectable in drop-down lists in graphical user interface dialog boxes in ANSYS FLUENT, after the function has been interpreted or compiled. 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 (e.g., inlet_x_velocity) will become visible and selectable in drop-down lists in the appropriate boundary condition dialog box (e.g., Velocity Inlet) in ANSYS FLUENT.

figure   

Note that 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 .

figure   

Make sure that there are no spaces between the macro (e.g., DEFINE_PROFILE) and the first parenthesis of the arguments, as this will cause an error in Windows.

figure   

Do not include a DEFINE macro statement (e.g., DEFINE_PROFILE) within a comment in your source code. This will cause a compilation error .




next up previous contents index Previous: 1.3 Limitations
Up: 1. Overview
Next: 1.4.1 Including the udf.h
Release 12.0 © ANSYS, Inc. 2009-01-14