How to compile and load Fluent UDF on Linux

Corrections to the UDF manual (version 18.1)

Due to the following typographical errors, you cannot make the UDF. So you need to fix these:

  • Page 341-341: the path “path/ansys_inc/v181/fluent/fluent18.1.0/src/” is inccorect. In reality, it should be “path/ansys_inc/v181/fluent/fluent18.1.0/src/udf/
  • Page 342: In procedure 5, the file of interest is NOT the makefile.udf2 but makefile.udf . -
  • AND rename the copied makefile.udf to makefile . The manual says Makefile but this doesn’t work.
  • Most importantly, it appears you need to copy the makefile into the each of the subdirectory under the architecture directory, e.g., /libudf/lnamd64/3ddp_host/ and /libudf/lnamd64/3ddp_node/ . This information is absent in the manual at all, which is really annoying. Could be environment dependent? but still…

Then, you should finally be able to do the

$ make "FLUENT_ARCH=lnamd64"

and finish compiling.

Prepare the case and data files

This step is important and should be done carefully. The general idea is to do minimum thing. Particularly, do not play with TUI before saving the case file, which could potentially harmful and might result in unexpected behaviour during the computation in the Linux server. In my case, I encountered a situation where the computation halts at the first dat file saving, which seemed to have been the result of changing the suffix or prefix for the auto-saved files (via TUI). When I discard the Fluent module in the Workbench and made a clean Fluent module, this problem disappeared. So be careful.

Unload the UDF

Don’t forget to “Unload” the UDF when you were checking e.g. the body motion in Windows' Fluent. For that, right-clicking the “User Defined Functions” (under the Tree view) and select “Manage…” then you will see the list of loaded UDFs.

Delete the Dynamic Mesh Zones

This may not be the mandatory (I haven’t checked yet) but probably preferable.

record (log) the actions for journal file

I recently found a very useful feature in Fluent, i.e. record (log) the journal actions. From the menu “File > Write > Start journal…” you can record the actions in a journal file.

Unfortunately, Fluent is not smart enough to convert the GUI actions to the TUI commands in the recorded journal file, i.e. they are simply “Click this button” “Click this tab” or such… So you must find the appropriate TUI commands by yourself… (sigh)

How to load the compiled files using a journal file?

Surprisingly, this fatal information is absent in the manual. The following command should work.

/define/user-defined/compiled-functions load "<NAME OF libudf DIRECTORY>"

How to enable Dynamic Mesh & Create Zone for rigid body motion using a journal file?

Note the following applies only for the dynamic mesh & rigid body motion.

For the simple dynamic mesh,

/define/dynamic-mesh/dynamic-mesh? yes no no no no

and for creating the dynamic zone for a simple rigid-body motion

/define/dynamic-mesh/zones/create <ZONE_NUMBER> rigid-body "<UDF_PROFILE>" no 0. 0. 0. 0. 0. 0. 0.

where you must specify the <ZONE_NUMBER> and <UDF_PROFILE>.

You can check the zone number in the Fluent’s Tree pane > Cell Zone Conditions.

And the udf profile is the one shown in the “Motion UDF/Profile” drop down list in the “Dynamic Mesh Zones” dialogue via GUI. (after loading the compiled UDF). It is something like “move_body::libudf” .