[ANSYS, Inc. Logo] return to home search
next up previous contents index

7.5.3 Predicates

There are a number of macros available in parallel ANSYS FLUENT that expand to logical tests. These logical macros, referred to as "predicates", are denoted by the suffix P and can be used as test conditions in your UDF. The following predicates return TRUE if the condition in the parenthesis is met.

/*  predicate definitions from para.h header file */

# define MULTIPLE_COMPUTE_NODE_P (compute_node_count > 1)
# define ONE_COMPUTE_NODE_P (compute_node_count == 1)
# define ZERO_COMPUTE_NODE_P (compute_node_count == 0)

There are a number of predicates that allow you to test the identity of the node process in your UDF, using the compute node ID. A compute node's ID is stored as the global integer variable myid (see Section  7.7). Each of the macros listed below tests certain conditions of myid for a process. For example, the predicate I_AM_NODE_ZERO_P compares the value of myid with the compute node-0 ID and returns TRUE when they are the same. I_AM_NODE_SAME_P(n), on the other hand, compares the compute node ID that is passed in n with myid. When the two IDs are the same, the function returns TRUE. Node ID predicates are often used in conditional-if statements in UDFs.

/*  predicate definitions from para.h header file */

# define I_AM_NODE_HOST_P (myid == node_host)
# define I_AM_NODE_ZERO_P (myid == node_zero)
# define I_AM_NODE_ONE_P (myid == node_one)
# define I_AM_NODE_LAST_P (myid == node_last)
# define I_AM_NODE_SAME_P(n) (myid == (n))
# define I_AM_NODE_LESS_P(n) (myid < (n))
# define I_AM_NODE_MORE_P(n) (myid > (n))

Recall that from Section  7.2, a face may appear in one or two partitions but in order that summation operations don't count it twice, it is officially allocated to only one of the partitions. The tests above are used with the neighboring cell's partition ID to determine if it belongs to the current partition. The convention that is used is that the smaller-numbered compute node is assigned as the "principal" compute node for that face. PRINCIPAL_FACE_P returns TRUE if the face is located on its principal compute node. The macro can be used as a test condition when you want to perform a global sum on faces and some of the faces are partition boundary faces. (The macro returns TRUE for the serial process). Below is the definition of PRINCIPAL_FACE_P from para.h. See Section  7.2 for more information about PRINCIPAL_FACE_P.

/*  predicate definitions from para.h header file */
# define PRINCIPAL_FACE_P(f,t) (!TWO_CELL_FACE_P(f,t) || \
       PRINCIPAL_TWO_CELL_FACE_P(f,t))

# define PRINCIPAL_TWO_CELL_FACE_P(f,t) \
    (!(I_AM_NODE_MORE_P(C_PART(F_C0(f,t),THREAD_T0(t))) || \
       I_AM_NODE_MORE_P(C_PART(F_C1(f,t),THREAD_T1(t)))))


next up previous contents index Previous: 7.5.2 Communicating Between the
Up: 7.5 Macros for Parallel
Next: 7.5.4 Global Reduction Macros
Release 12.0 © ANSYS, Inc. 2009-01-14