当前位置:文档之家› ANSYS_FLUENT中文培训教材4

ANSYS_FLUENT中文培训教材4


Source terms
Repeat
Solve U-Momentum
Solve V-Momentum
Solve W-Momentum
Solve Mass Continuity; Update Velocity
Source terms
Solve Mass & Momentum
Solve Mass, Momentum,
Source terms
A Pera Global Company © PERA China
UDF 数据结构 (1)
▪ 在UDF中,体域和面域通过Thread数据类型获得 ▪ Thread 是 FLUENT 定义的数据类型
Domain Cell
Boundary (face thread or zone)
ANSYS FLUENT 培训教材 第七节:UDF
安世亚太科技(北京)有限公司
A Pera Global Company © PERA China
概要
FLUENT UDF简介 FLUENT 数据结构和宏 两个例子 UDF 支持
A Pera Global Company © PERA China
简介
F_PROFILE 宏在面 f上施加 速度分量
代码以文本文件保存
inlet_bc.c
Header file “udf.h” must be included at the top of the program by the #include command
#include "udf.h" DEFINE_PROFILE(x_velocity,thread,nv) {
pointer c: a cell thread variable f: a face thread variable
end_c_loop (c,t)
– 对面thread中所有面循环
begin_f_loop(f, f_thread)
{…}
end_f_loop(f, f_thread)
A Pera Global Company © PERA China
什么是UDF?
– UDF 是用户自己用C语言写的一个函数,可以和FLUENT动态链接
• 标准C 函数
▪ 三角函数,指数,控制块,Do循环,文件读入/输出等
• 预定义宏
▪ 允许获得流场变量,材料属性,单元几何信息及其他
为什么使用 UDFs?
– 标准的界面不能编程模拟所有需求:
• 定制边界条件,源项,反应速率,材料属性等
UDF 数据结构(2)
cell_t 声明了识别单元的整型数据类型
face_t声明了识别面的整型数据类型
Type
Domain Thread cell_t face_t Node
Variable
*d; *t; c; f; *node;
Meaning of the declaration
d is a pointer to domain thread t is a pointer to thread c is cell thread variable f is a face thread variable node is a pointer to a node.
– 所有的UDFs 以 DEFINE_ 宏开始
– x_velocity 将在 GUI中 出现
– thread 和 nv DEFINE_PROFILE 宏的参 数, 分别用来识别域和变量
– begin_f_loop宏通过 thread指针,对所有的面f 循环
F_CENTROID宏赋单元位置向 量给 x[]
例子 – 抛物线分布的速度入口
在二维弯管入口施加抛物线分布的速度 x 方向的速度定义为
需要通过宏获得入口的中心点, 通过另外一个宏赋予速度条件
A Pera Global Company © PERA China
第1步 – 准备源代码
DEFINE_PROFILE 宏允许定 义x_velocity函数
UDF中的循环宏
几个经常用到的循环宏为:
– 对域d中所有单元thread循环:
thread_loop_c(ct,d) { }
– 对域d中所有面thread循环: thread_loop_f(ft,d) { }
– 对thread t中所有单元循环: begin_c_loop(c, t) {…}
d: a domain pointer ct, t: a cell thread pointer ft,f_thread: a face thread
Fluid (cell thread or zone)
Domain
Cell Thread
face Thread
Cells
Faces
▪ 为了在thread (zone)中获得数据,我们需要提供正确的指针,并 使用循环宏获得thread中的每个成员(cell or face)
A Pera Global Company © PERA China
Fluid cell-thread (control-volume ensemble)
Nodes
A Pera Global Company © PERA China
Boundary face-thread (boundarห้องสมุดไป่ตู้-face ensemble)
Internal face-thread (internal-face ensemble) associated with cell-threads
• 定制物理模型
• 用户提供的模型方程
• 调整函数
• 执行和需求函数
• 初始化
A Pera Global Company © PERA China
可以使用UDF的位置
Segregated
PBCS
DBCS
Initialize
UserBegin Loop defined
ADJUST
Solver?
User Defined INITIALIZE
Energy, Species
Source terms
Exit Loop Check Convergence
Solve Energy
Update Properties
Solve Species
User-Defined Properties User-Defined BCs
Solve Turbulence Equation(s) Solve Other Transport Equations as required
相关主题