huanayun
hengtianyun
vps567
莱卡云

[Linux操作系统]Ubuntu 下 OpenFOAM 的配置与安装指南|ubuntu安装openfoam,Ubuntu OpenFOAM 配置

PikPak

推荐阅读:

[AI-人工智能]免翻墙的AI利器:樱桃茶·智域GPT,让你轻松使用ChatGPT和Midjourney - 免费AIGC工具 - 拼车/合租账号 八折优惠码: AIGCJOEDISCOUNT2024

[AI-人工智能]银河录像局: 国内可靠的AI工具与流媒体的合租平台 高效省钱、现号秒发、翻车赔偿、无限续费|95折优惠码: AIGCJOE

[AI-人工智能]免梯免翻墙-ChatGPT拼车站月卡 | 可用GPT4/GPT4o/o1-preview | 会话隔离 | 全网最低价独享体验ChatGPT/Claude会员服务

[AI-人工智能]边界AICHAT - 超级永久终身会员激活 史诗级神器,口碑炸裂!300万人都在用的AI平台

本文介绍了在Ubuntu操作系统下如何配置与安装OpenFOAM。指南详细阐述了安装过程中的各个步骤,包括依赖关系的解决、OpenFOAM源代码的下载、编译以及环境变量的配置,旨在帮助用户顺利地在Ubuntu上搭建OpenFOAM计算环境。

本文目录导读:

  1. 系统要求
  2. 安装依赖
  3. 下载 OpenFOAM
  4. 编译 OpenFOAM

随着计算机辅助工程(CAE)的快速发展,OpenFOAM 作为一款开源的计算流体动力学(CFD)软件,受到了越来越多科研人员和工程师的青睐,本文将详细介绍如何在 Ubuntu 操作系统下配置和安装 OpenFOAM,帮助读者顺利搭建 CFD 模拟环境。

系统要求

在开始配置 OpenFOAM 之前,请确保您的 Ubuntu 系统满足以下要求:

1、操作系统:Ubuntu 18.04 或更高版本

2、CPU:64 位处理器

3、内存:至少 4GB

4、硬盘:至少 20GB 的可用空间

安装依赖

1、安装编译器

打开终端,输入以下命令安装编译器:

sudo apt-get update
sudo apt-get install g++ gfortran

2、安装并行计算库

OpenFOAM 支持并行计算,因此需要安装并行计算库,输入以下命令安装:

sudo apt-get install mpich libmpich-dev

3、安装其他依赖

OpenFOAM 还需要以下依赖库,输入以下命令安装:

sudo apt-get install cmake git gitk libopenmpi-dev libfftw3-dev 
libeigen3-dev libboost-all-dev

下载 OpenFOAM

1、访问 OpenFOAM 官方网站(https://openfoam.org/),下载最新版本的源代码。

2、将下载的压缩包解压到指定目录,例如/opt/openfoam

编译 OpenFOAM

1、打开终端,进入 OpenFOAM 源代码目录。

2、创建一个名为Allwmake 的脚本文件,并输入以下内容:

#!/bin/bash
Set the source and build directories
export WM_PROJECT_DIR=$(pwd)
export WM_PROJECT_VERSION=8
export WM_compile=ThirdParty
export WM_PRECISION=dp
export WM_LABEL_SIZE=32
export WMarching Bands=off
export WMmesh=off
export WMclean=off
export WMdoxygen=off
export WMOpenGL=off
export WMterminal=off
export WMundef=off
export WMversion=off
Create the build directory
mkdir -p $WM_PROJECT_DIR/build/$WM_PROJECT_VERSION/src
cd $WM_PROJECT_DIR/build/$WM_PROJECT_VERSION/src
Compile the ThirdParty libraries
echo "Compiling ThirdParty libraries..."
$WM_PROJECT_DIR/src/ThirdParty/Allwmake
Compile OpenFOAM
echo "Compiling OpenFOAM..."
$WM_PROJECT_DIR/src/Allwmake
Create symbolic links to the applications and libraries
echo "Creating symbolic links..."
ln -sf $WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/$WM_PRECISION/lib $WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER
ln -sf $WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/$WM_PRECISION/bin $WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER
Update the environment variables
echo "Updating environment variables..."
cat > $WM_PROJECT_DIR/setenv.sh << EOF
Set the source and build directories
export WM_PROJECT_DIR=$WM_PROJECT_DIR
export WM_PROJECT_VERSION=$WM_PROJECT_VERSION
export WM_COMPILE=$WM_compile
export WM_PRECISION=$WM_PRECISION
export WM_LABEL_SIZE=$WM_LABEL_SIZE
export WMarching Bands=$WMarching Bands
export WMmesh=$WMmesh
export WMclean=$WMclean
export WMdoxygen=$WMdoxygen
export WMOpenGL=$WMOpenGL
export WMterminal=$WMterminal
export WMundef=$WMundef
export WMversion=$WMversion
Set the path to the ThirdParty libraries
export WM_THIRD_PARTY_DIR=$WM_PROJECT_DIR/src/ThirdParty
Set the path to the OpenFOAM libraries and applications
export WM_PROJECT_USER_DIR=$HOME/OpenFOAM
export WM_PROJECT_APP_DIR=$WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/bin
export WM_PROJECT_LIB_DIR=$WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/lib
Set the path to the OpenFOAM Python modules
export PYTHONPATH=$WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/site-packages:$PYTHONPATH
Set the path to the OpenFOAM bash completion script
export WM_BASHRC=$WM_PROJECT_DIR/bashrc
Set the path to the OpenFOAM man pages
export WM_MANPATH=$WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/man:$WM_MANPATH
Set the path to the OpenFOAM documentation
export WM_DOC_DIR=$WM_PROJECT_DIR/doc
Set the path to the OpenFOAM examples
export WM_EXAMPLES_DIR=$WM_PROJECT_DIR/tutorials
Set the path to the OpenFOAM tests
export WM_TESTS_DIR=$WM_PROJECT_DIR/test
Set the path to the OpenFOAM utilities
export WM_UTILS_DIR=$WM_PROJECT_DIR/utils
Set the path to the OpenFOAM modules
export WM_MODULES_DIR=$WM_PROJECT_DIR/modules
Set the path to the OpenFOAM contrib
export WM_CONTRIB_DIR=$WM_PROJECT_DIR/contrib
Set the path to the OpenFOAM packages
export WM_PACKAGES_DIR=$WM_PROJECT_DIR/packages
Set the path to the OpenFOAM source directories
export WM_SRC_DIR=$WM_PROJECT_DIR/src
Set the path to the OpenFOAM build directories
export WM_BUILD_DIR=$WM_PROJECT_DIR/build/$WM_PROJECT_VERSION/src
Set the path to the OpenFOAM platform directories
export WM_ARCH=$WM_ARCH
export WM_COMPILER=$WM_COMPILER
Set the path to the OpenFOAM options file
export WM_OPTIONS=$WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/options
Set the path to the OpenFOAM site file
export WM_SITE=$WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/site
Set the path to the OpenFOAM etc directory
export WM_ETC=$WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/etc
Set the path to the OpenFOAM bash completion script
export WM_BASHRC=$WM_PROJECT_DIR/bashrc
Set the path to the OpenFOAM man pages
export WM_MANPATH=$WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/man:$WM_MANPATH
Set the path to the OpenFOAM documentation
export WM_DOC_DIR=$WM_PROJECT_DIR/doc
Set the path to the OpenFOAM examples
export WM_EXAMPLES_DIR=$WM_PROJECT_DIR/tutorials
Set the path to the OpenFOAM tests
export WM_TESTS_DIR=$WM_PROJECT_DIR/test
Set the path to the OpenFOAM utilities
export WM_UTILS_DIR=$WM_PROJECT_DIR/utils
Set the path to the OpenFOAM modules
export WM_MODULES_DIR=$WM_PROJECT_DIR/modules
Set the path to the OpenFOAM contrib
export WM_CONTRIB_DIR=$WM_PROJECT_DIR/contrib
Set the path to the OpenFOAM packages
export WM_PACKAGES_DIR=$WM_PROJECT_DIR/packages
Set the path to the OpenFOAM source directories
export WM_SRC_DIR=$WM_PROJECT_DIR/src
Set the path to the OpenFOAM build directories
export WM_BUILD_DIR=$WM_PROJECT_DIR/build/$WM_PROJECT_VERSION/src
Set the path to the OpenFOAM platform directories
export WM_ARCH=$WM_ARCH
export WM_COMPILER=$WM_COMPILER
Set the path to the OpenFOAM options file
export WM_OPTIONS=$WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/options
Set the path to the OpenFOAM site file
export WM_SITE=$WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/site
Set the path to the OpenFOAM etc directory
export WM_ETC=$WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/etc
Set the path to the OpenFOAM bash completion script
export WM_BASHRC=$WM_PROJECT_DIR/bashrc
Set the path to the OpenFOAM man pages
export WM_MANPATH=$WM_PROJECT_DIR/platforms/$WM_ARCH$WM_COMPILER/man:$WM_MANPATH
Set the path to the OpenFOAM documentation
export WM_DOC_DIR=$WM_PROJECT_DIR/doc
Set the path to the OpenFOAM examples
export WM_EXAMPLES_DIR=$WM_PROJECT_DIR/tutorials
Set the path to the OpenFOAM tests
export WM_TESTS_DIR=$WM_PROJECT_DIR/test
Set the path to the OpenFOAM utilities
export WM_UTILS_DIR=$WM_PROJECT_DIR/utils
Set the path to the OpenFOAM modules
export WM_MODULES_DIR=$WM_PROJECT_DIR/modules
Set the path to the OpenFOAM contrib
export WM_CONTRIB_DIR=$WM_PROJECT_DIR/contrib
Set the path to the OpenFOAM packages
export WM_PACKAGES_DIR=$WM_PROJECT_DIR/packages
Set the path to the OpenFOAM source directories
export WM_SRC_DIR=$WM_PROJECT_DIR/src
Set the path to the OpenFOAM build directories
export WM_BUILD_DIR=$WM_PROJECT_DIR/build/$WM_PROJECT_VERSION/src
Set the path to the OpenFOAM platform directories
export WM_ARCH=$WM_ARCH
export WM_COMPILER=$WM_COMPILER
Set the path to the Open
bwg Vultr justhost.asia racknerd hostkvm pesyun Pawns


本文标签属性:

Ubuntu OpenFOAM 配置:ubuntu openoffice

原文链接:,转发请注明来源!