Fluent UDF 调试之 Define_On_Demand

2025-11-21 10:21:23

1、首先找个比较小的例子调试。将下列文本保存成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)

}

}

2、设置memory,全设置为1。define→define function→memory

3、compile,知道保存的udf文件。define→define function→compile

4、compile & load。define→define function→compile, 然后load

5、初始化initializtion。因为里面有C_K,所以要获取cell的湍动能

6、excute on demand。define→define function→excute on demand。

就可以看到fluent的tui区域输出信息

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢