CyRhmU.jpeg
查看: 2731  |  回复: 8
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

llongtan

木虫 (小有名气)

老木虫

[求助] UDF的编译通不过

我从UDF的英文帮助中复制粘贴下面的内容成c程序,通过fluent的udf导入编译,(Define->user-defined->functions->interpreted)弹出下面的错误

cpp -I"C:\Fluent.Inc\fluent6.3.26/src" -I"C:\Fluent.Inc\fluent6.3.26/cortex/src" -I"C:\Fluent.Inc\fluent6.3.26/client/src" -I"C:\Fluent.Inc\fluent6.3.26/multiport/src" -I. -DUDFCONFIG_H="" "E:\计算\冷凝-重试\condensation-2.c"
Error: E:\\274\306\313\343\\300\344\304\375-\326\330\312\324\condensation-2.c: line 9: structure reference not implemented

我看了fluent的“dpm.h”的头文件,在其中存在这个结构,请问大侠,这个是什么原因造成的,怎样才能解决这个问题。

c程序在附件中也有一份。

/***********************************************************************
UDF for defining the heat and mass transport for
multicomponent particle vaporization
***********************************************************************/
#include "udf.h"

DEFINE_DPM_HEAT_MASS(multivap,p,Cp,hgas,hvap,cvap_surf,dydt,dzdt){
        int ns;
        int nc=TP_N_COMPONENTS(p); /* number of particle components */
       
        //以离散相P确定P所在的单元及线,以及单元,从而找到该单元连续相的信息。
        cell_t c0=RP_CELL(&(p->cCell)); /* cell and thread */
        Thread *t0=RP_THREAD(&(p->cCell)); /* where the particle is in */
       
        //离散相和连续相的材料
        Material *gas_mix=THREAD_MATERIAL(t0); /* gas mixture material */
        Material *cond_mix=p->injection->material;/* particle mixture material */

        cphase_state_t *c=&(p->cphase); /* cell info of particle location */

        //连续相的分子量及平均分子量
        real molwt[MAX_SPE_EQNS]; /* molecular weight of gas species */
        real molwt_bulk=0.0; /* average molecular weight in bulk gas */

        //离散相的信息:温度、质量、粒径,表面积,普朗特数Pr,努赛尔德数Nu,表面对流系数,;
        real Tp=P_T(p); /* particle temperature */
        real mp=P_MASS(p); /* particle mass */
        real Dp=DPM_DIAM_FROM_VOL(mp/P_RHO(p)); /* particle diameter */
        real Ap=DPM_AREA(Dp); /* particle surface */
        real Pr=c->sHeat*c->mu/c->tCond; /* Prandtl number */
        real Nu=2.0+0.6*sqrt(p->Re)*pow(Pr,1.0/3.0); /* Nusselt number 可以从《传热传质基本原理》的P270的公式(7.56)*/
        real h=Nu*c->tCond/Dp; /* Heat transfer coefficient */
        real dh_dt=h*(c->temp-Tp)*Ap; /* heat source term */
        dydt[0]+=dh_dt/(mp*Cp);
        dzdt->energy-=dh_dt;
       
        //求1/平均分子量的值,在解释中为平均分子量,实际计算为其倒数,因此在引用时要注意
        {
                Material *sp;
                mixture_species_loop(gas_mix,sp,ns){
                        molwt[ns]=MATERIAL_PROP(sp,PROP_mwi); /* molecular weight of gas species */
                        molwt_bulk+=C_YI(c0,t0,ns)/molwt[ns]; /* average molecular weight */
                }
        }
        /* prevent division by zero */
        molwt_bulk=MAX(molwt_bulk,DPM_SMALL);

        for(ns=0;ns                 /* gas species index of vaporization */
                int gas_index=TP_COMPONENT_INDEX_I(p,ns);
                if(gas_index>=0){
                        /* condensed material */
                        Material *cond_c=MIXTURE_COMPONENT(cond_mix,ns);
                        /* vaporization temperature */
                        real vap_temp=MATERIAL_PROP(cond_c,PROP_vap_temp);
                        /* diffusion coefficient */
                        real D=MATERIAL_PROP_POLYNOMIAL(cond_c,PROP_binary_diffusivity,c->temp);
                        /* Schmidt number */
                        real Sc=c->mu/(c->rho*D);
                        /* mass transfer coefficient */
                        real k=(2.0+0.6*sqrt(p->Re)*pow(Sc,1.0/3.0))*D/Dp;
                        /* bulk gas concentration */
                        real cvap_bulk=c->pressure/UNIVERSAL_GAS_CONSTANT/c->temp*c->yi[gas_index]/molwt_bulk/solver_par.molWeight[gas_index];
                        /* vaporization rate */
                        real vap_rate=k*molwt[gas_index]*Ap*(cvap_surf[ns]-cvap_bulk);
                        /* only condensation below vaporization temperature */
                        if(0.0                                 vap_rate=0.0;
                        dydt[1+ns]-=vap_rate;
                        dzdt->species[gas_index]+=vap_rate;
                        /* dT/dt = dh/dt / (m Cp)*/
                        dydt[0]-=hvap[gas_index]*vap_rate/(mp*Cp);
                        /* gas enthalpy source term */
                        dzdt->energy+=hgas[gas_index]*vap_rate;
                }
        }
}
1.jpg[ Last edited by llongtan on 2012-11-19 at 15:13 ]
回复此楼

» 本帖附件资源列表

  • 欢迎监督和反馈:小木虫仅提供交流平台,不对该内容负责。
    本内容由用户自主发布,如果其内容涉及到知识产权问题,其责任在于用户本人,如对版权有异议,请联系邮箱:xiaomuchong@tal.com
  • 附件 1 : condensation-2.c
  • 2012-11-19 15:09:25, 3.11 K
  • 附件 2 : 1.cas
  • 2012-11-19 15:13:59, 892.03 K
  • 附件 3 : 1.dat
  • 2012-11-19 15:14:03, 2.54 M

» 收录本帖的淘帖专辑推荐

fluent模拟及问题

» 猜你喜欢

» 本主题相关商家推荐: (我也要在这里推广)

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

llongtan

木虫 (小有名气)

老木虫

引用回帖:
2楼: Originally posted by zjspring at 2012-11-19 19:13:37
cell_t c=RP_CELL(&(p->cCell));
   Thread *t=RP_THREAD(&(p->cCell));
改为
cell_t c=RP_CELL(&p->cCell);
   Thread *t=RP_THREAD(&p->cCell);
p里本身就是存储一个指针,

我将红字删除后,你写的这两句也说是:
structure reference not implemented

按照你的方法修改后错误没有消失。

我觉得应该是没有引入DEFINE_DPM_HEAT_MASS中“P”的结构进入UDF中,才导致的编译不通过。
4楼2012-11-19 20:22:31
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 9 个回答

zjspring

木虫 (著名写手)

【答案】应助回帖

★ ★ ★ ★
感谢参与,应助指数 +1
llongtan: 金币+2 2012-11-19 20:22:43
xiegangmai: 金币+2, 谢谢参与 2012-11-20 21:49:40
cell_t c=RP_CELL(&(p->cCell));
   Thread *t=RP_THREAD(&(p->cCell));
改为
cell_t c=RP_CELL(&p->cCell);
   Thread *t=RP_THREAD(&p->cCell);
p里本身就是存储一个指针,再将这个指针付给cCell
2楼2012-11-19 19:13:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

llongtan

木虫 (小有名气)

老木虫

引用回帖:
2楼: Originally posted by zjspring at 2012-11-19 19:13:37
cell_t c=RP_CELL(&(p->cCell));
   Thread *t=RP_THREAD(&(p->cCell));
改为
cell_t c=RP_CELL(&p->cCell);
   Thread *t=RP_THREAD(&p->cCell);
p里本身就是存储一个指针,

可能上面的也是一个错误。

但是我从fluent中找的是对这一句错误?
int nc=TP_N_COMPONENTS(p); /* number of particle components */
3楼2012-11-19 20:16:55
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

achilFes1990

木虫 (著名写手)

【答案】应助回帖

★ ★
感谢参与,应助指数 +1
xiegangmai: 金币+2, 谢谢参与 2012-11-20 21:49:49
楼主,udf编译还要注意两点:
1、udf所在文件位置不要有中文路径;
2、udf文件与fluent的case和data文件放在一起。
扫一扫关注我的微信公众号,共同学习船舶CFD
5楼2012-11-20 09:08:07
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见