|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
我的udf很简单,就是记录一个动点每一步的压力变化,原来我选择分离求解器时没有任何问题,但选用耦合求解器后,计算完一步后出错,并且没有把我的结果记录下来,希望高手指点。
/* This program is to output the pressure of face. */
#include "udf.h"
#define v1 69.44
#define p1 9 /*Zone ID that can be found in define boundary condition in Fluent*/
real FC[3];/*存放face的质心坐标*/
FILE *fp;
DEFINE_EXECUTE_AT_END(output_pre)
{
int num_steps;
real curr_time;
real tolerance;
real dis;
real flow_t;
real FP[5];/*存放face质心的压力*/
real point1[3]={-55.95,-1.6,2.15}; /*输出结果点的初始坐标*/
face_t f;
cell_t c;
Thread *t,tf;
Domain *d;
d=Get_Domain(1);
fp=fopen("suidao52-500-1-1m.txt","a");
num_steps=N_TIME;
if (num_steps==1)
{
fprintf(fp,"%15s%15s%15s%15s%15s%15s\n","num_steps","flow_time","pre_p1");
}
curr_time=CURRENT_TIME;
flow_t=RP_Get_Real("flow-time");
fprintf(fp,"%15d",num_steps);
fprintf(fp,"%15.4f",flow_t);
point1[0]=point1[0]+v1*curr_time;
/*判断第一点*/
t=Lookup_Thread(d, p1); /*找到指定区域的thread,根据点所在的位置指定尽量小的区域*/
tolerance=1;
begin_f_loop(f,t)
{F_CENTROID(FC,f,t);
dis=sqrt((FC[0]-point1[0])*(FC[0]-point1[0])+(FC[1]-point1[1])*(FC[1]-point1[1])+(FC[2]-point1[2])*(FC[2]-point1[2]));
if(dis<tolerance)
{
tolerance=dis;
FP[1]=F_P(f,t);
/* fprintf(fp,"x1=%-12.4f y1=%-12.4f z1=%-12.4f\n",FC[0],FC[1],FC[2]); */
}
}
end_f_loop(f,t)
fprintf(fp,"%15.4f\n",FP[1]);
fclose(fp);
}
|
|