Fluent UDF 调试之 Define_On_Demand
- 原创
- |
- 浏览:4100
- |
- 更新:
用Fluent DUF编写时经常遇到不可预知的小错误,并且修改起来机器耗时,因此撰写次经验为自己,也为他人。
方法/步骤
首先找个比较小的例子调试。将下列文本保存成udf.c
/* This UDF is used to compute relative length scale in DES model*/
#include "udf.h"
#include "mem.h"
#include "math.h"
#include "stdio.h"
DEFINE_ON_DEMAND(rls)
{
/*#if !RP_HOST*/
Domain *domain=Get_Domain(1);
Thread *c_thread;
cell_t c;
face_t f;
Thread *tf;
Node *node;
int n,k,counter,i;
real delx,dely,delz,deltamax,maxx=0,maxy=0,maxz=0;
float x[8],y[8],z[8],temp;
thread_loop_c(c_thread,domain) /*loops over all cell threads in domain*/
{
begin_c_loop(c,c_thread) /* loops over cells in a cell thread */
{
temp=C_K(c,c_thread);//1.0-pow((pow(C_K(c,c_thread)/deltamax,2.0/3.0)/(0.23+pow(C_K(c,c_thread)/deltamax,2.0/3.0))),4.5);
C_UDMI(c,c_thread,0)=temp;
Message("%E10.5",temp);
}
end_c_loop(c,c_thread)
}
}
设置memory,全设置为1。define→define function→memory
compile,知道保存的udf文件。define→define function→compile
compile & load。define→define function→compile, 然后load
初始化initializtion。因为里面有C_K,所以要获取cell的湍动能
excute on demand。define→define function→excute on demand。
就可以看到fluent的tui区域输出信息
END- 相关内容未经授权抓取自百度经验