找回密码
 注册
查看: 2393|回复: 1

UDF例子的几点疑问

[复制链接]
发表于 2011-8-24 09:59:54 | 显示全部楼层 |阅读模式

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

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

x
在UDF手册中看到以下这个例子,关于C-UDSI和C-UDM使用的,有几个不明白的地方,请教一下大家:

UDMs are often used to store diagnostic values derived from calculated values of a UDS. Below is an example that shows a technique for plotting the gradient of any flow variable. In this case, the volume fraction of a phase is loaded into a user scalar. If an iteration is made such that the UDS is not calculated, the gradients of the scalar will nevertheless be updated without altering the values of the user scalar. The gradient is then available to be copied into a User Memory variable for displaying.


# include "udf.h"
# define domain_ID 2 (1。这个计算域的ID在那查找?)

DEFINE_ADJUST(adjust_gradient, domain)
{
  Thread *t;
  cell_t c;
  face_t f;
  
  domain = Get_Domain(domain_ID);

  /* Fill UDS with the variable. */  
  thread_loop_c (t,domain)
    {
       begin_c_loop (c,t)
         {
           C_UDSI(c,t,0) = C_VOF(c,t);  (2..如果这个这个变量是自己定义标量方程求解出来的,就比如是电位φ,也能写成C_PHI(c,t)这种宏的形式吗?
         }
       end_c_loop (c,t)
    }
   
  thread_loop_f (t,domain)
    {
       if (THREAD_STORAGE(t,SV_UDS_I(0))!=NULL)
       begin_f_loop (f,t)
         {
           F_UDSI(f,t,0) = F_VOF(f,t);     (3.我看后面没有用到面的变量,难道这一步这个例子只为了示范一下吗?)         }
       end_f_loop (f,t)
    }
}
(4.如果我只为了引用这个变量,是不是写到这就可了,然后子在新的uds中,直接用C-UDSI-G(c,t,0)可以吗)DEFINE_ON_DEMAND(store_gradient)
{
  Domain *domain;
  cell_t c;
  Thread *t;

  domain=Get_Domain(1);
  
  /* Fill the UDM with magnitude of gradient. */
  thread_loop_c (t,domain)
    {
       begin_c_loop (c,t)
         {
           C_UDMI(c,t,0) = NV_MAG(C_UDSI_G(c,t,0));
         }
       end_c_loop (c,t)
    }
}

5.AJUST函数在fluent计算顺序中是最先计算的(除了初始化),他如果是调用UDS中的变量(现在还没计算),会不会出错啊?)初学udf ,可能问的问题有些匪夷所思,呵呵,还望诸高手包涵,不要“回去看书”,呵呵

[ 本帖最后由 onlyforyou 于 2011-8-26 09:13 编辑 ]
 楼主| 发表于 2011-8-30 10:07:09 | 显示全部楼层

回复 1# onlyforyou 的帖子

1。这个计算域的ID在那查找?)混合区域为1 ,某一相的可以在Phase面板中查找
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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