You are on page 1of 10

Compiling and Loading User Defined Functions using

Fluent and Microsoft Visual Studio 2017 Community


(free) Edition running ANSYS Fluent in Serial and
Parallel
This document assumes that you have Administrator rights and know how to Share folders and Map
drives. If you do not please consult with your local IT personnel. Microsoft Visual Studio 2017 is not
officially supported for any current ANSYS Fluent release. It will be officially supported with ANSYS
Fluent 18.2 but can be used by following the instructions below. Alternatively, Microsoft Visual Studio
2017 will work if you launch Fluent from the Command Line using the Visual Studio 2017 x86 x64 Cross
Tools Command Prompt

Table of Contents

Downloading and Installing Microsoft Visual Studio 2017 Community ....................................................... 1


Download a UDF Batch File Fix for running Fluent without using the SDK Window .................................... 2
Compiling Fluent UDFs in serial or SMP (Shared Memory) .......................................................................... 3
Compiling Fluent UDFs in DMP (Distributed Memory) on Multiple Computers .......................................... 3
Launching and Configuring ANSYS Fluent to run across Multiple Computers and Compile UDFs ............... 4
Compiling ANSYS Fluent UDFs from the Command Line using the Visual Studio 2017 x86 x64 Cross Tools
Command Prompt (if using an earlier version of Fluent than Release 18.2) ................................................ 6
Compiling Fluent UDFs in serial or SMP (Shared Memory) .......................................................................... 7
Compiling Fluent UDFs in DMP (Distributed Memory) on Multiple Computers .......................................... 8
Launching and Configuring ANSYS Fluent to run across Multiple Computers and Compile UDFs ............... 8

Downloading and Installing Microsoft Visual Studio 2017 Community


Download and Install Microsoft Visual Studio 2017 Community
https://www.visualstudio.com/downloads/

1
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 2017 compiler with Fluent (until the release of 18.2) you will need to
download the attached file, udf-batch-file-2017.
2. Browse to C:\Program Files\ANSYS Inc\v18.x\fluent\ntbin\win64 and rename the existing
udf.bat.
3. Rename udf-batch-file-2017 to udf.bat and place it in the C:\Program Files\ANSYS
4. Inc\v18.x\fluent\ntbin\win64 directory

2
Note: The v18.x is an example. If you are running version 16 or 17 just browse to the correct
directory.

Compiling Fluent UDFs in serial or SMP (Shared Memory)


1. Launch Fluent ensuring that your Working Directory is set to the location where your
case, data and UDF is located in.
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

Compiling Fluent UDFs in DMP (Distributed Memory) on Multiple


Computers
NOTE: If you running the ANSYS Fluent solver on multiple computers and will be compiling and loading
UDFs you need to follow the steps below. If you are running in local parallel you do not need to share
and map drives. Follow the steps above except choose Parallel and the number of cores (processes) you
wish to run on.
1. Share the ANSYS Inc folder located at C:\Program Files\ANSYS Inc\v18.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.)

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\v18.x\fluent
5. Select Parallel under Processing Options and then enter the Number of Processes you will
be using.

6. Select the Parallel Settings tab


7. Choose File Containing Machine Names
8. Choose the Text icon and enter the machine names once.
9. Click OK once you have entered and saved the machines.txt file.
10. Click OK to launch ANSYS Fluent

4
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)

16. In the Library Name text box type in the \\Computer_name\share_name\libudf. It is


necessary to type in the network path to the compiled UDF in this text box if running across
multiple computers.
17. Select Build
18. Select Load

5
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 2017 x86 x64 Cross Tools Command Prompt (if using an earlier
version of Fluent than Release 18.2)
1. Open up the Visual Studio 2017 x86 x64 Cross Tools Command Prompt window and change to your
working directory where your case and data reside.

2. Create an ANSYS Fluent XX.X shortcut on the desktop

3. Drag the ANSYS Fluent shortcut into the Visual Studio 2017 x86 x64 Cross Tools Command
Prompt window.

6
4. Press Enter
5. ANSYS Fluent launches.
6. Follow the procedures below for compiling UDFs

Compiling Fluent UDFs in serial or SMP (Shared Memory)


1. Launch Fluent ensuring that your Working Directory is set to the location where your
case, data and UDF is located in.
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

7
Compiling Fluent UDFs in DMP (Distributed Memory) on Multiple
Computers
NOTE: If you running the ANSYS Fluent solver on multiple computers and will be compiling and loading
UDFs you need to follow the steps below. If you are running in local parallel you do not need to
share and map drives. Follow the steps above except choose Parallel and the number of cores
(processes) you wish to run on.
1. Share the ANSYS Inc folder located at C:\Program Files\ANSYS Inc\v18.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.)

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\v18.x\fluent
5. Select Parallel under Processing Options and then enter the Number of Processes you will
be using.

8
6. Select the Parallel Settings tab
7. Choose File Containing Machine Names
8. Choose the Text icon and enter the machine names once.
9. Click OK once you have entered and saved the machines.txt file.
10. Click OK to launch ANSYS Fluent

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)

9
16. In the Library Name text box type in the \\Computer_name\share_name\libudf. It is
necessary to type in the network path to the compiled UDF in this text box if running across
multiple computers.
17. Select Build
18. Select Load
19. After you have compiled the UDF the working folder will include a new subfolder called
libudf.

10

You might also like