|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
最近想做一个管道内随时间变化流动的模拟,压力压力边界条件想用实验数据给出。实验数据是txt格式。用UDF编写,单核计算UDF没有问题,但是到了并行计算上报错,贴上我的UDF源文件,请高手支招!先谢过了!
#include "udf.h"
real pressure_compute;
DEFINE_EXECUTE_AT_END(get_data)
{
#if !RP_NODE
FILE *fp;
int j;
real time, pressure;
real time_compute=RP_Get_Real("flow-time");
fp=fopen("test1.txt","r");
for(j=1;j<=13330;j++)
{
fscanf(fp,"%f%f",&time,&pressure);
if(fabs(time_compute-time)<=0.000005)
{
pressure_compute=pressure;
break;
}
else
continue;
}
printf("%f,%f",time_compute,pressure_compute);
fclose(fp);
#endif
host_to_node_real_1(pressure_compute);
}
DEFINE_PROFILE(pressure_profile,t,i)
{
#if !RP_HOST
face_t f;
begin_f_loop(f,t)
{
F_PROFILE(f,t,i)=pressure_compute*1000000;
}
end_f_loop(f,t)
printf("the pressure is set at exit: %f", pressure_compute);
#endif
}
采用解释执行后,说这一句“host_to_node_real_1(pressure_compute);”没有这个函数原型,但是去掉这一句后,虽然能够执行,但是从控制台信息打印信息来看,txt文档里面读取出来的数据并没有传递给DEFINE_PROFILE;DEFINE_PROFILE里面的 pressure_compute一直显示是0. |
|