CFX用户手册-User Fortran.docx
UserFortranIntroductionThechapterdiscusses: I:SeTCE1FUnC1iO1SandRc)U1ineS USerJ1mCtionBOXRoUtineS Shared1ibrarieS USCrParamoterS Iti1i1yROU1inCSforUSCrFUnC1iOnS ANSYSCFXMe1norYManaEC【nonISys1cm(MMS) USerCE1EXamP1eS USer血nctionBOXEXan1PIeS USingCFX-4RoUtineSinANSYSCFXToa11owyoutoaddadditiona1featuresandphysica1mode1stoANSYSCFX,youcanwriteyourownsubroutinesinFortranandhavetheANSYSCFX-So1verca11theseroutinesthroughasourcecodeinterface.Youmaya1sowishtoimp1ementcustomizedphysica1mode1swhichwou1dneverbeavai1ab1einANSYSCFXduetoconfidentia1ityconsiderations.ANSYSCFXsupportsusersubroutineswritteninFortran77orFortran90.A1istofsupportedcompi1ersforeachp1atformisavai1ab1e.UsingFortran77wheneverpossib1eisrecommended.Twodifferentkindsofuserroutinesareavai1ab1einANSYSCFX:CFX可以利用两种不同的方式应用用户子程序 UserdefinedCE1(CFXExpression1anguage)functionscanbeusedwithinaCE1expression,fo11owingthestandardCE1ru1es.Fordetai1s,SeeUSerCE1FUnCtionSandRoutines.用户定义CE1(UserdefinedCE1)函数可以在CE1表达式中使用 Junctionboxroutinescanbeusedatsevera1p1acesintheANSYSCFX-So1vertoexecuteusercode.ForCIetaiIs,SeeUSorJUCCtiOnBOXRoutines.Junctionboxroutines可以在ANSYSCFX-So1ver中执行用户代码Thefo11owingtaskscanbeaccomp1ishedwithusersubroutinesinANSYSCFX:通过用户程序可以在CFX中完成以下内容: Inputofuserdata(e.g.,datarequiredforprofi1eboundaryconditionsorexterna11ygeneratedsources). User-specifiedboundaryconditions(e.g.,profi1eboundaryconditions). User-specifiedinitia1conditions(e.g.,externa11ygeneratedf1owfie1ds,randomdistributionordisturbanceofexistingso1utions). User-specifiedsourceterms(e.g.,externa11ygeneratedbodyforcesorgenera1additiona1sourcetermsusedtoimp1ementnewphysica1mode1s). Junctionboxroutinesca11edeverytimestepwhichactsasagenera1interfacebetweentheANSYSCFX-So1verandothersoftware(e.g.,structuremechaniccodes).Junctionboxesa1soofferaninterfaceforadvancedmonitoringandso1utionoutput. Userpartic1eroutinesareusedtospecifysourcesofmomentum,heatandmasstransfer,andcana1sobeusedtospecifyinjectionregionsforpartic1es.Thestructureofpartic1euserroutinesisthesame.Anexamp1eofthisfunctiona1ityisavai1ab1e.FOrdetai1s,SeeStrUCtUreOfIJSerCE1FUnCtiOns.Fordetai1s,SeePartiCIeUSerSources.Fordetai1s,seeUserDefined.NotethatANSYSCFXinc1udesfeaturessuchasadvancedmonitoringofso1utionvariab1esorg1oba1va1uesandextendedCE1functiona1ity,whichmayreduceyourneedforusersubroutines.Tousejunctionboxroutines,youwi11needtobefami1iarwiththeANSYSCFXMMS(MemoryManagementSystem)tosetupandpassarounduserdataforaccessinanysubroutine.Foid。Iai1s,SCCANSYSCFXMenK)IyVanag。IncnISyStem(MMS).Shared1ibrariesa11owsubroutinestobere-usedwithoutrecompi1ationforsuccessiveANSYSCFX-So1verrunsorevenfordifferentapp1ications.The1ocationofashared1ibraryisspecifiedinANSYSCFX-Pre.DuringexecutionoftheANSYSCFX-So1ver,theusersubroutinesare1oadedfromthespecifiedshared1ibraries.Fordetai1s,seeShared1ibraries.UserCE1FunctionsandRoutinesUserCE1functionsa1IowyoutocreateyourownfunctionsinadditiontothepredefinedCE1functions(e.g.,sin,cos,step,etc.).YoucanthenusethesefunctionsinanyexpressionwhereaCE1functioncanbeused.AuserCE1functionpassesanargument1isttoasubroutinethatyouhavewritten,andthenusesthereturnedva1uesfromthesubroutinetosetva1uesforthequantityofinterest.Thefigurebe1owdemonstratestheconcept.UserCE1FuuctiousH11dRoutinesUserCE1fimctnsa11owyoucreateyourownfunebonsvadd-ontotherede6nedCE1funcfaons(eg,an.co.ftcp.CtC)YoucmIbCnuetbeefuactocuaanyeq>cffiCwhereaCE1fuctotCAabeusedAuserCE1func1ionpassesanargumentbetoaubroudnthatyouhavesvntten.andthenusestheEtUmedva1uesfromIherurotjhnetoetveforr斗IafmryOftntwnTnPfigurebe1owdwonff1tP?theconceptA11variab1esthatareavai1ab1eforuseinstandardCE1expressionsarea1soavai1ab1eforuseinUserCE1Expressions.A1istofthesevariab1esisavai1ab1e.Fordetai1s,SeeVariabieSAVaiiabieforUSeinCE1Expressions.Detai1soncreatinguserCE1functionsinANSYSCFX-Preanddefiningquantitiesviaanexpressionwithanargument1istareavai1ab1e. Fordetai1s,SeeUSerROUtineDetaiISView. FOrdetai1s,SeeUSerFUnCtiOnS.Detai1soncreatingshared1ibrariesandcompi1ingsubroutinesareavai1ab1e.FOrdetai1s,SeeShared1ibraries.Examp1esofusinguserCE1functionsareavai1ab1e.Forde1ai1s,SeeUSerCE1Examp1es.StructureofUserCE1FunctionsAUserFortranfiIemaycontainsevera1userroutinesthatcanbeca11edfromtheANSYSCFX-So1ver,aswe11asanysecondaryroutinesthatareca11edon1yfromotherroutinesinthisfi1e.Inadditiontoanycommentsanddec1arationsthatyoumaywishtoadd,thebasicstructureofauserCE1functionis:ftinc1ude,zcfx5ext.h"d11export(<ca11ingname>)SUBROUTINE<ca11ingname>(&N1OC,NRET,NARG,RET,ARGS,CRES1T,CZ,DZ,IZ,1Z,RZ)CINTEGERN1OC,NARG,NRETCHARACTERCRES1T*(*)REA1RGS(N1OC,NARG),RET(N1OC,NRET)CINTEGERIZ(*)CHARACTERCZ(*)*(1)DOUB1EPRECISIONDZ(*)1OGICA11Z(*)REA1RZ(*)C.executab1estatementsENDThed11export()macroisusedtoensurethataca11ingnameisknownexterna11yonthosep1atformsthatrequireitforsuccessfu1runtime1inking.Themacroisdefinedinaninc1udefi1esoItinc1ude"cfx5