fluent UDF第五章 使用宏存取FLUENT解算器变量.docx
- 文档编号:24798084
- 上传时间:2023-06-01
- 格式:DOCX
- 页数:30
- 大小:46.26KB
fluent UDF第五章 使用宏存取FLUENT解算器变量.docx
《fluent UDF第五章 使用宏存取FLUENT解算器变量.docx》由会员分享,可在线阅读,更多相关《fluent UDF第五章 使用宏存取FLUENT解算器变量.docx(30页珍藏版)》请在冰豆网上搜索。
fluentUDF第五章使用宏存取FLUENT解算器变量
第五章使用宏存取FLUENT解算器变量
本章提供了可以存取FLUENT解算器中变量的预定义宏。
5.1介绍
5.2单元宏
5.3面宏
5.4几何图形宏
5.5节点宏
5.6多相宏
5.7DPM宏
5.8NOx宏
5.1Introduction
FluentInc.hasprovidedyouwithasetofpredefinedfunctionsthatyoucanusetoaccessdatafromtheFLUENTsolver.Thesefunctionsareprimarilyimplementedinthecodeasmacros.Themacroslistedinthischapteraredefinedinheaderfilessuchasmem.h,metric.h,anddpm.h.Theudf.hfilecontainsdefinitionsforDEFINEmacros,aswellas#includedirectivesformostofthesolveraccessmacroheaderfilesfoundinthischapter.Therefore,includingudf.hinyoursourcecodefilewillalsoresultintheinclusionofsolveraccess.hfiles.Someexamplesofsolverdatayoucanaccessusingpredefinedmacrosare:
_solutionvariablesandtheirderivatives(e.g.,velocity,temperature,turbulencequantities)
_geometryvariables(e.g.,coordinates,areas,volumes)
_gridandnodevariables(e.g.,nodevelocities)
_materialpropertyvariables(e.g.,density,viscosity,conductivity)
_discretephasemodelvariables
5.1介绍
Fluent公司提供了一系列预定义函数来从求解器中读写数据。
这些函数以宏的形式存放在代码中。
这章的所列出的宏是被定义在扩展名为.h文件里的。
例如mem.h,metric.h,和dpm.h。
在udf.h文件中包含了宏的定义和这章中所用到的大部分宏文件和它的说明。
因此如果在你的原程序中包含了udf.h文件,那么也就包含了各种的求解器读写文件了。
(.h文件)。
下面列出了一些使用预先设计的宏来读写数据类型:
——溶液变量及它们的组合变量(速度,温度,湍流量等)
——几何变量(坐标,面积,体积等)
——网格和节点变量(节点速度等)
——材料性质变量(密度,粘度,导电性等)
——分散相模拟变量。
Foralltypesofdataexceptspecificheat,theword\access"referstoreadingandwriting
data.Inthecaseofspecificheat,however,datacanbereadbutcannotbemodified.
Inthefollowingsections,eachmacroislistedwithitsarguments,argumenttypes,and
returnedvalue.Argumentsbelongtothefollowingdatatypes:
cell_tccellidentifier
face_tffaceidentifier
Thread*tpointertoathread
Thread**ptpointertoanarrayofphasethreads
Intiintegerindex
Node*nodepointertoanode
Argumentsareeitherinputstoafunction,orareoutputs.Eachmacroreturnsavalue,
whicheitherisoutputbacktothesolver(asanargument),orisavailableforassignment
inyourfunction.
对于除了指定的热量以外的所有数据而言,存取这个词还指读写数据。
对于指定的的热量的数据是只能读不能改的。
在下面章节中列出了每一个宏的包含的参数,参数的类型和返回值。
其中参数属于下面的数据类型。
cell_tc单元格标识符
face_t面积标识符
Thread*t线指示器
Thread**pt象限矩阵指示器
IntI整数
Node*node节点指示器
参数既不是方程的输入也不是方程的输出。
每一个宏返回一个值,这个值要么作为一个参数以输出值的形式返回求解器,要么是你方程中可用参数。
Forexample,themacroC_T
realtemp;
temp=C_T(c,t);
hastwoarguments,cellidentifiercandthreadpointert.Theseargumentsarepassed
fromtheFLUENTsolvertothefunction.CTreturnstherealvalueoftemperature,
whichcanthenbeassignedtoavariableinyourUDF(tempinthisexample).
例如宏C_T
realtemp;
temp=C_T(c,t);
C_T有两个参数,单元标识符C和线指示器t。
这些参数从FLUENT求解器中返回到方程中。
C_T返回一个温度的实数值,这个值能够分配到的你的UDF变量中去。
(比如这个例子中的temp)
C_CENTROID(x,c,t);
hasthreearguments:
x,c,andt.Inthiscasethecellidentifiercandthreadpointer
tareinputarguments,whilethearrayx(thecellcentroid)isoutputtotheFLUENT
solverasanargument.
C_CENTROID(x,c,t)有三个参数,x,c,t。
在这里单元标识符C和线指示器是输入参数,而矩阵x(单元格的质心)是以参数形式输出到FLUENT求解器中的。
5.2CellMacros
Themacroslistedinthissectionarerealvariablesreturnedbythesolver,andarede_ned
onacell.Thesecellvariablesareavailableinboththesegregatedandthecoupledsolvers.
Definitionsforthesecellmacroscanbefoundinthereferencedheaderfiles(e.g.,mem.h).
5.2单元格宏
这章所列出的宏是由求解器返回的实数变量,并且这些变量都是定义在一个单元格中的。
这些单元格变量在单独的或是联合的求解器中都能得到。
(segregatedandthecoupledsolvers.)
这些单元格宏的定义在相关的扩展名为(.h)的文件中可以得到。
(例如mem.h等)
MacrosforaccessingflowvariablesinFLUENT
G,RG,M1,andM2suffixesthatareshownforthecelltemperaturemacro(CT)can
cellpressure(CP).Thesesuffixescorrespondtogradientvector,reconstructiongradient
vector,previoustimestep,and2ndprevioustimestep,respectively.Inthecaseofcell
pressure,thegradientvectorandcomponentsarederivedusingCDPinsteadofCPG.A
descriptionofeachsuffixanditsusageispresentedinthesectionsbelow.
在FLUENT中G,_RG,_M1,和_M2
表在mem.h文件中的流体变量宏
名称(参数)参数类型返回值
C_T(c,t)celltc,Thread*t温度
C_T_G(c,t)celltc,Thread*t温度梯度矢量
C_T_G(c,t)[i]celltc,Thread*t,inti温度梯度矢量的分量
C_T_RG(c,t)celltc,Thread*t改造后的温度梯度矢量
C_T_RG(c,t)[i]celltc,Thread*t,inti改造后的温度梯度矢量的
分量
C_T_M1(c,t)celltc,Thread*t温度的前一次步长
C_T_M2(c,t)celltc,Thread*t温度的前二次步长
C_P(c,t)celltc,Thread*t压力
**C_DPinsgmem.h
C_DP(c,t)celltc,Thread*t压力梯度矢量
C_DP(c,t)[i]celltc,Thread*t,intI压力梯度矢量的分量
C_U(c,t)celltc,Thread*tu方向的速度
C_V(c,t)celltc,Thread*tv方向的速度
C_W(c,t)celltc,Thread*tw方向的速度
C_H(c,t)celltc,Thread*t焓
C_YI(c,t,i)celltc,Thread*t,inti物质质量分数
C_K(c,t)celltc,Thread*t湍流运动能
C_D(c,t)celltc,Thread*t湍流运动能的分散
速率
C_O(c,t)celltc,Thread*t确定的分散速率
AccessingGradient(G)VectorsandComponents
YoucanaddthetheGsuffixtoyourmacrotoaccessthegradient(G)vectorofavariable
quantity.Forexample,
C_T_G(c,t);/*returnsthecelltemperaturegradientvector.*/
returnsthetemperaturegradientvector.Notethatgradientvariablesareavailableonly
whentheequationforthatvariableisbeingsolved.Forexample,ifyouaredefining
asourcetermforenergy,yourUDFcanaccessthecelltemperaturegradient(using
CTG),butitcan'tgetaccesstothex-velocitygradient(usingCUG).Therefore,if
youaresettingupauser-definedscalartransportequation,somegradientsmaynotbe
available.Thisisbecausethesolvercontinuallyremovesfrommemorydatathatitdoesn't
need.Youcanpreventthesolverfromfreeingupmemorybyissuingthetextcommand
solve/set/expert,andthenansweringyestothequestion,Keeptemporarysolver
memoryfrombeingfreed?
.Ifyoudothis,allofthegradientdataareretained,but
thecalculationrequiresmorememorytorun.
读写梯度矢量和其分量
你可以在你的宏中加入下标_G来得到梯度矢量和它的分量,例如:
C_T_G(c,t);/*返回单元格的温度梯度矢量.*/
注意只有当已经求解出包含这个变量的方程时才能得到梯度变量。
例如如果你定义了一个关于能量的原程序,那么你的UDF可以读写单元格的温度梯度(使用C_T_G)
但是你却不能读写X方向的速度分量(使用C_U_G)。
而且,如果你建立了一个由使用者确定的方式转移方程,那么你就不能得到一部分的梯度了。
这是因为求解器不断的移走它不需要的数据。
你可以使用下面的方法来阻止存储器释放记忆:
发出文本命令save/set/expert,然后对计算机提出的“是否阻止暂时的求解器记忆释放”这一提问回答“是”。
按照这种做法就可以保留所有的梯度数据,但是这种计算需要更多的内存。
Youcanaccessacomponentofagradientvectorbyspecifyingitasanargumentinthe
gradientvectorcall(0forthexcomponent;1fory;and2forz).Forexample,
C_T_G(c,t)[0];/*returnsthex-componentofthecelltemperature*/
/*gradientvector*/
returnsthex
thegradientandcomponentmacrosareshownonlyfortemperaturebutcanbeextended
toallofthevariablesexceptpressure.YoumustuseCDPtoaccessthecellpressure
在调用梯度矢量时把某一分量作为参数,这样就可以得到梯度分量了,(参数0代表X方向的分量,1代表Y方向的分量,2代表Z方向的分量)例如:
C_T_G(c,t)[0];/*返回温度梯度X方向的分量*/
AccessingReconstructionGradient(RG)Vectorsand
Components
Inthesamewayasthegradient,youcanaddtheRGsu_xtoyourmacrotoaccessthe
reconstructiongradient(RG)vectorandcomponentsofavariablequantity.Byspecify-
ingtheappropriateinteger(0forthexcomponent;1fory;and2forz)asanargument,
youcanobtainthedesiredvectorcomponent.Reconstructiongradientsaretypically
usedwhenyouwanttoimplementyourowninterpolationscheme.Reconstructiongra-
beextendedtoallofthevariables.NotethatRGvariables,likegradientvariables,are
availableonlywhentheequationforthatvariableisbeingsolved.
读写改造过的梯度矢量和其分量
AccessingPreviousTimeSteps
TheM1suffivalueofthevariableattheprevioustimestep(i.e.,t-_t).Thesedatamaybeuseful
inunsteadysimulations.Forexample,
C_T_M1(c,t);/*returnsvalueofcelltemperatureatprevioustimestep*/
returnsthevalueofthecelltemperatureattheprevioustimestep.
TheM2suffi
thevalueofthevariableatthetimestepbeforethepreviousone(i.e.,t-2_t).These
datamaybeusefulinunsteadysimulations.Previoustimestepmacrosareshownonly
读写前一步长下的时间
⊿t)的变量的值。
得到的这些数据可以在不稳定的模拟中使用。
例如:
C_T_M1(c,t);/*返回前一步时间下的单元格温度的值*/
若在宏的后面加上下标M2就可以得到前两次步长下的时间(t-2⊿
mem.h
名称(参数)
参数类型
返回值
CDUDX(c,t)
celltc,Thread*t
velocityderivative
CDUDY(c,t)
celltc,Thread*t
velocityderivative
CDUDZ(c,t)
celltc,Thread*t
velocityderivative
CDVDX(c,t)
celltc,Thread*t
velocityderivative
CDVDY(c,t)
celltc,Thread*t
velocityderivative
CDVDZ(c,t)
celltc,Thread*t
velocityderivative
CDWDX(c,t)
celltc,Thread*t
velocityderivative
CDWDY(c,t)
celltc,Thread*t
velocityderivative
CDWDZ(c,t)
celltc,Thread*t
velocityderivative
名称(参数)
参数类型
返回值
C_FMEAN(c,t)
celltc,Thread*t
第一次混合分数的平均值
C_FMEAN2(c,t)
celltc,Thread*t
第一次混合分数的平均值
C_FVAR(c,t)
celltc,Thread*t
第一次混合分数变量
C_FVAR2(c,t)
celltc,Thread*t
第二次混合分数变量
C_PREMIXC(c,t)
celltc,Thread*t
反应过程变量
C_LAMFLAMESPEED(c,t)
celltc,Thread*t
层流焰速度
C_CRITICALSTRAIN
celltc,Thread*t
临界应变速度
RATE(c,t)
C_POLLUT(c,t,i)
celltc,Thread*t,inti
第i个污染物质的质量分数
C_R(c,t)
celltc,Thread*t
密度
C_MUL(c,t)
celltc,Thread*t
层流速度
C_MUT(c,t)
celltc,Thread*t
湍流速度
C_MUEFF(c,t)
celltc,Thread*t
有效粘度
C_K_L(c,t)
celltc,Thread*t
热传导系数
C_K_T(c,t)
celltc,Thread*t
湍流热传导系数
C_K_EFF(c,t)
celltc,Thread*t
有效热传导系数
C_CP(c,t)
celltc,Thread*t
确定的热量
C_RGAS(c,t)
celltc,Thread*t
气体常数
C_DIFFL(c,t,i,j)
celltc,Thread*t,inti,
intj
层流物质的扩散率
C_DIFFEFF(c,t,i)
celltc,Thread*t,inti
物质的有效扩散率
C_ABSCOEFF(c,t)
celltc,Thread*t
吸附系数
C_SCATCOEFF(c,t)
celltc,Thread*t
扩散系数
C_NUT(c,t)
celltc,Thread*t
湍流速度forSpalart-Allmaras
finedScalarsandMemory
finedscalarsandmemory
forcells.
finedScalarandMemoryMacrosforCellsinmem.h
Name(Arguments)
ArgumentTypes
Returns
C_UDSI(c,t,i)
cell
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- fluent UDF第五章 使用宏存取FLUENT解算器变量 UDF 第五 使用 存取 解算器 变量