实例介绍
【实例简介】ANSYS官方用户自定义函数学习文档,可以用于被ANSYS FLUENT求解器动态加载以增强其标准功能的C语言程序。
【实例截图】
【核心代码】
Table of Contents Using This Manual ..................................................................................................................................... xxv 1.The Contents of This Manual ............................................................................................................. xxv 2.The Contents of the Fluent Manuals ................................................................................................ xxvii 3. Typographical Conventions ........................................................................................................... xxviii 4. Mathematical Conventions ............................................................................................................... xxx 5. Technical Support ........................................................................................................................... xxxi I. Creating and Using User Defined Functions ............................................................................................ 1 1. Overview of User-Defined Functions (UDFs) .................................................................................... 3 1.1.What is a User-Defined Function? ................................................................................................ 3 1.2. Limitations ................................................................................................................................. 4 1.3. Defining Your UDF Using DEFINE Macros ................................................................................... 4 1.3.1. Including the udf.h Header File in Your Source File ........................................................... 5 1.4. Interpreting and Compiling UDFs ................................................................................................ 6 1.4.1. Compiled UDFs .................................................................................................................. 6 1.4.2. Interpreted UDFs ............................................................................................................... 6 1.4.3. Differences Between Interpreted and Compiled UDFs ......................................................... 6 1.5. Hooking UDFs to Your ANSYS Fluent Model ................................................................................. 7 1.6. Mesh Terminology ...................................................................................................................... 8 1.7. Data Types in ANSYS Fluent ......................................................................................................... 9 1.8. UDF Calling Sequence in the Solution Process ........................................................................... 10 1.8.1. Pressure-Based Segregated Solver .................................................................................... 11 1.8.2. Pressure-Based Coupled Solver ......................................................................................... 12 1.8.3. Density-Based Solver ........................................................................................................ 13 1.9. Special Considerations for Multiphase UDFs .............................................................................. 14 1.9.1. Multiphase-specific Data Types ......................................................................................... 14 2. DEFINE Macros ............................................................................................................................... 17 2.1. Introduction ............................................................................................................................. 17 2.2. General Purpose DEFINE Macros ............................................................................................. 17 2.2.1. DEFINE_ADJUST ........................................................................................................... 18 2.2.1.1. Description ............................................................................................................. 18 2.2.1.2. Usage ...................................................................................................................... 19 2.2.1.3. Example 1 ............................................................................................................... 19 2.2.1.4. Example 2 ............................................................................................................... 20 2.2.1.5. Hooking an Adjust UDF to ANSYS Fluent .................................................................. 20 2.2.2. DEFINE_DELTAT ........................................................................................................... 20 2.2.2.1. Description ............................................................................................................. 20 2.2.2.2. Usage ...................................................................................................................... 20 2.2.2.3. Example .................................................................................................................. 21 2.2.2.4. Hooking an Adaptive Time Step UDF to ANSYS Fluent .............................................. 21 2.2.3.DEFINE_EXECUTE_AT_END .......................................................................................... 21 2.2.3.1. Description ............................................................................................................. 21 2.2.3.2. Usage ...................................................................................................................... 22 2.2.3.3. Example .................................................................................................................. 22 2.2.3.4. Hooking an Execute-at-End UDF to ANSYS Fluent ..................................................... 22 2.2.4. DEFINE_EXECUTE_AT_EXIT ....................................................................................... 23 2.2.4.1. Description ............................................................................................................. 23 2.2.4.2. Usage ...................................................................................................................... 23 2.2.4.3. Hooking an Execute-at-Exit UDF to ANSYS Fluent ..................................................... 23 2.2.5. DEFINE_EXECUTE_FROM_GUI ..................................................................................... 23 2.2.5.1. Description ............................................................................................................. 23 iii Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates. 2.2.5.2. Usage ...................................................................................................................... 23 2.2.5.3. Example .................................................................................................................. 24 2.2.5.4. Hooking an Execute From GUI UDF to ANSYS Fluent ................................................. 25 2.2.6. DEFINE_EXECUTE_ON_LOADING ................................................................................. 25 2.2.6.1. Description ............................................................................................................. 25 2.2.6.2. Usage ...................................................................................................................... 25 2.2.6.3. Example 1 ............................................................................................................... 25 2.2.6.4. Example 2 ............................................................................................................... 26 2.2.6.5. Hooking an Execute On Loading UDF to ANSYS Fluent ............................................. 27 2.2.7. DEFINE_EXECUTE_AFTER_CASE/DATA ...................................................................... 27 2.2.7.1. Description ............................................................................................................. 27 2.2.7.2. Usage ...................................................................................................................... 27 2.2.7.3. Example .................................................................................................................. 28 2.2.7.4. Hooking an Execute After Reading Case and Data File UDF to ANSYS Fluent .............. 28 2.2.8.DEFINE_INIT ................................................................................................................ 28 2.2.8.1. Description ............................................................................................................. 28 2.2.8.2. Usage ...................................................................................................................... 28 2.2.8.3. Example .................................................................................................................. 29 2.2.8.4. Hooking an Initialization UDF to ANSYS Fluent ......................................................... 29 2.2.9.DEFINE_ON_DEMAND ..................................................................................................... 29 2.2.9.1. Description ............................................................................................................. 29 2.2.9.2. Usage ...................................................................................................................... 30 2.2.9.3. Example .................................................................................................................. 30 2.2.9.4. Hooking an On-Demand UDF to ANSYS Fluent ......................................................... 31 2.2.10. DEFINE_OUTPUT_PARAMETER ................................................................................... 31 2.2.10.1. Description ............................................................................................................ 31 2.2.10.2. Usage .................................................................................................................... 31 2.2.10.3. Example ................................................................................................................ 32 2.2.10.4. Hooking an Output Parameter UDF to ANSYS Fluent .............................................. 32 2.2.11. DEFINE_RW_FILE ....................................................................................................... 33 2.2.11.1. Description ............................................................................................................ 33 2.2.11.2. Usage .................................................................................................................... 33 2.2.11.3. Example ................................................................................................................ 33 2.2.11.4. Hooking a Read/Write Case or Data File UDF to ANSYS Fluent ................................. 34 2.2.12. DEFINE_RW_HDF_FILE .............................................................................................. 34 2.2.12.1. Description ............................................................................................................ 34 2.2.12.2. Usage .................................................................................................................... 34 2.2.12.3. Helper Functions ................................................................................................... 34 2.2.12.4. Examples ............................................................................................................... 39 2.2.12.5. Hooking a Read/Write HDF Case or Data File UDF to ANSYS Fluent .......................... 40 2.3. Model-Specific DEFINE Macros ................................................................................................ 40 2.3.1.DEFINE_ANISOTROPIC_CONDUCTIVITY .................................................................... 47 2.3.1.1. Description ............................................................................................................. 47 2.3.1.2. Usage ...................................................................................................................... 47 2.3.1.3. Example .................................................................................................................. 47 2.3.1.4. Hooking an Anisotropic Conductivity UDF to ANSYS Fluent ...................................... 48 2.3.2.DEFINE_CHEM_STEP ..................................................................................................... 49 2.3.2.1. Description ............................................................................................................. 49 2.3.2.2. Usage ...................................................................................................................... 49 2.3.2.3. Example .................................................................................................................. 50 2.3.2.4. Hooking a Chemistry Step UDF to ANSYS Fluent ....................................................... 50 2.3.3.DEFINE_CPHI ................................................................................................................ 50 Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information iv of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 2.3.3.1. Description ............................................................................................................. 50 2.3.3.2. Usage ...................................................................................................................... 50 2.3.3.3. Hooking a Mixing Constant UDF to ANSYS Fluent ..................................................... 51 2.3.4. DEFINE_DIFFUSIVITY ................................................................................................ 51 2.3.4.1. Description ............................................................................................................. 51 2.3.4.2. Usage ...................................................................................................................... 51 2.3.4.3. Example .................................................................................................................. 51 2.3.4.4. Hooking a Diffusivity UDF to ANSYS Fluent .............................................................. 52 2.3.5.DEFINE_DOM_DIFFUSE_REFLECTIVITY .................................................................... 52 2.3.5.1. Description ............................................................................................................. 52 2.3.5.2. Usage ...................................................................................................................... 52 2.3.5.3. Example .................................................................................................................. 53 2.3.5.4. Hooking a Discrete Ordinates Model (DOM) Diffuse Reflectivity UDF to ANSYS Fluent ..................................................................................................................................... 53 2.3.6. DEFINE_DOM_SOURCE .................................................................................................. 54 2.3.6.1. Description ............................................................................................................. 54 2.3.6.2. Usage ...................................................................................................................... 54 2.3.6.3. Example .................................................................................................................. 54 2.3.6.4. Hooking a DOM Source UDF to ANSYS Fluent ........................................................... 55 2.3.7. DEFINE_DOM_SPECULAR_REFLECTIVITY ................................................................. 55 2.3.7.1. Description ............................................................................................................. 55 2.3.7.2. Usage ...................................................................................................................... 55 2.3.7.3. Example .................................................................................................................. 56 2.3.7.4. Hooking a Discrete Ordinates Model (DOM) Specular Reflectivity UDF to ANSYS Fluent ..................................................................................................................................... 56 2.3.8. DEFINE_ECFM_SOURCE ................................................................................................ 57 2.3.8.1. Description ............................................................................................................. 57 2.3.8.2. Usage ...................................................................................................................... 57 2.3.8.3. Example .................................................................................................................. 57 2.3.8.4. Hooking an ECFM Flame Density Area Source UDF to ANSYS Fluent .......................... 58 2.3.9. DEFINE_ECFM_SPARK_SOURCE ................................................................................... 58 2.3.9.1. Description ............................................................................................................. 58 2.3.9.2. Usage ...................................................................................................................... 58 2.3.9.3. Example .................................................................................................................. 59 2.3.9.4. Hooking an ECFM Spark Source UDF to ANSYS Fluent ............................................... 59 2.3.10. DEFINE_EMISSIVITY_WEIGHTING_FACTOR ........................................................... 59 2.3.10.1. Description ............................................................................................................ 59 2.3.10.2. Usage .................................................................................................................... 59 2.3.10.3. Example ................................................................................................................ 60 2.3.10.4. Hooking an Emissivity Weighting Factor UDF to ANSYS Fluent ................................ 60 2.3.11. DEFINE_ZONE_MOTION .............................................................................................. 60 2.3.11.1. Description ............................................................................................................ 60 2.3.11.2. Usage .................................................................................................................... 60 2.3.11.3. Example ................................................................................................................ 61 2.3.11.4. Hooking a Frame Motion UDF to ANSYS Fluent ....................................................... 62 2.3.12. DEFINE_GRAY_BAND_ABS_COEFF ............................................................................. 62 2.3.12.1. Description ............................................................................................................ 62 2.3.12.2. Usage .................................................................................................................... 62 2.3.12.3. Example ................................................................................................................ 62 2.3.12.4. Hooking a Gray Band Coefficient UDF to ANSYS Fluent ........................................... 63 2.3.13. DEFINE_HEAT_FLUX ................................................................................................... 63 2.3.13.1. Description ............................................................................................................ 63 v Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 2.3.13.2. Usage .................................................................................................................... 63 2.3.13.3. Example ................................................................................................................ 64 2.3.13.4. Hooking a Heat Flux UDF to ANSYS Fluent .............................................................. 64 2.3.14. DEFINE_IGNITE_SOURCE .......................................................................................... 64 2.3.14.1. Description ............................................................................................................ 64 2.3.14.2. Usage .................................................................................................................... 64 2.3.14.3. Example ................................................................................................................ 65 2.3.14.4. Hooking an Ignition Source UDF to ANSYS Fluent ................................................... 66 2.3.15. DEFINE_NET_REACTION_RATE ................................................................................. 66 2.3.15.1. Description ............................................................................................................ 66 2.3.15.2. Usage .................................................................................................................... 67 2.3.15.3. Example ................................................................................................................ 67 2.3.15.4. Hooking a Net Reaction Rate UDF to ANSYS Fluent ................................................. 68 2.3.16. DEFINE_NOX_RATE ..................................................................................................... 68 2.3.16.1. Description ............................................................................................................ 68 2.3.16.2. Usage .................................................................................................................... 69 2.3.16.3. Example 1 ............................................................................................................. 70 2.3.16.4. Example 2 ............................................................................................................. 71 2.3.16.5. Hooking a NOx Rate UDF to ANSYS Fluent .............................................................. 72 2.3.17. DEFINE_PDF_TABLE ................................................................................................... 72 2.3.17.1. Description ............................................................................................................ 72 2.3.17.2. Usage .................................................................................................................... 73 2.3.17.3. Example 1 ............................................................................................................. 75 2.3.17.4. Example 2 ............................................................................................................. 76 2.3.17.5. Hooking a DEFINE_PDF_TABLE UDF to ANSYS Fluent .............................................. 78 2.3.18. DEFINE_PR_RATE ....................................................................................................... 78 2.3.18.1. Description ............................................................................................................ 78 2.3.18.2. Usage .................................................................................................................... 78 2.3.18.3. Auxiliary function .................................................................................................. 79 2.3.18.4. Example 1 ............................................................................................................. 79 2.3.18.5. Example 2 ............................................................................................................. 80 2.3.18.6. Hooking a Particle Reaction Rate UDF to ANSYS Fluent ........................................... 81 2.3.19. DEFINE_PRANDTL UDFs .............................................................................................. 81 2.3.19.1. DEFINE_PRANDTL_D .......................................................................................... 82 2.3.19.2. Description ............................................................................................................ 82 2.3.19.3. Usage .................................................................................................................... 82 2.3.19.4. Example ................................................................................................................ 82 2.3.19.5. Hooking a Prandtl Number UDF to ANSYS Fluent .................................................... 82 2.3.19.6. DEFINE_PRANDTL_K .......................................................................................... 82 2.3.19.7. Description ............................................................................................................ 82 2.3.19.8. Usage .................................................................................................................... 82 2.3.19.9. Example ................................................................................................................ 83 2.3.19.10. Hooking a Prandtl Number UDF to ANSYS Fluent .................................................. 84 2.3.19.11. DEFINE_PRANDTL_O ........................................................................................ 84 2.3.19.12. Description .......................................................................................................... 84 2.3.19.13. Usage .................................................................................................................. 84 2.3.19.14. Example .............................................................................................................. 85 2.3.19.15. Hooking a Prandtl Number UDF to ANSYS Fluent .................................................. 85 2.3.19.16. DEFINE_PRANDTL_T ........................................................................................ 85 2.3.19.17. Description .......................................................................................................... 85 2.3.19.18. Usage .................................................................................................................. 85 2.3.19.19. Example .............................................................................................................. 85 Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information vi of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 2.3.19.20. Hooking a Prandtl Number UDF to ANSYS Fluent .................................................. 86 2.3.19.21. DEFINE_PRANDTL_T_WALL ............................................................................. 86 2.3.19.22. Description .......................................................................................................... 86 2.3.19.23. Usage .................................................................................................................. 86 2.3.19.24. Example .............................................................................................................. 86 2.3.19.25. Hooking a Prandtl Number UDF to ANSYS Fluent .................................................. 86 2.3.20. DEFINE_PROFILE ....................................................................................................... 87 2.3.20.1. Description ............................................................................................................ 87 2.3.20.2. Usage .................................................................................................................... 87 2.3.20.3. Example 1 - Pressure Profile ................................................................................... 88 2.3.20.4. Example 2 - Velocity,Turbulent Kinetic Energy, and Turbulent Dissipation Rate Profiles .................................................................................................................................... 89 2.3.20.5. Example 3 - Fixed Velocity UDF ............................................................................... 91 2.3.20.6. Example 4 - Wall Heat Generation Rate Profile ........................................................ 93 2.3.20.7. Example 5 - Beam Direction Profile at Semi-Transparent Walls ................................. 93 2.3.20.8. Example 6 - Viscous Resistance Profile in a Porous Zone .......................................... 94 2.3.20.9. Example 7 - Porous Resistance Direction Vector ...................................................... 95 2.3.20.10. Example 8 -Target Mass Flow Rate UDF as a Function of Physical Flow Time ........... 95 2.3.20.11. Example 9 - Mass Flow Rate UDF for the Mass Flow Inlet ....................................... 96 2.3.20.12. Hooking a Boundary Profile UDF to ANSYS Fluent ................................................. 96 2.3.21. DEFINE_PROPERTY UDFs ............................................................................................ 96 2.3.21.1. Description ............................................................................................................ 96 2.3.21.2. Usage .................................................................................................................... 98 2.3.21.3. Auxiliary Utilities .................................................................................................... 98 2.3.21.4. Example 1 - Temperature-dependent Viscosity Property ....................................... 100 2.3.21.5. Example 2 - User-defined Mixing Law for Thermal Conductivity ............................ 100 2.3.21.6. Example 3 - Surface Tension Coefficient UDF ........................................................ 101 2.3.21.7. Example 4 - Density Function for Compressible Liquids ......................................... 101 2.3.21.8. Hooking a Property UDF to ANSYS Fluent ............................................................. 102 2.3.22. DEFINE_REACTING_CHANNEL_BC ........................................................................... 102 2.3.22.1. Description .......................................................................................................... 102 2.3.22.2. Usage .................................................................................................................. 102 2.3.22.3. Example .............................................................................................................. 103 2.3.22.4. Hooking a Reacting Channel Solver UDF to ANSYS Fluent ..................................... 104 2.3.23. DEFINE_REACTING_CHANNEL_SOLVER .................................................................. 104 2.3.23.1. Description .......................................................................................................... 104 2.3.23.2. Usage .................................................................................................................. 105 2.3.23.3. Example .............................................................................................................. 105 2.3.23.4. Hooking a Reacting Channel Solver UDF to ANSYS Fluent ..................................... 107 2.3.24.DEFINE_SCAT_PHASE_FUNC .................................................................................... 107 2.3.24.1. Description .......................................................................................................... 107 2.3.24.2. Usage .................................................................................................................. 108 2.3.24.3. Example .............................................................................................................. 108 2.3.24.4. Hooking a Scattering Phase UDF to ANSYS Fluent ................................................. 109 2.3.25.DEFINE_SOLAR_INTENSITY .................................................................................... 109 2.3.25.1. Description .......................................................................................................... 109 2.3.25.2. Usage .................................................................................................................. 109 2.3.25.3. Example .............................................................................................................. 110 2.3.25.4. Hooking a Solar Intensity UDF to ANSYS Fluent .................................................... 110 2.3.26. DEFINE_SOLIDIFICATION_PARAMS ...................................................................... 110 2.3.26.1. Description .......................................................................................................... 110 2.3.26.2. Usage .................................................................................................................. 110 vii Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 2.3.26.3. Example .............................................................................................................. 111 2.3.26.4. Hooking a Solidification Parameter UDF in ANSYS Fluent ...................................... 111 2.3.27.DEFINE_SOOT_MASS_RATES .................................................................................... 111 2.3.27.1. Description .......................................................................................................... 111 2.3.27.2. Usage .................................................................................................................. 111 2.3.27.3. Example: Soot Mass Rate ...................................................................................... 112 2.3.27.4. Hooking a Soot Mass Rate UDF to ANSYS Fluent ................................................... 113 2.3.28. DEFINE_SOOT_NUCLEATION_RATES ...................................................................... 114 2.3.28.1. Description .......................................................................................................... 114 2.3.28.2. Usage .................................................................................................................. 114 2.3.28.3. Example: Soot Nucleation and Coagulation Rates ................................................. 115 2.3.28.4. Hooking a Nucleation and Coagulation Rates UDF to ANSYS Fluent ...................... 116 2.3.29. DEFINE_SOOT_OXIDATION_RATE ........................................................................... 116 2.3.29.1. Description .......................................................................................................... 116 2.3.29.2. Usage .................................................................................................................. 116 2.3.29.3. Example: Soot Oxidation Rate ............................................................................... 117 2.3.29.4. Hooking a Soot Oxidation Rate UDF to ANSYS Fluent ............................................ 118 2.3.30. DEFINE_SOOT_PRECURSOR ...................................................................................... 118 2.3.30.1. Description .......................................................................................................... 118 2.3.30.1.1. Usage ......................................................................................................... 118 2.3.30.1.2. Example: Soot Precursor .............................................................................. 118 2.3.30.1.3. Hooking a SOOT_PRECURSOR UDF to ANSYS Fluent ..................................... 119 2.3.31. DEFINE_SOURCE ....................................................................................................... 119 2.3.31.1. Description .......................................................................................................... 119 2.3.31.2. Usage .................................................................................................................. 119 2.3.31.3. Example 1 - Source Term Addition ........................................................................ 120 2.3.31.4. Example 2 - Degassing Boundary Condition ......................................................... 121 2.3.31.5. Hooking a Source UDF to ANSYS Fluent ................................................................ 122 2.3.32. DEFINE_SOX_RATE ................................................................................................... 122 2.3.32.1. Description .......................................................................................................... 122 2.3.32.2. Usage .................................................................................................................. 123 2.3.32.3. Example 1 ............................................................................................................ 124 2.3.32.4. Example 2 ............................................................................................................ 126 2.3.32.5. Hooking a SOx Rate UDF to ANSYS Fluent ............................................................. 127 2.3.33.DEFINE_SPARK_GEOM (R14.5 spark model) ................................................... 127 2.3.33.1. Description .......................................................................................................... 127 2.3.33.2. Usage .................................................................................................................. 127 2.3.33.3. Example .............................................................................................................. 128 2.3.33.4. Hooking a Spark Geometry UDF to ANSYS Fluent ................................................. 129 2.3.34. DEFINE_SPECIFIC_HEAT ........................................................................................ 130 2.3.34.1. Description .......................................................................................................... 130 2.3.34.2. Usage .................................................................................................................. 130 2.3.34.3. Example .............................................................................................................. 130 2.3.34.4. Hooking a Specific Heat UDF to ANSYS Fluent ...................................................... 131 2.3.35. DEFINE_SR_RATE ..................................................................................................... 131 2.3.35.1. Description .......................................................................................................... 131 2.3.35.2. Usage .................................................................................................................. 131 2.3.35.3. Example 1 - Surface Reaction Rate Using Species Mass Fractions ........................... 132 2.3.35.4. Example 2 - Surface Reaction Rate Using Site Species ........................................... 132 2.3.35.5. Hooking a Surface Reaction Rate UDF to ANSYS Fluent ......................................... 133 2.3.36. DEFINE_THICKENED_FLAME_MODEL ...................................................................... 133 2.3.36.1. Description .......................................................................................................... 133 Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information viii of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 2.3.36.2. Usage .................................................................................................................. 133 2.3.36.3. Example - Thickened Flame Model ....................................................................... 134 2.3.36.4. Hooking a Thickened Flame Model UDF to ANSYS Fluent ...................................... 134 2.3.37. DEFINE_TRANS UDFs ................................................................................................. 134 2.3.37.1. DEFINE_TRANS_FLENGTH ............................................................................... 135 2.3.37.2. Description .......................................................................................................... 135 2.3.37.3. Usage .................................................................................................................. 135 2.3.37.4. Example .............................................................................................................. 135 2.3.37.5. Hooking a Transition Correlation UDF to ANSYS Fluent ......................................... 135 2.3.37.6. DEFINE_TRANS_RETHETA_C ........................................................................... 135 2.3.37.7. Description .......................................................................................................... 135 2.3.37.8. Usage .................................................................................................................. 135 2.3.37.9. Example .............................................................................................................. 136 2.3.37.10. Hooking a Transition Correlation UDF to ANSYS Fluent ....................................... 136 2.3.37.11. DEFINE_TRANS_RETHETA_T ......................................................................... 136 2.3.37.12. Description ........................................................................................................ 136 2.3.37.13. Usage ................................................................................................................ 136 2.3.37.14. Example ............................................................................................................ 137 2.3.37.15. Hooking a Transition Correlation UDF to ANSYS Fluent ....................................... 137 2.3.38. DEFINE_TRANSIENT_PROFILE ............................................................................... 137 2.3.38.1. Description .......................................................................................................... 137 2.3.38.2. Usage .................................................................................................................. 137 2.3.38.3. Example .............................................................................................................. 138 2.3.38.4. Hooking a Transient Profile UDF to ANSYS Fluent .................................................. 138 2.3.39. DEFINE_TURB_PREMIX_SOURCE ............................................................................. 138 2.3.39.1. Description .......................................................................................................... 138 2.3.39.2. Usage .................................................................................................................. 138 2.3.39.3. Example .............................................................................................................. 139 2.3.39.4. Hooking a Turbulent Premixed Source UDF to ANSYS Fluent ................................. 139 2.3.40. DEFINE_TURB_SCHMIDT UDF ................................................................................... 140 2.3.40.1. Description .......................................................................................................... 140 2.3.40.2. Usage .................................................................................................................. 140 2.3.40.3. Example .............................................................................................................. 140 2.3.40.4. Hooking a Turbulent Schmidt Number UDF to ANSYS Fluent ................................ 140 2.3.41. DEFINE_TURBULENT_VISCOSITY ........................................................................... 141 2.3.41.1. Description .......................................................................................................... 141 2.3.41.2. Usage .................................................................................................................. 141 2.3.41.3. Example 1 - Single Phase Turbulent Viscosity UDF ................................................. 141 2.3.41.4. Example 2 - Multiphase Turbulent Viscosity UDF ................................................... 142 2.3.41.5. Hooking a Turbulent Viscosity UDF to ANSYS Fluent ............................................. 142 2.3.42. DEFINE_VR_RATE ..................................................................................................... 142 2.3.42.1. Description .......................................................................................................... 142 2.3.42.2. Usage .................................................................................................................. 143 2.3.42.3. Example 1 ............................................................................................................ 143 2.3.42.4. Example 2 ............................................................................................................ 144 2.3.42.5. Hooking a Volumetric Reaction Rate UDF to ANSYS Fluent .................................... 145 2.3.43. DEFINE_WALL_FUNCTIONS ...................................................................................... 145 2.3.43.1. Description .......................................................................................................... 145 2.3.43.2. Usage .................................................................................................................. 145 2.3.43.3. Example .............................................................................................................. 145 2.3.43.4. Hooking a Wall Function UDF to ANSYS Fluent ..................................................... 146 2.3.44.DEFINE_WSGGM_ABS_COEFF .................................................................................... 146 ix Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 2.3.44.1. Description .......................................................................................................... 146 2.3.44.2. Usage .................................................................................................................. 146 2.3.44.3. Example .............................................................................................................. 147 2.3.44.4. Hooking a Wall Function UDF to ANSYS Fluent ..................................................... 148 2.4. Multiphase DEFINE Macros .................................................................................................... 148 2.4.1. DEFINE_BOILING_PROPERTY ................................................................................... 150 2.4.1.1. Description ............................................................................................................ 150 2.4.1.2. Usage .................................................................................................................... 150 2.4.1.3. Example ................................................................................................................ 151 2.4.1.4. Hooking a Boiling Property UDF to ANSYS Fluent ................................................... 151 2.4.2. DEFINE_CAVITATION_RATE ..................................................................................... 151 2.4.2.1. Description ............................................................................................................ 151 2.4.2.2. Usage .................................................................................................................... 151 2.4.2.3. Example ................................................................................................................ 152 2.4.2.4. Hooking a Cavitation Rate UDF to ANSYS Fluent ..................................................... 153 2.4.3. DEFINE_EXCHANGE_PROPERTY ................................................................................. 153 2.4.3.1. Description ............................................................................................................ 153 2.4.3.2. Usage .................................................................................................................... 154 2.4.3.3. Example 1 - Custom Drag Law ................................................................................ 155 2.4.3.4. Example 2 - Custom Lift Law .................................................................................. 156 2.4.3.5. Example 3- Heat Transfer ........................................................................................ 157 2.4.3.6. Example 4- Custom Interfacial Area ........................................................................ 157 2.4.3.7. Hooking an Exchange Property UDF to ANSYS Fluent ............................................. 157 2.4.4. DEFINE_HET_RXN_RATE ............................................................................................ 158 2.4.4.1. Description ............................................................................................................ 158 2.4.4.2. Usage .................................................................................................................... 158 2.4.4.3. Example ................................................................................................................ 159 2.4.4.4. Hooking a Heterogeneous Reaction Rate UDF to ANSYS Fluent ............................... 160 2.4.5. DEFINE_LINEARIZED_MASS_TRANSFER .................................................................. 161 2.4.5.1. Description ............................................................................................................ 161 2.4.5.2. Usage .................................................................................................................... 161 2.4.5.3. Example ................................................................................................................ 162 2.4.5.4. Hooking a Linearized Mass Transfer UDF to ANSYS Fluent ....................................... 163 2.4.6. DEFINE_MASS_TRANSFER .......................................................................................... 164 2.4.6.1. Description ............................................................................................................ 164 2.4.6.2. Usage .................................................................................................................... 164 2.4.6.3. Example ................................................................................................................ 165 2.4.6.4. Hooking a Mass Transfer UDF to ANSYS Fluent ........................................................ 165 2.4.7. DEFINE_VECTOR_EXCHANGE_PROPERTY .................................................................. 166 2.4.7.1. Description ............................................................................................................ 166 2.4.7.2. Usage .................................................................................................................... 166 2.4.7.3. Example 1 — Custom Slip Velocity ......................................................................... 167 2.4.7.4. Example 2 — Custom Turbulent Dispersion ............................................................ 167 2.4.7.5. Hooking a Vector Exchange Property UDF to ANSYS Fluent ..................................... 168 2.5. Discrete Phase Model (DPM) DEFINE Macros .......................................................................... 168 2.5.1. DEFINE_DPM_BC ......................................................................................................... 169 2.5.1.1. Description ............................................................................................................ 169 2.5.1.2. Usage .................................................................................................................... 170 2.5.1.3. Example 1 ............................................................................................................. 170 2.5.1.4. Example 2 ............................................................................................................. 172 2.5.1.5. Hooking a DPM Boundary Condition UDF to ANSYS Fluent ..................................... 174 2.5.2. DEFINE_DPM_BODY_FORCE ........................................................................................ 174 Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information x of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 2.5.2.1. Description ............................................................................................................ 174 2.5.2.2. Usage .................................................................................................................... 174 2.5.2.3. Example ................................................................................................................ 175 2.5.2.4. Hooking a DPM Body Force UDF to ANSYS Fluent ................................................... 175 2.5.3. DEFINE_DPM_DRAG ..................................................................................................... 176 2.5.3.1. Description ............................................................................................................ 176 2.5.3.2. Usage .................................................................................................................... 176 2.5.3.3. Example ................................................................................................................ 176 2.5.3.4. Hooking a DPM Drag Coefficient UDF to ANSYS Fluent ........................................... 177 2.5.4. DEFINE_DPM_EROSION .............................................................................................. 177 2.5.4.1. Description ............................................................................................................ 177 2.5.4.2. Usage .................................................................................................................... 177 2.5.4.3. Example ................................................................................................................ 178 2.5.4.4. Hooking an Erosion/Accretion UDF to ANSYS Fluent ............................................... 181 2.5.5. DEFINE_DPM_HEAT_MASS .......................................................................................... 181 2.5.5.1. Description ............................................................................................................ 181 2.5.5.2. Usage .................................................................................................................... 181 2.5.5.3. Example ................................................................................................................ 182 2.5.5.4. Hooking a DPM Particle Heat and Mass Transfer UDF to ANSYS Fluent ..................... 184 2.5.6. DEFINE_DPM_INJECTION_INIT ............................................................................... 184 2.5.6.1. Description ............................................................................................................ 184 2.5.6.2. Usage .................................................................................................................... 184 2.5.6.3. Example ................................................................................................................ 184 2.5.6.4. Hooking a DPM Initialization UDF to ANSYS Fluent ................................................. 186 2.5.7. DEFINE_DPM_LAW ....................................................................................................... 186 2.5.7.1. Description ............................................................................................................ 186 2.5.7.2. Usage .................................................................................................................... 186 2.5.7.3. Example ................................................................................................................ 187 2.5.7.4. Hooking a Custom DPM Law to ANSYS Fluent ........................................................ 187 2.5.8. DEFINE_DPM_OUTPUT ................................................................................................ 187 2.5.8.1. Description ............................................................................................................ 187 2.5.8.2. Usage .................................................................................................................... 187 2.5.8.3. Example ................................................................................................................ 188 2.5.8.4. Hooking a DPM Output UDF to ANSYS Fluent ......................................................... 190 2.5.9. DEFINE_DPM_PROPERTY ............................................................................................ 190 2.5.9.1. Description ............................................................................................................ 190 2.5.9.2. Usage .................................................................................................................... 191 2.5.9.3. Example ................................................................................................................ 192 2.5.9.4. Hooking a DPM Material Property UDF to ANSYS Fluent ......................................... 193 2.5.10. DEFINE_DPM_SCALAR_UPDATE ............................................................................... 193 2.5.10.1. Description .......................................................................................................... 193 2.5.10.2. Usage .................................................................................................................. 193 2.5.10.3. Example .............................................................................................................. 194 2.5.10.4. Hooking a DPM Scalar Update UDF to ANSYS Fluent ............................................. 195 2.5.11.DEFINE_DPM_SOURCE ............................................................................................... 196 2.5.11.1. Description .......................................................................................................... 196 2.5.11.2. Usage .................................................................................................................. 196 2.5.11.3. Example .............................................................................................................. 196 2.5.11.4. Hooking a DPM Source Term UDF to ANSYS Fluent ............................................... 197 2.5.12. DEFINE_DPM_SPRAY_COLLIDE ............................................................................... 197 2.5.12.1. Description .......................................................................................................... 197 2.5.12.2. Usage .................................................................................................................. 197 xi Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 2.5.12.3. Example .............................................................................................................. 197 2.5.12.4. Hooking a DPM Spray Collide UDF to ANSYS Fluent .............................................. 198 2.5.13.DEFINE_DPM_SWITCH ............................................................................................... 198 2.5.13.1. Description .......................................................................................................... 198 2.5.13.2. Usage .................................................................................................................. 198 2.5.13.3. Example .............................................................................................................. 199 2.5.13.4. Hooking a DPM Switching UDF to ANSYS Fluent ................................................... 202 2.5.14. DEFINE_DPM_TIMESTEP .......................................................................................... 202 2.5.14.1. Description .......................................................................................................... 202 2.5.14.2. Usage .................................................................................................................. 202 2.5.14.3. Example 1 ............................................................................................................ 202 2.5.14.4. Example 2 ............................................................................................................ 203 2.5.14.5. Hooking a DPM Timestep UDF to ANSYS Fluent .................................................... 203 2.5.15. DEFINE_DPM_VP_EQUILIB ...................................................................................... 203 2.5.15.1. Description .......................................................................................................... 203 2.5.15.2. Usage .................................................................................................................. 203 2.5.15.3. Example .............................................................................................................. 204 2.5.15.4. Hooking a DPM Vapor Equilibrium UDF to ANSYS Fluent ....................................... 205 2.5.16. DEFINE_IMPINGEMENT ............................................................................................ 205 2.5.16.1. Description .......................................................................................................... 205 2.5.16.2. Usage .................................................................................................................. 205 2.5.16.3. Example .............................................................................................................. 206 2.5.16.4. Hooking an Impingement UDF to ANSYS Fluent ................................................... 207 2.5.17. DEFINE_FILM_REGIME ............................................................................................ 208 2.5.17.1. Description .......................................................................................................... 208 2.5.17.2. Usage .................................................................................................................. 208 2.5.17.3. Example .............................................................................................................. 209 2.5.17.4. Hooking a Film Regime UDF to ANSYS Fluent ....................................................... 210 2.5.18. DEFINE_SPLASHING_DISTRIBUTION .................................................................... 210 2.5.18.1. Description .......................................................................................................... 210 2.5.18.2. Usage .................................................................................................................. 210 2.5.18.3. Example .............................................................................................................. 211 2.5.18.4. Hooking a Splashing Distribution UDF to ANSYS Fluent ........................................ 213 2.6. Dynamic Mesh DEFINE Macros .............................................................................................. 213 2.6.1. DEFINE_CG_MOTION ................................................................................................... 214 2.6.1.1. Description ............................................................................................................ 214 2.6.1.2. Usage .................................................................................................................... 214 2.6.1.3. Example ................................................................................................................ 215 2.6.1.4. Hooking a Center of Gravity Motion UDF to ANSYS Fluent ...................................... 215 2.6.2. DEFINE_DYNAMIC_ZONE_PROPERTY ........................................................................ 215 2.6.2.1. Description ............................................................................................................ 215 2.6.2.2. Swirl Center Definition for In-Cylinder Applications ................................................. 216 2.6.2.2.1. Usage ........................................................................................................... 216 2.6.2.2.2. Example ....................................................................................................... 216 2.6.2.2.3. Hooking a Swirl Center UDF to ANSYS Fluent ................................................. 217 2.6.2.3.Variable Cell Layering Height .................................................................................. 217 2.6.2.3.1. Usage ........................................................................................................... 217 2.6.2.3.2. Example ....................................................................................................... 218 2.6.2.3.3. Hooking a Variable Cell Layering Height UDF to ANSYS Fluent ........................ 219 2.6.3. DEFINE_GEOM .............................................................................................................. 219 2.6.3.1. Description ............................................................................................................ 219 2.6.3.2. Usage .................................................................................................................... 219 Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information xii of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 2.6.3.3. Example ................................................................................................................ 220 2.6.3.4. Hooking a Dynamic Mesh Geometry UDF to ANSYS Fluent ..................................... 220 2.6.4. DEFINE_GRID_MOTION .............................................................................................. 220 2.6.4.1. Description ............................................................................................................ 220 2.6.4.2. Usage .................................................................................................................... 220 2.6.4.3. Example ................................................................................................................ 221 2.6.4.4. Hooking a DEFINE_GRID_MOTION to ANSYS Fluent ............................................ 222 2.6.5. DEFINE_SDOF_PROPERTIES ..................................................................................... 222 2.6.5.1. Description ............................................................................................................ 222 2.6.5.2. Usage .................................................................................................................... 222 2.6.5.3. Custom Transformation Variables ........................................................................... 223 2.6.5.4. Example 1 ............................................................................................................. 223 2.6.5.5. Example 2 ............................................................................................................. 224 2.6.5.6. Hooking a DEFINE_SDOF_PROPERTIES UDF to ANSYS Fluent ............................ 224 2.6.6. DEFINE_CONTACT ....................................................................................................... 225 2.6.6.1. Description ............................................................................................................ 225 2.6.6.2. Usage .................................................................................................................... 225 2.6.6.3. Example 1 ............................................................................................................. 225 2.6.6.4. Example 2 ............................................................................................................. 228 2.6.6.5. Hooking a DEFINE_CONTACT UDF to ANSYS Fluent ............................................. 229 2.7. User-Defined Scalar (UDS) Transport Equation DEFINE Macros ............................................... 229 2.7.1. Introduction ................................................................................................................... 229 2.7.1.1. Diffusion Coefficient UDFs ..................................................................................... 230 2.7.1.2. Flux UDFs .............................................................................................................. 230 2.7.1.3. Unsteady UDFs ...................................................................................................... 230 2.7.1.4. Source Term UDFs .................................................................................................. 230 2.7.1.5. Fixed Value Boundary Condition UDFs .................................................................... 230 2.7.1.6.Wall, Inflow, and Outflow Boundary Condition UDFs ............................................... 231 2.7.2. DEFINE_ANISOTROPIC_DIFFUSIVITY .................................................................... 231 2.7.2.1. Description ............................................................................................................ 231 2.7.2.2. Usage .................................................................................................................... 231 2.7.2.3. Example ................................................................................................................ 231 2.7.2.4. Hooking an Anisotropic Diffusivity UDF to ANSYS Fluent ........................................ 233 2.7.3. DEFINE_UDS_FLUX ..................................................................................................... 233 2.7.3.1. Description ............................................................................................................ 233 2.7.3.2. Usage .................................................................................................................... 233 2.7.3.3. Example ................................................................................................................ 235 2.7.3.4. Hooking a UDS Flux Function to ANSYS Fluent ....................................................... 235 2.7.4. DEFINE_UDS_UNSTEADY ............................................................................................ 236 2.7.4.1. Description ............................................................................................................ 236 2.7.4.2. Usage .................................................................................................................... 236 2.7.4.3. Example ................................................................................................................ 237 2.7.4.4. Hooking a UDS Unsteady Function to ANSYS Fluent ............................................... 237 3. Additional Macros for Writing UDFs ............................................................................................. 239 3.1. Introduction ........................................................................................................................... 239 3.2. Data Access Macros ................................................................................................................. 241 3.2.1. Axisymmetric Considerations for Data Access Macros ...................................................... 241 3.2.2. Node Macros .................................................................................................................. 241 3.2.2.1. Node Position ........................................................................................................ 241 3.2.2.2. Number of Nodes in a Face (F_NNODES) ................................................................ 242 3.2.3. Cell Macros .................................................................................................................... 242 3.2.3.1. Cell Centroid (C_CENTROID) ................................................................................. 242 xiii Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 3.2.3.2. Cell Volume (C_VOLUME) ....................................................................................... 242 3.2.3.3. Number of Faces (C_NFACES) and Nodes (C_NNODES) in a Cell ............................. 243 3.2.3.4. Cell Face Index (C_FACE) ....................................................................................... 243 3.2.3.5. Cell Face Index (C_FACE_THREAD) ....................................................................... 243 3.2.3.6. Flow Variable Macros for Cells ................................................................................ 243 3.2.3.6.1. Species Fractions Calculations with the Non- and Partially- Premixed Models .............................................................................................................................. 244 3.2.3.7. Gradient (G) and Reconstruction Gradient (RG) Vector Macros ................................ 245 3.2.3.8. Previous Time Step Macros ..................................................................................... 250 3.2.3.9. Derivative Macros .................................................................................................. 251 3.2.3.10. Material Property Macros ..................................................................................... 252 3.2.3.11. Reynolds Stress Model Macros ............................................................................. 254 3.2.3.12. VOF Multiphase Model Macro .............................................................................. 254 3.2.4. Face Macros ................................................................................................................... 254 3.2.4.1. Face Centroid (F_CENTROID) ............................................................................... 255 3.2.4.2. Face Area Vector (F_AREA) .................................................................................... 255 3.2.4.3. Flow Variable Macros for Boundary Faces ............................................................... 256 3.2.4.4. Flow Variable Macros at Interior and Boundary Faces .............................................. 256 3.2.5. Connectivity Macros ....................................................................................................... 257 3.2.5.1. Adjacent Cell Index (F_C0, F_C1) .......................................................................... 258 3.2.5.2. Adjacent Cell Thread (THREAD_T0, THREAD_T1) .................................................. 258 3.2.5.3. Interior Face Geometry (INTERIOR_FACE_GEOMETRY) ....................................... 259 3.2.5.4. Boundary Face Geometry (BOUNDARY_FACE_GEOMETRY) ................................... 259 3.2.5.5. Boundary Face Thread (BOUNDARY_FACE_THREAD) ............................................. 260 3.2.5.6. Boundary Secondary Gradient Source (BOUNDARY_SECONDARY_GRADIENT_SOURCE) ................................................................................................................. 260 3.2.6. Special Macros ............................................................................................................... 260 3.2.6.1.Thread Pointer for Zone ID (Lookup_Thread) ...................................................... 261 3.2.6.2. Zone ID (THREAD_ID) ........................................................................................... 262 3.2.6.3. Domain Pointer (Get_Domain) ............................................................................ 262 3.2.6.4. Set Boundary Condition Value (F_PROFILE) ......................................................... 264 3.2.6.5. THREAD_SHADOW(t) .......................................................................................... 265 3.2.7.Time-Sampled Data ........................................................................................................ 265 3.2.8. Model-Specific Macros ................................................................................................... 267 3.2.8.1. DPM Macros .......................................................................................................... 267 3.2.8.2. NOx Macros ........................................................................................................... 272 3.2.8.3. SOx Macros ........................................................................................................... 274 3.2.8.4. Dynamic Mesh Macros ........................................................................................... 275 3.2.9. NIST Real Gas Saturation Properties ................................................................................ 275 3.2.10. User-Defined Scalar (UDS) Transport Equation Macros ................................................... 276 3.2.10.1. Set_User_Scalar_Name ............................................................................... 276 3.2.10.2. F_UDSI .............................................................................................................. 277 3.2.10.3. C_UDSI .............................................................................................................. 277 3.2.10.4. Reserving UDS Variables ...................................................................................... 277 3.2.10.5.Reserve_User_Scalar_Vars ....................................................................... 278 3.2.10.6. Unreserving UDS Variables ................................................................................... 278 3.2.10.7. N_UDS ................................................................................................................ 278 3.2.11. User-Defined Memory (UDM) Macros ............................................................................ 278 3.2.11.1. Set_User_Memory_Name ............................................................................... 279 3.2.11.2. Set_User_Node_Memory_Name .................................................................... 279 3.2.11.3. F_UDMI .............................................................................................................. 279 3.2.11.4. C_UDMI .............................................................................................................. 280 Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information xiv of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 3.2.11.5. N_UDMI .............................................................................................................. 280 3.2.11.6. Example UDF that Utilizes UDM and UDS Variables ............................................... 281 3.2.11.7. Reserving UDM Variables Using Reserve_User_Memory_Vars ...................... 282 3.2.11.8. Example 1 ............................................................................................................ 283 3.2.11.9. Example 2 ............................................................................................................ 284 3.2.11.10. Unreserving UDM Variables ................................................................................ 285 3.3. Looping Macros ...................................................................................................................... 285 3.3.1. Looping Over Cell Threads in a Domain (thread_loop_c) ........................................... 285 3.3.2. Looping Over Face Threads in a Domain (thread_loop_f) .......................................... 286 3.3.3. Looping Over Cells in a Cell Thread (begin...end_c_loop) ....................................... 286 3.3.4. Looping Over Faces in a Face Thread (begin...end_f_loop) .................................... 286 3.3.5. Looping Over Faces of a Cell (c_face_loop) ................................................................ 287 3.3.6. Looping Over Nodes of a Cell (c_node_loop) ............................................................... 287 3.3.7. Looping Over Nodes of a Face (f_node_loop) ............................................................. 287 3.3.8. Multiphase Looping Macros ........................................................................................... 288 3.3.8.1. Looping Over Phase Domains in Mixture (sub_domain_loop) ............................ 288 3.3.8.2. Looping Over Phase Threads in Mixture (sub_thread_loop) .............................. 289 3.3.8.3. Looping Over Phase Cell Threads in Mixture (mp_thread_loop_c) ..................... 290 3.3.8.4. Looping Over Phase Face Threads in Mixture (mp_thread_loop_f) .................... 290 3.3.9. Advanced Multiphase Macros ......................................................................................... 291 3.3.9.1. Phase Domain Pointer (DOMAIN_SUB_DOMAIN) ................................................... 291 3.3.9.2. Phase-Level Thread Pointer (THREAD_SUB_THREAD) ............................................ 292 3.3.9.3. Phase Thread Pointer Array (THREAD_SUB_THREAD) ............................................ 292 3.3.9.4. Mixture Domain Pointer (DOMAIN_SUPER_DOMAIN) ............................................ 293 3.3.9.5. Mixture Thread Pointer (THREAD_SUPER_THREAD) .............................................. 293 3.3.9.6. Domain ID (DOMAIN_ID) ...................................................................................... 293 3.3.9.7. Phase Domain Index (PHASE_DOMAIN_INDEX) ................................................... 294 3.4.Vector and Dimension Macros ................................................................................................. 294 3.4.1. Macros for Dealing with Two and Three Dimensions ........................................................ 294 3.4.1.1. RP_2D and RP_3D ................................................................................................ 295 3.4.2. The ND Macros ............................................................................................................... 295 3.4.2.1. ND_ND .................................................................................................................. 295 3.4.2.2. ND_SUM ................................................................................................................ 295 3.4.2.3. ND_SET ................................................................................................................ 295 3.4.3. The NV Macros ............................................................................................................... 295 3.4.3.1. NV_V .................................................................................................................... 295 3.4.3.2. NV_VV .................................................................................................................. 296 3.4.3.3. NV_V_VS .............................................................................................................. 296 3.4.3.4. NV_VS_VS ............................................................................................................ 296 3.4.4.Vector Operation Macros ................................................................................................ 296 3.4.4.1.Vector Magnitude Using NV_MAG and NV_MAG2 .................................................... 296 3.4.4.2. Dot Product ........................................................................................................... 297 3.4.4.3. Cross Product ........................................................................................................ 297 3.5.Time-Dependent Macros ......................................................................................................... 297 3.6. Scheme Macros ...................................................................................................................... 299 3.6.1. Defining a Scheme Variable in the Text Interface ............................................................. 300 3.6.2. Accessing a Scheme Variable in the Text Interface ........................................................... 300 3.6.3. Changing a Scheme Variable to Another Value in the Text Interface ................................. 300 3.6.4. Accessing a Scheme Variable in a UDF ............................................................................. 300 3.7. Input/Output Macros .............................................................................................................. 301 3.7.1. Message ...................................................................................................................... 301 3.7.2. Error ........................................................................................................................... 302 xv Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 3.7.3.The par_fprintf_head and par_fprintf Macros ................................................. 302 3.7.3.1. par_fprintf_head .......................................................................................... 302 3.7.3.2. par_fprintf ..................................................................................................... 302 3.8. Miscellaneous Macros ............................................................................................................. 303 3.8.1. N_UDS ........................................................................................................................... 303 3.8.2. N_UDM ........................................................................................................................... 303 3.8.3. Data_Valid_P() ....................................................................................................... 304 3.8.4. FLUID_THREAD_P() ................................................................................................... 304 3.8.5. NULLP & NNULLP ....................................................................................................... 304 3.8.6. M_PI ............................................................................................................................. 304 3.8.7. UNIVERSAL_GAS_CONSTANT ..................................................................................... 305 3.8.8. SQR(k) ......................................................................................................................... 305 4. Interpreting UDFs .......................................................................................................................... 307 4.1. Introduction ........................................................................................................................... 307 4.1.1. Location of the udf.h File ............................................................................................. 307 4.1.2. Limitations ..................................................................................................................... 308 4.2. Interpreting a UDF Source File Using the Interpreted UDFs Dialog Box ..................................... 308 4.3. Common Errors Made While Interpreting A Source File ............................................................ 311 5. Compiling UDFs ............................................................................................................................. 313 5.1. Introduction ........................................................................................................................... 314 5.1.1. Location of the udf.h File ............................................................................................. 314 5.1.2. Compilers ...................................................................................................................... 315 5.2. Compiling a UDF Using the GUI ............................................................................................... 317 5.3. Compile a UDF Using the TUI ................................................................................................... 321 5.3.1. Set Up the Directory Structure ........................................................................................ 322 5.3.1.1.Windows Systems .................................................................................................. 322 5.3.1.2. Linux Systems ........................................................................................................ 323 5.3.2. Build the UDF Library ..................................................................................................... 324 5.3.2.1.Windows Systems .................................................................................................. 324 5.3.2.2. Linux Systems ........................................................................................................ 326 5.3.3. Load the UDF Library ...................................................................................................... 327 5.4. Link Precompiled Object Files From Non-ANSYS Fluent Sources ............................................... 327 5.4.1.Windows Systems ........................................................................................................... 328 5.4.2. Linux Systems ................................................................................................................ 328 5.4.3. Example: Link Precompiled Objects to ANSYS Fluent ....................................................... 329 5.5. Load and Unload Libraries Using the UDF Library Manager Dialog Box ..................................... 332 5.5.1. Load the UDF Library ...................................................................................................... 332 5.5.2. Unload the UDF Library .................................................................................................. 333 5.6. Common Errors When Building and Loading a UDF Library ...................................................... 333 5.6.1.Windows Parallel ............................................................................................................ 334 5.7. Special Considerations for Parallel ANSYS Fluent ...................................................................... 335 6. Hooking UDFs to ANSYS Fluent .................................................................................................... 337 6.1. Hooking General Purpose UDFs ............................................................................................... 337 6.1.1. Hooking DEFINE_ADJUST UDFs ................................................................................... 337 6.1.2. Hooking DEFINE_DELTAT UDFs ................................................................................... 339 6.1.3. Hooking DEFINE_EXECUTE_AT_END UDFs ................................................................. 340 6.1.4. Hooking DEFINE_EXECUTE_AT_EXIT UDFs ............................................................... 341 6.1.5. Hooking DEFINE_INIT UDFs ....................................................................................... 343 6.1.6. Hooking DEFINE_ON_DEMAND UDFs ............................................................................ 344 6.1.7. Hooking DEFINE_RW_FILE and DEFINE_RW_HDF_FILE UDFs ................................. 345 6.1.8. User-Defined Memory Storage ....................................................................................... 346 6.2. Hooking Model-Specific UDFs ................................................................................................. 347 Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information xvi of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 6.2.1. Hooking DEFINE_ANISOTROPIC_CONDUCTIVITY UDFs ........................................... 348 6.2.2. Hooking DEFINE_CHEM_STEP UDFs ............................................................................ 350 6.2.3. Hooking DEFINE_CPHI UDFs ....................................................................................... 351 6.2.4. Hooking DEFINE_DIFFUSIVITY UDFs ........................................................................ 352 6.2.5. Hooking DEFINE_DOM_DIFFUSE_REFLECTIVITY UDFs ........................................... 354 6.2.6. Hooking DEFINE_DOM_SOURCE UDFs .......................................................................... 355 6.2.7. Hooking DEFINE_DOM_SPECULAR_REFLECTIVITY UDFs ......................................... 356 6.2.8. Hooking DEFINE_ECFM_SOURCE UDFs ........................................................................ 357 6.2.9. Hooking DEFINE_ECFM_SPARK_SOURCE UDFs .......................................................... 359 6.2.10. Hooking DEFINE_EMISSIVITY_WEIGHTING_FACTOR UDFs .................................. 360 6.2.11. Hooking DEFINE_ZONE_MOTION UDFs ...................................................................... 361 6.2.12. Hooking DEFINE_GRAY_BAND_ABS_COEFF UDFs .................................................... 362 6.2.13. Hooking DEFINE_HEAT_FLUX UDFs .......................................................................... 363 6.2.14. Hooking DEFINE_IGNITE_SOURCE UDFs ................................................................. 364 6.2.15. Hooking DEFINE_NET_REACTION_RATE UDFs ........................................................ 365 6.2.16. Hooking DEFINE_NOX_RATE UDFs ............................................................................ 367 6.2.17. Hooking DEFINE_PDF_TABLE UDFs .......................................................................... 369 6.2.18. Hooking DEFINE_PR_RATE UDFs .............................................................................. 369 6.2.19. Hooking DEFINE_PRANDTL UDFs .............................................................................. 370 6.2.20. Hooking DEFINE_PROFILE UDFs .............................................................................. 371 6.2.20.1. Hooking Profiles for UDS Equations ...................................................................... 373 6.2.21. Hooking DEFINE_PROPERTY UDFs ............................................................................ 375 6.2.22. Hooking DEFINE_REACTING_CHANNEL_BC UDFs .................................................... 377 6.2.23. Hooking DEFINE_REACTING_CHANNEL_SOLVER UDFs ........................................... 377 6.2.24. Hooking DEFINE_SCAT_PHASE_FUNC UDFs ............................................................. 378 6.2.25. Hooking DEFINE_SOLAR_INTENSITY UDFs ............................................................. 380 6.2.26. Hooking DEFINE_SOLIDIFICATION_PARAMS UDFs ................................................ 381 6.2.27. Hooking DEFINE_SOURCE UDFs ................................................................................. 382 6.2.28. Hooking DEFINE_SOOT_MASS_RATES UDFs ............................................................. 384 6.2.29. Hooking DEFINE_SOOT_NUCLEATION_RATES UDFs ................................................ 385 6.2.30. Hooking DEFINE_SOOT_OXIDATION_RATE UDFs .................................................... 386 6.2.31. Hooking DEFINE_SOOT_PRECURSOR UDFs ............................................................... 387 6.2.32. Hooking DEFINE_SOX_RATE UDFs ............................................................................ 387 6.2.33. Hooking DEFINE_SPARK_GEOM UDFs ........................................................................ 389 6.2.34. Hooking DEFINE_SPECIFIC_HEAT UDFs ................................................................. 390 6.2.35. Hooking DEFINE_SR_RATE UDFs .............................................................................. 391 6.2.36. Hooking DEFINE_THICKENED_FLAME_MODEL UDFs ................................................ 392 6.2.37. Hooking DEFINE_TRANS UDFs ................................................................................... 393 6.2.38. Hooking DEFINE_TRANSIENT_PROFILE UDFs ........................................................ 394 6.2.39. Hooking DEFINE_TURB_PREMIX_SOURCE UDFs ...................................................... 395 6.2.40. Hooking DEFINE_TURB_SCHMIDT UDFs ................................................................... 396 6.2.41. Hooking DEFINE_TURBULENT_VISCOSITY UDFs .................................................... 397 6.2.42. Hooking DEFINE_VR_RATE UDFs .............................................................................. 398 6.2.43. Hooking DEFINE_WALL_FUNCTIONS UDFs ............................................................... 399 6.2.44. Hooking DEFINE_WSGGM_ABS_COEFF UDFs ............................................................. 400 6.3. Hooking Multiphase UDFs ....................................................................................................... 402 6.3.1. Hooking DEFINE_BOILING_PROPERTY UDFs ............................................................. 402 6.3.2. Hooking DEFINE_CAVITATION_RATE UDFs ............................................................... 403 6.3.3. Hooking DEFINE_EXCHANGE_PROPERTY UDFs .......................................................... 405 6.3.4. Hooking DEFINE_HET_RXN_RATE UDFs ..................................................................... 407 6.3.5. Hooking DEFINE_LINEARIZED_MASS_TRANSFER UDFs ........................................... 408 6.3.6. Hooking DEFINE_MASS_TRANSFER UDFs ................................................................... 409 xvii Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 6.3.7. Hooking DEFINE_VECTOR_EXCHANGE_PROPERTY UDFs ........................................... 410 6.4. Hooking Discrete Phase Model (DPM) UDFs ............................................................................. 412 6.4.1. Hooking DEFINE_DPM_BC UDFs ................................................................................... 412 6.4.2. Hooking DEFINE_DPM_BODY_FORCE UDFs ................................................................. 413 6.4.3. Hooking DEFINE_DPM_DRAG UDFs .............................................................................. 414 6.4.4. Hooking DEFINE_DPM_EROSION UDFs ........................................................................ 415 6.4.5. Hooking DEFINE_DPM_HEAT_MASS UDFs ................................................................... 416 6.4.6. Hooking DEFINE_DPM_INJECTION_INIT UDFs ........................................................ 417 6.4.7. Hooking DEFINE_DPM_LAW UDFs ................................................................................ 418 6.4.8. Hooking DEFINE_DPM_OUTPUT UDFs .......................................................................... 419 6.4.9. Hooking DEFINE_DPM_PROPERTY UDFs ..................................................................... 420 6.4.10. Hooking DEFINE_DPM_SCALAR_UPDATE UDFs ........................................................ 422 6.4.11. Hooking DEFINE_DPM_SOURCE UDFs ........................................................................ 423 6.4.12. Hooking DEFINE_DPM_SPRAY_COLLIDE UDFs ........................................................ 423 6.4.13. Hooking DEFINE_DPM_SWITCH UDFs ........................................................................ 424 6.4.14. Hooking DEFINE_DPM_TIMESTEP UDFs ................................................................... 425 6.4.15. Hooking DEFINE_DPM_VP_EQUILIB UDFs ............................................................... 426 6.4.16. Hooking DEFINE_IMPINGEMENT UDFs ...................................................................... 428 6.4.17. Hooking DEFINE_FILM_REGIME UDFs ...................................................................... 429 6.4.18. Hooking DEFINE_SPLASHING_DISTRIBUTION UDFs ............................................. 431 6.5. Hooking Dynamic Mesh UDFs ................................................................................................. 432 6.5.1. Hooking DEFINE_CG_MOTION UDFs ............................................................................ 433 6.5.2. Hooking DEFINE_DYNAMIC_ZONE_PROPERTY UDFs .................................................. 433 6.5.2.1. Hooking a Swirl Center UDF ................................................................................... 434 6.5.2.2. Hooking a Variable Cell Layering Height UDF .......................................................... 435 6.5.3. Hooking DEFINE_GEOM UDFs ....................................................................................... 436 6.5.4. Hooking DEFINE_GRID_MOTION UDFs ........................................................................ 437 6.5.5. Hooking DEFINE_SDOF_PROPERTIES UDFs ............................................................... 438 6.5.6. Hooking DEFINE_CONTACT UDFs ................................................................................ 439 6.6. Hooking User-Defined Scalar (UDS) Transport Equation UDFs .................................................. 440 6.6.1. Hooking DEFINE_ANISOTROPIC_DIFFUSIVITY UDFs ............................................. 441 6.6.2. Hooking DEFINE_UDS_FLUX UDFs .............................................................................. 442 6.6.3. Hooking DEFINE_UDS_UNSTEADY UDFs ..................................................................... 443 6.7. Common Errors While Hooking a UDF to ANSYS Fluent ............................................................ 444 7. Parallel Considerations ................................................................................................................. 447 7.1. Overview of Parallel ANSYS Fluent ........................................................................................... 447 7.1.1. Command Transfer and Communication ......................................................................... 449 7.2. Cells and Faces in a Partitioned Mesh ....................................................................................... 451 7.2.1. Cell Types in a Partitioned Mesh ...................................................................................... 451 7.2.2. Faces at Partition Boundaries .......................................................................................... 452 7.2.3. PRINCIPAL_FACE_P ................................................................................................... 453 7.2.4. Exterior Thread Storage .................................................................................................. 453 7.2.5. Extended Neighborhood ................................................................................................ 454 7.3. Parallelizing Your Serial UDF .................................................................................................... 455 7.4. Parallelization of Discrete Phase Model (DPM) UDFs ................................................................. 456 7.5. Macros for Parallel UDFs .......................................................................................................... 456 7.5.1. Compiler Directives ........................................................................................................ 457 7.5.2. Communicating Between the Host and Node Processes .................................................. 458 7.5.2.1. Host-to-Node Data Transfer .................................................................................... 458 7.5.2.2. Node-to-Host Data Transfer .................................................................................... 459 7.5.3. Predicates ...................................................................................................................... 460 7.5.4. Global Reduction Macros ................................................................................................ 461 Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information xviii of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 7.5.4.1. Global Summations ............................................................................................... 462 7.5.4.2. Global Maximums and Minimums .......................................................................... 462 7.5.4.3. Global Logicals ...................................................................................................... 463 7.5.4.4. Global Synchronization .......................................................................................... 463 7.5.5. Looping Macros ............................................................................................................. 463 7.5.5.1. Looping Over Cells ................................................................................................. 464 7.5.5.2. Interior Cell Looping Macro .................................................................................... 464 7.5.5.3. Exterior Cell Looping Macro ................................................................................... 465 7.5.5.4. Interior and Exterior Cell Looping Macro ................................................................ 465 7.5.5.5. Looping Over Faces ............................................................................................... 466 7.5.6. Cell and Face Partition ID Macros .................................................................................... 467 7.5.6.1. Cell Partition IDs .................................................................................................... 467 7.5.6.2. Face Partition IDs ................................................................................................... 468 7.5.7. Message Displaying Macros ............................................................................................ 468 7.5.8. Message Passing Macros ................................................................................................ 469 7.5.9. Macros for Exchanging Data Between Compute Nodes ................................................... 472 7.6. Limitations of Parallel UDFs ..................................................................................................... 472 7.7. Process Identification .............................................................................................................. 473 7.8. Parallel UDF Example .............................................................................................................. 474 7.9. Reading and Writing Files in Parallel ........................................................................................ 476 7.9.1. Reading Files in Parallel .................................................................................................. 476 7.9.2.Writing Files in Parallel .................................................................................................... 477 7.10. Enabling Fluent UDFs to Execute on General Purpose Graphics Processing Units (GPGPUs) ..... 478 8. Examples ....................................................................................................................................... 481 8.1. Step-By-Step UDF Example ..................................................................................................... 481 8.1.1. Process Overview ........................................................................................................... 481 8.1.2. Step 1: Define Your Problem ............................................................................................ 482 8.1.3. Step 2: Create a C Source File .......................................................................................... 484 8.1.4. Step 3: Start ANSYS Fluent and Read (or Set Up) the Case File .......................................... 484 8.1.5. Step 4: Interpret or Compile the Source File ..................................................................... 485 8.1.5.1. Interpret the Source File ......................................................................................... 485 8.1.5.2. Compile the Source File ......................................................................................... 487 8.1.6. Step 5: Hook the UDF to ANSYS Fluent ............................................................................ 490 8.1.7. Step 6: Run the Calculation ............................................................................................. 490 8.1.8. Step 7: Analyze the Numerical Solution and Compare to Expected Results ....................... 491 8.2. Detailed UDF Examples ........................................................................................................... 491 8.2.1. Boundary Conditions ...................................................................................................... 491 8.2.1.1. Parabolic Velocity Inlet Profile in an Elbow Duct ...................................................... 492 8.2.1.2.Transient Pressure Outlet Profile for Flow in a Tube ................................................. 496 8.2.2. Source Terms .................................................................................................................. 501 8.2.2.1. Adding a Momentum Source to a Duct Flow .......................................................... 501 8.2.3. Physical Properties ......................................................................................................... 506 8.2.3.1. Solidification via a Temperature-Dependent Viscosity ............................................. 506 8.2.4. Reaction Rates ............................................................................................................... 509 8.2.4.1.Volume Reaction Rate ............................................................................................ 510 8.2.5. User-Defined Scalars ...................................................................................................... 513 8.2.5.1. Postprocessing Using User-Defined Scalars ............................................................ 513 8.2.5.2. Implementing ANSYS Fluent’s P-1 Radiation Model Using User-Defined Scalars ....... 515 8.2.6. User-Defined Real Gas Models (UDRGM) ......................................................................... 518 8.2.6.1. UDRGM Example: Redlich-Kwong Equation of State ................................................ 518 8.2.6.2. Specific Volume and Density .................................................................................. 518 8.2.6.3. Derivatives of Specific Volume and Density ............................................................ 520 xix Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 8.2.6.4. Specific Heat and Enthalpy ..................................................................................... 520 8.2.6.5. Entropy ................................................................................................................. 521 8.2.6.6. Speed of Sound ..................................................................................................... 521 8.2.6.7.Viscosity and Thermal Conductivity ........................................................................ 522 8.2.6.8. Using the Redlich-Kwong Real Gas UDRGM ............................................................ 522 8.2.6.9. Redlich-Kwong Real Gas UDRGM Code Listing ........................................................ 523 8.2.6.9.1. UDRGM Example: Multiple-Species Real Gas Model ........................................ 529 8.2.6.9.2. UDRGM Example: Real Gas Model with Volumetric Reactions ......................... 535 A. C Programming Basics ..................................................................................................................... 547 A.1. Introduction ........................................................................................................................... 547 A.2. Commenting Your C Code ....................................................................................................... 547 A.3. C Data Types in ANSYS Fluent .................................................................................................. 548 A.4. Constants ............................................................................................................................... 548 A.5.Variables ................................................................................................................................. 548 A.5.1. Declaring Variables ........................................................................................................ 549 A.5.2. External Variables ........................................................................................................... 549 A.5.2.1. Example ................................................................................................................ 549 A.5.3. Static Variables ............................................................................................................... 550 A.5.3.1. Example - Static Global Variable ............................................................................. 550 A.6. User-Defined Data Types ......................................................................................................... 551 A.6.1. Example ........................................................................................................................ 551 A.7. Casting ................................................................................................................................... 551 A.8. Functions ............................................................................................................................... 551 A.9. Arrays ..................................................................................................................................... 552 A.9.1. Examples ....................................................................................................................... 552 A.10. Pointers ................................................................................................................................ 552 A.10.1. Pointers as Function Arguments ................................................................................... 553 A.11. Control Statements ............................................................................................................... 553 A.11.1.if Statement ............................................................................................................... 553 A.11.1.1. Example .............................................................................................................. 553 A.11.2.if-else Statement .................................................................................................... 553 A.11.2.1. Example .............................................................................................................. 553 A.11.3. for Loops ................................................................................................................... 554 A.11.3.1. Example .............................................................................................................. 554 A.12. Common C Operators ........................................................................................................... 554 A.12.1. Arithmetic Operators ................................................................................................... 554 A.12.2. Logical Operators ......................................................................................................... 555 A.13. C Library Functions ............................................................................................................... 555 A.13.1. Trigonometric Functions .............................................................................................. 555 A.13.2. Miscellaneous Mathematical Functions ......................................................................... 555 A.13.3. Standard I/O Functions ................................................................................................. 556 A.13.3.1. fopen ................................................................................................................ 556 A.13.3.2. fclose .............................................................................................................. 557 A.13.3.3. printf .............................................................................................................. 557 A.13.3.4.fprintf ............................................................................................................ 557 A.13.3.5. fscanf .............................................................................................................. 558 A.14. Preprocessor Directives ......................................................................................................... 558 A.14.1. Macro Substitution Directive Using #define .............................................................. 558 A.14.2. File Inclusion Directive Using #include ...................................................................... 559 A.15. Comparison with FORTRAN ................................................................................................... 559 B. DEFINE Macro Definitions .............................................................................................................. 561 B.1. General Solver DEFINE Macros ............................................................................................... 561 Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information xx of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual B.2. Model-Specific DEFINE Macro Definitions .............................................................................. 561 B.3. Multiphase DEFINE Macros .................................................................................................... 563 B.4. Dynamic Mesh Model DEFINE Macros ................................................................................... 563 B.5. Discrete Phase Model DEFINE Macros .................................................................................... 564 B.6. User-Defined Scalar (UDS) DEFINE Macros ............................................................................. 565 C. Quick Reference Guide for Multiphase DEFINE Macros .................................................................... 567 C.1.VOF Model .............................................................................................................................. 567 C.2. Mixture Model ........................................................................................................................ 569 C.3. Eulerian Model - Laminar Flow ................................................................................................ 571 C.4. Eulerian Model - Mixture Turbulence Flow ............................................................................... 573 C.5. Eulerian Model - Dispersed Turbulence Flow ............................................................................ 575 C.6. Eulerian Model - Per Phase Turbulence Flow ............................................................................ 578 Bibliography ....................................................................................................................................... 581 II. Creating Custom User Interfaces in Fluent ......................................................................................... 583 1. Introduction to Fluent User Interface Concepts ........................................................................... 585 1.1. Introduction ........................................................................................................................... 585 1.2. Limitations ............................................................................................................................. 585 1.2.1. Menu Items Read Into Fluent Can’t Be Removed Or Overwritten ...................................... 585 1.2.2. Help Button Unusable .................................................................................................... 586 1.3. Scheme Basics ........................................................................................................................ 586 1.3.1. Data Types ..................................................................................................................... 586 1.3.1.1. Boolean ................................................................................................................. 586 1.3.1.2. Integers ................................................................................................................. 587 1.3.1.3. Reals ..................................................................................................................... 587 1.3.1.4. Characters ............................................................................................................. 587 1.3.1.5. Strings ................................................................................................................... 588 1.3.1.6. Symbols ................................................................................................................ 588 1.3.1.7. Pairs and Lists ........................................................................................................ 589 1.3.2. Important Concepts ....................................................................................................... 589 1.3.2.1. Define ................................................................................................................... 590 1.3.2.2. Set! ........................................................................................................................ 590 1.3.2.3. Let ......................................................................................................................... 590 1.3.2.4. Lambda ................................................................................................................. 591 1.3.2.5. If ........................................................................................................................... 591 1.3.2.6. Map ...................................................................................................................... 592 1.4. RP Variables ............................................................................................................................ 592 1.4.1. Creating an RP Variable ................................................................................................... 592 1.4.2. Changing an RP Variable ................................................................................................. 593 1.4.3. Accessing the Value of an RP Variable In Your GUI ............................................................ 593 1.4.4. Accessing the Value of an RP Variable In Your UDF ........................................................... 593 1.4.5. Saving and Loading RP Variables ..................................................................................... 593 1.5. The .fluent File ........................................................................................................................ 594 2. How to Create an Interface ............................................................................................................ 597 2.1. Dialog Boxes (cx-create-panel) ................................................................................................ 597 2.1.1. Description .................................................................................................................... 597 2.1.2. Usage ............................................................................................................................ 597 2.1.2.1. cx-create-panel ...................................................................................................... 597 2.1.2.2. cx-show-panel ....................................................................................................... 598 2.1.3. Examples ....................................................................................................................... 598 2.1.3.1. Example One ......................................................................................................... 598 2.1.3.2. Example Two ......................................................................................................... 599 2.1.3.3. Additional Examples .............................................................................................. 599 xxi Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 2.2. Tables (cx-create-table) ........................................................................................................... 599 2.2.1. Description .................................................................................................................... 600 2.2.2. Usage ............................................................................................................................ 600 2.2.3. Examples ....................................................................................................................... 600 3. Interface Elements ........................................................................................................................ 601 3.1. Integer Entry (cx-create-integer-entry) ..................................................................................... 601 3.1.1. Description .................................................................................................................... 601 3.1.2. Usage ............................................................................................................................ 601 3.1.2.1. cx-create-integer-entry .......................................................................................... 601 3.1.2.2. cx-set-integer-entry ............................................................................................... 602 3.1.2.3. cx-show-integer-entry ........................................................................................... 602 3.1.3. Integer Entry Example .................................................................................................... 602 3.2. Real Number Entry (cx-create-real-entry) ................................................................................. 603 3.2.1. Description .................................................................................................................... 603 3.2.2. Usage ............................................................................................................................ 603 3.2.2.1. cx-create-real-entry ............................................................................................... 603 3.2.2.2. cx-set-real-entry .................................................................................................... 604 3.2.2.3. cx-show-real-entry ................................................................................................. 604 3.2.3. Real Number Entry Example ........................................................................................... 604 3.3. Text Entry (cx-create-text-entry) .............................................................................................. 605 3.3.1. Description .................................................................................................................... 605 3.3.2. Usage ............................................................................................................................ 605 3.3.2.1. cx-create-text-entry ............................................................................................... 605 3.3.2.2. cx-set-text-entry .................................................................................................... 606 3.3.2.3. cx-show-text-entry ................................................................................................ 606 3.3.3.Text Entry Example ......................................................................................................... 606 3.4. Check Boxes & Radio Buttons (cx-create-toggle-button) ........................................................... 607 3.4.1. Description .................................................................................................................... 607 3.4.2. Usage ............................................................................................................................ 608 3.4.2.1. cx-create-button-box ............................................................................................. 608 3.4.2.2. cx-create-toggle-button ......................................................................................... 608 3.4.2.3. cx-set-toggle-button ............................................................................................. 608 3.4.2.4. cx-show-toggle-button .......................................................................................... 608 3.4.3. Check Box Example ........................................................................................................ 608 3.4.4. Option Button Example .................................................................................................. 609 3.5. Buttons (cx-create-button) ...................................................................................................... 610 3.5.1. Description .................................................................................................................... 610 3.5.2. Usage ............................................................................................................................ 610 3.5.3. Button Example .............................................................................................................. 611 3.6. Lists & Drop-down Lists (cx-create-list) & (cx-create-drop-down-list) ......................................... 612 3.6.1. Description .................................................................................................................... 612 3.6.2. Usage ............................................................................................................................ 612 3.6.2.1. cx-create-list .......................................................................................................... 612 3.6.2.2. cx-create-drop-down-list ....................................................................................... 613 3.6.2.3. cx-set-list-items ..................................................................................................... 613 3.6.2.4. cx-set-list-selections .............................................................................................. 614 3.6.2.5. cx-show-list-selections ........................................................................................... 614 3.6.3. List Example ................................................................................................................... 614 3.6.4. Drop Down List Example ................................................................................................ 615 4. Menu Bar Entries ........................................................................................................................... 617 4.1. Adding a New Menu ............................................................................................................... 617 4.1.1. Description .................................................................................................................... 617 Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information xxii of ANSYS, Inc. and its subsidiaries and affiliates. Customization Manual 4.1.2. Usage ............................................................................................................................ 617 4.1.3. Examples ....................................................................................................................... 618 4.2. Adding a New Submenu ......................................................................................................... 618 4.2.1. Description .................................................................................................................... 618 4.2.2. Usage ............................................................................................................................ 618 4.2.3. Examples ....................................................................................................................... 619 4.3. Adding a New Menu Item ........................................................................................................ 619 4.3.1. Description .................................................................................................................... 619 4.3.2. Usage ............................................................................................................................ 620 4.3.3. Examples ....................................................................................................................... 620 5. Comprehensive Examples ............................................................................................................. 621 5.1. Dialog Box Example ................................................................................................................ 621 5.2. Menu Bar Example .................................................................................................................. 624 5.3. UDF Example .......................................................................................................................... 625 A. Avoiding Common Mistakes ............................................................................................................ 627 A.1. Keeping Track Of Parentheses ................................................................................................. 627 A.2. Knowing The Type Of Each Variable ......................................................................................... 627 A.3. Overwriting Interface Elements ............................................................................................... 627 A.3.1. Example One ................................................................................................................. 627 A.3.2. Example Two ................................................................................................................. 628 B. Reference Table For Fluent Macros ................................................................................................... 631 Index ........................................................................................................................................................ 633
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论