24小时热门版块排行榜    

Znn3bq.jpeg
北京石油化工学院2026年研究生招生接收调剂公告
查看: 2041  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 化工学硕 285求调剂 +25 Wisjxn 2026-04-07 25/1250 2026-04-08 11:41 by 猪会飞
[考研] 材料调剂 +11 一样YWY 2026-04-06 11/550 2026-04-08 11:26 by Evan_Liu
[考研] 农学,求调剂,314分 +4 访客记录可爱 2026-04-04 4/200 2026-04-07 21:07 by 等岸
[考研] 22408 318分求调剂 +4 勤奋的小笼包 2026-04-06 6/300 2026-04-07 15:05 by 纸鹤555
[考研] 化工调剂303分,过四级 +34 栖梧待风 2026-04-02 34/1700 2026-04-07 12:30 by 1018329917
[考研] 材料工程310专硕调剂 +14 捞捞我…. 2026-04-04 15/750 2026-04-06 14:18 by lqwchd
[考研] 专硕0854初试考材科基,求调剂 +6 3220548044 2026-04-06 9/450 2026-04-06 10:26 by barlinike
[考研] 考研生物学考A区211,初试322,科目生化和生物综合,求调剂 +6 。。。54 2026-04-03 6/300 2026-04-05 14:54 by JOKER0401
[考研] 081200-11408-276学硕求调剂 +4 崔wj 2026-04-04 5/250 2026-04-05 14:06 by imissbao
[考研] 调剂 +4 是可乐不是可乐 2026-04-04 4/200 2026-04-04 19:41 by 唐沐儿
[考研] 309求调剂 +4 快乐的小白鸽 2026-04-04 5/250 2026-04-04 15:55 by cql1109
[考研] 22408,264求调剂 +3 ywh729 2026-04-03 4/200 2026-04-04 11:04 by ywh729
[考研] 考研调剂 +3 15615482637 2026-04-03 3/150 2026-04-03 22:50 by ms629
[考研] 求调剂 +4 压力??大 2026-04-03 4/200 2026-04-03 21:36 by 啵啵啵0119
[考研] 专硕085601求调剂 +7 suyifei 2026-04-03 8/400 2026-04-03 14:00 by 欣喜777
[硕博家园] 求老师收留 +9 lllq123 2026-04-03 9/450 2026-04-03 13:48 by 呼吸都是减肥
[考研] 重庆大学材料与化工085600,初试370+,求求调剂建议 +8 shzhou_ 2026-04-01 9/450 2026-04-03 09:31 by 蓝云思雨
[考研] 295求调剂 +7 愿旅途永远坦然 2026-04-02 7/350 2026-04-03 08:22 by fangshan711
[考研] 312求调剂 +4 赊月色 2026-04-02 5/250 2026-04-03 08:21 by fangshan711
[考研] 279求调剂 +5 傅文秋 2026-04-02 5/250 2026-04-02 18:10 by 笔落锦州
信息提示
请填处理意见