|
楼主 |
发表于 2014-11-6 18:24:32
|
显示全部楼层
/*迭代时间不同,入口速度也不同*/
#include "udf.h"
#include "mem.h"
#include "metric.h"
int kount=0;
real m;
real r=350.;
real kp=0.01,ki=0.01;
real temp_last;
/* real temp;*/
DEFINE_ADJUST(demo_calc,domain)
{
kount++;
printf("kount=%d\n",kount);
}
DEFINE_ADJUST(best_point_temp,domain)
{
cell_t c;
Thread *t;
real xc[ND_ND];
real temp;
/* loop over all cell threads in the domain*/
thread_loop_c(t,domain)
{
/* loop over all cells*/
begin_c_loop(c,t)
{
C_CENTROID(xc,c,t);
if (kount<50.)
{
if(sqrt(ND_SUM(pow(xc[0]-0.07,2.),pow(xc[1]-0.07,2.)))<0.001)
{
m=1;
temp=r-C_T(c,t);
temp_last=r-C_T_M1(c,t);
m+=kp*(temp-temp_last)+ki*temp;
printf("temp_last=%d\n",temp_last);
}
else
{
return;
}
}
else
{
temp_last=r-C_T(c,t);
printf("temp_last=%n \n",temp_last);
m=2;
}
}
end_c_loop(c,t)
}
}
DEFINE_PROFILE(x_velocity,thread,nv)
{
float x[2];
float y;
face_t f;
begin_f_loop(f,thread)
{
y=x[1]; /* x[0]=x; x[1]=y; x[2]=z */
F_PROFILE(f,thread,nv)=m;
}
end_f_loop(f,thread)
}
|
|