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

1.5 Interpreting and Compiling UDFs

Source code files containing UDFs can be either interpreted or compiled in ANSYS FLUENT. In both cases the functions are compiled, but the way in which the source code is compiled, and the code that results from the compilation process is different for the two methods. These differences are explained below.



Compiled UDFs


Compiled UDFs are built in the same way that the ANSYS FLUENT executable itself is built. A script called Makefile is used to invoke the system C compiler to build an object code library . You initiate this action in the Compiled UDFs dialog box by clicking the Build button. The object code library contains the native machine language translation of your higher-level C source code. The shared library must then loaded into ANSYS FLUENT at runtime by a process called "dynamic loading.'' You initiate this action in the Compiled UDFs dialog box by clicking the Load button. The object libraries are specific to the computer architecture being used, as well as to the particular version of the ANSYS FLUENT executable being run. The libraries must, therefore, be rebuilt any time ANSYS FLUENT is upgraded, when the computer's operating system level changes, or when the job is run on a different type of computer.

In summary, compiled UDFs are compiled from source files using the graphical user interface, in a two-step process. The process involves the Compiled UDFs dialog box, where you first build a shared library object file from a source file, and then load the shared library that was just built into ANSYS FLUENT.



Interpreted UDFs


Interpreted UDFs are interpreted from source files using the graphical user interface, but in a single-step process. The process, which occurs at runtime, involves a visit to the Interpreted UDFs dialog box where you Interpret a source file.

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.

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:




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