找回密码
 注册
查看: 2021|回复: 2

UDF里面有返回值的define宏能用循环宏吗?返回值应该在循环里面还是外面

[复制链接]
发表于 2014-11-12 14:46:51 | 显示全部楼层 |阅读模式

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

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

x
请教各位大神,我的问题是氯化锂溶液除去湿空气中的水蒸气,两相流用VOF模型,主相是湿空气,次相是溶液,湿空气和氯化锂溶液分别用组分输运模型,湿空气的组分有水蒸气和空气,溶液的组分是LiCl和液态水,我想定义氯化锂溶液的密度,这个密度是跟溶液的温度和质量分数有关系的,关系式有点复杂,程序如下。程序编译没问题,但是有说rho_licl definition shadows previous definitions,好像意思是会覆盖,所以我不明白返回值应该放在哪里。还有另外一个问题是初始化时却提示fatal error,不能初始化。求各位大神指点
#include "udf.h"
DEFINE_PROPERTY(cell_density,cell,thread)
{
    int phase_domain_index;
    cell_t cell;
    Thread *cell_thread;
    Domain *subdomain;
    Domain *mixture_domain;
    real rho_licl;
    sub_domain_loop(subdomain, mixture_domain, phase_domain_index)  /* loop over all subdomains (phases) in the superdomain (mixture) */
       {
          if (DOMAIN_ID(subdomain) == 2) /* loop if secondary phase */
              thread_loop_c (cell_thread,subdomain) /* loop over all cell threads in the secondary phase domain */
                 {
                     begin_c_loop_all (cell,cell_thread) /* loop over all cells in secondary phase cell threads */
                       {
                          real T=C_T(cell,cell_thread); /*得到次相温度*/
                          real MF=C_YI(cell,cell_thread,0);  /* 得到次相中LiCl的质量分数,在material里在LiCl是在第一个位置,所以是0*/
                          rho_licl=(322*(1+1.9937*pow((1-(T+273.15)/647.3),0.3333)
                                   +1.0985*pow((1-(T+273.15)/647.3),0.6667)
                                   -0.5094*pow((1-(T+273.15)/647.3),1.6667)
                                   -1.7619*pow((1-(T+273.15)/647.3),5.3333)
                                   -44.9005*pow((1-(T+273.15)/647.3),14.3333)
                                   -723692.2618*pow((1-(T+273.15)/647.3),36.6667)))
                                   *(1+0.5409*(MF/(1-MF))-0.303792*pow((MF/(1-MF)),2)
                                   +0.1007*pow((MF/(1-MF)),3));  /*密度和温度质量分数的关系式*/
                          return rho_licl;
                       }
                    end_c_loop_all (cell,cell_thread)
                 }
      }
}
发表于 2014-11-12 15:29:30 | 显示全部楼层
帮顶,复合运动的质心轴如何定义

点评

谢谢你啊,我已经解决啦,其实这个宏不需要用循环的 #include "udf.h" DEFINE_PROPERTY(cell_density,cell,thread) { real rho_licl; real T=C_T(cell,thread); /*得到次相温度*/ real MF=C_YI(cell,  详情 回复 发表于 2014-11-13 14:51
 楼主| 发表于 2014-11-13 14:51:22 | 显示全部楼层
wangyg517 发表于 2014-11-12 15:29
帮顶,复合运动的质心轴如何定义

谢谢你啊,我已经解决啦,其实这个宏不需要用循环的
#include "udf.h"
DEFINE_PROPERTY(cell_density,cell,thread)
{
   real rho_licl;
   real T=C_T(cell,thread); /*得到次相温度*/
   real MF=C_YI(cell,thread,0);  /* 得到次相中LiCl的质量分数,在material里在LiCl是在第一个位置,所以是0*/
   rho_licl=(322*(1+1.993771843*pow((1-(T+273.15)/647.3),0.3333333333333333333333333)
           +1.0985211604*pow((1-(T+273.15)/647.3),0.6666666666666666666667)
           -0.5094492996*pow((1-(T+273.15)/647.3),1.6666666666666666666667)
           -1.761912427*pow((1-(T+273.15)/647.3),5.333333333333333333)
           -44.9005480267*pow((1-(T+273.15)/647.3),14.333333333333333)
           -723692.2618632*pow((1-(T+273.15)/647.3),36.66666666666666667)))
           *(1+0.540966*(MF/(1-MF))-0.303792*pow((MF/(1-MF)),2)
           +0.100791*pow((MF/(1-MF)),3));  /*密度和温度质量分数的关系式*/
   return rho_licl;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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