24小时热门版块排行榜    

Znn3bq.jpeg
查看: 1752  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 急需调剂 +6 绝不放弃22 2026-04-15 6/300 2026-04-16 11:45 by lifeisbrave
[考研] 307中医考研调剂 +5 于以采蘩 2026-04-14 5/250 2026-04-16 10:40 by dick_runner
[考研] 0854调剂 +13 长弓傲 2026-04-12 16/800 2026-04-15 13:45 by fenglj492
[考研] 279求调剂 +12 张番茄不炒蛋 2026-04-11 12/600 2026-04-14 15:38 by zs92450
[教师之家] 转长聘了 +7 简单化xn 2026-04-13 7/350 2026-04-14 14:50 by xindong
[考研] 245求调剂 +6 冰糖橘?汽水 2026-04-13 10/500 2026-04-14 10:49 by jyl0317
[考研] 考研英一数一338分 +9 长江大学东校区 2026-04-13 10/500 2026-04-14 00:41 by 王珺璞
[考研] 22408 352分求调剂 +5 努力的夏末 2026-04-09 5/250 2026-04-12 19:17 by wj165256
[考研] 材料工程日语考生求调剂 +7 0856?调剂 2026-04-10 7/350 2026-04-11 21:33 by 蓝云思雨
[考研] 求调剂 +11 翩翩一书生 2026-04-09 11/550 2026-04-11 19:57 by 逆水乘风
[考研] 352 求调剂 +6 yzion 2026-04-11 8/400 2026-04-11 16:24 by 明月此时有
[考研] 283求调剂 +22 那个噜子 2026-04-09 22/1100 2026-04-11 10:41 by 逆水乘风
[考研] 一志愿985机械学硕380求调剂 +5 关关雎鸠10 2026-04-11 5/250 2026-04-11 10:10 by 知念。A
[考研] 广东省 085601 329分求调剂 +14 Eddieddd 2026-04-10 14/700 2026-04-11 09:58 by bljnqdcc
[考研] 282,求调剂 +12 jggshjkkm 2026-04-09 14/700 2026-04-11 09:39 by 猪会飞
[考研] 0854调剂 +4 长弓傲 2026-04-09 4/200 2026-04-11 09:18 by 猪会飞
[考研] 342电子信息专硕求调剂 +9 你让我怎么荔枝 2026-04-10 10/500 2026-04-11 08:33 by zhq0425
[考研] 调剂 +19 小张ZA 2026-04-10 20/1000 2026-04-10 22:08 by 猪会飞
[考研] 083200 305分 求二轮调剂 不接受跨专业 +9 Claireyyyy 2026-04-09 10/500 2026-04-10 21:21 by Claireyyyy
[考研] 265求调剂 +12 风说她早忘了 2026-04-10 13/650 2026-04-10 18:56 by chemisry
信息提示
请填处理意见