CODE:
#include "udf.h"
#define cp 800
#define density 2180
DEFINE_PROFILE (unsteady_temp,t,i)
{
real tempn, templ, volume, Q,Q_tot,time,a,b,tempad;
real Heat[5]={278.5,280.7,278.5,280.5,285.2};
Domain *d;
Thread *t,*ct,*t0;
cell_t c,c0;
face_t f;
time = RP_Get_Real("flow-time");
a =time/3600;
b =a/24;
d = Get_Domain(1);
int i=(int)((int)a/24);
if (int(b)==b) /*如果b是实数,Q_tot归零,否则在以往计算的基础上累加[color=Red]我这样表达正确么?[/color]*/
Q_tot=0;
thread_loop_c(ct,d) /*Compute Q */ /*Loop over all cells循环DOMAIN上所有THREAD */
{
begin_c_loop(c,ct) /*Loop over all cells循环所有THREAD上所有CELL */
{
volume=C_VOLUME(c,ct); /* get cell volume */
templ=C_T_M1(c,ct); /*Get cell tempertuare of previous step有问题!!!!!!!!*/
tempn=C_T(c,ct); /*Get cell tempertuare*/
Q=cp*density*volume*(tempn-templ);
Q_tot +=Q;
}
end_c_loop(c,ct)
}
if (Q_tot<= Heat[i])
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=333; /*BC:Temp=333K*/
}
end_f_loop(f,t)
else
begin_f_loop(f,t)
{
c0 = F_C0(f,t);
t0 = THREAD_T0(t);
tempad=C_T(c0,t0); /*temperature of adjacent cell [color=Red]这样取相邻CELL温度正确吗?可不可以直接取相邻FACE的温度值呢?查了MANUAL没有看到F_T(f0,t)的表达啊[/color]*/
F_PROFILE(f,t,i)=tempad;
}
end_f_loop(f,t)
}