FLUENT中udf的程序编译为什么总是出现parse error?
如题,我的代码如下,请高手指教。谢谢!我想输入一个二维边界条件x=0.001[0.9cos(0.3t)+0.006sin(0.3t)]y=0.001[0.8cos(0.3...
如题,我的代码如下,请高手指教。谢谢!我想输入一个二维边界条件
x=0.001[0.9cos(0.3t)+0.006sin(0.3t)]
y=0.001[0.8cos(0.3t)+0.003sin(0.3t)]
#include "udf.h"
/* profile for x-velocity */
DEFINE_PROFILE(inlet_x_velocity, thread, nv)
{
face_t f;
begin_f_loop(f, thread)
{
real t=RP_Get_Real("flow-time");
F_PROFILE(f, thread, nv)=.001*(.9*cos(.3*t)+.006sin(.3*t));
}
end_f_loop(f, thread)
}
/* profile for y-velocity */
DEFINE_PROFILE(inlet_y_velocity, thread, nv)
{
face_t f;
begin_f_loop(f, thread)
{
real t=RP_Get_Real("flow-time");
F_PROFILE(f, thread, nv)=.001*(.8*cos(.3*t)+.003sin(.3*t));
}
end_f_loop(f, thread)
}
编译时提示F_PROFILE(f, thread, nv)=.001*(.9*cos(.3*t)+.006sin(.3*t));这行parse error。我是第一编这个,请各位指教。 展开
x=0.001[0.9cos(0.3t)+0.006sin(0.3t)]
y=0.001[0.8cos(0.3t)+0.003sin(0.3t)]
#include "udf.h"
/* profile for x-velocity */
DEFINE_PROFILE(inlet_x_velocity, thread, nv)
{
face_t f;
begin_f_loop(f, thread)
{
real t=RP_Get_Real("flow-time");
F_PROFILE(f, thread, nv)=.001*(.9*cos(.3*t)+.006sin(.3*t));
}
end_f_loop(f, thread)
}
/* profile for y-velocity */
DEFINE_PROFILE(inlet_y_velocity, thread, nv)
{
face_t f;
begin_f_loop(f, thread)
{
real t=RP_Get_Real("flow-time");
F_PROFILE(f, thread, nv)=.001*(.8*cos(.3*t)+.003sin(.3*t));
}
end_f_loop(f, thread)
}
编译时提示F_PROFILE(f, thread, nv)=.001*(.9*cos(.3*t)+.006sin(.3*t));这行parse error。我是第一编这个,请各位指教。 展开
2个回答
展开全部
高手帮我也看一下,我抄的教程上的程序,编译也出现语法错误,求指教!
#include "udf.h"
static real viscosity_0;
DEFINE_INIT(melt_setup, domain)
{
/* if memory for the particle variable titles has not been
* allocated yet, do it now */
if (NULLP(user_particle_vars)) Init_User_Particle_Vars();
/* now set the name and label */
strcpy(user_particle_vars[0].name,"melting-index");
strcpy(user_particle_vars[0].label,"Melting Index");
}
/* update the user scalar variables */
DEFINE_DPM_SCALAR_UPDATE(melting_index, cell, thread, initialize, p)
{
cphase_state_t *c = &(p->cphase);
if (initialize)
{
/* this is the initialization call, set:
* p->user[0] contains the melting index, initialize to 0
* viscosity_0 contains the viscosity at the start of a time step*/
p->user[0] = 0.;
viscosity_0 = c->mu;
}
else
{
/* use a trapezoidal rule to integrate the melting index */
p->user[0] += P_DT(p) * .5 * (1/viscosity_0 + 1/c->mu);
/* save current fluid viscosity for start of next step */
viscosity_0 = c->mu;
}
}
/* write melting index when sorting particles at surfaces */
DEFINE_DPM_OUTPUT(melting_output, header, fp, p, thread, plane)
{
char name[100];
if (header)
{
if (NNULLP(thread))
cxprintf(fp,"(%s %d)\n",thread->head->dpm_summary.sort_file_name,11);
else
cxprintf(fp,"(%s %d)\n",plane->sort_file_name,11);
cxprintf(fp,"(%10s %10s %10s %10s %10s %10s %10s"
" %10s %10s %10s %10s %s)\n",
"X","Y","Z","U","V","W","diameter","T","mass-flow",
"time","melt-index","name");
}
else
{
sprintf(name,"%s:%d",p->injection->name,p->part_id);
cxprintf(fp,
"((%10.6g %10.6g %10.6g %10.6g %10.6g %10.6g "
"%10.6g %10.6g %10.6g %10.6g %10.6g) %s)\n",
p->state.pos[0], p->state.pos[1], p->state.pos[2],
p->state.V[0], p->state.V[1], p->state.V[2],
p->state.diam, p->state.temp, p->flow_rate, p->state.time,
p->user[0], name);
}
}
#include "udf.h"
static real viscosity_0;
DEFINE_INIT(melt_setup, domain)
{
/* if memory for the particle variable titles has not been
* allocated yet, do it now */
if (NULLP(user_particle_vars)) Init_User_Particle_Vars();
/* now set the name and label */
strcpy(user_particle_vars[0].name,"melting-index");
strcpy(user_particle_vars[0].label,"Melting Index");
}
/* update the user scalar variables */
DEFINE_DPM_SCALAR_UPDATE(melting_index, cell, thread, initialize, p)
{
cphase_state_t *c = &(p->cphase);
if (initialize)
{
/* this is the initialization call, set:
* p->user[0] contains the melting index, initialize to 0
* viscosity_0 contains the viscosity at the start of a time step*/
p->user[0] = 0.;
viscosity_0 = c->mu;
}
else
{
/* use a trapezoidal rule to integrate the melting index */
p->user[0] += P_DT(p) * .5 * (1/viscosity_0 + 1/c->mu);
/* save current fluid viscosity for start of next step */
viscosity_0 = c->mu;
}
}
/* write melting index when sorting particles at surfaces */
DEFINE_DPM_OUTPUT(melting_output, header, fp, p, thread, plane)
{
char name[100];
if (header)
{
if (NNULLP(thread))
cxprintf(fp,"(%s %d)\n",thread->head->dpm_summary.sort_file_name,11);
else
cxprintf(fp,"(%s %d)\n",plane->sort_file_name,11);
cxprintf(fp,"(%10s %10s %10s %10s %10s %10s %10s"
" %10s %10s %10s %10s %s)\n",
"X","Y","Z","U","V","W","diameter","T","mass-flow",
"time","melt-index","name");
}
else
{
sprintf(name,"%s:%d",p->injection->name,p->part_id);
cxprintf(fp,
"((%10.6g %10.6g %10.6g %10.6g %10.6g %10.6g "
"%10.6g %10.6g %10.6g %10.6g %10.6g) %s)\n",
p->state.pos[0], p->state.pos[1], p->state.pos[2],
p->state.V[0], p->state.V[1], p->state.V[2],
p->state.diam, p->state.temp, p->flow_rate, p->state.time,
p->user[0], name);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询