文档介绍:Making “User Defined Functions”
Work for You
Anirudh Mukhopadhyay
2002 Fluent Users’ Group Meeting
Agenda
u General Introduction to User Defined Functions
u Introduction to C Programming
u Fluent Data Structure and Macro-s
u Interpreted / Compiled UDF
u UDF Hooks - ‘DEFINE’ macro-s
u User Defined Scalars and Memories
u UDF for Discrete Phase and Multiphase Flows
u UDF for Parallel FLUENT
u Miscellaneous Functions / Macros
UGM 2002 2
Why Build UDFs?
u Standard interface can not be programmed to anticipate all needs
u Customization of boundary conditions, source terms, reaction rates (volume
and surface), properties
u Solution initialization
u Adjust functions (once per iteration)
u Solve for user defined scalars
u Modify model specific parameters
u Many more...
u Limitations
l Not all solution variables or solver models can be accessed by UDFs
l Example: Cannot change specific heat (would require additional solver
capabilities)
UGM 2002 3
User Access to Fluent Solver
u Fluent is so designed that the user can access the solver at some strategic
instances during the solution process Segregated Solver Coupled Solver
User-
Initialize Begin Loop defined Solve U-Momentum
ADJUST
Flow User Solve V-Momentum Solve Mass
Defined Momentum &
Energy Source terms
Diagram Initialize Source terms Solve W-Momentum
of
Solve Mass Continuity;
FLUENT Update Velocity
Solvers Exit Loop Repeat
Solve Energy
Boxes in Solve Species
blue are
Check
some Convergence Solve Turbulence
important ic Energy Source terms
user
access Update Properties Solve Eddy
points Dissipation
User-Defined Properties
User-Defined Boundary Conditions
UGM 2002 4
User Defined Functions in Fluent
u User Defined Functions are not just any C-functions:
u User access needs specific “Type” of function calls
u These Function types or ‘macro’-s are defined in the header file:
~/src/
u UDF’s in