Follow the procedure described in Set Up the Directory Structure.
Copy your precompiled object files (for example, myobject1.o myobject2.o) to all of the architecture/version directories you created in Step 1 (for example, lnamd64/2d_node and lnamd64/2d_host).
Important: The object files should be compiled using similar flags to those
used for ANSYS Fluent. Common flags used by ANSYS Fluent are: -KPIC, -O, and -ansi which often have equivalents such as -fpic, -O3, and -xansi.
Using a text editor, edit the file user.udf in each version folder to set the following parameters: CSOURCES, HSOURCES, and the ANSYS Fluent path.
| Put the names of your UDF C files here. They will be calling the functions in the User Objects. |
| Put the names of your UDF H files here. |
| The path to your release directory. |
An excerpt from a sample user.udf is shown below:
CSOURCES = udfexample.c
HSOURCES = udfexample.h
FLUENT_INC=/path/ansys_inc/v182/fluent
In the previous example, represents the directory where you installed ANSYS Fluent.path
Using a text editor, edit the file Makefile in your src directory to set the USER_OBJECTS parameters:
|
|
The precompiled object file(s) that you want to build a shared library for (for example, myobject1.o). Use a space delimiter to specify multiple object files (for example, myobject1.o myobject2.o). |
An excerpt from a sample Makefile is
shown below:
#-----------------------------------------------------------# # Makefile for user defined functions # #-----------------------------------------------------------# # User modifiable section. #-----------------------------------------------------------# include user.udf # Precompiled User Object files (for example .o files from .f sources) USER_OBJECTS= myobject1.o myobject2.o #-----------------------------------------------------------# # Build targets (do not modify below this line). #-----------------------------------------------------------# . . .
In your library directory (for example, libudf), execute the Makefile by typing a command that begins with make and includes the architecture of the machine on which you will run ANSYS Fluent,
which you identified in a previous step (for example, lnamd64).
make "FLUENT_ARCH=lnamd64"
The following messages will be displayed:
# linking to ../../src/Makefile in lnamd64/2d_node # building library in lnamd64/2d_node # linking to ../../src/Makefile in lnamd64/2d_host # building library in lnamd64/2d_host