HsChen07讨论 | 贡献2007年8月22日 (三) 20:46的版本 AMD64 Systems 对于AMD64系统

跳转至: 导航, 搜索

文章出处: http://wiki.ubuntu.org.cn/index.php?title=UbuntuHelp:OpenFOAM

翻译人员: HsChen07


How to install OpenFOAM CFD software 怎样安装OpenFOAM计算液体力学软件

Introduction 简介

This HowTo is aimed to all Engineers, Scientist, Students interested in learning/applying/experimenting Computational Fluids Dynamics (CFD)本教程为那些对学习、应用、实验计算液体力学(CFD)感兴趣的工程师、科学家和学生而创作, CFD uses numerical approximation to the partial differential equations that govern flow of fluids in nature (i.e. Navier-Stokes equation, etc) the solution of the Navier-Stokes equation once it comply with the requirements of the Continuity equation gives the behavior of the fluids subject to the given boundary and initial conditions. This has a tremendous importance since practically any fluid can be simulated/modelled in a computer before doing any 'real life' experiment. For example you can test the design of a new aircraft using computational techniques before even build a small scale prototype for wind tunnel testing. Thus a wide range of experimental conditions can be fully tested and corrected on the fly... Since the basic equations (full) that govern fluid flow are in form of PDEs, the numerical methods to approximate the solution are complex, a very simple problem can be solved in a couple of minutes however if the problem is much more complicated the solver can take days in find a solution... in general CFD is not intended for common PCs but for high end computers designed to tackle this kind of problems. Of course this cannot stop you, you can install this software in your computer and 'play' with simple geometries and doing a lot of assumptions to solve a given problem more easily. There are several CFD brands out there like Fluent, COMSOL, CFD-RC, CFD-ADAPCO, (which are quite expensive though) ... however there are also free alternatives like ELMER Multiphysics, OpenFOAM and many others. Inherently CFD software is a bit complicated to use, it requires a deep understanding of the physical phenomena involved in given problem, and a good mathematical background.

AMD64 Systems 对于AMD64系统

If you are installing this on an AMD64 system, it is necessary to set the parameter $WM_64 to "on". To achieve this, do the following in a terminal: 如果要把它安装在 AMD64 系统上,必须把参数 $WM_64打开。在终端下按如下操作进行:

gedit ~/OpenFOAM/OpenFOAM-1.3/.bashrc

Then, I added directly above the Java section, the following: 然后,在 Java 段上面我直接添加了下面几句:

# 64 Bit Machine set to on else set to blank   64位系统设为 on, 否则留空即可

After doing so you must source your bashrc to make sure the changes take effect. 完后为了使这些变化生效,你必须把这些变化提供给 bashrc。

. ~/.bashrc

N.B. it is . space ~/... 注意这里是 .空格~/...

System requirements 系统要求

(based on the specs of the PC tested for the installation)

  • AMD Athlon XP LV 1500+ (or equivalent or higher or better or Intel or PowerPC)
  • 640 MB (The web page states nothing, but everybody knows the more, the better)
  • 1 GB hard drive available, this is a must, uncompressed files takes 750 MB, plus the cases, tutorials, grids, etc
  • Broadband conection (the compressed files are from 50 to 100 MB average) of course you can use dial up and wait 48 hours to download it, it's up to you...
  • Ubuntu LINUX 5.10 Breeze Badger Kernel version 2.6.12-9-386, if you download the AMD64 version then use the 64bit LINUX kernel
  • Not tested on kernel versions above or below (you should try to do this if this is not yor kernel version)
  • Not sure if this would work on other LINUX distributions

Step by step instructions 一步一步教你安装

1 * Check system requirements (listed above) 检查系统要求(上面已列出)

2 * Enter to OpenFOAM web page 进入OpenFOAM网页

or 或

3 * Click on download 点击下载

4 * Select your version 选择你想要下载的版本

5 * Dowload all the packages to your Desktop (very advance LINUX users can avoid obvious steps) 把程序包下载到你的桌面(LINUX高级用户可跳过这些简单步骤)


where ~/ is the home folder for example /home/<username> 其中~/就是主文件夹,如 /home/<用户名>

N.B from this point it is necesary to remenber that LINUX is CASE SENSITIVE, a mistake can delay you some hours... 注意,这里需要记住LINUX对大小写敏感,一个小小的错误就能耽搁你好几个小时

second I did install everything in my home folder which is ~/ it is the recommended option from the web site 第二,我都是在我的主文件夹~/下进行所有安装的,这是“官方”网站上建议的选择

6 * create a folder caller OpenFOAM in ~/ using mkdir 在~/下用mkdir命令建立一个叫做OpenFOAM的文件夹

copy 复制

  • OpenFOAM-1.3.General.gtgz
  • OpenFOAM-1.3.linuxGcc4DPOpt.gtgz
  • OpenFOAM-1.3.linuxGcc4SPOpt.gtgz

which are on ~/Desktop to the folder you've just created ~/OpenFOAM 它们都在~/Desktop(桌面)上,将其复制到刚刚建立的 ~/OpenFOAM下

7 * create the following folder using mkdir (remember LINUX is case sensitive) 用mkdir命令建立如下文件夹(注意LINUX对大小写敏感)


8 * copy 复制

  • gcc-4.1.0.linux.tgz
  • paraview-2.4.2.linux.tgz
  • j2sdk1.4.2_05.linux.tgz
  • which are in ~/Desktop to ~/OpenFOAM/linux 将其从 ~/Desktop 复制到 ~/OpenFOAM/linux

9 * untar avery single file in the following order 按照下面的顺序解压各文件:

  • OpenFOAM-1.3.General.gtgz
  • OpenFOAM-1.3.linuxGcc4DPOpt.gtgz
  • OpenFOAM-1.3.linuxGcc4SPOpt.gtgz
  • gcc-4.1.0.linux.tgz
  • paraview-2.4.2.linux.tgz
  • j2sdk1.4.2_05.linux.tgz

typing 解压命令格式

tar -xzvf <filename>   tar -xzvf <文件名>

This takes a bit of time 这个过程需要一些时间

10 * after finishing you will see new directories created in ~/OpenFOAM 完后你就会在~/OpenFOAM 下看到几个新目录

11 * now look for foamSystemCheck 现在找一下foamSystemCheck which is located at 它位于


this is a shell script that we have to execute, however we need to change it to an executable format 这是一个我们要运行的shell脚本,但首先我们得将它变成可执行的格式

type 输入

chmod -v 555 foamSystemCheck

press enter, then type 回车,然后输入

[[UbuntuHelp:export PATH=$PATH:~/OpenFOAM/OpenFOAM-1.3/bin/]]

press enter, then type 回车,再输入


press enter 回车

At this time, the shell script will call some functions to check if your system comply with the minimum requirements for the installation, Host, username, Linux version, and Network conectivity, however at the end of the process some error occur, just ignore any warning or fatal error about ssh or rsh, this is not needed for the stand alone installation (It doesn't matter what it tells you, just ignore it!!!) 这时shell脚本将调用一些命令来检查是否满足安装的最低要求,主机、用户名、Linux 版本及网络连接等等,如果在处理的最后会报一些错,就忽略它报告的那些关于ssh或rsh的警告或致命错误,对于仅仅安装来说这没必要(不管它报告给你了什么,尽管忽略!!!)

type 输入

chmod -v 755 foamSystemCheck

press enter 回车

12 * * * * * * Now you have to set the environment variables for a correct file access, the environment variable settings are stored in


since I am using the default options in UBUNTU, my shell is BASH and my text editor is gedit, you can use VIM as well


echo $SHELL

(if you are not sure which shell you are using and edit the following files according to your shell syntax)

now type

gedit ~/.bashrc &

once in gedit type

. ~/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3/bashrc

N.B. it is 'dot', space~/....... select file>save and then file>quit

now update the environment typing

. ~/.bashrc

N.B. it is 'dot', space ~/.......

the environment variables are updated, you can see this if you type

echo $PATH

Testing the installation 测试安装是否成功

13 **** look for foamInstallationTest which it is located at


in the same way, this file is a shell script


chmod -v 555 foamInstallationTest

press enter

now you don't need to export the path, since you have already done it...

now type


press enter

here the shell scrip verifies every directory and assigns to each of them an environment variable (PATH), also this takes a bit of time. However you will see an error at the end of the process, something like this:

test_rsh unsuccessful_conection_refused* test_ssh unsuccessful_conection_refused*

FATAL: No remote shell available (etc....)

For the stand alone version, this message is normal and you can safely ignore it, just after this OpenFOAM is ready to run

Getting started with OpenFOAM 开始 OpenFOAM 之旅

Library documentation is included in


you will find there some PDFs with tutorials and very useful examples, after a short reading you can start modelling right away.

Troubleshooting 常见问题

When installing this on a Dapper 64-bit system, I ran into the problem that the default JAVA_HOME, and therefore JAVA_PATH were directed to the following:


where there should be an OpenFOAM-1.3 directory after the OpenFOAM directory. To fix this, I opened a terminal and did the following:

gedit ~/OpenFOAM/OpenFOAM-1.3/.bashrc

Then, browse to the Java section, under the # Linux Workstation subsection, edit the export JAVA_HOME line to look like the following:

export JAVA_HOME=$WM_PROJECT_INST_DIR/OpenFOAM-1.3/$WM_ARCH/j2sdk1.4.2_05

Then save and close, and source your bashrc

. ~/.bashrc

N.B. it is . space ~/....

Acknowledgements 致谢

  • Thank you to the OpenFOAM CFD developement team for making it available under the GLP.
  • Thank you to Ubuntu Team for the great effort in this Operating System
  • Thank you for reading this wiki
  • This wiki is based in my previous Ubuntu Forum Thread ScientificUbuntu Installing OpenFOAM CFD Software
  • * * * * derjames * * * * *