[ANSYS, Inc. Logo] return to home search
next up previous contents index


5.4 Link Precompiled Object Files From Non- ANSYS FLUENT Sources

ANSYS FLUENT allows you to build a shared library for precompiled object files that are derived from external sources using the text user interface (TUI) option. For example, you can link precompiled objects derived from FORTRAN sources ( .o objects from .f sources) to ANSYS FLUENT for use by a UDF. The following sections describe the procedures for doing this on a Windows system and a UNIX/Linux system.



Windows Systems


1.   Follow the procedure for setting up the folder structure described in Section Section  5.3.1.

2.   Copy your precompiled object files (e.g., myobject1.obj myobject2.obj) to all of the architecture/version folders you created in Step 1 (e.g., ntx86/2d, ntx86/3d).

figure   

The object files should be compiled using similar flags to those used by ANSYS FLUENT (e.g., /c /Za).

3.   Using a text editor, edit the user_nt.udf files in each architecture/version folder.



UNIX and Linux Systems


1.   Follow the procedure for setting up the directory structure described in
Section  5.3.1.

2.   Copy your precompiled object files (e.g., myobject1.o myobject2.o) to all of the architecture/version directories you created in Step 1 (e.g., ultra/2d and ultra/3d).

figure   

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.

3.   Using a text editor, edit the file makefile in your src directory to set the following three parameters: SOURCES, FLUENT_INC, and USER_OBJECTS.


   
SOURCES = Put the names of your UDF C files here. They will
  be calling the functions in the User Objects.
FLUENT_INC = the path to your release directory.
USER_OBJECTS = the precompiled object file(s) that you want to
  build a shared library for (e.g., myobject1.o).
  Use a space delimiter to specify multiple object files
  (e.g., myobject1.o myobject2.o).
   

An excerpt from a sample makefile is shown below:

#-----------------------------------------------------------#
# makefile for user defined functions
#
#-----------------------------------------------------------#
#-----------------------------------------------------------#
# User modifiable section.
#-----------------------------------------------------------#
SOURCES=udf_source1.c
FLUENT_INC= / path /ansys_inc/v120/fluent
# 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).
#-----------------------------------------------------------#
.
.
.

Note that in the previous example, path represents the directory where you installed ANSYS FLUENT.

4.   In your library directory (e.g., 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 (e.g., ultra).

    make  "FLUENT_ARCH=ultra"

The following messages will be displayed:

    # linking to ../../src/makefile in ultra/2d
    # building library in ultra/2d
    # linking to ../../src/makefile in ultra/3d
    # building library in ultra/3d




next up previous contents index Previous: 5.3.3 Load the UDF
Up: 5. Compiling UDFs
Next: 5.4.1 Example - Link
Release 12.0 © ANSYS, Inc. 2009-01-14