24小时热门版块排行榜    

查看: 1655  |  回复: 16

xiaoguai3

新虫 (初入文坛)

[求助] 新手求教UDF问题~

能解释,但一添加到边界或初始化就报错。
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()

我的UDF如下,二维模型,简单的固体传热问题,想在模拟过程的同时累加整个固体区域的所有得热量,达到一定值后改变热流边界值。由于刚接触UDF不久,不知道问题出在何处。请指教!d= Get_Domain(1);这个语句有问题吗?
#include "udf.h"
real Q_tot=0;
DEFINE_PROFILE (unsteady_heatflux, thread, position)
{
Domain *d;
real cp=880;
real density=2180;
real tempn, templ, volume, Q;
Thread *t;
cell_t c;
d= Get_Domain(1); /*Get the domain using Fluent utility *//*Loop over all cell threads in the domain*/
thread_loop_c(t,d) /*Compute Q */ /*Loop over all cells */
begin_c_loop(c,t)
{
real time= RP_Get_Real("flow-time";
real b=(int)(time/3600)+1;
int i=(int)((b-1)/24);
real Heat[3]={278.5, 280.7, 278.5};
volume=C_VOLUME(c,t); /* get cell volume */
templ=C_T_M1(c,t); /*Get cell tempertuare of previous step*/
tempn=C_T(c,t); /*Get cell tempertuare*/
Q=cp*density*volume*(tempn-templ);
Q_tot +=Q;
if (Q_tot<= Heat )
F_PROFILE(c,t,position)=60;
else F_PROFILE(c,t,position)=0;
}
end_c_loop(c,t)
}
回复此楼

» 本帖@通知

» 猜你喜欢

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

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

wuming524

专家顾问 (著名写手)

石化蛀虫

【答案】应助回帖


感谢参与,应助指数 +1
xiegangmai(金币+1): 谢谢参与! 2012-01-04 22:45:44
楼主太抬举俺了,出现这种问题你需要检查你的语句,大多出现调用无效语句出现的错误。本人也不是太懂。待高人解答吧~好运。
2楼2012-01-04 22:06:19
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

kylafree

至尊木虫 (知名作家)

【答案】应助回帖


感谢参与,应助指数 +1
xiegangmai(金币+1): 鼓励讨论交流! 2012-01-04 22:45:54
real Q_tot=0;
real Heat[3]={278.5, 280.7, 278.5};

if (Q_tot<= Heat )
这里是一个数组和一个数在比大小吗?
3楼2012-01-04 22:06:24
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xiaoguai3

新虫 (初入文坛)

引用回帖:
3楼: Originally posted by kylafree at 2012-01-04 22:06:24:
real Q_tot=0;
real Heat[3]={278.5, 280.7, 278.5};

if (Q_tot<= Heat )
这里是一个数组和一个数在比大小吗?

不好意思打错了,是if (Q_tot <= Heat )
Q_tot是得热之和,由下求得
Q=cp*density*volume*(tempn-templ);
Q_tot +=Q;
4楼2012-01-04 22:15:32
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xiaoguai3

新虫 (初入文坛)

引用回帖:
3楼: Originally posted by kylafree at 2012-01-04 22:06:24:
real Q_tot=0;
real Heat[3]={278.5, 280.7, 278.5};

if (Q_tot<= Heat )
这里是一个数组和一个数在比大小吗?

为什么帖子中我数组后头的方括号就是打不出来???
5楼2012-01-04 22:16:16
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xiegangmai

版主 (职业作家)

我没头衔

优秀版主优秀版主优秀版主


臭水沟(金币+1): 谢谢交流~~ 2012-01-09 11:21:29
引用回帖:
5楼: Originally posted by xiaoguai3 at 2012-01-04 22:16:16:
为什么帖子中我数组后头的方括号就是打不出来???

请使用插入代码的功能
明德厚学、求是创新
6楼2012-01-04 22:46:29
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xiaoguai3

新虫 (初入文坛)

引用回帖:
3楼: Originally posted by kylafree at 2012-01-04 22:06:24:
real Q_tot=0;
real Heat[3]={278.5, 280.7, 278.5};

if (Q_tot<= Heat )
这里是一个数组和一个数在比大小吗?

不好意思,是这样的
CODE:
#include "udf.h"
real Q_tot=0;
DEFINE_PROFILE (unsteady_heatflux, thread, position)
{
Domain *d;
real cp=880;
real density=2180;
real tempn, templ, volume, Q;
Thread *t;
cell_t c;
d= Get_Domain(1); /*Get the domain using Fluent utility *//*Loop over all cell threads in the domain*/
thread_loop_c(t,d) /*Compute Q */ /*Loop over all cells */
begin_c_loop(c,t)
{
real time= RP_Get_Real("flow-time";
real b=(int)(time/3600)+1;
int i=(int)((b-1)/24);
real Heat[3]={278.5, 280.7, 278.5};
volume=C_VOLUME(c,t); /* get cell volume */
templ=C_T_M1(c,t); /*Get cell tempertuare of previous step*/
tempn=C_T(c,t); /*Get cell tempertuare*/
Q=cp*density*volume*(tempn-templ);
Q_tot +=Q;
if (Q_tot<= Heat[i] )
F_PROFILE(c,t,position)=60;
else F_PROFILE(c,t,position)=0;
}
end_c_loop(c,t)
}

7楼2012-01-04 22:52:46
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xiaoguai3

新虫 (初入文坛)

引用回帖:
: Originally posted by xiegangmai at 2012-01-04 22:46:29:
请使用插入代码的功能

谢谢版主
8楼2012-01-04 22:53:10
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xiaoguai3

新虫 (初入文坛)

引用回帖:
: Originally posted by wuming524 at 2012-01-04 22:06:19:
楼主太抬举俺了,出现这种问题你需要检查你的语句,大多出现调用无效语句出现的错误。本人也不是太懂。待高人解答吧~好运。

还是谢谢~
9楼2012-01-04 22:53:26
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xiaoguai3

新虫 (初入文坛)

引用回帖:
: Originally posted by kylafree at 2012-01-04 22:06:24:
real Q_tot=0;
real Heat[3]={278.5, 280.7, 278.5};

if (Q_tot<= Heat )
这里是一个数组和一个数在比大小吗?

你好,我改了下CODE,还是出错,能帮我看下吗?谢谢了~
http://muchong.com/bbs/viewthread.php?tid=4026752&pid=2&page=1#pid2
10楼2012-01-08 15:30:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 xiaoguai3 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 成果系统访问量大,请一小时后再尝试。---NSFC啥时候好哦,已经两天这样了 +3 NSFC2026我来了 2026-02-28 3/150 2026-03-01 21:41 by autumntian
[考研] 306分材料调剂 +4 chuanzhu川烛 2026-03-01 5/250 2026-03-01 19:48 by 无际的草原
[考研] 化工299分求调剂 一志愿985落榜 +5 嘻嘻(*^ω^*) 2026-03-01 5/250 2026-03-01 19:47 by 无际的草原
[考研] 265分求调剂不调专业和学校有行学上就 +5 礼堂丁真258 2026-02-28 7/350 2026-03-01 19:12 by Js512888
[考研] 298求调剂 +6 axyz3 2026-02-28 6/300 2026-03-01 19:00 by 18137688336
[考研] 一志愿中南大学理学化学 +4 15779376950 2026-03-01 5/250 2026-03-01 19:00 by Fff-1
[考研] 0856材料求调剂 +11 hyf hyf hyf 2026-02-28 12/600 2026-03-01 18:57 by 18137688336
[考研] 0857调剂 +3 一ll半 2026-02-28 3/150 2026-03-01 18:32 by 热情沙漠
[考研] 281求调剂 +4 2026计算机_诚心 2026-03-01 7/350 2026-03-01 17:20 by 2026计算机_诚心
[考研] 321求调剂一志愿东北林业大学材料与化工英二数二 +4 虫虫虫虫虫7 2026-03-01 7/350 2026-03-01 16:52 by caszguilin
[考研] 313求调剂 +3 水流年lc 2026-02-28 3/150 2026-03-01 16:01 by 新能源达人
[考研] 311求调剂 +6 亭亭亭01 2026-03-01 6/300 2026-03-01 15:41 by 324616
[考研] 303求调剂 +4 今夏不夏 2026-03-01 4/200 2026-03-01 14:46 by 嘟嘟小浣熊
[考研] 295复试调剂 +3 简木ChuFront 2026-03-01 3/150 2026-03-01 14:27 by zzxw520th
[考研] 寻找调剂 +4 LYidhsjabdj 2026-02-28 4/200 2026-03-01 10:56 by sunny81
[考研] 311求调剂 +9 南迦720 2026-02-28 10/500 2026-03-01 10:55 by sunny81
[论文投稿] 求助coordination chemistry reviews 的写作模板 10+3 ljplijiapeng 2026-02-27 4/200 2026-03-01 09:07 by babero
[考研] 307求调剂 +4 73372112 2026-02-28 6/300 2026-03-01 00:04 by ll247
[考研] 264求调剂 +3 巴拉巴拉根556 2026-02-28 3/150 2026-02-28 21:31 by gaoxiaoniuma
[高分子] 求环氧树脂研发1名 +3 孙xc 2026-02-25 11/550 2026-02-28 16:57 by ichall
信息提示
请填处理意见