An interpreted UDF is a function that is interpreted directly from a source file (for example, udfexample.c) at run time. You will use the Interpreted UDFs dialog box to interpret all of the functions in the source file in a single step.
After a source file is interpreted, you can write the case file, and the names and contents of the interpreted function(s) are stored in the case. In this way, the function(s) will be automatically interpreted whenever the case file is subsequently read. After it has been interpreted (either manually through the Interpreted UDFs dialog box or automatically upon reading a case file), all of the interpreted UDFs that are contained within a source file will become visible and selectable in dialog boxes in Ansys Fluent.
Inside Ansys Fluent, the source code is compiled into an intermediate, architecture-independent machine code using a C preprocessor. This machine code then executes on an internal emulator, or interpreter, when the UDF is invoked. This extra layer of code incurs a performance penalty, but allows an interpreted UDF to be shared effortlessly between different architectures, operating systems, and Ansys Fluent versions. If execution speed does become an issue, an interpreted UDF can always be run in compiled mode without modification.
For more information, see the following:
UDFs are defined using DEFINE macros
(see
DEFINE Macros) and the definitions
for DEFINE macros are included in udf.h header file. Consequently, before you can interpret
a UDF source file, udf.h will need to be accessible
in your path, or saved locally within your working folder.
The location of the udf.h file is:
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).
Important:
You should not, under any circumstances, alter the udf.h file.
In general, you should not copy udf.h from the installation area. The compiler is designed to look for this file locally (in your current folder) first. If it is not found in your current folder, the compiler will look in the \src\udf folder automatically. In the event that you upgrade your release area, but do not delete an old copy of udf.h from your working folder, you will not be accessing the most recent version of this file.
The interpreter that is used for interpreted UDFs does not have all of the capabilities of a standard C compiler (which is used for compiled UDFs). Specifically, interpreted UDFs cannot contain any of the following C programming language elements:
gotostatementsNon-ANSI-C prototypes for syntax
Direct data structure references
Declarations of local structures
Unions
Pointers to functions
Arrays of functions
Multi-dimensional arrays
In addition, the following types of macros are not supported in interpreted UDFs:
Caution: Unlike compiled UDFs, there is no filtering for interpreted UDFs in the Fluent user interface, meaning that care needs to be taken to assign the appropriate UDF type to the corresponding field. For example, an interpreted DEFINE_PROPERTY UDF can be assigned to a field that only accepts DEFINE_PROFILE UDFs, which may cause Fluent to fail at run time.