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

5.1 Introduction

Compiled UDFs are built in the same way that the ANSYS FLUENT executable itself is built. Internally, a script called Makefile is used to invoke the system C compiler to build an object code library that contains the native machine language translation of your higher-level C source code. The object library is specific to the computer architecture being used during the ANSYS FLUENT session, as well as to the particular version of the ANSYS FLUENT executable being run. Therefore, UDF object libraries must 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 architecture. The generic process for compiling a UDF involves two steps: compile/build and load.

The compile/build step takes one or more source files (e.g., myudf.c) containing at least one UDF and compiles them into object files (e.g., myudf.o or myudf.obj) and then builds a "shared library" (e.g., libudf) with the object files. If you compile your source file using the GUI, this compile/build process is executed when you click the Build button in the Compiled UDFs dialog box. The shared library that you name (e.g., libudf) is automatically built for the architecture and version of ANSYS FLUENT you are running during that session (e.g., hpux11/2d), and will store the UDF object file(s).

If you compile your source file using the TUI, you will first need to setup target folders for the shared libraries, modify a file named makefile to specify source parameters, and then execute the Makefile which directs the compile/build process. Compiling a UDF using the TUI has the added advantage of allowing precompiled object files derived from non- ANSYS FLUENT sources to be linked to ANSYS FLUENT (Section  5.4). This option is not available using the GUI.

After the shared library is built (using the TUI or GUI) you will need to load the UDF library into ANSYS FLUENT before you can use it. This can be done using the Load button in the Compiled UDFs dialog box. After being loaded, all of the compiled UDFs that are contained within the shared library will become visible and selectable in graphics dialog boxes in ANSYS FLUENT. Note that compiled UDFs are displayed in ANSYS FLUENT dialog boxes with the associated UDF library name separated by two colons ( ::). For example, a compiled UDF named rrate that is associated with a shared library named libudf would appear in ANSYS FLUENT dialog boxes as rrate::libudf. This distinguishes UDFs that are compiled from those that are interpreted.

If you write your case file when a UDF library is loaded, the library will be saved with the case and will be automatically loaded whenever that case file is subsequently read. This process of "dynamic loading'' saves you having to reload the compiled library every time you want to run a simulation.

Before you compile your UDF source file(s) using one of the two methods provided in Sections  5.2 and 5.3, you will first need to make sure that the udf.h header file is accessible in your path, or is saved locally within your working folder (Section  5.1.1).




next up previous contents index Previous: 5. Compiling UDFs
Up: 5. Compiling UDFs
Next: 5.1.1 Location of the
Release 12.0 © ANSYS, Inc. 2009-01-14