There are two ways that you can deal with expressions involving
two and three dimensions in your UDF. The first is to use an explicit
method to direct the compiler to compile separate sections of the
code for 2D and 3D, respectively. This is done using RP_2D and RP_3D in conditional-if statements.
The second method allows you to include general 3D expressions in
your UDF, and use ND and NV macros that will remove the z-components when
compiling with RP_2D. NV macros operate on vectors while ND macros
operate on separate components.
The use of a RP_2D and RP_3D macro in a conditional-if statement will direct
the compiler to compile separate sections of the code for 2D and 3D,
respectively. For example, if you want to direct the compiler to compute
swirl terms for the 3D version of ANSYS Fluent only, then you would use
the following conditional compile statement in your UDF:
#if RP_3D /* compute swirl terms */ #endif