1.下载OpenFOAM 源码压缩包,在根目录下解压于OpenFOAM 文件夹中;即解压的文件位于$HOME/OpenFOAM/OpenFOAM-4.0 下。
2.修改根目录下的 .bashrc (加点是因为该文件为隐藏文件)文件
           vi .bashrc
添加
           source $HOME/OpenFOAM/OpenFOAM-4.0/etc/bashrc
保存后更新修改
           source .bashrc
3.修改 $WM_PROJECT_DIR/etc/bashrc
           vi bashrc
修改其中MPI
           export WM_MPLIB=MPICH
并增加并行编译线程控制数量
           export WM_NCOMPPROCS=12
保存后,更新修改:source bashrc
4.修改Boost CGAL MPI 控制路径
                   cd $WM_PROJECT_DIR/etc/config.sh
         修改 CGAL 文件中的BOOST_ARCH_PATH CGAL_ARCH_PATH
                   vi CGAL
                            boost_version=boost-1.62.0
                            cgal_version=CGAL-4.9
                            export BOOST_ARCH_PATH=/vol/usr/local/boost-1.62.0
                            export CGAL_ARCH_PATH=/vol/usr/local/CGAL-4.9
         保存退出;
修改 mpi 文件中对应MPICH FOAM_MPI MPI_HOME MPI_ARCH_PATH
         vi mpi
           export FOAM_MPI=mvapich2-2.0-gcc-opt
    export MPI_HOME=/vol/usr/local/mvapich2-2.0-gcc-opt
               export MPI_ARCH_PATH=/vol/usr/local/mvapich2-2.0-gcc-opt
保存退出;
5.修改编译器控制配置,转至路径
           cd $WM_PROJECT_DIR/wmake/rules/linux64Gcc
修改 c 文件cc 配置
           cc          = /vol/usr/local/mvapich2-2.0-gcc-opt
修改 c++ 文件CC 配置
           CC          = g++ -std=c++0x -m64 -L/vol/usr/local/lib -lpmi
6.进行完上述修改后,跳转到目录
           cd $WM_PROJECT_DIR
执行
           source etc/bashrc
                   nohup ./Allwmake –j 12 &> log &
为显示实时编译情况:tail –f log0


实测有效!整理来自我的师兄:周博(村长),感谢!

Logo

更多推荐