關于udf小程序
#include"udf.h"
#include"mem.h"
#define p_pretotal 350000
#define pcr 185000
#define R 287.06
#define k 1.4
#define T 300
DEFINE_ADJUST(on_demamd_avg,d)
{
real p_sum = 0;
real p;
real v = 0;
real r = 0,tem;
real V;
real xc[ND_ND];
Thread *t;
face_t f;
Domain *d;
d = Get_Domain(1); /*獲取液態區域的網格 */
t=Lookup_Thread(d,12);/* 找到出口截面的線指針(ID在fluent中的phase找的) */
/* 單元循環 */
begin_f_loop(f,t)
{
F_CENTROID(xc,f,t); /* 將網格坐標存入數組xc中 */
p_sum = F_P(f, t);
if(p_sum<=p_pretotal)
{
if(p_sum>=pcr)
{
F_U(f,t)=sqrt((2*k*R*T/(k-1))*pow((1-(p_sum/p_pretotal)),(k-1)/k));
}
else
F_U(f,t)=sqrt(k*R*T*pow((p_sum/p_pretotal),(k-1)/k));
}
else
F_U(f,t)=0;
}
end_f_loop(f,t);
}
通過獲取壓力 比較壓力得到相應的速度公式 求高手指點

虞倫 


















