24小时热门版块排行榜    

查看: 2026  |  回复: 1

liangsg521

新虫 (初入文坛)

[求助] udf能读入,但是一初始化计算就闪退!

用udf编写了如下程序,希望达到读取速度分量作为大涡模拟的入口条件,可是每次一初始化就闪退,求问各位大神问题出在哪里?

# include <udf.h>
DEFINE_PROFILE(vel_X,t,index)
{
float V_x;
FILE *fp;
char ch;
face_t f;
int i,j;
int count=1;

fp=fopen("E:\LHC\LES\velocity_U","r";
if(fp==NULL){
        printf("Can not open file!\n";       
}
begin_f_loop(f,t)
{
        int step=RP_Get_Integer("time-step";
        for(i=0;i<count;i++){
                for(j=0;j<step+1;j++){
                        fscanf(fp,"%lf%c",&V_x,&ch);
                }
        }
        F_PROFILE(f,t,index)=V_x;
        count++;
}
end_f_loop(f,t);
if(fclose(fp)){
        printf("Can not close the file!\n";
       
}
}
//V_y
DEFINE_PROFILE(vel_y,t,index)
{
float V_y;
FILE *fp;
char ch;
face_t f;
int i,j;
int count=1;

fp=fopen("E:\LHC\LES\velocity_V","r";
if(fp==NULL){
        printf("Can not open file!\n";       
}
begin_f_loop(f,t)
{
        int step=RP_Get_Integer("time-step";
        for(i=0;i<count;i++){
                for(j=0;j<step+1;j++){
                        fscanf(fp,"%lf%c",&V_y,&ch);
                }
        }
        F_PROFILE(f,t,index)=V_y;
        count++;
}
end_f_loop(f,t);
if(fclose(fp)){
        printf("Can not close the file!\n";
       
}
}
//V_z
DEFINE_PROFILE(vel_z,t,index)
{
float V_z;
FILE *fp;
char ch;
face_t f;
int i,j;
int count=1;

fp=fopen("E:\LHC\LES\velocity_W","r";
if(fp==NULL){
        printf("Can not open file!\n";       
}
begin_f_loop(f,t)
{
        int step=RP_Get_Integer("time-step";
        for(i=0;i<count;i++){
                for(j=0;j<step+1;j++){
                        fscanf(fp,"%lf%c",&V_z,&ch);
                }
        }
        F_PROFILE(f,t,index)=V_z;
        count++;
}
end_f_loop(f,t);
if(fclose(fp)){
        printf("Can not close the file!\n";
       
}
}

非常感谢!!!
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

小虫子被鸟吃

新虫 (小有名气)

要不试试,把fscanf放到loop外面试试?
2楼2015-05-27 16:13:27
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 liangsg521 的主题更新
信息提示
请填处理意见