|
楼主 |
发表于 2005-9-30 17:03:41
|
显示全部楼层
udf运行时错误信息,帮忙分析!谢谢!
我的udf:
#include "udf.h"
#define Npoint 50
#define N_Species 3
float X_Max[Npoint],X_Min[Npoint],Y_Max[Npoint],Y_Min[Npoint],Z_Max[Npoint],Z_Min[Npoint];
float xxxx2,yyyy2,zzzz2,Cz[N_Species];
const float X_In[Npoint]={0,71,100,150,200,364,412,510};
const float Y_In[Npoint]={0,0,0,0,0,0,0};
const float Z_In[Npoint]={0.4,0.4,0.4,0.4,0.4,0.4,0.4};
float C_In[Npoint][N_Species]; /*注意不要使用real类型的数据*/
DEFINE_PROFILE(inlet_x_velocity,thread,position)
{
real x[ND_ND];
real y;
real z0=0.010;
real z1=10.0;
face_t f;
begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
y=x[2];
F_PROFILE(f,thread,position)=2.4*(log(y)-log(z0))/(log(z1)-log(z0));
}
end_f_loop(f,thread)
}
DEFINE_DELTAT(my_timestep,d)
{
real time_step;
real flow_time=RP_Get_Real("flow-time");
if(flow_time<90.0)
time_step=0.1;
else
time_step=1.0;
return time_step;
}
DEFINE_INIT(my_init,domain)
{
FILE *f;
f=fopen("pointdata.txt","w");
if(f==0) printf("\n\ncan NOT open the pointdata file.");
fclose(f);
}
DEFINE_EXECUTE_AT_END(EAE_WPD)
{
Domain *d=Get_Domain(1);
Thread *t;
real x[ND_ND];
real alpha[Npoint],beta[Npoint],gama[Npoint];
real C_Near[Npoint][2][2][2][N_Species];
int i,j;
cell_t c;
FILE *f;
const real Epsilon=0.00001;
f=fopen("pointdata.txt","a");
if(f==0) printf("\n\ncan NOT open the pointdata file!");
for(i=0;i<Npoint;i++)
{
X_Max=X_In+5000;
X_Min=X_In-5000;
Y_Max=Y_In+5000;
Y_Min=Y_In-5000;
Z_Max=Z_In+5000;
Z_Min=Z_In-5000;
}
thread_loop_c(t,d)
{
begin_c_loop_all(c,t)
{
C_CENTROID(x,c,t);
xxxx2=x[0];
yyyy2=x[1];
zzzz2=x[2];
for(i=0;i<Npoint;i++)
{
if((xxxx2>X_In)&&(xxxx2<X_Max)) X_Max=xxxx2;
if((xxxx2<X_In)&&(xxxx2>X_Min)) X_Min=xxxx2;
if((yyyy2>Y_In)&&(yyyy2<Y_Max)) Y_Max=yyyy2;
if((yyyy2<Y_In)&&(yyyy2>Y_Min)) Y_Min=yyyy2;
if((zzzz2>Z_In)&&(zzzz2<Z_Max)) Z_Max=zzzz2;
if((zzzz2<Z_In)&&(zzzz2>Z_Min)) Z_Min=zzzz2;
for(j=0;j<N_Species;j++)
{
Cz[j]=C_YI(c,t,j);
if((fabs(xxxx2-X_Max)<Epsilon)&&(fabs(yyyy2-Y_Max)<Epsilon)&&(fabs(zzzz2-Z_Max)<Epsilon)) C_Near[1][1][1][j]=Cz[j];
if((fabs(xxxx2-X_Max)<Epsilon)&&(fabs(yyyy2-Y_Max)<Epsilon)&&(fabs(zzzz2-Z_Min)<Epsilon)) C_Near[1][1][0][j]=Cz[j];
if((fabs(xxxx2-X_Max)<Epsilon)&&(fabs(yyyy2-Y_Min)<Epsilon)&&(fabs(zzzz2-Z_Max)<Epsilon)) C_Near[1][0][1][j]=Cz[j];
if((fabs(xxxx2-X_Max)<Epsilon)&&(fabs(yyyy2-Y_Min)<Epsilon)&&(fabs(zzzz2-Z_Min)<Epsilon)) C_Near[1][0][0][j]=Cz[j];
if((fabs(xxxx2-X_Min)<Epsilon)&&(fabs(yyyy2-Y_Max)<Epsilon)&&(fabs(zzzz2-Z_Max)<Epsilon)) C_Near[0][1][1][j]=Cz[j];
if((fabs(xxxx2-X_Min)<Epsilon)&&(fabs(yyyy2-Y_Max)<Epsilon)&&(fabs(zzzz2-Z_Min)<Epsilon)) C_Near[0][1][0][j]=Cz[j];
if((fabs(xxxx2-X_Min)<Epsilon)&&(fabs(yyyy2-Y_Min)<Epsilon)&&(fabs(zzzz2-Z_Max)<Epsilon)) C_Near[0][0][1][j]=Cz[j];
if((fabs(xxxx2-X_Min)<Epsilon)&&(fabs(yyyy2-Y_Min)<Epsilon)&&(fabs(zzzz2-Z_Min)<Epsilon)) C_Near[0][0][0][j]=Cz[j];
}
}
}end_c_loop_all(c,thread)
}
fprintf(f,"flow time:\t%5.2f\n",CURRENT_TIME);
fprintf(f,"\t|mass fraction|\t|position|\n");
for(i=0;i<Npoint;i++)
{
alpha=(X_In-X_Min)/(X_Max-X_Min);
beta=(Y_In-Y_Min)/(Y_Max-Y_Min);
gama=(Z_In-Z_Min)/(Z_Max-Z_Min);
for(j=0;j<N_Species;j++)
{
C_In[j]=0.0;
C_In[j]=(1-alpha)*(1-beta)*(1-gama)*C_Near[0][0][0][j];
C_In[j]=C_In[j]+(1-alpha)*(1-beta)*gama*C_Near[0][0][1][j];
C_In[j]=C_In[j]+(1-alpha)*beta*(1-gama)*C_Near[0][1][0][j];
C_In[j]=C_In[j]+alpha*(1-beta)*(1-gama)*C_Near[1][0][0][j];
C_In[j]=C_In[j]+alpha*beta*(1-gama)*C_Near[1][1][0][j];
C_In[j]=C_In[j]+alpha*(1-beta)*gama*C_Near[1][0][1][j];
C_In[j]=C_In[j]+(1-alpha)*beta*gama*C_Near[0][1][1][j];
C_In[j]=C_In[j]+alpha*beta*gama*C_Near[1][1][1][j];
fprintf(f,"%5.4f,",C_In[j]);
}
fprintf(f,"\t(%5.4f,%5.4f,%5.4f)\n",X_In,Y_In,Z_In);
}
fclose(f);
}
我已经接近崩溃的边缘了. |
|