OpenFOAM - XiZi's Blog

OpenFOAM 1.7.x 的ubuntu 依赖

sudo apt-get install binutils-dev flex bison git-core build-essential python-dev \
libreadline5-dev wget zlib1g-dev cmake libpng12-dev libxt-dev libxi-dev \
libxrender-dev libxrandr-dev libxcursor-dev libxinerama-dev libfreetype6-dev \
libfontconfig1-dev libglib2.0-dev freeglut3-dev libqt4-dev qt4-dev-tools libstdc++5

 

OpenFoam 1.6 编译

1.安装缺失的包

sudo apt-get install flex
sudo apt-get install binutils-dev
sudo apt-get install bison
sudo apt-get install libzip-dev

 

 

2.修正源文件

自己down一个mpfr-2.4.1.tar.gz,解压到ThirdParty-1.6目录下面对应的文件夹里,原文件夹好像缺少部分文件。

3.开始执行wmake

回到OpenFOAM-1.6目录执行        

 

cd $WM_PROJECT_DIR
./Allwmake

 

 

历时1天,终于搞定了OpenFOAM.给个总结吧!

1、错误是不可避免的,一定按照Readme来作,顺序不可以错。不要着急上一步还没弄完就急着下一步,往往会遇见不可理喻的错误。

2、对于paraView的编译是问题的关键,华处理要依赖于此,所以如果这个没编译好就编译PV3FoamReader模块,就会出现以下错误:

        cannot find -lpqComponents

如果你使用的是OpenFOAM默认的ThirdParty中的paraView(对于我的OpenFOAM1.5就是ParaView3.3-cvs),那么按照说明去编译你的PV3FoamReader吧,应该没问题了。还有问题?好看看你的环境变量吧:

 

env
#下面是我的结果: 主要注意红色的几个

WM_LINK_LANGUAGE=c++
MANPATH=
ORBIT_SOCKETDIR=/tmp/orbit-ado
FOAM_SOLVERS=/home/ado/OpenFOAM/OpenFOAM-1.5/applications/solvers
FOAM_APPBIN=/home/ado/OpenFOAM/OpenFOAM-1.5/applications/bin/linux64GccDPOpt
SSH_AGENT_PID=3746
FOAM_TUTORIALS=/home/ado/OpenFOAM/OpenFOAM-1.5/tutorials
FOAM_JOB_DIR=/home/ado/OpenFOAM/jobControl
WM_ARCH=linux64
GPG_AGENT_INFO=/tmp/seahorse-JyCvcj/S.gpg-agent:3869:1
WM_JAVAC_OPTION=Opt
TERM=xterm
SHELL=/bin/bash
MPI_ARCH_PATH=/home/ado/OpenFOAM/ThirdParty/openmpi-1.2.6/platforms/linux64GccDPOpt
FOAM_LIB=/home/ado/OpenFOAM/OpenFOAM-1.5/lib
WM_THIRD_PARTY_DIR=/home/ado/OpenFOAM/ThirdParty
XDG_SESSION_COOKIE=0cb345adacd15ab1d7f9e4c34a606381-1248739202.385802-1787204229
GTK_RC_FILES=/etc/gtk/gtkrc:/home/ado/.gtkrc-1.2-gnome2
WINDOWID=63494839
ParaView_INST_DIR=/home/ado/OpenFOAM/ThirdParty/ParaView3.6.1
FOAM_MPI_LIBBIN=/home/ado/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/openmpi-1.2.6
GTK_MODULES=canberra-gtk-module
FOAM_APP=/home/ado/OpenFOAM/OpenFOAM-1.5/applications
WM_CXXFLAGS=-m64 -fPIC
WM_CFLAGS=-m64 -fPIC
WM_PROJECT_VERSION=1.5
OPAL_PREFIX=/home/ado/OpenFOAM/ThirdParty/openmpi-1.2.6/platforms/linux64GccDPOpt
USER=ado
LD_LIBRARY_PATH=/home/ado/OpenFOAM/ThirdParty/ParaView3.6.1/platforms/linux64Gcc/bin:/home/ado/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt/openmpi-1.2.6:/home/ado/OpenFOAM/ThirdParty/openmpi-1.2.6/platforms/linux64GccDPOpt/lib:/home/ado/OpenFOAM/ThirdParty/gcc-4.3.1/platforms/linux64/lib64:/home/ado/OpenFOAM/ThirdParty/gcc-4.3.1/platforms/linux64/lib:/home/ado/OpenFOAM/ado-1.5/lib/linux64GccDPOpt:/home/ado/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:
MPI_BUFFER_SIZE=20000000
WM_COMPILER_LIB_ARCH=64
FOAM_SRC=/home/ado/OpenFOAM/OpenFOAM-1.5/src
FOAM_SIGFPE=
ParaView_DIR=/home/ado/OpenFOAM/ThirdParty/ParaView3.6.1/platforms/linux64Gcc
WM_PROJECT_INST_DIR=/home/ado/OpenFOAM
FOAM_UTILITIES=/home/ado/OpenFOAM/OpenFOAM-1.5/applications/utilities
WM_CXX=g++
WM_PROJECT_DIR=/home/ado/OpenFOAM/OpenFOAM-1.5
GNOME_KEYRING_SOCKET=/tmp/keyring-6ttQQv/socket
SSH_AUTH_SOCK=/tmp/keyring-6ttQQv/socket.ssh
WM_COMPILER_ARCH=
SESSION_MANAGER=local/ado-Main:/tmp/.ICE-unix/3546
USERNAME=ado
CINTSYSDIR=/home/ado/pub/CINT/cint
WM_PROJECT=OpenFOAM
WM_LDFLAGS=-m64
WM_COMPILER=Gcc
WM_MPLIB=OPENMPI
DESKTOP_SESSION=default
PATH=/home/ado/OpenFOAM/ThirdParty/ParaView3.6.1/platforms/linux64Gcc/bin:/home/ado/OpenFOAM/ThirdParty/openmpi-1.2.6/platforms/linux64GccDPOpt/bin:/home/ado/OpenFOAM/ThirdParty/gcc-4.3.1/platforms/linux64/bin:/home/ado/OpenFOAM/ado-1.5/applications/bin/linux64GccDPOpt:/home/ado/OpenFOAM/OpenFOAM-1.5/applications/bin/linux64GccDPOpt:/home/ado/OpenFOAM/OpenFOAM-1.5/wmake:/home/ado/OpenFOAM/OpenFOAM-1.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/real/RealPlayer
FOAM_USER_LIBBIN=/home/ado/OpenFOAM/ado-1.5/lib/linux64GccDPOpt
QT_IM_MODULE=xim
WM_COMPILER_DIR=/home/ado/OpenFOAM/ThirdParty/gcc-4.3.1/platforms/linux64
GDM_XSERVER_LOCATION=local
WM_CC=gcc
PWD=/home/ado
XMODIFIERS=@im=SCIM
LANG=en_US.UTF-8
GNOME_KEYRING_PID=3532
GDM_LANG=en_US.UTF-8
PV_PLUGIN_PATH=/home/ado/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt
FOAM_INST_DIR=/home/ado/OpenFOAM
FOAM_LIBBIN=/home/ado/OpenFOAM/OpenFOAM-1.5/lib/linux64GccDPOpt
WM_COMPILE_OPTION=Opt
GDMSESSION=default
HISTCONTROL=ignoreboth
ParaView_VERSION=3.6.1
WM_DIR=/home/ado/OpenFOAM/OpenFOAM-1.5/wmake
SHLVL=1
HOME=/home/ado
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
PYTHONPATH=/home/ado/OpenFOAM/ThirdParty/ParaView3.6.1/platforms/linux64Gcc/Utilities/VTKPythonWrapping
LOGNAME=ado
WM_PROJECT_USER_DIR=/home/ado/OpenFOAM/ado-1.5
FOAM_RUN=/home/ado/OpenFOAM/ado-1.5/run
XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-gxBh7E8bUq,guid=f696868c90a37644fe4f4b2d4a6e3f84
MPI_HOME=/home/ado/OpenFOAM/ThirdParty/openmpi-1.2.6
WM_OPTIONS=linux64GccDPOpt
LESSOPEN=| /usr/bin/lesspipe %s
WINDOWPATH=7
DISPLAY=:0.0
WM_PRECISION_OPTION=DP
GTK_IM_MODULE=scim-bridge
WM_ARCH_OPTION=64
WM_OS=Unix
LESSCLOSE=/usr/bin/lesspipe %s %s
FOAM_USER_APPBIN=/home/ado/OpenFOAM/ado-1.5/applications/bin/linux64GccDPOpt
XAUTHORITY=/home/ado/.Xauthority
COLORTERM=gnome-terminal
_=/usr/bin/env
 

 

 

这里我的就是安装的最新的ParaView3.6.1,不是安装的默认的。如果你装的也不是默认的那么可以修改这个文件实现自动配置以上环境变量:

 

gedit $WM_PROJECT_DIR/etc/apps/paraview3/bashrc

# 修改

export ParaView_VERSION="3.3-cvs"

# 为

ParaView_VERSION=<your paraview version> !对于我这里是 "3.6.1"
# 应该和ThirdParty中的paraView目录想对应。

 

 

 

好了,应该可以编译了。

3、对于默认编译paraView3.3-cvs是提示 “No Target“ 什么的错误,是因为你的QT不是4.3.x的版本,我的ubuntu9.04就是默认的QT4.5。想编译?方法就是把其目录下的CMakeLists.txt中对应的检查QT版本的给该了:

 

# 原代码 83开始
  # ParaView requires this minimum version of Qt, and let's do it here before
  # our first call to FindQt4.cmake
  SET(QT_MIN_VERSION "4.3.0")
  SET(QT_REQUIRED TRUE)
  FIND_PACKAGE(Qt4)
  IF(NOT QT4_FOUND)
    MESSAGE(SEND_ERROR "Qt ${QT_MIN_VERSION} or greater not found.  Please check the QT_QMAKE_EXECUTABLE variable.")
  ELSE(NOT QT4_FOUND)
    # don'
t go greater than supported version
    STRING(REGEX MATCH "^4\\.3\\.[0-9]+" qt_version_tmp "${QTVERSION}")  //注意改这一行
    IF (NOT qt_version_tmp)
      MESSAGE(SEND_ERROR "Qt ${QTVERSION} not supported.  Please use Qt 4.3 (you may need to clean your dirtied cache).")
    ENDIF (NOT qt_version_tmp)
    # enforce Carbon in VTK for Qt/Mac
    IF(Q_WS_MAC)
      SET(VTK_USE_CARBON ON CACHE BOOL "Build VTK with Carbon" FORCE)
      SET(VTK_USE_COCOA OFF CACHE BOOL "Build VTK with Cocoa" FORCE)
    ENDIF(Q_WS_MAC)
    # Mark these Qt variables as advanced. Users don't really have to set them.
    MARK_AS_ADVANCED(DESIRED_QT_VERSION VTK_USE_QVTK VTK_USE_GUISUPPORT)
    MARK_AS_ADVANCED(QT_MKSPECS_DIR QT_PLUGINS_DIR QT_X11_X11_LIBRARY QT_X11_Xext_LIBRARY QT_X11_m_LIBRARY)
  ENDIF(NOT QT4_FOUND)

# 修改为:
  # ParaView requires this minimum version of Qt, and let'
s do it here before
  # our first call to FindQt4.cmake
  SET(QT_MIN_VERSION "4.3.0")
  SET(QT_REQUIRED TRUE)
  FIND_PACKAGE(Qt4)
  IF(NOT QT4_FOUND)
    MESSAGE(SEND_ERROR "Qt ${QT_MIN_VERSION} or greater not found.  Please check the QT_QMAKE_EXECUTABLE variable.")
  ELSE(NOT QT4_FOUND)
    # don't go greater than supported version
    STRING(REGEX MATCH "^4\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}") 
//修该为这个样子
    IF (NOT qt_version_tmp)
      MESSAGE(SEND_ERROR "Qt ${QTVERSION} not supported.  Please use Qt 4.3 (you may need to clean your dirtied cache).")
    ENDIF (NOT qt_version_tmp)
    # enforce Carbon in VTK for Qt/Mac
    IF(Q_WS_MAC)
      SET(VTK_USE_CARBON ON CACHE BOOL "Build VTK with Carbon" FORCE)
      SET(VTK_USE_COCOA OFF CACHE BOOL "Build VTK with Cocoa" FORCE)
    ENDIF(Q_WS_MAC)
    # Mark these Qt variables as advanced. Users don'
t really have to set them.
    MARK_AS_ADVANCED(DESIRED_QT_VERSION VTK_USE_QVTK VTK_USE_GUISUPPORT)
    MARK_AS_ADVANCED(QT_MKSPECS_DIR QT_PLUGINS_DIR QT_X11_X11_LIBRARY QT_X11_Xext_LIBRARY QT_X11_m_LIBRARY)
  ENDIF(NOT QT4_FOUND)
 

应该差不多了。发现信问题再更新吧。

 

我的OpenFOAM第一步

基本上按照OpenFOAM的指导进行安装,但Ubuntu默认没有这几个库,得先手动装一下。

 

sudo apt-get install flex
sudo apt-get install binutils-dev

其他的还On the Way

还有就是确认你的ThirthParty目录里面有Gcc。没有的话,找一个方里面。我就是在OpenFOAM官方down的一个Bin包。

 

 




Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee