![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
N_UDS
You can use N_UDS to access the number of user-defined scalar (UDS) transport equations that have been specified in ANSYS FLUENT. The macro takes no arguments and returns the integer number of equations. It is defined in models.h.
N_UDM
You can use N_UDM to access the number of user-defined memory (UDM) locations that have been used in ANSYS FLUENT. The macro takes no arguments, and returns the integer number of memory locations used. It is defined in models.h .
Data_Valid_P()
You can check that the cell values of the variables that appear in your UDF are accessible before you use them in a computation by using the Data_Valid_P macro.
cxboolean Data_Valid_P() |
Data_Valid_P is defined in the id.h header file, and is included in udf.h. The function returns 1 (true) if the data that is passed as an argument is valid, and 0 (false) if it is not.
Example:
if(!Data_Valid_P()) return; |
Suppose you read a case file and, in the process, load a UDF. If the UDF performs a calculation using variables that have not yet been initialized, such as the velocity at interior cells, then an error will occur. To avoid this kind of error, an if else condition can be added to your code. If ( if) the data are available, the function can be computed in the normal way. If the data are not available ( else), then no calculation, or a trivial calculation can be performed instead. After the flow field has been initialized, the function can be reinvoked so that the correct calculation can be performed.
FLUID_THREAD_P()
cxboolean FLUID_THREAD_P(t); |
You can use FLUID_THREAD_P to check whether a cell thread is a fluid thread. The macro is passed a cell thread pointer t, and returns 1 (or TRUE) if the thread that is passed is a fluid thread, and 0 (or FALSE) if it is not.
Note that FLUID_THREAD_P(t) assumes that the thread is a cell thread.
For example,
FLUID_THREAD_P(t0); |
returns TRUE if the thread pointer t0 passed as an argument represents a fluid thread.
NULLP & NNULLP
You can use the NULLP and NNULLP functions to check whether storage has been allocated for user-defined scalars. NULLP returns TRUE if storage is not allocated, and NNULLP returns TRUE if storage is allocated. Below are some examples of usage.
NULLP(T_STORAGE_R_NV(t0, SV_UDSI_G(p1))) /* NULLP returns TRUE if storage is not allocated for user-defined storage variable */ |
NNULLP(T_STORAGE_R_NV(t0, SV_UDSI_G(p1))) /* NNULLP returns TRUE if storage is allocated for user-defined storage variable */ |
M_PI
The macro
M_PI returns the value of
.
UNIVERSAL_GAS_CONSTANT
UNIVERSAL_GAS_CONSTANT returns the value of the universal gas constant (
-
).
|
Note that this constant is
not expressed in SI units.
|
See Section 2.3.27 for an example UDF that utilizes UNIVERSAL_GAS_CONSTANT.
SQR(k)
SQR(k) returns the square of the given variable
k, or
.