FLUENT UDF案例一

下面是一个怎样在 UDF 中应用方程的例子UDFs 的功能由主要的DEFINE 宏 the leading DEFINE macro 来定义此处
DEFINE_PROFILE 宏用来表示下面的代码旨在给求解器提供边界的分布信息profile information at boundaries 书中将在以后部
分讨论其它的DEFINE 宏

/************************************************/
/*udfexample.c*/
/*UDF for specifying a steady-state velocity profile boundary condition*/
/*****************************************************/
#include"udf.h"
DEFINE_PROFILE(inlet_x-velocity, thread, index)
{
	real x[ND_ND];/*this will hold the position vector*/
	real y;
	face_t f;
	begin_f_loop(f, thread)
	{
		F_CENTROID(x, f, thread);
		y=x[1];
		F_PROFILE(f, thread, index)=20.-y*y/(.0745*.0745)*20.;
	}
	end_f_loop(f,thread)
}

DEFINE_PROFILE 宏的第一个变量 inlet_x_velocity 用来定义Velocity Inlet 面板中的函数 名称可任意指定在给定的边界区
域上的所有单元面identified by f in the face loop 上将会使用函数的这个方程。

当用户在FLUENT 用户界面选定 UDF 作为边界条件时将会自动定义线thread 索引The index 由begin_f_loop工具 the begin_f_loop utility 自动定义UDF 中begin_f_loop被用来形成对边界面上所有单元面的循环 loop through all cell faces in the boundary zone

对于每个面面的质心the face centroid 的座标可由 F_CENTROID 宏来获得抛物线方程中用到了y 座标 y 速度值通过 F_PROFILE 宏来返回给面 begin_f_loop宏和 F_PROFILE 宏都是 FLUENT 提供的宏。

配套案例D:\CFD case\0516

参考链接:https://mp.weixin.qq.com/s/Q6qx_hOW3CFOzxj34KZ13A

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章