Compiling and Loading UDFs Ansys Fluent
Compiling and Loading UDFs Ansys Fluent
Reaction rates
Source terms
Customized post-processing
More
UDFs can either be compiled or interpreted. Fluent is bundled with a C++ interpreter that can be used to
interpret UDFs. To compile UDFs, you can use Microsoft Visual Studio (Express or Professional Editions)
under Windows. Most Linux systems provide a C compiler as a standard feature.
Here are a few important differences between an interpreted code vs. a compiled code:
Interpreted:
Compiled:
Creates shared libraries which are linked with the rest of the solver
Does require a compilation step between creating/editing your UDF and using it
In some situation you need to compile your code. To do so, you will need to configure Visual Studio to
become accessible from Fluent. The following steps will help you achieve this:
1. ANSYS did not provide support for the 2012 compiler until Release 15. In order to use the 2012
compiler and compile Fluent UDFs using the Fluent Launcher and if you are running Fluent 14.5 you will
need to download the attached file, udf-batch-file-fixed-for-2012. If you are running Fluent 15 you do not
need to do this.
2. Browse to C:\Program Files\ANSYS Inc\v145\fluent\ntbin\win64 and rename udf.bat.
3. Rename udf-batch-file-fixed-for-2012 to udf.bat and place it in the C:\Program Files\ANSYS
Inc\v145\fluent\ntbin\win64 directory.
4. Download and Install Microsoft Visual Studio 2012 Express for Windows Desktop
http://www.microsoft.com/en-us/download/details.aspx?id=34673 (If this link is not active do an Internet
search for: Download Microsoft Visual Studio 2012 Express for Windows Desktop
NOTE: If you are running ANSYS Fluent serial and not parallel you can stop here and compile
without taking any further steps.
5. Share the fluent folder located at: C:\Program Files\Ansys Inc\v145\fluent or: C:\Program Files\Ansys
Inc\v150\fluent
6. Create a working directory that contains the FLUENT case, data files and UDF source code files. DO
NOT COMPILE OR LOAD UDFS FROM FOLDERS WITH SPACES IN THE NAME AND DO NOT
INCLUDE SPACES IN THE NAME OF YOUR CASE AND DATA FILES.
7. Share the Working directory folder.
Follow these steps to share a folder:
Right-click on the folder and choose Properties, then select the Sharing tab.
Click Advanced Sharing
Check Share this folder, then click Permissions
Check Allow on the Full Control row
Make sure that you have Full Control
Click Apply, OK
8. Map a drive letter to the shared folder, for example, Z:\ (When compiling UDFs and running in parallel
you must use a mapped drive letter to the shared folder. FLUENT will use this shared folder as its
Working Directory in the FLUENT Launcher.)
Follow these steps to map a drive:
There are several ways to map a drive letter. After the working directory is shared with Full
Control, right-click on Computer (My Computer) and choose Map Network Drive.
Enter in your computer name and the share name as shown in the image below.
NOTE: If you have problems with any of these steps please contact your local IT department.
5. Select OK to start FLUENT, then select Define > User Defined > Functions > Compiled.
6. Select the Add button to add your source file.
7. Select Build.
8. After the UDF has been successfully built it is necessary to type in the network path to the compiled
UDF in the Library Name panelBEFORE loading the UDF.
9. In front of the folder, libudf, type in the name of the computer where the UDF resides using the UNC
format and the name of the shared folder. In the example below, the shared folder name is "working.
10. Click Load.
After you have compiled the UDF the working folder will include a new subfolder called libudf.
3. Start Fluent from the command line. You may need to put Fluent on path or call Fluent directly call it
from your installation folder:
http://www.simutechgroup.com/CFD/compiling-and-loading-user-defined-functionsusing-fluent-14-5-or-15-0.html