How to retrieve the subgrid turbulent kinetic energy for the LES turbulence model from within a UDF ?


FLUENT's implementation of LES model doesn't explicitly solve the equation for the subgrid turbulent kinetic energy. However, this variable is available during post-processing under the category of turbulent variables. The FLUENT12.1 user's guide provides the equation (31.4.39) which is used to calculate the value of subgrid turbulent kinetic energy.

However, how to access this variable on C-side, i.e. in a UDF?
/*UDF to retrieve the Subgrid Turbulent Kinetic Energy with LES model*/

/*
Information:- FLUENT's implementation of LES turbulence model doesn't explicitly solve the equation for "Subgrid turbulent kinetic energy". However, it can be retrieved as a post-processing variable. The subgrid turbulent kinetic energy is defined by the equation 31.4.3 (refer FLUENT12.1 User's Guide).

This UDF (which is of DEFINE_ON_DEMAND type) actually solves the equation to get the value of subgrid turbulent kinetic energy. The calculated value of Turbulent kinetic energy is stored in a USER DEFINED MEMORY (UDM).

A variable SMALL is defined to avoid division by zero. This has a hard coded value in FLUENT and hence not required to assign any explicit value in this UDF.


How to use the udf:-
o Read the case and data file of the LES case.
o Define a UDM through Define-->User Defined-->Memory
o Compile and Load the udf through Define-->User Defined-->Compiled.
o Perform iterations.
o Go to Define-->User Defined-->Execute-on-demand and Execute the function "cal_k_subgrid".
o This will store the value of subgrid turbulent kinetic energy in UDM-0.

o Note that this udf works fine on both serial and parallel FLUENT. Both are been tested on Linux clusters with pnet and smpi communicators.
*/


#include "udf.h"

DEFINE_ON_DEMAND(cal_k_subgrid)
{
Domain *d; /* declare domain pointer since it is not passed as an
argument to the DEFINE macro */
Thread *t;
cell_t c;

d = Get_Domain(1);

#if !RP_HOST /*Serial or on nodes*/

thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
real L_sgs = Compute_L_sgs(C_VOLUME(c,t),C_WALL_DIST(c,t),C_Centroid_Y(c,t));
C_UDMI(c,t,0) = SQR(C_MU_T(c,t)/(L_sgs*C_R(c,t) + SMALL));
}
end_c_loop(c,t)
}
#endif /*!RP_HOST*/
}





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