|
发表于 2011-1-22 02:05:22
|
显示全部楼层
附上正确程序,首先根据设定的初始时间判断何时开启光源,接着进入周期脉冲阶段,直到人为停止程序,如有问题请回复
#include "udf.h"
DEFINE_PROFILE(temperature_profile, thread, position)
{
real m[ND_ND];
real x,x1;
real y,y1;
face_t f;
real x0,y0,R;
real v=0.00167;
real T=0.03;
real T0=0.006;
real t0=9; /*¼ÙÉ迪ʼÆô¶¯Ê±¼äΪt0*/
int i=1;
real k;
real r=0.0003;
real J=1.5;
real t = RP_Get_Real("flow-time");
k=t - T * floor((t-t0)/T);
if(k<=T0)
{
begin_f_loop(f,thread)
{
F_CENTROID(m,f,thread);
x=m[0];
y=m[1];
x0=v*t;
y0=0;
R=sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0));
if(R<=r)
F_PROFILE(f,thread,position)=3*1.5*0.8/(3.14159*T0*r*r)*exp(-3*R*R/r*r);
else
F_PROFILE(f, thread, position)=0;
}
end_f_loop(f, thread)
printf("1");
printf("%f",t);
}
else
{
begin_f_loop(f,thread)
{
F_PROFILE(f, thread, position)=0;
}
end_f_loop(f, thread)
printf("2");
printf("%f",t);
}
k=0;
} |
|