24小时热门版块排行榜    

CyRhmU.jpeg
查看: 3551  |  回复: 2

风卷尘沙起

铜虫 (初入文坛)

[求助] fluent UDF 读取txt文件数据,并存入数组赋值给入口速度~

#include "udf.h"
DEFINE_PROFILE(inlet_z_volecity,thread,position)
{
    double volecity_1[1000];
        real x[ND_ND];
        real y;
        real y1;
        face_t f;
        int i,j=0;
        /**define varibles, file pointer**/
        FILE *fp;
        /**open the file in the read-only mode**/
        fp=fopen("aa.txt","r";
        if(fp==NULL)
        printf(" Can't open the file. Sorry.\n";
        else
        {
        /**initialise the the fluent_mode array**/
        for(i=0;i<1000;i++)
    {
            fscanf(fp,"%lf\n",&volecity_1);
    }
    }
    fclose(fp);
        begin_f_loop(f,thread)
        {
                F_CENTROID(x,f,thread);
                y=x[1];
                y1=volecity_1[j];
                F_PROFILE(f, thread, position)=10*y1;
                j++;
        }
        end_f_loop(f,thread)
        }

这是我的代码,udf新新手,用interpreted 可以编译过去,但是就是给速度赋值的时候y1貌似一直都是0,不知道为什么。求大神帮忙解释解释,谢谢啦。
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

林一鸣123

新虫 (小有名气)

老铁解决了吗,我用的时候也是这样

发自小木虫Android客户端
2楼2021-01-21 17:47:00
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

匿名

本帖仅楼主可见
3楼2021-10-10 16:04:19
已阅   申请计算强帖   回复此楼   编辑   查看我的主页
相关版块跳转 我要订阅楼主 风卷尘沙起 的主题更新
信息提示
请填处理意见