After you have set up the folder structure and put the files in the proper places, you can compile and build the shared library using the TUI.
Edit every user_nt.udf file in
each version folder to set the following parameters: CSOURCES, HSOURCES, VERSION, and PARALLEL_NODE.
CSOURCES =the user-defined source file(s) to be compiled.
Use the prefix $(SRC) before each filename. For example, $(SRC)udfexample.c for one file, and $(SRC)udfexample1.c $(SRC)udfexample2.c for two files.
HSOURCES =the user-defined header file(s) to be compiled.
Use the prefix $(SRC) before each filename. For example, $(SRC)udfexample.h for one file, and $(SRC)udfexample1.h $(SRC)udfexample2.h for two files.
VERSION = the version of the solver you are running which will be the name of
the build folder where user_nt.udf is located.
(2d_host, 2d_node,
3d_host, 3d_node,
2ddp_host, 2ddp_node,
3ddp_host, or
3ddp_node).
PARALLEL_NODE =the parallel communications library.
Specify none for the host version, or one of
the following for the node version:
ibmmpi: parallel using IBM MPI
intel: parallel using Intel MPI
msmpi: parallel using Microsoft MPI
Important: Be sure to edit both copies of
user_nt.udf (the one in the host folder and the one in
the node folder), and specify the appropriate CSOURCES,
HSOURCES, VERSION, and
PARALLEL_NODE in each file. Set PARALLEL_NODE
= none for the host version and one of the other options (that is,
ibmmpi, intel, or
msmpi) for the node version, depending on which message
passing method you are going to use.
An excerpt from a sample user_nt.udf file is shown below:
# Replace text in " " (and remove quotes) # | indicates a choice # note: $(SRC) is defined in the Makefile CSOURCES = $(SRC)udfexample.c HSOURCES = $(SRC)udfexample.h VERSION = 2d_host PARALLEL_NODE = none
In the Visual Studio command prompt window, go to each version folder
(for example, libudf\win64\2d_node and
libudf\win64\2d_host), and type
nmake as shown in the following example.
C:\users\user_name\work_dir\libudf\win64\2d_node>nmake
The following messages will be displayed:
Microsoft (R) Program Maintenance Utility Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
cl /c /Za /DUDF_EXPORTING
-Ic:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\win64\2d_node
-Ic:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\src
-Ic:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\cortex\src
-Ic:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\client\src
-Ic:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\tgrid\src
-Ic:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\multiport\src
..\..\src\udfexample.c
Microsoft (R) 32-bit C/C++ Standard Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
udfexample.c
# Generating udf_names.c because of Makefile udfexample.obj
cl /c /Za /DUDF_EXPORTING
-Ic:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\win64\2d_node
-Ic:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\src
-Ic:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\cortex\src
-Ic:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\client\src
-Ic:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\tgrid\src
-Ic:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\multiport\src
udf_names.c
Microsoft (R) 32-bit C/C++ Standard Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
udf_names.c
# Linking libudf.dll because of Makefile user_nt.udf
udf_names.obj udfexample.obj
link /Libpath:c:\Program Files\ANSYS Inc\v182\fluent\fluent18.2.0\win64\2d_node
/dll
/out:libudf.dl
l udf_names.obj udfexample.obj fl1829s.lib
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
Creating library libudf.lib and object libudf.exp
C:\Program Files\ANSYS Inc\v182\fluent\ntbin\win64\libudf\win64\2d_node>
Important: Note that if there are problems with the build, you can do a
complete rebuild by typing nmake clean and
then nmake again.
Edit every user.udf file in each
version folder to set the following parameters: CSOURCES, HSOURCES, and ANSYS Fluent path.
CSOURCES =The name of your source file(s) (for example, udfexample.c). Multiple sources can be specified by using a space delimiter (for example, udfexample1.c udfexample2.c).
HSOURCES =The name of your header file(s) (for example, udfexample.h). Multiple headers can be specified by using a space delimiter (for example, udfexample1.h udfexample2.h).
FLUENT_INC =The path to your release directory.
An excerpt from a sample user.udf file 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
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 you will run ANSYS Fluent on,
which you identified in a previous step. For example, for the Linux
(lnamd64) architecture type:
make "FLUENT_ARCH=lnamd64"
ANSYS Fluent will build a shared library for each version you created
a directory for (Set Up the Directory Structure) and
will display messages about the compile/build process in the console.
You can view the compilation history in the log file that is saved in your working directory.
For example, when compiling/building a shared library for a source file named profile.c and a UDF library named libudf on a Linux architecture, the console messages may include the following:
Working...
for d in lnamd64[23]*; do \
( \
cd $d; \
for f in ../../src*.[ch] ../../src/Makefile; do \
if [ ! -f ’basename $f’ ]; then \
echo "# linking to " $f "in" $d; \
ln -s $f .; \
fi; \
done; \
echo ""; \
echo "# building library in" $d; \
make -k>makelog 2>&1; \
cat makelog; \
) \
done
# linking to ... myudf.c in lnamd64/2d_node
# building library in lnamd64/2d_node
make[1]: Entering directory ..../udf_names.c
# Generating udf_names
make[2]: Entering directory ..../profile.c
make libudf.so ...
# Compiling udf_names.o ...
# Compiling profile.o ...
# Linking libudf.so ...
make[2]: Leaving directory ..../udf_names.c
make[1]: Leaving directory ..../profile.c
You can also see the ’log’-file in
the working directory for compilation history
Done.