fluentudf环境变量的设置

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

A N S Y S15.0f l u e n t u d f环境变量的设置初学udf,还没进入主题就被udf问题搞死了,摸索了一两天终于让我搞出了点名堂,本人用的是ANSYS 15.0和vc 10.0.不多说,先把ANSYS 和vc都装上,网上有教程安装的,一步步来别跳步。

最好把vc6也装一下,因为里面有的东西设置环境变量要用到。

先不要打开软件。

设置环境变量:
1.C:\Program Files\ANSYS Inc\v150\fluent\ntbin\win64目录下双击setenv和remenv
2.设置环境变量:
INCLUDE
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\Include;
LIB
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64;C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\Lib\x64;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib;
PATH
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;
找个udf文件,注意udf是支持三维还是二维的,打开fluent , 设置工作目录。

如下:
接着就是编译了,不用打开case的,直接就可以define ….
如果出现什么xcopy….我们找到C:\Windows\System32里面的xcopy复制到
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64;
如果出现“size_t”: 重定义;不同的基类型,可能是你的udf文件有问题。

如果实在不行,按照下面的环境变量重新设置一下,重启电脑。

INCLUDE C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include;
LIB C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64; C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\lib;
PATH C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools;c:\program files\ansys inc\v150\fluent\ntbin\win64
4.1 Problem with 'nmake'?
According to the manual, I wrote a C code, saved it in my working folder, added it, clicked Build... and then I saw this:
1 file(s) copied.
(chdir "example")()
(chdir "win64\2d")()
'nmake' is not recognized as an internal or external command,
operable program or batch file.
'nmake' is not recognized as an internal or external command,
operable program or batch file.
Done.
4.2 Solution to the 'nmake' problem
Without any detail, the problem is caused because nmake.exe cannot be found. The solution is to start Fluent from the x64 version of the Visual Studio 2013 Command Prompt:
1. Open the?Start screen?(press Windows button on your keyboard)
2. Type 'Visual Studio Tools', click the folder.
3. In the folder click and start 'VS2013 x64 Cross Tools Command Prompt'
4. Navigate to your working folder, i.e. the folder where your case and data files are (.cas & .dat).
6. Make sure that on the Environment tab 'Setup Compilation Environment for UDF' is ticked. The default address is fine.
Starting Fluent this way should solve the 'nmake' problem and the compilation message should look like this:
1 file(s) copied.
(chdir "exex")()
(chdir "win64\2d")()
# Generating ud_io1.h
velocity_profile.c
# Generating udf_names.c because of makefile velocity_profile.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj velocity_profile.obj
Copyright (C) Microsoft Corporation. All rights reserved.
Creating library libudf.lib and object libudf.exp
Done.
5.1 Problem with x64 system
In case you do not have Microsoft Visual Studio 2013 Express then likely you tried starting Fluent from the 'Visual Studio Command Prompt (2010)' or any other previous version of VS command prompt. It is likely that you encountered a problem when clicking Load, specifically this one:
The UDF library you are trying to load (libudf) is not compiled for 2d on the curent platform (win64).
The system cannot find the file specified.
X:\<your working folder>libudf\win64\2d\libudf.dll
The reason of this error is that previous versions of Visual Studio are 32bit and do not work with your x64 version of Fluent. You probably googled the problem and found advice to start Fluent from the command promt of the SDK (Software Development Kit) 7.0/7.1 instead, or from the command prompt of the .NET Framework. Unfortunately, as Microsoft states on their website at the?Windows SDK 8.1 download page:
"The Windows SDK no longer ships with a complete command-line build environment. You must install a compiler and build environment separately. If you require a complete development environment that includes compilers and a build environment, you can download Visual Studio 2013, which includes the appropriate components of the Windows SDK."
Older versions of the .NET Framework and SDK do not seem to work properly on Windows 8.1
([citation needed], just my experience??). I also found out that with a working x64 SDK installed you can start the simple windows command prompt (cmd.exe) with the proper environmental variables using a cmd.exe /k "<environmental variables>" command, which I failed to get to work.
5.2 Solution to the problem of x64 system
The solution to this is to start Fluent from the x64 command prompt 'VS2013 x64 Cross Tools Command Prompt' as described in (4.1) instead of previous versions of VS or SDK/.NET command prompts.
6.1 Problem with math.h
Another problem occurred even after I had everything set up. This problem was reported by cfd-online user KITetima as well in?this forum topic.
The very simple c code to initialize the velocity on the inlet boundary to a given velocity profile did not compile, and the following error message appeared:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: syntax error : ','
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2143: syntax error : missing ')' before 'constant'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2143: syntax error : missing '{' before 'constant'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: syntax error : 'constant'
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(482) : error C2059: syntax error : ')'
Done.
I could not figure out exactly what is the problem, but it seems that the header file math.h provided by VS2013 has some mistakes, or somehow isn't compatible with Fluent 14 (and Fluent 14.5).
First I tried to give the math.h header file for the UDF myself in the Header section (see Figure above), however, the compiler still used the math.h file that is located in C:\Program Files
(x86)\Microsoft Visual Studio 12.0\VC\include.
6.2 Solution to the problem with math.h
1. Keep the software installed on your computer, but also install?Microsoft Visual C++ 2010 Express
2. Go to the following folder:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include
3. From this folder copy the math.h file to
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
4. Start Fluent as described above in (4.2). Now you will be using VS2013 as compiler but the math.h file from VS2010, which worked fine for me.
7. Setting the Environmental Variables?
Many pages that you find dealing with the problem give suggestions like "make sure your environmental variables are set". However, it is not clear how to do that. I succeeded finally at making it work, however, before that I managed to ruin my Windows and I needed a network registry operation to fix it, so first of all:
0.?DO NOT DELETE OR MODIFY WHAT IS ALREADY IN THE 'PATH' VARIABLE.
1. Right click on?'My computer'/'This PC'?and click?'Properties'
2. On the left side of the screen click?'Advanced system settings'
3. On the bottom click?'Environmental variables'
4. In the bottom box look for the Variable named?'Path', select it and click?'Edit'
5. Be careful not to modify anything that is already there.
6. At the end, put a semicolon ( ; ) and after that paste the address of your Fluent executable, i.e. add to the end of the Path variable
;C:\<your Fluent executable folder>
7. Add to the end the folder where the 'vcvarsx86_amd64.bat' file of your Visual Studio 12 is found. By default this is:
;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64
8. Click OK and OK your way out of the My computer properties. You are all set hopefully.
This will enable you to start fluent by simply typing the command "fluent" in your command
prompt. You can also add the 2D and 3D executables separately to the Path variable.
8. Remarks and disclaimer
I would like to emphasize that I am in no way an expert in CFD/C++/UDFs/Windows SDK, only a beginner user. I do not take any responsibility for anything described or suggested on this page, or any damage caused by following these steps. This is merely a summary of my experiences with my system, and I cannot guarantee that the solutions will work in any other setup (or with this setup on other systems).
However, I do hope that some will find it useful and some people will save many hours of searching for the solutions.
Kind regards,
用户变量
FLUENT_INC
c:\program files\ansys inc\v140\fluent
ICEM_ACN
C:\Program Files\ANSYS Inc\v140\icemcfd\win64_amd
include
d:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\Include;
lib
d:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64;C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\Lib\x64
MSDevDir
D:\Program Files (x86)\Microsoft Visual Studio\Common\MSDev98
Path
d:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64;d:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;
PVX_INSTALL_DIR
D:\proe_GB_ku\MONLibs\
TEMP
%USERPROFILE%\AppData\Local\Temp
TMP
%USERPROFILE%\AppData\Local\Temp
系统变量
ADSK_3DSMAX_x64_2014
C:\Program Files\Autodesk\3ds Max 2014\
ANSYS_SYSDIR
winx64
ANSYS_SYSDIR32
win32
ANSYS140_DIR
C:\Program Files\ANSYS Inc\v140\ANSYS
ANSYSLIC_DIR
C:\Program Files\ANSYS Inc\Shared Files\Licensing
AWP_LOCALE130
en-us
AWP_ROOT140
C:\Program Files\ANSYS Inc\v140
CADOE_DOCDIR140
C:\Program Files\ANSYS Inc\v140\CommonFiles\help\en-us\solviewer
CADOE_LIBDIR140
C:\Program Files\ANSYS Inc\v140\CommonFiles\Language\en-us
CM2014DIR
C:\Program Files (x86)\Common Files\Autodesk Shared\Materials\
ComSpec
%SystemRoot%\system32\cmd.exe
D:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;
D:\Program Files (x86)\Microsoft Visual Studio\VC98\Lib;
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64
DEVMGR_SHOW_DETAILS
1
FP_NO_HOST_CHECK
NO
ICEMCFD_ROOT140
C:\Program Files\ANSYS Inc\v140\icemcfd
IDTCOMMON
C:\Program Files\Common Files\IDT
ILBDIR
C:\Program Files (x86)\Common Files\Autodesk Shared\Materials\
ILMDIR
C:\Program Files (x86)\Common Files\Autodesk Shared\Materials\
include
d:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include;C:\Program Files (x86)\Microsoft
SDKs\Windows\v7.0A\Include;
lib
d:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\amd64;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64
LSTC_LICENSE
ANSYS
MONLIBS_DIR
D:\proe_GB_ku\MONLibs
NUMBER_OF_PROCESSORS
4
OS
Windows_NT
P_SCHEMA
C:\Program Files\ANSYS Inc\v140\AISOL\CADIntegration\Parasolid\PSchema
path
d:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64;d:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;
PATHEXT
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC pro_library_dir
D:\proe_GB_ku
PROCESSOR_ARCHITECTURE
AMD64
PROCESSOR_IDENTIFIER
Intel64 Family 6 Model 42 Stepping 7, GenuineIntel
PROCESSOR_LEVEL
6
PROCESSOR_REVISION
2a07
PSModulePath
%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\ TEMP
C:\temp
TMP
C:\temp
VS100COMNTOOLS
D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\。

相关文档
最新文档