24小时热门版块排行榜    

查看: 2175  |  回复: 1
【悬赏金币】回答本帖问题,作者矢志不渝……将赠送您 10 个金币

矢志不渝……

新虫 (初入文坛)

[求助] fluent udf message宏的使用问题 已有1人参与

程序如下,用于获取并显示计算域最小温度,最大温度和平均温度(来源于udf manual文档DEFINE_ON_DEMAND一节的示例)
#include "udf.h"
#include "math.h"
#include "sg.h"

DEFINE_ON_DEMAND(ex)
{
    Domain *d;
    real tavg = 0.;
    real tmax = 0.;
    real tmin = 0.;
    real temp,volume,vol_tot;
    real i = 0;
    Thread *t;
    cell_t c;
    d = Get_Domain(1);

    thread_loop_c(t,d)
    {
        begin_c_loop(c,t)
        {
            volume = C_VOLUME(c,t);
            temp = C_T(c,t);

            if (temp < tmin || tmin == 0.) tmin = temp;
            if (temp > tmax || tmax == 0.) tmax = temp;

            vol_tot += volume;
            tavg += temp*volume;

        }
        end_c_loop(c,t)

        tavg /= vol_tot;
        i = i+1;
        Message0("\n Tmin = %g; Tmax = %g ;Tavg = %g; i= %g\n",tmin,tmax,tavg,i);
    }
}
然而,在fluent中execute后,显示结果如下:
Tmin = 2589.32; Tmax = 3136.66; Tavg = 3057.71; i= 1

Tmin = 300; Tmax = 3136.66; Tavg = 3.70544e+07; i= 2

Tmin = 300; Tmax = 3136.6;6 Tavg = 4.45858e+11; i= 3
实际情况是,计算域最小温度为300K,最高温度应该没错。也就是说,一次execute输出了三行的错误信息,请问问题出在哪里?
回复此楼

» 猜你喜欢

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

舒城向量

新虫 (初入文坛)

【答案】应助回帖

解决方式:
1. 并行化udf。
2. 串行计算。
2楼2023-07-15 10:24:21
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 矢志不渝…… 的主题更新
不应助 确定回帖应助 (注意:应助才可能被奖励,但不允许灌水,必须填写15个字符以上)
信息提示
请填处理意见