Each process in parallel ANSYS Fluent has a unique integer identifier that is stored as the
global variable myid. When you use myid
in your parallel UDF, it will return the integer ID of the current compute node
(including the host). The host process has an ID of host(=999999)
and is stored as the global variable host. Compute node-0 has an ID
of 0 and is assigned to the global variable
node_zero. Below is a list of global variables in parallel
ANSYS Fluent.
Global Variables in Parallel ANSYS Fluent
int node_zero = 0; int host = 999999; int node_one = 1; int node_last; /* returns the id of the last compute node */ int compute_node_count; /* returns the number of compute nodes */ int myid; /* returns the id of the current compute node (and host) */
myid is commonly used in conditional-if statements in parallel
UDF code. Below is some sample code that uses the global variable
myid. In this example, the total number of faces in a face thread
is first computed by accumulation. Then, if myid is not compute
node-0, the number of faces is passed from all of the compute nodes to compute node-0 using
the message passing macro PRF_CSEND_INT. (See Message Passing Macros for details on
PRF_CSEND_INT.)
Example: Usage of myid
int noface=0;
begin_f_loop(f, tf) /* loops over faces in a face thread and
computes number of faces */
{
noface++;
}
end_f_loop(f, tf)
/* Pass the number of faces from node 1,2, ... to node 0 */
#if RP_NODE if(myid!=node_zero)
{
PRF_CSEND_INT(node_zero, &noface, 1, myid);
}
#endif