24小时热门版块排行榜    

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

柚一

新虫 (初入文坛)

[求助] 利用udf做边界条件时,导入了c文件,自动生成了h文件,但是h文件报错怎么办?已有1人参与

h 文件是自动生成的,怎么修改呢?
h文件内容如下:
/*
*        Copyright 1997 Fluent Inc.
*        All Rights Reserved
*
*        This is unpublished proprietary source code of Fluent Inc.
*        It is protected by U.S. copyright law as an unpublished work
*        and is furnished pursuant to a written license agreement.  It
*        is considered by Fluent Inc. to be confidential and may not be
*        used, copied, or disclosed to others except in accordance with
*        the terms and conditions of the license agreement.
*/

#define UDF_COMPILER 1

#define EOF (-1)
#define NULL (0)

#define const
#define register


typedef unsigned long size_t;



/* config.h */

#define RP_2D 0
#define RP_3D 1
#define RP_HOST 0
#define RP_NODE 0
#define RP_DOUBLE 1
#define RP_STORE_FACE_AVE 1
#define RP_STORE_CELL_AVE 1
#define RP_NETWORK 1

#define STRUCT_OFF(t,offset,type)((type*)((char *)(t)+offset))
#define STRUCT_REF(t,offset,type)(*STRUCT_OFF(t,offset,type))

#define DOMAIN_C(t)STRUCT_REF(t,0,Thread *)
#define DOMAIN_NOSOLVE_C(t)STRUCT_REF(t,8,Thread *)
#define DOMAIN_NOSOLVE_EXT_C(t)STRUCT_REF(t,16,Thread *)
#define DOMAIN_F(t)STRUCT_REF(t,24,Thread *)
#define DOMAIN_NOSOLVE_F(t)STRUCT_REF(t,32,Thread *)
#define DOMAIN_ID(t)STRUCT_REF(t,2064,int)
#define PHASE_DOMAIN_INDEX(t)STRUCT_REF(t,2068,int)
#define DOMAIN_N_DOMAINS(t)STRUCT_REF(t,2076,int)
#define DOMAIN_SUPER_DOMAIN(t)STRUCT_REF(t,2256,Domain *)
#define DOMAIN_SUB_DOMAIN(t,i)(STRUCT_OFF(t,2080,Domain *))

#define THREAD_STORAGE(t,nv)(STRUCT_OFF(t,72,void *)[nv])
#define THREAD_T0(t)STRUCT_REF(t,72760,Thread *)
#define THREAD_T1(t)STRUCT_REF(t,72768,Thread *)
#define THREAD_NEXT(t)STRUCT_REF(t,72856,Thread *)
#define THREAD_SHADOW(t)STRUCT_REF(t,72864,Thread *)
#define THREAD_ID(t)STRUCT_REF(t,73160,int)
#define THREAD_NAME(t)STRUCT_REF(t,72488,char *)
#define THREAD_N_ELEMENTS(t)STRUCT_REF(t,72748,int)
#define THREAD_FLAGS(t)STRUCT_REF(t,73164,int)
#define THREAD_SUB_THREAD(t,i)(STRUCT_OFF(t,72928,Thread *))
#define THREAD_SUB_THREADS(t)STRUCT_OFF(t,72928,Thread *)
#define THREAD_SUPER_THREAD(t)STRUCT_REF(t,72904,Thread *)
#define THREAD_DOMAIN(t)STRUCT_REF(t,73176,Domain *)
#define THREAD_HEAD(t)STRUCT_REF(t,0,Thread_Head *)
#define THREAD_MATERIAL(t)(STRUCT_REF(THREAD_HEAD(t),376640,Material *))

#define NODE_COORD(v)STRUCT_OFF(v,0,real)

#define P_INIT_DIAM(p)STRUCT_REF(p,432,real)
#define P_INIT_MASS(p)STRUCT_REF(p,448,real)
#define P_INIT_RHO(p)STRUCT_REF(p,440,real)
#define P_INIT_TEMP(p)STRUCT_REF(p,456,real)
#define P_INIT_LF(p)STRUCT_REF(p,472,real)
#define P_VFF(p)STRUCT_REF(p,5192,real)
#define P_DT(p)STRUCT_REF(p,56,real)
#define P_DIAM(p)STRUCT_REF(p,624,real)
#define P_T(p)STRUCT_REF(p,648,real)
#define P_VEL(p)STRUCT_OFF(p,600,real)
#define P_RHO(p)STRUCT_REF(p,632,real)
#define P_LF(p)STRUCT_REF(p,664,real)
#define P_MASS(p)STRUCT_REF(p,640,real)
#define P_TIME(p)STRUCT_REF(p,656,real)
#define P_DIAM0(p)STRUCT_REF(p,528,real)
#define P_VEL0(p)STRUCT_OFF(p,504,real)
#define P_T0(p)STRUCT_REF(p,552,real)
#define P_RHO0(p)STRUCT_REF(p,536,real)
#define P_LF0(p)STRUCT_REF(p,568,real)
#define P_MASS0(p)STRUCT_REF(p,544,real)
#define P_TIME0(p)STRUCT_REF(p,560,real)
#define P_CURRENT_LAW_INDEX(p)STRUCT_REF(p,276,int)
#define P_INJECTION(p)STRUCT_REF(p,368,Injection *)
#define P_EVAP_SPECIES_INDEX(p)STRUCT_REF(P_INJECTION(p),1032,int)
#define P_DEVOL_SPECIES_INDEX(p)STRUCT_REF(P_INJECTION(p),1036,int)
#define P_OXID_SPECIES_INDEX(p)STRUCT_REF(P_INJECTION(p),1040,int)
#define P_PROD_SPECIES_INDEX(p)STRUCT_REF(P_INJECTION(p),1044,int)
#define P_LAWS(p,in)STRUCT_OFF(P_INJECTION(p),116,int)[in]

#define MATERIAL_PROPERTY(m)STRUCT_OFF(m,64,Property)
#define PROPERTY_LENGTH 144
#define MATERIAL_PROPERTY_ELEMENT(m,i)((Property *)((char *)MATERIAL_PROPERTY(m)+PROPERTY_LENGTH*i))
#define MATERIAL_PROP(m,i)(STRUCT_REF(MATERIAL_PROPERTY_ELEMENT(m,i),4,float))

#define NW_CELL(n) STRUCT_REF(((char *)network+n*24),16,Network_cell *)
#define NWC_T(n,c) STRUCT_REF(((char *)NW_CELL(n)+c*376),200,real)
#define NWE_T(e) STRUCT_REF(((char *)nw_end + e*264),8,real)
c文件内容如下:
#include "udf.h"
DEFINE_PROFILE(unsteady_velocity,thread,position)
{
    face_t f;
    begin_f_loop(f,thread)
     {
        real t=RP_Get_Real("flow-time";
real T=10; /* T 是周期 */
real g=9.81; /* g 为重力加速度 */
real H1=4.5; /* H 为上游水位 */
real A=3.14; /* A 为入口断面面积 */
if (t<=T)
   {
   F_PROFILE(f,thread,position)=0.6*sqrt(2*g*H1)*t/T;
   }
   else  
  {
   F_PROFILE(f,thread,position)=1.78; /* 阀门全开时的入口速度 */
   }
      }
end_f_loop(f,thread)
}

#include "udf.h"
DEFINE_INIT(my_init_function, domain)
{
cell_t c;
Thread *t;
real xc[ND_ND]; /* loop over all cell threads in the domain */
thread_loop_c (t,domain)
  {/* loop over all cells */
   begin_c_loop_all (c,t)
   {
   C_CENTROID(xc,c,t);
   if (xc[1]>=2.5)
   C_P(c,t) =0.;
   else
   C_P(c,t) = 9810*(2.5-xc[1]);
   }
  end_c_loop_all (c,t)
  }
}
#include "udf.h"
DEFINE_PROFILE(outlet_z_pressure,thread,position)
{
    face_t f;
    real z[ND_ND];
    real y;
    real g=9.81; /* g 为重力加速度 */
    real p=1000; /* p 为液体密度 */
    begin_f_loop(f,thread)
     {
real t=RP_Get_Real("flow-time";
F_CENTROID(z,f,thread);
y=z[1];
if(t>=40)
  {
  if (y<=2.5)
   {
    F_PROFILE(f,thread,position)=g*p*(2.5-y);
    }
    else  
   {
    F_PROFILE(f,thread,position)=0;  
    }
  }
else
  {
   F_PROFILE(f,thread,position)=0;  

错误语句为:Error:udfconfig.h:line 22:parse error
请问各位大神怎么办呢
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

pl980

禁虫 (小有名气)

本帖内容被屏蔽

7楼2019-12-31 16:26:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 10 个回答

柚一

新虫 (初入文坛)

真的醉了 自己百度到的答案

发自小木虫Android客户端
2楼2017-05-12 07:39:14
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

柚一

新虫 (初入文坛)

不得不说这个论坛真的太菜……了 充币才能问问题百度都不干……

发自小木虫Android客户端
3楼2017-05-12 07:39:57
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

微流咨询

新虫 (正式写手)


【答案】应助回帖

头文件报错基本上都是环境变量的问题。
你这个udf建议用解释加载。





fluent仿真咨询
4楼2017-05-16 21:01:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见