FLUENT V6 - Generating a step-by-step particle tracking report file from a calculation running in batch mode




Running FLUENT calculations in batch mode requires the use of text user interface (TUI) commands written in a journal file. The Step-by-Step particle tracking feature available in the Graphical User Interface (GUI) does not have an equivalent command in the TUI. This prevents the feature from being used in calculations being run in batch mode. This solution provides a User Defined Function (UDF) that allows the step-by-step particle tracking report file to be written even with calculations running in batch mode.
Use the following UDF to write the file.

Steps:

1. compile the UDF
2. hook the UDF to the DPM_SCALAR_UPDATE hook located on the dpm model panel
3. track the particles (for steady tracking, use "solve dpm-update"; for unsteady tracking, iterate as usual)

/********************************************************************/
/* */
/* Hook on the DPM panel under DPM Scalar Update */
/* */
/********************************************************************/

#include "udf.h"
#include "dpm.h"

DEFINE_DPM_SCALAR_UPDATE(track_dpm_particles,c,t,initialize,p)
{
if (RP_Get_Boolean("dpm/unsteady-tracking?"))
{

if (initialize)
{

float time = RP_Get_Real("flow-time");
float x = p->state.pos[0];
float y = p->state.pos[1];
float u = p->state.V[0];
float v = p->state.V[1];
#if RP_3D
float z = p->state.pos[2];
float w = p->state.V[2];
#endif

FILE *fd;
int id = p->part_id;

fd = fopen("dpm_positions.out", "a");
#if RP_3D
fprintf(fd, "%i %f %e %e %e %e %e %e %e %e %e n", id, time, x, y, z, u, v, w, P_T(p), P_MASS(p), P_RHO(p));
#else
fprintf(fd, "%i %f %e %e %e %e %e %e %e n", id, time, x, y, u, v, P_T(p), P_MASS(p), P_RHO(p));
#endif
fclose(fd);

}
}

else
{
float time = RP_Get_Real("flow-time");
float x = p->state.pos[0];
float y = p->state.pos[1];
float u = p->state.V[0];
float v = p->state.V[1];
#if RP_3D
float z = p->state.pos[2];
float w = p->state.V[2];
#endif

FILE *fd;
int id = p->part_id;

fd = fopen("dpm_positions.out", "a");
#if RP_3D
fprintf(fd, "%i %f %e %e %e %e %e %e %e %e %e n", id, time, x, y, z, u, v, w, P_T(p), P_MASS(p), P_RHO(p));
#else
fprintf(fd, "%i %f %e %e %e %e %e %e %e n", id, time, x, y, u, v, P_T(p), P_MASS(p), P_RHO(p));
#endif
fclose(fd);
}

}





Show Form
No comments yet. Be the first to add a comment!