![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
The general procedure for compiling a UDF source file and building a shared library for the resulting objects, and loading the compiled UDF library into ANSYS FLUENT using the graphical user interface (GUI) is as follows.
|
Note that in order to compile a UDF when running serial or parallel
ANSYS FLUENT on a Windows system, then you must have Microsoft Visual Studio installed on your machine, preferably on the
C: drive.
|
Define
User-Defined
Functions
Compiled...
The Select File dialog box will close and the file you selected (e.g., udfexample.c) will appear in the Source Files list in the Compiled UDFs dialog box (Figure 5.2.3). You can delete a file after adding it by selecting the source file and then clicking Delete in the Compiled UDFs dialog box.
As the compile/build process begins, a Warning dialog box (Figure 5.2.4) will appear reminding you that the source file(s) need to be in the same folder as the case and data files. Click OK to close the dialog and continue with the build.
As the build process progresses, the results of the build will be displayed on the console. You can also view the compilation history in the log file that is saved in your working folder.
Console messages for a successful compile/build for a source file named udfexample.c and a UDF library named libudf for a Windows architecture are shown below.
Deleted old libudf\ntx86\2d\libudf.dll 1 file(s) copied. (system "copy C:\Program Files\ANSYS Inc\v120\fluent\fluent12.0.9\src \makefile_nt.udf libudf\ntx86\2d\makefile") 1 file(s) copied. (chdir "libudf")() (chdir "ntx86\2d")() udfexample.c # Generating udf_names.c because of makefile udfexample.obj udf_names.c # Linking libudf.dll because of makefile user_nt.udf udf_names.obj udfexample.obj Microsoft (R) Incremental Linker Version 7.10.3077 Copyright (C) Microsoft Corporation. All rights reserved. Creating library libudf.lib and object libudf.exp Done. |
A message will be displayed on the console providing a status of the load process. For example:
"Z:/mywork" Opening library "libudf"... Library "libudf\ntx86\2d\libudf.dll" opened inlet_x_velocity Done. |
indicates that the shared library named libudf was successfully loaded (on a Windows machine) and it contains one function named inlet_x_velocity.
|
Note that compiled UDFs are displayed in
ANSYS FLUENT dialog boxes with the associated UDF library name using the
:: identifier. For example, a compiled UDF named
inlet_x_velocity that is associated with a shared library named
libudf will appear in
ANSYS FLUENT dialog boxes as
inlet_x_velocity::libudf. This visually distinguishes UDFs that are compiled from those that are interpreted.
|
After the compiled UDF(s) become visible and selectable in graphics dialog boxes in ANSYS FLUENT, they can be hooked to your model. See Chapter 6 for details. You can use the UDF Library Manager dialog box to unload the shared library, if desired. See Section 5.5 for details.
|
If you do not want the shared library saved with your case file, then you must remember to load it into
ANSYS FLUENT using the
Compiled UDFs dialog box or the
UDF Library Manager dialog box in subsequent sessions.
|