1©2015ANSYS,Inc.June7,201516.0ReleaseLecture7:UDFsforMultiphaseFlowUserDefinedFunctionsinANSYSFluent2©2015ANSYS,Inc.June7,2015MultiphaseUDFs•HowmultiphasespecificUDFdiffersfromsingle-phasespecificUDF?•Howtoaccessphasespecificdatausingdataaccessmacros?•HowtoretrievemultiphasespecificdomainorthreadpointersthatareNOTpassedbyDEFINEmacro?•WhataretheimplicationsofusingsamegeneralpurposeDEFINEmacrowithdifferentmultiphasemodels?•WhatarethedifferentutilityandloopingmacrosavailableformultiphaseUDFs?3©2015ANSYS,Inc.June7,2015Fluent-specificDataTypesIntegerdatatypeface_t:Identifiesaparticularfacewithinafacethread.cell_t:Identifiesaparticularcellwithinacellthread.StructuredatatypeNode:Storesdataassociatedwithameshpoint.Thread:Storesdatathatiscommontothegroupofcellsorfacesthatitrepresents.Multiphase:Thereisathreadstructureforeachphase,aswellasforthemixture.Domain:Storesdataassociatedwithacollectionofnode,face,andcellthreadsinamesh.Single-phase:Thereisonlyasingledomainstructure.Multiphase:Therearedomainstructuresforeachphase,theinteractionbetweenphases,aswellasforthemixture.DeclarationinUDF:face_txx;cell_txx;Pointervariables:Node*xx;Thread*xx;Domain*xx;4©2015ANSYS,Inc.June7,2015SubdomainsInheritsmixturespecificdata,andmaintainsphase-specificdataSuperdomainContainsallphase-independentdata,andmixturepropertiesandvalues(sumoverallphases)Multiphase:DomainStructureHierarchyInteractiondomainsForcustomizationofphaseinteractionmechanismsMixturedomainPrimaryphasedomainSecondaryphasedomainSecondaryphasedomain5©2015ANSYS,Inc.June7,2015Multiphase:ThreadStructureHierarchy•Threadspossesasimilarhierarchythatmatchesthatofadomain.•Threadsassociatedwiththesuperdomainarereferredtoas‘superthreads’,whilethreadsassociatedwiththesubdomainarereferredtoasphase-levelthreads,or‘subthreads’.FluidzonesMixturelevelthreadsBoundaryzonesSecondaryphasethreadsSecondaryphasethreadsPrimaryphasethreadsSimilartoduplicationofthreadsforeachphase.Moreonnextslide...6©2015ANSYS,Inc.June7,2015Multiphase:ThreadDataStructureSimilartoduplicationofthreadsforeachphase.Advantage:Samecellindex(cell_tc)andfaceindex(face_tf)isusedbyalldifferentthreadsinanyloops.begin_c_loop(c,mix_thread)/*MixtureorPhasethreadcanbeused*/{Message(“TotalVOF=%f=1.0\n”,C_VOF(c,thread_primary)+C_VOF(c,thread_secondary1)+C_VOF(c,thread_secondary2))}end_c_loop(c,mix_thread)Volumefractionforthephasecorrespondingtothephasethread.Example:7©2015ANSYS,Inc.June7,2015DomainPointersandPhaseDomainIDs•DomainIDs−ANSYSFluentassignsuniqueintegerIDstoeachofthedomains.−MixtureDOMAIN_IDisalways1.−PhaseDOMAIN_IDcanbefoundfromphasestaskpageinGUI.•RelatedUDFutilitymacrosDomain*mixture_domain=Get_Domain(1);Domain*d_coal_par=Get_Domain(5);DomainIDsMixtureorphasedomainpointersGet_Domain(id)DOMAIN_ID(subdomain)Domain*phase_domain;intdomain_id=DOMAIN_ID(phase_domain);SelectphaseCorrespondingdomainIDisshownhereIDsmaynotbeconsecutiveSolutionSetupPhasesExamples:8©2015ANSYS,Inc.June7,2015PhaseDomainPointersandPhaseDomainIndex•PhaseDomainIndex–Anintegerindexforeachofthephasedomains.–Startswith0fortheprimaryphaseandisincrementedbyoneforeachsecondaryphase.–Primarilyusedtoretrievephasedomainpointers.–Sometimesusedtoretrievephasethreadpointers.•RelatedUDFutilitymacros:PHASE_DOMAIN_INDEX(phase_domain)PhaseDomainIndexPhasedomainpointersDOMAIN_SUB_DOMAIN(mixture_domain,phase_domain_index)intphase_domain_index=0;/*primaryphaseindexis0*/Domain*mixture_domain;Domain*subdomain;subdomain=DOMAIN_SUB_DOMAIN(mixture_domain,phase_domain_index);Domain*subdomain;intphase_domain_index;phase_domain_index=PHASE_DOMAIN_INDEX(subdomain);Examples:9©2015ANSYS,Inc.June7,2015UsingDEFINEMacrosforMultiphaseUDFsSomegeneralpurposeDEFINEmacrospassonlyfewUDFvariableswhileothersdonotpassanyvariable.•DEFINE_ADJUST(name,mix_domain)•DEFINE_INIT(name,mix_domain)•DEFINE_ON_DEMAND(name)•DEFINE_EXECUTE_AT_EXIT(name)OnlymixturedomainpointerispassedtoUDFDonotpassanyUDFvariableMixturedomainpointerCustomizationusingdataaccessmacrosDEFINE_ADJUST(name,md)Toaccessphasedomainandphasethreadpointers,usemultiphasespecificutilitymacros.Usegeneralpurposeutilitymacrose.g.loopingovercellsorfaces10©2015ANSYS,Inc.June7,2015RetrievingMixtureandPhaseDomainPointersMixturedomainpointerPhasedomainpointersDOMAIN_SUB_DOMAIN(mix_domain,phase_domain_index);DOMAIN_SUPER_DOMAIN(phase_domain);DomainIDGet_Domain(1);Get_Domain(ID);FromGUI11©2015ANSYS,Inc.June7,2015RetrievingMixtureandPhaseThreadPointers(1)MixturethreadpointersLookup_Thread(mix_domain,zone_ID);thread_loop_c(mix_thread,mix_domain){}PhasethreadpointersNextslideDomain*mix_domain;Thread*mix_thread;/*loopsoverallcellthreadsindomain*/thread_loop_c(mix_thread,mix_domain){}intzone_ID=2;/*fromGUI*/Thread*mix_thread;mix_thread=Lookup_Thread(mix_domain,zone_ID);Examples:12©2015ANSYS,Inc.June7,2015RetrievingMixtureandPhaseThreadPointers(2)MixturethreadpointersPhasethreadpointersTHREAD_SUB_THREAD(mix_thread,phase_domain_index);THREAD_SUPER_THREAD(phase_thread);THREAD_SUB_THREADS(mix_thread);/*PhaseThreadPointerArray*/Thread*mixture_thread;Threa