3.7.3. The par_fprintf_head and par_fprintf Macros

When using DEFINE_DPM_OUTPUT to write a DPM sample file, the special text output macros par_fprintf and par_fprintf_head must be used in place of the C I/O function fprintf. Typically, one or more header lines is written to the top of the file with column headings or other non-repeating information using par_fprintf_head. Following the header, a line is written for each particle sample using par_fprintf. Further details and examples are provided in the following sections:

3.7.3.1. par_fprintf_head

The par_fprintf_head macro generates a header at the top of the DPM sample file.

int par_fprintf_head(FILE *fp, const char *format, ...);

The first argument is the file pointer provided by the calling routine defined with DEFINE_DPM_OUTPUT. The second argument is the format string, used as described for the Message macro in Message . An example of the usage of par_fprintf_head is given below:

Example:

par_fprintf_head(fp, "x-coordinate y-coordinate z-coordinate\n");

This prints the column names x-coordinate, y-coordinate, and z-coordinate followed by a line feed at the top of the file indicated by FILE pointer fp. Multiple calls can be made to par_fprintf_head as needed to write all desired information to the top of the sample file.

For an illustration of the use of par_fprintf_head within a DEFINE_DPM_OUTPUT UDF refer to the Example provided in DEFINE_DPM_OUTPUT .

3.7.3.2. par_fprintf

The par_fprintf macro writes a single particle sample line into a DPM sample file.

int par_fprintf(FILE *fp, const char *format, ...);

The first argument is the file pointer provided by the calling routine defined with DEFINE_DPM_OUTPUT. The second argument is the format string, used as described for the Message macro in Message . When used with par_fprintf, the first two replacement variables in the format string must be the particle injection ID and particle ID respectively. The rest of the format string can be chosen to specify the output that will be written and its formatting. An example of the usage of par_fprintf is given below:

Example:

par_fprintf(fp, "%d %" int64_fmt " %e\t%e\t%e\n",
             P_INJ_ID(TP_INJECTION(tp)), 
             TP_ID(tp), 
             TP_POS(tp)[0], TP_POS(tp)[1], TP_POS(tp)[2]);

The symbolic constant int64_fmt provides the appropriate conversion character for 64–bit particle ID’s on all computer architectures. The parameters P_INJ_ID(TP_INJECTION(tp)) and TP_ID(tp) provide the particle’s injection ID and particle ID respectively, required as noted above. The macro TP_POS(tp)[i] provides the coordinates of the particle.


Note:  ANSYS Fluent will automatically remove the particle injection ID and particle ID fields when closing the sample file.


For an illustration of the use of par_fprintf within a DEFINE_DPM_OUTPUT UDF refer to Example in DEFINE_DPM_OUTPUT .


Release 18.2 - © ANSYS, Inc. All rights reserved.