文档介绍:? Fluent Inc. 2017-2-20 G1 Fluent Software Training TRN-99-003 用户自定义函数 User Defined Functions ? Fluent Inc. 2017-2-20 G2 Fluent Software Training TRN-99-003 Introduction ? What is a User Defined Function? ? A UDF is a routine (programmed by the user) written in C which can be dynamically linked with the solver. ? Standard C functions ? ., trigonometric, exponential, control blocks, do-loops, file i/o, etc. ? Pre-Defined Macros ? Allows access to field variable, material property, and cell geometry data. ? Why build UDF ’ s? ? Standard interface cannot be programmed to anticipate all needs. ? Customization of boundary conditions, source terms, reaction rates, material properties, etc. ? Adjust functions (once per iteration) ? Solve for User Defined Scalars ? Solution Initialization ? Fluent Inc. 2017-2-20 G3 Fluent Software Training TRN-99-003 UDF Basics ? UDF ’ s assigns values (., boundary data, source terms) to individual cells and cell faces in boundary and fluid zones. ? In a UDF, zones are referred to as threads . ? A looping macro is used to access individual cells belonging to a thread. ? ., a face-loop macro visits 563 faces on face zone 3 (velocity-inlet). ? Position of each face is available to calculate and assign spatially varying properties. ? Thread and variable references are automatically passed to UDF when assigned to boundary in GUI. ? Values returned to the solver by UDFs must be in SI units. ? Fluent Inc. 2017-2-20 G4 Fluent Software Training TRN-99-003 Using UDFs in the Solvers ? The basic steps for using UDFs in FLUENT are as follows: STEP 1: Create a file containing the UDF source code STEP 2: Start the solver and read in your case/data files STEP 3: Interpret pile the UDF STEP 4: Assign the UDF to the appropriate variable and zone in BC panel. STEP 5: Set the UDF update frequency in the Iterate panel STEP 6: Run the calculation ? Fluent Inc. 2017-2-20 G5 Fluent Software Training TRN-99-003 Exa