ANSYS Fluent’s solver contains three types of executable: Cortex,
host, and compute node (or simply "node" for short). When ANSYS Fluent runs, an
instance of Cortex starts, followed by one host and n compute nodes,
thereby giving a total of n+2 running processes. For this reason, it
is necessary when running in parallel (and recommended when running in serial) that you make
sure that your function will successfully execute as a host and a node process. At first it
may appear that you should write two different versions of your UDF: one for host, and one
for node. Good programming practice, however, would suggest that you write a single UDF that,
when compiled, can execute on any of the two versions. This process is referred to in this
manual as “parallelizing” a serial UDF (that is , a UDF that does not account
for the separate processes). You can do this by adding special macros as well as compiler
directives to your UDF, as described below. Compiler directives, (such as #if
RP_NODE, RP_HOST, PARALLEL)
and their negated forms, direct the compiler to include only portions of the function that
apply to a particular process, and ignore the rest (see Compiler Directives).
A general rule of thumb is that your serial UDF must be “parallelized” if it performs an operation that is dependent on sending or receiving data from another compute node (or the host) or uses a macro type that was introduced after ANSYS Fluent version 18.2 (which are not guaranteed to be supported in serial UDF). Some types of operations that require parallelization of serial source code when used with multiple nodes include the following:
Reading and Writing Files
Global Reductions
Global Sums
Global Minimums and Maximums
Global Logicals
Certain Loops over Cells and Faces
Displaying Messages on a Console
Printing to a Host or Node Process
After the source code for your “parallelized” UDF has been written, it can be compiled using the same methods for serial UDFs. Instructions for compiling UDFs can be found in Compiling UDFs.