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

各位大神看看我的udf程序有什么问题?

[复制链接]
发表于 2013-9-4 10:43:01 | 显示全部楼层 |阅读模式

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

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

x
各位大神看看我的udf程序有什么问题?
为什么后缀是.cpp时,就不能复制。
如果后缀是.c时,就可以复制。
弄了很久了,麻烦大家




我现在主要有两个问题。第一个是,我用c++编程的,保存程序是后缀是 zaobo.cpp,我用udf时,编译时提示是这样的:


Deleted old libudf\ntx86\2d\libudf.dll
系统找不到指定的文件。
已复制         1 个文件。
(system "copy C:\Fluent.Inc\fluent6.2.16\src\makefile_nt.udf libudf\ntx86\2d\makefile")已复制         1 个文件。
0
(chdir "libudf")()
(chdir "ntx86\2d")()


Done.



如果我把后缀改成  zaobo.c 时,编译提示是这样的:
Deleted old libudf\ntx86\2d\libudf.dll
已复制         1 个文件。
已复制         1 个文件。
(system "copy C:\Fluent.Inc\fluent6.2.16\src\makefile_nt.udf libudf\ntx86\2d\makefile")已复制         1 个文件。
0
(chdir "libudf")()
(chdir "ntx86\2d")()
zaobo.c
..\..\src\zaobo.c(8) : error C2085: 'zbqx_source' : not in formal parameter list
..\..\src\zaobo.c(8) : error C2143: syntax error : missing ';' before '{'
..\..\src\zaobo.c(23) : error C2065: 't' : undeclared identifier
..\..\src\zaobo.c(23) : error C2223: left of '->storage' must point to struct/union
..\..\src\zaobo.c(23) : error C2065: 'c' : undeclared identifier
..\..\src\zaobo.c(23) : error C2223: left of '->storage' must point to struct/union
..\..\src\zaobo.c(33) : error C2065: 'source' : undeclared identifier
..\..\src\zaobo.c(38) : error C2143: syntax error : missing ')' before ';'
..\..\src\zaobo.c(39) : error C2065: 'eqn' : undeclared identifier
..\..\src\zaobo.c(39) : error C2106: '=' : left operand must be l-value
..\..\src\zaobo.c(42) : error C2065: 'source' : undeclared identifier
..\..\src\zaobo.c(49) : error C2061: syntax error : identifier 'zbqy_source'
..\..\src\zaobo.c(49) : error C2059: syntax error : ';'
..\..\src\zaobo.c(49) : error C2059: syntax error : 'type'
..\..\src\zaobo.c(118) : error C2065: 'source' : undeclared identifier
..\..\src\zaobo.c(118) : error C2064: term does not evaluate to a function
..\..\src\zaobo.c(118) : error C2107: illegal index, indirection not allowed
..\..\src\zaobo.c(118) : error C2113: pointer can only be subtracted from another pointer
..\..\src\zaobo.c(121) : error C2064: term does not evaluate to a function
..\..\src\zaobo.c(125) : error C2064: term does not evaluate to a function
..\..\src\zaobo.c(126) : error C2064: term does not evaluate to a function
..\..\src\zaobo.c(129) : error C2143: syntax error : missing ')' before ';'
..\..\src\zaobo.c(130) : error C2063: 'ds' : not a function
..\..\src\zaobo.c(133) : error C2065: 'source' : undeclared identifier
..\..\src\zaobo.c(140) : error C2061: syntax error : identifier 'qxbqy_source'
..\..\src\zaobo.c(140) : error C2059: syntax error : ';'
..\..\src\zaobo.c(140) : error C2059: syntax error : 'type'
..\..\src\zaobo.c(214) : error C2065: 'source' : undeclared identifier
..\..\src\zaobo.c(215) : error C2064: term does not evaluate to a function
..\..\src\zaobo.c(215) : error C2018: unknown character '0xa3'
..\..\src\zaobo.c(215) : error C2018: unknown character '0xbb'
..\..\src\zaobo.c(216) : error C2146: syntax error : missing ')' before identifier 'ds'
..\..\src\zaobo.c(219) : error C2065: 'source' : undeclared identifier
..\..\src\zaobo.c(225) : error C2061: syntax error : identifier 'wxbqy_source'
..\..\src\zaobo.c(225) : error C2059: syntax error : ';'
..\..\src\zaobo.c(225) : error C2059: syntax error : 'type'
..\..\src\zaobo.c(253) : error C2018: unknown character '0xa3'
..\..\src\zaobo.c(253) : error C2018: unknown character '0xbb'


程序如下::

include"udf.h"
#include<stdio.h>
#include<math.h>
int main(void)
/*造波区x方向*/

DEFINE_SOURCE(zbqx_source,c,t,ds,eqn)
{
#define H 0.1
#define h 0.7
#define k 00
#define w 3.1415
#define g 9.81
#define pi 3.1415
#define rol 1

real dt;
real deltat;
real c1;
real x[ND_ND];
real y;

C_CENTROID(x,c,t)
y=x[1];
dt=RP_Get_Real("flow-time");
deltat=RP_Get_Real("physical-time-step");

if(x[0]>=0&&x[0]<=5)
{
        if(y>=-0.7&&y<=0)
{
                c1=sin((x[0]*pi)/10);
        source=(1-c1)*((-rol*g*y)+rol*g*H*k*cosh(k*(y+h))*sin(k*x[0]-w*dt)/(2*cosh(k*h)))
                   -rol*H*w*cosh(k*y+k*h)*cos(k*x[0]-w*dt)/(2*sinh(k*h)*deltat)
           +rol*(1-c1*c1)*((H*w*cosh(k*y+k*h)*cos(k*x[0]-w*dt)/(2*sinh(k*h)))
           *(-H*w*cosh(k*y+k*h)*sin(k*x[0]-w*dt)*k/(2*sinh(k*h))
                   +((H*w*sinh(k*y+k*h)*sin(k*x[0]-w*dt)/(2*sinh(k*h))
                   *(H*w*sinh(k*y+k*h)*cos(k*x[0]-w*dt)*k/(2*sinh(k*h))));
        ds(eqn)=0;
}
}
return source;
}
                  
/******************************************************************************************/
/*造波区y方向*/


DEFINE_SOURCE(zbqy_source,c,t,ds,eqn)
{
#define H 0.1
#define h 0.7
#define k 00
#define w 3.1415
#define g 9.81
#define pi 3.1415
#define rol 1

real dt;
real deltat;
real c1;
real x[ND_ND];
real y;

C_CENTROID(x,c,t)
y=x[1];
dt=RP_Get_Real("flow-time");
deltat=RP_Get_Real("physical-time-step");

if(x[0]>=0&&x[0]<=5)
{
        if(y>=-0.7&&y<=0)
{
                c1=sin((x[0]*pi)/10);
    source=(1-c1)*(((-rol*g)-rol*g*H*sinh(k*y+k*h)*cos(k*x[0]-w*dt)*k/(2*cosh(k*h)))
                  -(rol*H*w*sinh(k*y+k*h)*sin(k*x-w*dt)/(2*sinh(k*h)*deltat)))
                  +rol*(1-c1*c1)*((H*w*cosh(k*y+k*h)*cos(k*x[0]-w*dt)/(2*sinh(k*h)))
                  *(H*w*sinh(k*y+k*h)*cos(k*x[0]-w*dt)*k/(2*sinh(k*h))
                  +(H*w*sinh(k*y+k*h)*sin(k*x[0]-w*dt)/(2*sinh(k*h)))
                  *(H*w*cosh(k*y+k*h)*sin(k*x[0]-w*dt)*k/(2*sinh(k*h)))
          +rol*g;
        ds(eqn)=0;
        }
}
return source;
发表于 2013-9-4 12:33:55 | 显示全部楼层

回复 1# daban0212 的帖子

int main(void) 这行用不着,删掉,可能主要问题就是这行。

另外,你那么多define宏数据最好统一放到全局变量里面,我建议还是定义成全局变量,写在#include 下面,real a=xx这么定义。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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