找回密码
 注册
查看: 4999|回复: 6

请高手帮忙UDF文件改错

[复制链接]
发表于 2006-4-17 16:22:42 | 显示全部楼层 |阅读模式

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

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

x
UDF文件如下,是FLUENT软件中的English Tutorial材料中英文UDF指导材料FLUENT 6.1 UDF Manual(Fluent Inc. January 22, 2003)中的一个例子,是关于在一个时间微段中物体受力加速的问题,完全拷贝下来,居然解释时出错.
先是"static real v_prev = 0.0;"有错,Error: D:\UDF-test\UDF\colmove-udf-1.c: line 9: parse error.
后来我改为"real v_prev = 0.0;"。接着又是"t=DT_THREAD(dt);"有错.Error: D:\UDF-test\UDF\colmove-udf-1.c: line 26: structure reference not implemented
我的Fluent软件的版本是6.2.16.
有高手可以帮忙改错吗?
/************************************************************
*
* 1-degree of freedom equation of motion (x-direction)
* compiled UDF
*
************************************************************/
#include "udf.h"
static real v_prev = 0.0;
DEFINE_CG_MOTION(piston, dt, vel, omega, time, dtime)
{
Thread *t;
face_t f;
real NV_VEC (A);
real force, dv;
/* reset velocities */
NV_S (vel, =, 0.0);
NV_S (omega, =, 0.0);
if (!Data_Valid_P ())
return;
/* get the thread pointer for which this motion is defined */
t=DT_THREAD(dt);
/* compute pressure force on body by looping through all faces */
force = 0.0;
begin_f_loop (f, t)
{
F_AREA (A, f, t);
force += F_P (f, t) * NV_MAG (A);
}
end_f_loop (f, t)
/* compute change in velocity, i.e., dv = F * dt / mass
velocity update using explicit Euler formula */
dv = dtime * force / 50.0;
v_prev += dv;
Message ("time = %f, x_vel = %f, force = %f\n", time, v_prev, force);
/* set x-component of velocity */
vel[0] = v_prev;
}
发表于 2006-4-18 11:27:28 | 显示全部楼层

请高手帮忙UDF文件改错

你用的什么编译方式?
有指针不要用解释型
 楼主| 发表于 2006-4-19 16:22:06 | 显示全部楼层

请高手帮忙UDF文件改错

谢谢!
能不能说的具体一些?
 楼主| 发表于 2006-4-23 22:12:09 | 显示全部楼层

请高手帮忙UDF文件改错

问题解决了,办法如下:
1.static变量不能用Interprete方法,得用Compile方法。
2.安装或重新安装vc,并选择环境变量;没有正确设置环境变量的,按以下方法:
. 在我的电脑 > 属性 > 高级 > 环境变量中设置“include”“lib”“path”变量的值,
. include:D:\Program Files\Microsoft Visual Studio .NET\Vc7\include\
. lib:D:\Program Files\Microsoft Visual Studio .NET\Vc7\lib\
. 找到Microsoft Visual Studio .NET\Vc7\bin\cl.exe的动态链接库mspdb70.dll, 将mspdb70.dll的
路径加入到path的值。
cl.exe 是 the Microsoft Visual Studio的编辑执行文件,只要正确设置环境变量后,你才能看到以下信息:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption...
(b)(system "move user_nt.udf libudf\ntx86\3d")0
(system "copy C:\fluent.inc\fluent6.1\src\makefile_nt.udf libudf\ntx86\3d\makefile")已复制 1 个文件。
0
(chdir "libudf")()
(chdir "ntx86\3d")()
udf.c
# Generating udf_names.c because of makefile udf.obj
udf_names.c
udf_names.c(7) : error C2059: syntax error : ';}';
udf_names.c(8) : warning C4034: sizeof returns 0
3.PDF文件中的UDF例子不能直接拷贝到Visual C ++中,得逐字敲入到Visual C ++中.
发表于 2006-4-26 20:14:44 | 显示全部楼层

请高手帮忙UDF文件改错

>我得函数头文件是:
#include "udf.h"  
&#35;include <winsock.h>
&#35;include "stdafx.h"
&#35;include <windows.h>
&#35;include <stdio.h>
&#35;include <stdlib.h>
&#35;pragma comment(lib,"wsock32.lib")
>
>
>错误提示:
>C:\Program Files\Microsoft Visual Studio\VC98\include\winnt.h(357) : error C2467: illegal declaration of anonymous ';struct';
..........好多错误信息
.........
.........
上网查了一下:
http://community.vietfun.com/showthread.php?t=277072&goto=nextoldest

Check project properties, there is something called language propeties. You can enable or disable Microsoft extensions. Enable extension could help.
Anonymous struct is a Microsoft extension to the language and not in the ANSI standard. You may be setting the compiler to use strict ANSI
> 在编译UDF时,遇到了错误提示,问题可能时UDF函数只能用标准C编写,不能调用windows下的库函数,不能包含#include<window.h>等

>我该怎么办???才能解决问题
>谢谢您的答复!
发表于 2006-5-13 16:12:50 | 显示全部楼层

请高手帮忙UDF文件改错

你这个问题我也碰到过,后来装了vc(安装时选择环境变量),用compile就可以了,含有函数指针时不能用interpret解释型
发表于 2006-5-13 20:37:36 | 显示全部楼层

请高手帮忙UDF文件改错

这个问题已经解决,方法是采用eric的vc++对FLUENT二次开发的软件编译这个程序
http://219.232.54.3/cgi-bin/LB5000/topic.cgi?forum=51&topic=78&show=0[br][br][以下内容由 hp270388026 在 2006年05月13日 08:39pm 时添加] [br]
用其它方法不可能解决问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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