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

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