Sei sulla pagina 1di 4

6/17/2016

FLUENT6.3UDFManual3.3.2AdvancedMultiphaseMacros

3.3.2AdvancedMultiphaseMacros
FormoststandardUDFswrittenformultiphasemodels(e.g.,sourceterm,materialproperty,profile
functions),variablesthatyourfunctionneeds(domainpointers,threadpointers,etc.)arepasseddirectly
toyourUDFasargumentsbythesolverinthesolutionprocess.AllyouneedtodoishooktheUDFto
yourmodelandeverythingistakencareof.Forexample,ifyourmultiphaseUDFdefinesacustom
profileforaparticularboundaryzone(usingDEFINE_PROFILE)andishookedtotheappropriatephaseor
mixtureinFLUENTintherelevantboundaryconditionpanel,thenappropriatephaseormixture
variableswillbepassedtoyourfunctionbythesolveratruntime.
Theremay,however,bemorecomplexfunctionsyouwishtowritethatrequireavariablethatisnot
directlypassedthroughitsarguments.DEFINE_ADJUSTandDEFINE_INITfunctions,forexample,arepassed
mixturedomainvariablesonly.IfaUDFrequiresaphasedomainpointer,instead,thenitwillneedto
utilizemacrospresentedinthissectiontoretrieveit.ON_DEMANDUDFSaren'tdirectlypassedanyvariables
thorughtheirarguments.Consequently,anyondemandfunctionthatrequiresaccesstophaseordomain
variableswillalsoneedtoutilizemacrospresentedinthissectiontoretrievethem.
RecallthatwhenyouarewritingUDFsformultiphasemodels,youwillneedtokeepinmindthe
hierarchyofstructureswithinFLUENT(seeSection1.10.1fordetails).Theparticulardomainorthread
structurethatgetspassedintoyourUDFfromthesolverdependsontheDEFINEmacroyouareusing,as
wellasthedomainthefunctionishookedto(eitherthroughthegraphicaluserinterface,orhardwiredin
thecode).Asmentionedabove,italsomaydependonthemultiphasemodelthatyouareusing.Referto
Section1.10.1and,inparticular,Figure1.10.1foradiscussiononhierarchyofstructureswithin
FLUENT.

PhaseDomainPointer(DOMAIN_SUB_DOMAIN)
Therearetwowaysyoucangetaccesstoaspecificphase(orsubdomain)pointerwithinthemixture
domain.YoucanuseeithertheDOMAIN_SUB_DOMAINmacro(describedbelow)orGet_Domain,whichis
describedbelow.
DOMAIN_SUB_DOMAINhastwoarguments:mixture_domainandphase_domain_index.Thefunctionreturnsthe
phasepointersubdomainforthegivenphase_domain_index.NotethatDOMAIN_SUB_DOMAINissimilarin
implementationtotheTHREAD_SUB_THREADmacrodescribedinSection3.3.2.
intphase_domain_index=0;/*primaryphaseindexis0*/
Domain*mixture_domain;
Domain*subdomain=DOMAIN_SUB_DOMAIN(mixture_domain,phase_domain_index);
mixture_domainisapointertothemixtureleveldomain.ItisautomaticallypassedtoyourUDFbythe
FLUENTsolverwhenyouuseaDEFINEmacrothatcontainsadomainvariableargument(e.g.,
https://www.sharcnet.ca/Software/Fluent6/html/udf/node99.htm

1/4

6/17/2016

FLUENT6.3UDFManual3.3.2AdvancedMultiphaseMacros

DEFINE_ADJUST)andyourUDFishookedtothemixture.Otherwise,ifthemixture_domainisnotexplicitly
passedtoyourUDF,youwillneedtouseanotherutilitymacrotoretrieveit(e.g.,Get_Domain(1))before
callingsub_domain_loop.
phase_domain_indexisanindexofsubdomainpointers.Itisanintegerthatstartswith0fortheprimary
phaseandisincrementedbyoneforeachsecondaryphase.phase_domain_indexisautomaticallypassed
toyourUDFbytheFLUENTsolverwhenyouuseaDEFINEmacrothatcontainsaphasedomainindex
argument(DEFINE_EXCHANGE_PROPERTY,DEFINE_VECTOR_EXCHANGE_PROPERTY)andyourUDFishookedtoa
specificinteractionphase.Otherwise,youwillneedtohardcodetheintegervalueofphase_domain_index
totheDOMAIN_SUB_DOMAINmacro.Ifyourmultiphasemodelhasonlytwophasesdefined,then
phase_domain_indexis0fortheprimaryphase,and1forthesecondaryphase.However,ifyouhavemore

thanonesecondaryphasedefinedforyourmultiphasemodel,youwillneedtousethe
PHASE_DOMAIN_INDEXutilitytoretrievethecorrespondingphase_domain_indexforthegivendomain.See
Section3.3.2fordetails.

PhaseLevelThreadPointer(THREAD_SUB_THREAD)
TheTHREAD_SUB_THREADmacrocanbeusedtoretrievethephaselevelthread(subthread)pointer,given
thephasedomainindex.THREAD_SUB_THREADhastwoarguments:mixture_threadandphase_domain_index.
Thefunctionreturnsthephaselevelthreadpointerforthegivenphase_domain_index.Notethat
THREAD_SUB_THREADissimilarinimplementationtotheDOMAIN_SUB_DOMAINmacrodescribedinSection
3.3.2.
intphase_domain_index=0;/*primaryphaseindexis0*/
Thread*mixture_thread;/*mixturelevelthreadpointer*/
Thread*subthread=THREAD_SUB_THREAD(mixture_thread,phase_domain_index);
mixture_threadisapointertoamixturelevelthread.ItisautomaticallypassedtoyourUDFbythe
FLUENTsolverwhenyouuseaDEFINEmacrothatcontainsavariablethreadargument(e.g.,
DEFINE_PROFILE),andthefunctionishookedtothemixture.Otherwise,ifthemixturethreadpointeris
notexplicitlypassedtoyourUDF,thenyouwillneedtousetheLookup_Threadutilitymacrotoretrieveit

(seeSection3.2.6).
phase_domain_indexisanindexofsubdomainpointers.Itisanintegerthatstartswith0fortheprimary
phaseandisincrementedbyoneforeachsecondaryphase.phase_domain_indexisautomaticallypassed
toyourUDFbytheFLUENTsolverwhenyouuseaDEFINEmacrothatcontainsaphasedomainindex
argument(DEFINE_EXCHANGE_PROPERTY,DEFINE_VECTOR_EXCHANGE_PROPERTY)andyourUDFishookedtoa

specificinteractionphase.(SeeSection2.4.2foranexampleUDF.)Otherwise,youwillneedtohard
codetheintegervalueofphase_domain_indextotheTHREAD_SUB_THREADmacro.Ifyourmultiphasemodel
hasonlytwophasesdefined,thenphase_domain_indexis0fortheprimaryphase,and1forthesecondary
phase.However,ifyouhavemorethanonesecondaryphasedefinedforyourmultiphasemodel,youwill
needtousethePHASE_DOMAIN_INDEXutilitytoretrievethecorrespondingphase_domain_indexforthe
givendomain.SeeSection3.3.2fordetails.

PhaseThreadPointerArray(THREAD_SUB_THREAD)
https://www.sharcnet.ca/Software/Fluent6/html/udf/node99.htm

2/4

6/17/2016

FLUENT6.3UDFManual3.3.2AdvancedMultiphaseMacros

TheTHREAD_SUB_THREADSmacrocanbeusedtoretrievethepointerarray,pt,whoseelementscontain
pointerstophaselevelthreads(subthreads).THREADS_SUB_THREADShasoneargument,mixture_thread.
Thread*mixture_thread;
Thread**pt;/*initializept*/
pt=THREAD_SUB_THREADS(mixture_thread);
mixture_threadisapointertoamixturelevelthreadwhichcanrepresentacellthreadorafacethread.It
isautomaticallypassedtoyourUDFbytheFLUENTsolverwhenyouuseaDEFINEmacrothatcontains
avariablethreadargument(e.g.,DEFINE_PROFILE),andthefunctionishookedtothemixture.Otherwise,

ifthemixturethreadpointerisnotexplicitlypassedtoyourUDF,thenyouwillneedtouseanother
methodtoretrieveit.ForexampleyoucanusetheLookup_Threadutilitymacro(seeSection3.2.6).
pt[i],anelementinthearray,isapointertothecorrespondingphaselevelthreadforthe thphase,
whereiisthephase_domain_index.Youcanusept[i]asanargumenttosomecellvariablemacroswhen
youwanttoretrievespecificphaseinformationatacell.Forexample,C_R(c,pt[i])canbeusedtoreturn

thedensityofthe thphasefluidatcellc.Thepointerpt[i]canalsoberetrievedusing
THREAD_SUB_THREAD,discussedinSection3.3.2,usingiasanargument.Thephase_domain_indexcanbe
retrievedusingthePHASE_DOMAIN_INDEXmacro.SeeSection3.3.2fordetails.

MixtureDomainPointer(DOMAIN_SUPER_DOMAIN)
YoucanuseDOMAIN_SUPER_DOMAINwhenyourUDFhasaccesstoaparticularphaseleveldomain
(subdomain)pointer,andyouwanttoretrievethemixtureleveldomainpointer.DOMAIN_SUPER_DOMAINhas
oneargument,subdomain.NotethatDOMAIN_SUPER_DOMAINissimilarinimplementationtothe
THREAD_SUPER_THREADmacrodescribedinSection3.3.2.
Domain*subdomain;
Domain*mixture_domain=DOMAIN_SUPER_DOMAIN(subdomain);
subdomainisapointertoaphaseleveldomainwithinthemultiphasemixture.Itisautomaticallypassed
toyourUDFbytheFLUENTsolverwhenyouuseaDEFINEmacrothatcontainsadomainvariable
argument(e.g.,DEFINE_ADJUST),andthefunctionishookedtoaprimaryorsecondaryphaseinthe
mixture.NotethatinthecurrentversionofFLUENT,DOMAIN_SUPER_DOMAINwillreturnthesamepointer
asGet_Domain(1).Therefore,ifasubdomainpointerisavailableinyourUDF,itisrecommendedthatthe
DOMAIN_SUPER_DOMAINmacrobeusedinsteadoftheGet_Domainmacrotoavoidpotentialincompatibility

issueswithfuturereleasesofFLUENT.

MixtureThreadPointer(THREAD_SUPER_THREAD)
YoucanusetheTHREAD_SUPER_THREADmacrowhenyourUDFhasaccesstoaparticularphaselevelthread
(subthread)pointer,andyouwanttoretrievethemixturelevelthreadpointer.THREAD_SUPER_THREADhas
oneargument,subthread.
https://www.sharcnet.ca/Software/Fluent6/html/udf/node99.htm

3/4

6/17/2016

FLUENT6.3UDFManual3.3.2AdvancedMultiphaseMacros

Thread*subthread;
Thread*mixture_thread=THREAD_SUPER_THREAD(subthread);
subthreadisapointertoaparticularphaselevelthreadwithinthemultiphasemixture.Itisautomatically
passedtoyourUDFbytheFLUENTsolverwhenyouuseaDEFINEmacrothatcontainsathreadvariable
argument(e.g.,DEFINE_PROFILE,andthefunctionishookedtoaprimaryorsecondaryphaseinthe
mixture.NotethatTHREAD_SUPER_THREADissimilarinimplementationtotheDOMAIN_SUPER_DOMAINmacro

describedinSection3.3.2.

DomainID(DOMAIN_ID)
YoucanuseDOMAIN_IDwhenyouwanttoaccessthedomain_idthatcorrespondstoagivenphaselevel
domainpointer.DOMAIN_IDhasoneargument,subdomain,whichisthepointertoaphaseleveldomain.
Thedefaultdomain_idvalueforthetopleveldomain(mixture)is1.Thatis,ifthedomainpointerthatis
passedtoDOMAIN_IDisthemixtureleveldomainpointer,thenthefunctionwillreturnavalueof1.Note
thatthedomain_idthatisreturnedbythemacroisthesameintegerIDthatisdisplayedinthegraphical
userinterfacewhenyouselectthedesiredphaseinthePhasespanelinFLUENT.
Domain*subdomain;
intdomain_id=DOMAIN_ID(subdomain);

PhaseDomainIndex(PHASE_DOMAIN_INDEX)
ThePHASE_DOMAIN_INDEXmacroretrievesthephase_domain_indexforagivenphaseleveldomain
(subdomain)pointer.PHASE_DOMAIN_INDEXhasoneargument,subdomain,whichisthepointertoaphase
leveldomain.phase_domain_indexisanindexofsubdomainpointers.Itisanintegerthatstartswith0for
theprimaryphaseandisincrementedbyoneforeachsecondaryphase.
Domain*subdomain;
intphase_domain_index=PHASE_DOMAIN_INDEX(subdomain);

Previous:3.3.1MultiphaseLoopingMacros
Up:3.3LoopingMacros
Next:3.4VectorandDimension
FluentInc.20060913

https://www.sharcnet.ca/Software/Fluent6/html/udf/node99.htm

4/4

Potrebbero piacerti anche