6. Utilities (工具)
本章提供了针对FLUENT变量性能计算的FLUENT公司提供的预处理工具列表。
? ? ? ? ? ? ? ? ?
6.1 Introduction 简要
6.2 General-Purpose Looping Macros 一般目的的宏
6.3 Multiphase-Specific Looping Macros 多项组分的宏
6.4 Setting Face Variables ( F_PROFILE) 设置面变量
6.5 Accessing Variables That Are Not Passed as Arguments 访问没有作为Argument传递的变量
6.6 Accessing Neighboring Cell and Thread Variables 访问邻近单元(网格点和线)上的变量
?
6.7 User-Defined Memory for Cells ( C_UDMI) 用户为网格定义内存(C-UDMI)
?
6.8 Vector Utilities 矢量工具
?
6.9 Macros for Time-Dependent Simulations 与时间相关的数值模拟宏
?
6.10 Miscellaneous Utilities 其他各种工具
6.1简要
Fluent Inc.提供了针对Fluent变量操作的一系列工具。这些工具中大部分可以作为宏直接执行。
许多宏可以用于单相和多相模型的UDFs中,但是有些是只针对多相流的。回想一下当你为多相流模型写UDFs时,你将记住FLUENT的结构的层次。(详细参考3.11.1)。
从求解器中导入到你的UDFs中特殊的控制区和线性结构,依赖于你所使用的DEFINE宏和相关的控制区函数。(通过图形用户界面和用户定义的源代码)
它或许也依赖于你所使用的多相流模型。将控制区的结构传递给DEFINE_INIT 和 DEFINE_ADJUST 函数,但是它与多相流模型是相互独立的。这些函数始终被传递给与混合物有关的控制区结构。DEFINE_ON_DEMAND UDFs没有被传递给任何控制区。
如果你的PDF没有显式地传给你的函数所需要的线性的或者控制区的结构,那么你可以利用本章提供的宏工具修复。提供的许多宏使你的函数可以寻找到给定线和区的所有的网格点和面。
6.2一般目的的循环宏
下面这些循环的宏可以用于FLUENT单相和多相模型的UDFs中。这些宏的定义包含再mem.h头文件中。
? ? ? ? ? ? ? ? ? ? ? ?
6.2.1 Looping over Cell Threads in a Domain ( thread_loop_c) 查询控制区的单元线
6.2.2 Looping over Face Threads in a Domain ( thread_loop_f) 查询控制区的面
6.2.3 Looping over Cells in a Cell Thread ( begin...end_c_loop) 查询单元线中的单元
6.2.4 Looping over Faces in a Face Thread ( begin...end_f_loop) 查询面单元中的面
6.2.5 Looping over Faces on a Cell ( c_face_loop) 查询单元面
6.2.6 Looping over Nodes of a Cell ( c_node_loop) 查询单元节点
6.2.1查询控制区的单元线
当你想查询给定控制区的单元线时,你可以用thread_loop_c。它包含单独的说明,后面是对控制区的单元线所做操作,正如下面显示的包含在{ }中。注意:thread_loop_c在执行上和thread_loop_f相似,参考6.2.2部分。
Domain *domain; Thread *c_thread;
thread_loop_c(c_thread, domain) /*loops over all cell threads in domain*/ {
}
6.2.2查询控制区的面
当你想要查询给定控制区的面时,你可以应用thread_loop_f。它包含单独的说明,后面是对控制区的面单元所做操作,正如下面显示的包含在{ }中。注意:thread_loop_f在执行上和thread_loop_c相似,参考6.2.1部分。
Thread *f_thread; Domain *domain;
thread_loop_f(f_thread, domain)/* loops over all face threads in a domain*/ { }
6.2.3 查询单元线中的单元
当你想要查询给定单元线c_thread上所有的单元时,你可以应用begin_c_loop和end_c_loop。它包含begin 和 end loop的说明,完成对单元线中单元所做的操作,定义包含在{ }中。当你想查找控制区单元线的单元时,应用的loop全嵌套在thread_loop_c中。 cell_t c;
Thread *c_thread;
begin_c_loop(c, c_thread) /* loops over cells in a cell thread */ { } end_c_loop(c, c_thread)
例子:
/* Loop over cells in a thread to get information stored in cells. */ begin_c_loop(c, c_thread) {
/* C_T gets cell temperature. The += will cause all of the cell temperatures to be added together. */
temp += C_T(c, c_thread); }
end_c_loop(c, c_thread) }
6.2.4查询面线中的面
当你想要查找给定面线f_thread的所有的面时,你可以用begin_f_loop and end_f_loop。它包含begin 和 end loop的说明,完成对面线中面单元所做的操作,定义包含在{ }中。当你想查找控制区面线的所有面时,应用的loop全嵌套在thread_loop_f中。 face_t f;
Thread *f_thread;
begin_f_loop(f, f_thread) /* loops over faces in a face thread */ { } end_f_loop(f, f_thread)
例子:
/* Loop over faces in a face thread to get the information stored on faces. */ begin_f_loop(f, f_thread) {
/* F_T gets face temperature. The += will cause all of the face temperatures to be added together. */
temp += F_T(f, f_thread); }
end_f_loop(f, f_thread)
6.2.5 查询单元中的面
下面函数用以查询给定单元中所有面。包含单独的查询说明,后面是所做的操作包含在{}。 face_t f; Thread *tf; int n;
c_face_loop(c, t, n) /* loops over all faces on a cell */ { . . .
f = C_FACE(c,t,n);
tf = C_FACE_THREAD(c,t,n); . . . }
这里,n是当地面的索引号。当地面的索引号用在C_FACE宏中以获得所有面的数量(e.g., f = C_FACE(c,t,n))。
另一个在c_face_loop中有用的宏是C_FACE_THREAD。这个宏用于合并两个面线。
(e.g., tf = C_FACE_THREAD(c,t,n)). 查找与 c_face_loop有关的宏参考 6.10部分。
6.2.6查询单元节点( c_node_loop)
下面函数用以查询给定单元中所有节点。包含单独的查询说明,后面是所做的操作包含在{}。 cell_t c;
Thread *t; int n;
c_node_loop(c, t, n) { . . .
node = C_NODE(c,t,n); . . . }
这里,n是当地节点的索引号。当地面的索引号用在C_NODE宏中以获得所有面的数量((e.g., node = C_NODE(c,t,n)
6.3多相组分查询宏
下面这些宏用于多相模型的UDFs。关于FLUENT里的结构的层次的讨论参考3.11部分尤其是图3.11.1。
? ? ? ? ? ? ?
6.3.1 Looping over Phase Domains in a Mixture ( sub_domain_loop) 查询混合物中的相控制区
6.3.2 Looping over Phase Threads in a Mixture ( sub_thread_loop) 查询混合物中的相线
6.3.3 Looping over Phase Cell Threads in a Mixture ( mp_thread_loop_c) 查询混合物中的相单元线
6.3.4 Looping over Phase Face Threads in a Mixture ( mp_thread_loop_f)