找回密码
 注册
查看: 1455|回复: 0

想利用UDF控制入口流速,但入口流速要根据内热源的温度进行变化

[复制链接]
发表于 2020-10-16 15:21:45 | 显示全部楼层 |阅读模式
2金钱
想利用UDF控制入口流速,但入口流速要根据内热源的温度进行变化,加载UDF之后Fluent后出现闪退,不知道UDF哪里有问题
#include "udf.h"
/*调用两个宏进行计算,应用define_on_demand对参考点温度进行取值,应用define_profile对入口边界速度进行赋值*/

DEFINE_ON_DEMAND(tmax)
{
Domain *d; /* declare domain pointer since it is not passed as an
  argument to the DEFINE macro */
  /*声明域指针,*/
real tmax = 0.;/*最大温度*/
real temp;
Thread *t;
cell_t c;
d = Get_Domain(6);  /* Get the domain using ANSYS Fluent utility 获取Domain的ID  */
/* Loop over all cell threads in the domain  在所有的单元上做循环*/
thread_loop_c(t, d)
{
  /* Compute max, min, volume-averaged temperature */
  /* Loop over all cells */
  begin_c_loop(c, t)
  {
   temp = C_T(c, t);   /* get cell temperature */
   if (temp > tmax || tmax == 0.) tmax = temp;/* 判断语句,当temp>tamx或者tmax=0时,进行tmax=temp */

  }
  end_c_loop(c, t)
   C_UDMI(c, t, 0) = tmax;

}
}
DEFINE_PROFILE(vel_profile, t, i)
{
real x[ND_ND];    /* this will hold the position vector */
real vel;
cell_t c;
face_t f;
vel = 0.0;
begin_c_loop(f, t)
{
  C_CENTROID(x, c, t);
  vel = C_UDMI(c, t, 0) / 100;
  C_UDMI(c, t, 1) = vel;
  F_PROFILE(c, t, i) = C_UDMI(c, t, 1);
}
end_f_loop(c, t)
}

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表