Udfs 2019
Udfs 2019
NOTE: The Microsoft Visual Studio compilers are generally NOT free of charge. Please read the Microsoft
agreements for restrictions or licenses needed or contact your IT Department
Table of Contents
1
https://www.microsoft.com/en-us/download/details.aspx?id=49077
If you do not have this patch you will get this error when trying to compile Fluent UDFs
fatal error: Cannot open include file 'stdio.h': No such file or directory
ANSYS is not responsible for the correct installation of Microsoft Visual Studio. If you have issues
installing the compiler, please contact Microsoft or your IT staff.
NOTE: You will need to choose the selection in RED as well as the optional components on the
right hand side of the screenshot for the SDK, etc.
Download a UDF Batch File Fix for running Fluent without using the SDK
Window
1. In order to use the 2019 compiler with Fluent (until the release of 2020) you will need to
download the attached file, udf-batch-file-2019.
2. Browse to C:\Program Files\ANSYS Inc\v19.x\fluent\ntbin\win64 and rename the existing
udf.bat.
2
3. Rename udf-batch-file-2019 to udf.bat and place it in the C:\Program Files\ANSYS 4.
Inc\v19.x\fluent\ntbin\win64 directory
Note: The v19.x is an example. If you are running any other version of Fluent browse to the
appropriate v##.# directory.
1. Share the “ANSYS Inc” folder located at C:\Program Files\ANSYS Inc\v19.x with Full Control
3
2. Create a working directory that contains the ANSYS 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.
3. Share the Working directory folder with Full Control
4. Map a drive letter to the shared folder, for example, U:\ (When compiling UDFs and
running in parallel (across machines) 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.)
4
10. Click OK to launch ANSYS Fluent
5
17. Select Build
18. Select Load
19. After you have compiled the UDF the working folder will include a new subfolder called
libudf.
Compiling ANSYS Fluent UDFs from the Command Line using the Visual
Studio 2019 x64 Native Tools Command Prompt window
1. Open up the Visual Studio 2019 x64 Native Tools Command Prompt window and change to your
working directory where your case and data reside.
3. Drag the ANSYS Fluent shortcut into the x64 Native tools Command Prompt window.
6
4. Press Enter
5. ANSYS Fluent launches.
6. Follow the procedures below for compiling UDFs
NOTE: If you are compiling from the x64 Native Tools Command Prompt then you must uncheck
this box when Fluent launches. Choose the Environment Tab, uncheck “Set up Compilation
Environment for UDF”. If you have replaced the udf.bat file as noted above, do not uncheck
this box.
7
2. Read in your model
3. Select the Console tab (at the bottom of the Fluent window)
4. Select the User Defined tab
5. Choose Functions > Compiled
6. Select the Add button to add your source file (.c)
7. Select Build
8. Select Load
1. Share the “ANSYS Inc” folder located at C:\Program Files\ANSYS Inc\v19.x with Full Control
2. Create a working directory that contains the ANSYS 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.
3. Share the Working directory folder with Full Control
4. Map a drive letter to the shared folder, for example, U:\ (When compiling UDFs and
running in parallel (across machines) 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.)
8
Launching and Configuring ANSYS Fluent to run across Multiple
Computers and Compile UDFs
1. Launch ANSYS Fluent
2. Select Show More Options from the ANSYS Fluent Launcher.
3. Set your Working Directory to the shared, mapped drive letter that you created earlier
4. Change the Fluent Root Path to in UNC format with the Computer_name\and the Shared
ANSYS Inc directory, for example, \\Computer_name\ANSYS Inc\v19.x\fluent
5. Select Parallel under Processing Options and then enter the Number of Processes you will
be using.
9
11. Read in your model
12. Select the Console tab (at the bottom of the Fluent window)
13. Select the User Defined tab
14. Choose Functions > Compiled
15. Select the Add button to add your source file (.c)
10