5-1 FLUENT流体模拟-UDF-讲解解析

相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Solve V-Momentum
Solve W-Momentum
User Defined INITIALIZE Repeat
Solve Mass & Momentum
Solve Mass, Momentum, Energy, Species
Source terms
Solve Mass Continuity; Update Velocity
▪ 三角函数,指数,控制块,Do循环,文件读入/输出等
• 预定义宏
▪ 允许获得流场变量,材料属性,单元几何信息及其他
为什么使用 UDFs?
– 标准的界面不能编程模拟所有需求:
• 定制边界条件,源项,反应速率,材料属性等 • 定制物理模型 • 用户提供的模型方程 • 调整函数 • 执行和需求函数 • 初始化
Fluid cell-thread (control-volume ensemble)
Boundary face-thread (boundary-face ensemble)
Nodes
Internal face-thread (internal-face ensemble) associated with cell-threads
Fluid (cell thread or zone)
Cells Faces
为了在thread (zone)中获得数据,我们需要提供正确的指针,并 使用循环宏获得thread中的每个成员(cell or face)
A Pera Global Company © PERA China
UDFБайду номын сангаас数据结构(2)
A Pera Global Company © PERA China
UDF中的循环宏
几个经常用到的循环宏为:
– 对域d中所有单元thread循环: thread_loop_c(ct,d) { – 对域d中所有面thread循环: thread_loop_f(ft,d) { – 对thread t中所有单元循环: begin_c_loop(c, t) {…} end_c_loop (c,t) } }
d: a domain pointer ct, t: a cell thread pointer ft,f_thread: a face thread pointer c: a cell thread variable f: a face thread variable
– 对面thread中所有面循环 begin_f_loop(f, f_thread) { … } end_f_loop(f, f_thread)
A Pera Global Company © PERA China
例子 – 抛物线分布的速度入口
在二维弯管入口施加抛物线分布的速度 x 方向的速度定义为
需要通过宏获得入口的中心点, 通过另外一个宏赋予速度条件
A Pera Global Company © PERA China
第1步 – 准备源代码
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) { float x[3]; /* an array for the coordinates */ float y; face_t f; /* f is a face thread index */
Exit Loop
Check Convergence
Update Properties User-Defined Properties User-Defined BCs
Solve Energy Solve Species Solve Turbulence Equation(s) Solve Other Transport Equations as required
Source terms
A Pera Global Company © PERA China
UDF 数据结构 (1)
在UDF中,体域和面域通过Thread数据类型获得 Thread 是 FLUENT 定义的数据类型
Domain Domain Cell Cell Thread Boundary (face thread or zone) face Thread
cell_t 声明了识别单元的整型数据类型 face_t声明了识别面的整型数据类型
Type Variable Meaning of the declaration
Domain Thread cell_t face_t Node
*d; *t; c; f; *node;
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.
DEFINE_PROFILE 宏允许定 义x_velocity函数 – 所有的UDFs 以 DEFINE_ 宏开始 – x_velocity 将在 GUI中 出现 – thread 和 nv DEFINE_PROFILE 宏的参 数, 分别用来识别域和变量 – begin_f_loop宏通过 thread指针,对所有的面f 循环 F_CENTROID宏赋单元位置向 量给 x[] F_PROFILE 宏在面 f上施加 速度分量 代码以文本文件保存 inlet_bc.c
A Pera Global Company © PERA China
可以使用UDF的位置
Segregated Userdefined ADJUST PBCS DBCS
Initialize
Begin Loop
Solver? Source terms
Solve U-Momentum
Source terms
计算流体力学软件Fluent培训
UDF基础
概要
FLUENT UDF简介
FLUENT 数据结构和宏 两个例子
UDF 支持
A Pera Global Company © PERA China
简介
什么是UDF?
– UDF 是用户自己用C语言写的一个函数,可以和FLUENT动态链接
• 标准C 函数
相关文档
最新文档