}
end_f_loop(f, t) }
/* profile for kinetic energy */
DEFINE_PROFILE(k_profile, t, i) {
real y, del, h, ufree, x[ND_ND]; real ff, utau, knw, kinf; face_t f;
h = YMAX - YMIN; del = DELOVRH*h; ufree = UMEAN*(B+1.);
ff = 0.045/pow(ufree*del/VISC,0.25); utau=sqrt(ff*pow(ufree,2.)/2.0); knw=pow(utau,2.)/sqrt(CMU); kinf=0.002*pow(ufree,2.);
begin_f_loop(f, t) {
F_CENTROID(x,f,t); y=x[1];
if (y <= del)
F_PROFILE(f,t,i)=knw+y/del*(kinf-knw); else
F_PROFILE(f,t,i)=knw+(h-y)/del*(kinf-knw); }
end_f_loop(f, t) }
/* profile for dissipation rate */
DEFINE_PROFILE(dissip_profile, t, i) {
real y, x[ND_ND], del, h, ufree; real ff, utau, knw, kinf;
real mix, kay; face_t f;
h = YMAX - YMIN; del = DELOVRH*h; ufree = UMEAN*(B+1.);
ff = 0.045/pow(ufree*del/VISC,0.25); utau=sqrt(ff*pow(ufree,2.)/2.0); knw=pow(utau,2.)/sqrt(CMU); kinf=0.002*pow(ufree,2.);
begin_f_loop(f, t) {
F_CENTROID(x,f,t); y=x[1];
if (y <= del)
kay=knw+y/del*(kinf-knw); else
kay=knw+(h-y)/del*(kinf-knw);
if (VKC*y < 0.085*del) mix = VKC*y; else
mix = 0.085*del;
F_PROFILE(f,t,i)=pow(CMU,0.75)*pow(kay,1.5)/mix; }
end_f_loop(f,t) }
例子: 3
在下面的例子中:, DEFINE_PROFILE is used to fix flow variables that are held constant during computation in a cell zone. Three separate UDFs named fixed_u, fixed_v, and fixed_ke are defined in a single C source file. They specify fixed velocities that simulate the transient startup of an impeller in an impeller-driven mixing tank. The physical impeller is simulated by fixing the velocities and turbulence quantities using the fix option. See Section 6.26 of the User's Guide for more information on fixing variables.
/***********************************************************************/
/* Concatenated UDFs for simulating an impeller using fixed velocity */
/***********************************************************************/
#include \
#define FLUID_ID 1 #define ua1 -7.1357e-2 #define ua2 54.304 #define ua3 -3.1345e3 #define ua4 4.5578e4 #define ua5 -1.9664e5
#define va1 3.1131e-2 #define va2 -10.313 #define va3 9.5558e2 #define va4 -2.0051e4 #define va5 1.1856e5
#define ka1 2.2723e-2 #define ka2 6.7989 #define ka3 -424.18 #define ka4 9.4615e3 #define ka5 -7.7251e4 #define ka6 1.8410e5
#define da1 -6.5819e-2 #define da2 88.845 #define da3 -5.3731e3 #define da4 1.1643e5 #define da5 -9.1202e5 #define da6 1.9567e6
DEFINE_PROFILE(fixed_u, thread, np) {
cell_t c;
real x[ND_ND]; real r;
begin_c_loop (c,thread) {
/* centroid is defined to specify position dependent profiles*/
C_CENTROID(x,c,thread); r =x[1];
F_PROFILE(c,thread,np) =
ua1+(ua2*r)+(ua3*r*r)+(ua4*r*r*r)+(ua5*r*r*r*r); }
end_c_loop (c,thread) }
DEFINE_PROFILE(fixed_v, thread, np) {
cell_t c;
real x[ND_ND]; real r;
begin_c_loop (c,thread) {
/* centroid is defined to specify position dependent profiles*/
C_CENTROID(x,c,thread); r =x[1];
F_PROFILE(c,thread,np) =
va1+(va2*r)+(va3*r*r)+(va4*r*r*r)+(va5*r*r*r*r); }
end_c_loop (c,thread) }
DEFINE_PROFILE(fixed_ke, thread, np) {
cell_t c;
real x[ND_ND]; real r;
begin_c_loop (c,thread) {
/* centroid is defined to specify position dependent profiles*/
C_CENTROID(x,c,thread); r =x[1];
F_PROFILE(c,thread,np) =
ka1+(ka2*r)+(ka3*r*r)+(ka4*r*r*r)+(ka5*r*r*r*r)+(ka6*r*r*r*r*r);
}
end_c_loop (c,thread) }
Activating a Profile UDF in FLUENT
Once you have compiled and linked your profile UDF, you can activate it by selecting it in the appropriate boundary condition panel in FLUENT (e.g., the Velocity Inlet panel). See Section 8.2.1 for more details.
4.3.6 DEFINE_PROPERTY 功能和使用方法的介绍
你可以使用DEFINE_PROPERTY macro to specify a custom material property in FLUENT. Some of the properties you can customize are
? ? ? ? ? ? ? ?
density (as a function of temperature only) viscosity
thermal conductivity mass diffusivity
absorption and scattering coefficients laminar flow speed rate of strain
particle or droplet diameter (multiphase mixture model)
!! UDFs cannot be used to define specific heat properties; specific heat data can only be accessed, not modified in FLUENT.
Macro: DEFINE_PROPERTY ( name, c, t) Argument types: cell_t c Thread *t Function returns: real
There are three arguments to DEFINE_PROPERTY: name, c, and t. name is the name of the UDF, specified by you. 当你的UDF编译和连接时,你为函数所选择的名字会在FLUENT图形用户界面中变得可见,且可被选择。 c and t are variables that are passed by the FLUENT solver to your UDF.