![](https://img-blog.csdnimg.cn/20190516145651919.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyMDIwNTYz,size_16,color_FFFFFF,t_70)
下面是一个怎样在 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)
} |