Fluent UDF造波源程序集
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
法一:边界造波法
程序一:inlet.c
#include "udf.h" /* #include
#include
#include
#define HH 0.5 /*waver hight*/ /*不同波形需要修改的波形参数*/
#define LL 0.95 /*波长*/
#define g 9.81
#define pi 3.1415925
#define d 0.5 /*water deepth */
DEFINE_PROFILE(x_velocity,thread,index)
{
real kk = 2.0*pi/LL;
real c = sqrt(g*tanh(kk*d)/kk); /*参见一般性公式的推导*/
real TT = LL/c;
real x[ND_ND]; /* this will hold the position vector */
real y = 0;
real s = 0;
real ct = 0; /*相位角*/
face_t f;
real t = CURRENT_TIME;
real u = 0;
t=RP_Get_Real("flow-time");
begin_f_loop(f,thread) /* loops over all faces in the thread passed
in the DEFINE macro argument */ {
F_CENTROID(x,f,thread);
y = x[1];
s = y+d;
ct = kk*(x[0]-c*t); /*参见一般性公式的推导*/
if(y < 0.5*HH*sin(ct)) /*水面以下,其中,0.5*HH*sin(ct)为波面方程*/ u = pi*HH*cosh(kk*s)*sin(ct)/(TT*sinh(kk*d)); /*x方向速度分量公
式,参见一般性公式的推导*/ else u = 0.0; /*水面以上流体单位速度矢量的x方向分量*/
F_PROFILE(f,thread,index) = u;
}
end_f_loop(f,thread)
}
DEFINE_PROFILE(y_velocity,thread,index)
{
real kk = 2.0*pi/LL;
real c = sqrt(g*tanh(kk*d)/kk);
real TT = LL/c;
real x[ND_ND]; /* this will hold the position vector */
real y = 0;
real s = 0;
real ct = 0;
face_t f;
real t = CURRENT_TIME;
real v = 0;
t=RP_Get_Real("flow-time");
begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
y = x[1];
s = y+d;
ct = kk*(x[0]-c*t);
if(y < 0.5*HH*sin(ct))
v = pi*HH*sinh(kk*s)*cos(ct)/(TT*sinh(kk*d));
else v = 0.0;
F_PROFILE(f,thread,index) = v;
}
end_f_loop(f,thread)
}
DEFINE_PROFILE(voffactor,thread,index)
{
real kk = 2.0*pi/LL;
real c = sqrt(g*tanh(kk*d)/kk);
real TT = LL/c;
real x[ND_ND]; /* this will hold the position vector */ real y = 0;
real s = 0;
real ct = 0;
face_t f;
real t = CURRENT_TIME;
t=RP_Get_Real("flow-time");
begin_f_loop(f,thread)
{
F_CENTROID(x,f,thread);
y = x[1];
s = y+d;
ct = kk*(x[0]-c*t);
if(y < 0.5*HH*sin(ct))
F_PROFILE(f,thread,index) = 1.0;
else
F_PROFILE(f,thread,index) = 0.0;
}
end_f_loop(f,thread)
程序二:wave.c (此程序同程序一大致相同)
#include "udf.h" /* must be at the beginning of every UDF you write new9 case */ real AA=0.5; /*waver amplitude*/
real LL=0.95; /*不同波形需要修改的波形参数*/
real TT=0.78;
real pi=3.1415926
real kk=2.0*pi/TT;
real ww=2.0*pi/LL;
real h=0.5; /*water deepth */
real ux=1.0; /*此为何变量?*/
DEFINE_PROFILE(x_velocity,thread,index)
{
real x[ND_ND]; /* this will hold the position vector */
real y;
face_t f;
real t = CURRENT_TIME;
real u;
begin_f_loop(f,thread) /* loops over all faces in the thread passed
in the DEFINE macro argument */ {
F_CENTROID(x,f,thread);
y = x[1];
if(y<(AA*cos(kk*x[0]-ww*t))) /*(-a*sin(w*t)+2.0为入口的波面随时间的变化*/
/*u=a*w*(exp(k*(y+h))+exp(-k*(y+h)))*-sin(w*t)/(exp(k*h)-exp(-k*h))*/
u=9.8*AA*kk/ww*cosh(kk*(y+h))*cos(kk*x[0]-ww*t)/cosh(kk*h);
else u =0.0; /*水面以上流体单位速度矢量的x方向分量*/
F_PROFILE(f,thread,index)=u;
}
end_f_loop(f,thread)
}
DEFINE_PROFILE(y_velocity,thread,index)
{
real x[ND_ND]; /* this will hold the position vector */
real y;
face_t f;
real t = CURRENT_TIME;
real v;
t=RP_Get_Real("flow-time");
begin_f_loop(f,thread) /* loops over all faces in the thread passed
in the DEFINE macro argument */ {
F_CENTROID(x,f,thread);
y = x[1];