| 5 | 1/1 | 返回列表 |
| 查看: 2411 | 回復(fù): 6 | |||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | |||
leixiaobo713銀蟲 (正式寫手)
|
[求助]
fluent中UDF編譯的問題!
|
||
|
本人現(xiàn)在做fluent模擬的問題,需要用UDF對(duì)熱源進(jìn)行編譯。其中熱源是隨時(shí)間變化的,當(dāng)時(shí)間t=0時(shí),熱源為一個(gè)關(guān)于溫度的函數(shù),當(dāng)t不等于0時(shí),熱源為0(也就是材料僅有一個(gè)初始熱源)。下面為所編程序,但是老是出錯(cuò),請(qǐng)高手指教,感激不盡! #include "udf.h" DEFINE_SOURCE(source_terms,c,t,dS,eqn) { real A=0.01; real B=0.02; real C=0.001; real D=0.001; real T=C_T(c,t); real t=RP_Get_Real("flow-time" ); real source; if(t=0) source=A*T+B*pow(T,2)+C*pow(T,3)+D*pow(T,4); else source=0; dS[eqn]=0; return source; } 結(jié)果interpreted時(shí)出現(xiàn)下面提示: t definition shadows previous definition Error: C:\Documents and Settings\Administrator\\327\300\303\346\Source terms.c: line 14: invalid expression type for if: float. 不知如何解決啊,里面既有時(shí)間t, 也有real T=C_T(c,t); [ Last edited by leixiaobo713 on 2013-7-14 at 23:57 ] |
Fluent UDF |

銀蟲 (正式寫手)

|
有兩個(gè)問題: 1.你想用時(shí)間變量t,但這個(gè)t在宏DEFINE_SOURCE里面已經(jīng)定義了; 2.“if (t=0)”這種寫法不太好,因?yàn)橛?jì)算機(jī)里面的數(shù)和我們想的不太一樣,我們認(rèn)為是0,但計(jì)算機(jī)里面它可能是0.00000000001這種,因此你判斷等于時(shí)一定要注意一下。像這種你最好寫成“if (t<1e-10)”之類的。 |
銀蟲 (正式寫手)
|
我按照你的說法把程度改了下,如下: #include "udf.h" DEFINE_SOURCE(source_terms,c,t,dS,eqn) { real A=0.01; real B=0.02; real C=0.001; real D=0.001; real T=C_T(c,t); real source; if(t<1e-10) source=A*T+B*pow(T,2)+C*pow(T,3)+D*pow(T,4); else source=0; dS[eqn]=0; return source; } 但是interpreted后出現(xiàn)下面的提示: line 10: invalid type for binary expression: pointer to structure < float. |

鐵桿木蟲 (正式寫手)
|
if(t=0) source=A*T+B*pow(T,2)+C*pow(T,3)+D*pow(T,4); else source=0; t=0是賦值,判斷用== |

| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 0703 化學(xué) 求調(diào)劑,一志愿山東大學(xué) 342 分 +5 | Shern—- 2026-03-28 | 5/250 |
|
|---|---|---|---|---|
|
[考研] 290求調(diào)劑 +3 | dfffsar 2026-03-29 | 3/150 |
|
|
[考研] 南京大學(xué)化學(xué)調(diào)劑 +9 | 景隨風(fēng) 2026-03-29 | 14/700 |
|
|
[考博] 26申博自薦 +6 | whh869393 2026-03-24 | 6/300 |
|
|
[考研] 300求調(diào)劑,材料科學(xué)英一數(shù)二 +10 | leaflight 2026-03-24 | 10/500 |
|
|
[考研] 22408 359分調(diào)劑 +4 | Qshers 2026-03-27 | 6/300 |
|
|
[考研] 349求調(diào)劑 +6 | 李木子啊哈哈 2026-03-25 | 6/300 |
|
|
[考研] 083000學(xué)碩274求調(diào)劑 +8 | Li李魚 2026-03-26 | 8/400 |
|
|
[材料工程] 一志愿C9材料與化工專業(yè)總分300求調(diào)劑 +8 | 曼111 2026-03-24 | 9/450 |
|
|
[考研] 328求調(diào)劑 +7 | 嗯滴的基本都 2026-03-27 | 7/350 |
|
|
[考研] 求調(diào)劑323材料與化工 +7 | 1124361 2026-03-24 | 7/350 |
|
|
[考研] 341求調(diào)劑 +7 | 青檸檬1 2026-03-26 | 7/350 |
|
|
[考研] 321求調(diào)劑 +6 | Ymlll 2026-03-24 | 6/300 |
|
|
[考研] 機(jī)械學(xué)碩總分317求調(diào)劑!。。 +4 | Acaciad 2026-03-25 | 4/200 |
|
|
[考研] 材料與化工304求B區(qū)調(diào)劑 +3 | 邱gl 2026-03-25 | 3/150 |
|
|
[考研] 求調(diào)劑 +3 | 李李不服輸 2026-03-25 | 3/150 |
|
|
[考研] 086003食品工程求調(diào)劑 +6 | 淼淼111 2026-03-24 | 6/300 |
|
|
[考研] 080500求調(diào)劑 +3 | zzzzfan 2026-03-24 | 3/150 |
|
|
[考研] 材料/農(nóng)業(yè)專業(yè),07/08開頭均可,過線就行 +3 | 呵唔哦豁 2026-03-23 | 4/200 |
|
|
[考研] 336化工調(diào)劑 +4 | 王大坦1 2026-03-23 | 5/250 |
|