24小时热门版块排行榜    

CyRhmU.jpeg
查看: 1426  |  回复: 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的回帖

gyctju

金虫 (正式写手)

【答案】应助回帖

★ ★
感谢参与,应助指数 +1
xiegangmai(金币+2): 谢谢应助! 2012-01-08 22:58:47
可能你想法错了。边界条件部分不应该跟累加传热量的循环放在一起,这样的实际效果跟你想的是不一样的。
还有边界条件设定时应该用begin-f-loop
建议修改成如下形式试试
#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*/
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};
thread_loop_c(t,d) /*Compute Q */ /*Loop over all cells */
begin_c_loop(c,t)
{

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;  
}
end_c_loop(c,t)
}
begine_f_loop(c,t,)
{
if (Q_tot<= Heat )
F_PROFILE(c,t,position)=60;
else F_PROFILE(c,t,position)=0;
}
end_f_loop
11楼2012-01-08 21:11:19
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

gyctju

金虫 (正式写手)


xiegangmai(金币+1): 谢谢参与! 2012-01-09 21:27:48
第一个循环就是累加热量的
13楼2012-01-09 10:42:57
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

gyctju

金虫 (正式写手)

引用回帖:
12楼: Originally posted by xiaoguai3 at 2012-01-09 09:29:51:
谢谢回复~请问累加传热量该怎么处理呢?

我上边回复的那个修改大括号那块出错了,把begine_f_loop前面的大括号挪到最后去
14楼2012-01-09 10:45:24
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

gyctju

金虫 (正式写手)


xiegangmai(金币+1): 谢谢参与! 2012-01-09 21:28:09
again,边界条件用begin_f_loop
估计你都没看我修改后的语句。
16楼2012-01-09 19:16:54
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 xiaoguai3 的主题更新
信息提示
请填处理意见