©2012ANSYS,Inc.June17,20131Release14.514.5ReleaseChapter4UserDefinedMemoriesandScalarsUserDefinedFunctionsinANSYSFluent©2012ANSYS,Inc.June17,20132Release14.5UserDefinedMemorySometimesitisusefultodefineextrafieldvariablestostoreandretrievevaluesdefinedbytheuser.UserDefinedMemories(UDMs)aredefinedin:Define→UserDefined→UserDefinedMemory•Upto500UDMscanbeusedtostoreandretrieveuservalues.•Theycanbeplottedincontoursandaresavedinthedatafile.•ThesevaluesarenotchangedbyFluent,onlyinaUDFwith:•C_UDMI(c,ct,i)=my_cell_value;•F_UDMI(f,ft,i)=my_face_value;(Onlyonboundaryfaces)©2012ANSYS,Inc.June17,20133Release14.5PostProcessingwithUDMsThisADJUSTUDFsetsaUDMtothemagnitudeofthespatialgradientvectorofaUDSsothatcontoursandotherpost-processingcanbedoneonthegradient.#includeudf.hDEFINE_ADJUST(set_uds0_gradient_magnitude,domain){Thread*ct;cell_tc;intindex;index=0;/*CoulddoaloopoverN_UDS,thenumberofUDSs*//*oroverN_UDM,thenumberofUDMsdefined.*/thread_loop_c(ct,domain){begin_c_loop(c,ct){/*Thegradientvectorofmanycalculatedvaluescanbegot*//*byadding_Gtothestandardvariablename:C_T_G(c,ct)*/C_UDMI(c,ct,index)=NV_MAG(C_UDSI_G(c,ct,index));}end_c_loop(c,ct)}}©2012ANSYS,Inc.June17,20134Release14.54User-DefinedScalarsFLUENTcansolvethetransportequationsfortheNUserDefinedScalars(UDS)governedbythegenericPDEs:•ThemenuisaccessedthroughDefineModelsUser-DefinedScalars…•UserspecifiesnumberofUser-DefinedScalarsandUDFcanbeusedforpartsofscalartransportequation:Advectiveflux:DEFINE_UDS_FLUXforthenon-defaultdefinitionUnsteadyterm:DEFINE_UDS_UNSTEADYDiffusivity:DEFINE_DIFFUSIVITY©2012ANSYS,Inc.June17,20135Release14.5User-DefinedScalarsEachscalarcanbesettoonlybecalculatedinfluidzones,solidzones,allzonesorjustselectedzones.EachscalarcanhaveadifferentFluxFunctionsetting.©2012ANSYS,Inc.June17,20136Release14.5UserDefinedScalarsWhenaUDSisdefined,thediffusivityofthescalarmustbedefinedinthematerialpropertypanelforeachmaterial:Define→MaterialProperty•Thedefaultdiffusivityforallscalarsis1.0•ThisconstantcanbechangedtoadifferentvalueormodifiedusingaDEFINE_DIFFUSIVITYUDF©2012ANSYS,Inc.June17,20137Release14.5UserDefinedScalarsBoundaryconditionsforthescalarscanbedefinedusing:Define→BoundaryConditions→....OptionsforspecifyingaconstantvalueorfluxoruseofaUDFProfileforeither.©2012ANSYS,Inc.June17,20138Release14.5UserDefinedScalarsTheSourcetermsforthescalarsaresetusingthestandardDEFINE_SOURCEmacrointroducedbefore.Theothertermsinthetransportequationcanbecustomizedusing:−TheFluxtermcanbemodifiedusing:DEFINE_UDS_FLUX•Thismacroreturnsthedotproductofthefluxvectorandthefaceareavectorofeachfaceofacell−TheUnsteadytermissetusing:DEFINE_UDS_UNSTEADY•SeetheUDSworkshopfortheunsteadyUDSfunction