24小时热门版块排行榜    

查看: 1678  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 化学工程321分求调剂 +18 大米饭! 2026-03-15 22/1100 2026-03-21 20:20 by HH领袖
[考研] 工科0856求调剂 +3 沐析汀汀 2026-03-21 3/150 2026-03-21 18:30 by 学员8dgXkO
[考研] 297求调剂 +11 戏精丹丹丹 2026-03-17 12/600 2026-03-21 17:47 by ColorlessPI
[考研] 26考研一志愿中国石油大学(华东)305分求调剂 +6 嘉年新程 2026-03-15 6/300 2026-03-21 17:07 by Dream007008
[考研] 301求调剂 +10 yy要上岸呀 2026-03-17 10/500 2026-03-21 03:14 by JourneyLucky
[考研] 22408 344分 求调剂 一志愿 华电计算机技术 +4 solanXXX 2026-03-20 4/200 2026-03-20 23:49 by alg094825
[考研] 287求调剂 +7 晨昏线与星海 2026-03-19 8/400 2026-03-20 22:19 by JourneyLucky
[考研] 085600材料与化工 +8 安全上岸! 2026-03-16 8/400 2026-03-20 22:13 by luoyongfeng
[考研] 材料与化工 322求调剂 +4 然11 2026-03-19 4/200 2026-03-20 22:12 by luoyongfeng
[考研] 329求调剂 +9 想上学吖吖 2026-03-19 9/450 2026-03-20 22:01 by luoyongfeng
[考研] 材料学硕297已过四六级求调剂推荐 +11 adaie 2026-03-19 11/550 2026-03-20 21:30 by laoshidan
[考研] 319求调剂 +3 小力气珂珂 2026-03-20 3/150 2026-03-20 19:47 by JourneyLucky
[考研] 求调剂 +3 @taotao 2026-03-20 3/150 2026-03-20 19:35 by JourneyLucky
[考研] 261求B区调剂,科研经历丰富 +3 牛奶很忙 2026-03-20 4/200 2026-03-20 19:34 by JourneyLucky
[考研] 一志愿南理工085701环境302求调剂院校 +3 葵梓卫队 2026-03-20 3/150 2026-03-20 19:28 by zhukairuo
[考研] 085601材料工程专硕求调剂 +10 慕寒mio 2026-03-16 10/500 2026-03-19 15:26 by 丁丁*
[考研] 0854,计算机类招收调剂 +3 胡辣汤放糖 2026-03-15 6/300 2026-03-18 12:09 by 上岸上岸……..
[考研] 085601求调剂 +4 Du.11 2026-03-16 4/200 2026-03-17 17:08 by ruiyingmiao
[考研] 一志愿,福州大学材料专硕339分求调剂 +3 木子momo青争 2026-03-15 3/150 2026-03-17 07:52 by laoshidan
[考研] 321求调剂 +5 大米饭! 2026-03-15 5/250 2026-03-16 16:33 by houyaoxu
信息提示
请填处理意见