找回密码
 注册
查看: 3064|回复: 3

udf求助

[复制链接]
发表于 2009-7-19 11:46:55 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
最近想在fluent加载一个边界条件,在一水平面上du/dy=-dt/dx.dt/dy=0,这里t是温度,流动定常。我自己写了个UDF,但是初始化时出错了。请大家帮我看看错哪了。谢谢!
/******************************************************************************
                         myudf.c                                                         
UDF for specifying v gradient of velocity u and temperature at the free surface  
******************************************************************************/
#include "udf.h"
real xigema = -1;               /* the coefficient after dimensioned */

DEFINE_PROFILE(inlet_x_velocity,thread,position)
{
   cell_t c;
   begin_c_loop(c, thread)
    {
     C_T_RG(c,thread)[1]=0.0;
     C_UDMI(c,thread,0)=C_T_G(c,thread)[0];
     C_U_RG(c,thread)[1]=xigema*C_UDMI(c,thread,0);
    }
  end_c_loop(c, thread)
  
}
 楼主| 发表于 2009-7-19 15:35:51 | 显示全部楼层

大家帮帮忙哦!

大家帮帮忙哦!
发表于 2009-7-19 16:05:52 | 显示全部楼层
老问题了,为了节约内存,fluent会将和正在求解的方程无关的梯度存储单元删除,所以获取变量梯度的宏只有在方程求解过程中才能使用。不过,你可以使用solve/set/expert命令并输入yes来告诉fluent保留梯度,这样虽然耗些内存,但可以在非方程求解过程中获取梯度的值, 以下摘自udf帮助。
Note that gradient variables are
available only when the equation for that variable is being solved. For example, if you
are defining a source term for energy, your UDF can access the cell temperature gradient
(using C_T_G), but it cannot get access to the x-velocity gradient (using C_U_G). The
reason for this is that the solver continually removes data from memory that it doesn't
need. In order to retain the gradient data (when you want to set up user-defined scalar
transport equations, for example), you can prevent the solver from freeing up memory by
issuing the text command solve/set/expert and then answering yes to the question
Keep temporary solver memory from being freed?. Note that when you do this, all
of the gradient data is retained, but the calculation requires more memory to run.
 楼主| 发表于 2009-7-21 10:04:10 | 显示全部楼层
谢谢!我再看看!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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