Linux下SU2 8.0.1源码编译安装及使用

基本依赖:

1、C/C++ 编译器

2、Python3.6及以上

其它依赖:需要联网。build过程中会自动下载至源码路径下的externals文件夹中。

一、源码下载

方式1:通过访问SU2官网下载。

方式2:通过git下载。

             使用命令行跳转到需要存储SU2源码的文件夹,如E:\software\SU2

cd /mnt/e/software/SU2

             命令行输入:

git clone https://github.com/su2code/SU2.git

二、解压缩(通过方式1下载源码.zip格式)

unzip SU2.zip

三、构建编译所需的配置文件

在解压缩后的文件夹内,开始构建编译配置文件,可以选择默认配置或自定义配置。

构建1:默认配置

./meson.py build

可以通过configure参数查看所有编译缺省配置及其对应的功能介绍。

./meson.py configure

构建2:自定义

本人需要配置支持mpi的并行SU2,但通过添加--Dwith-mpi选项后,构建时会报错,提示未找到mpicc/mpicxx。实际情况是已经安装mpich,不知为何未找到。于是使用-Dcustom-mpi选项强制使用自定义mpi,并对meson.build文件进行修改,可以成功重新构建。同时,可以通过--prefix指定安装路径。

./meson.py build -Dcustom-mpi=true -Dwith-mpi=enabled --prefix=/mnt/e/SU2

如果构建失败或需要开启其它配置选项,可通过添加--reconfigure选项进行重新构建。

./meson.py build --reconfigure -Dcustom-mpi=true -Dwith-mpi=enabled --prefix=/mnt/e/SU2

PS:使用--custom-mpi选项后,对meson.build文件修改如下。根据读者自己的mpi安装路径修改mpi_dep的值,将包含mpi.h和libmpi.so的路径添加进去,并增加link选项,开启“-lmpi”库链接,才可以确保编译过程中正确链接mpi相关文件。

# If custom mpi mode is enabled, include and library pathes for MPI have to be set manually to env variables
if get_option('custom-mpi')
  mpi_dep = [declare_dependency(include_directories: ['/usr/include/x86_64-linux-gnu/mpich','/usr/lib/x86_64-linux-gnu'],link_args:'-lmpi')]
  mpi = true

配置成功会显示下列信息:

Message: -------------------------------------------------------------------------
         |    ___ _   _ ___                                                      |
         |   / __| | | |_  )   Release 8.0.1 "Harrier"                           |
         |   \__ \ |_| |/ /                                                      |
         |   |___/\___//___|   Meson Configuration Summary                       |
         |                                                                       |
         -------------------------------------------------------------------------

         Option          Value
         ---------------------
         TecIO:          true
         CGNS:           true
         AD (reverse):   false
         AD (forward):   false
         Python Wrapper: false
         Intel-MKL:      false
         OpenBlas:       false
         PaStiX:         false
         Mixed Float:    false
         libROM:         false
         CoolProp:       false
         MLPCpp:         false

         Please be sure to add the $SU2_HOME and $SU2_RUN environment variables,
         and update your $PATH (and $PYTHONPATH if applicable) with $SU2_RUN

         Based on the input to this configuration, add these lines to your .bashrc file:

         export SU2_RUN=/mnt/e/SU2/bin
         export SU2_HOME=/mnt/e/SU2-master
         export PATH=$PATH:$SU2_RUN
         export PYTHONPATH=$PYTHONPATH:$SU2_RUN

         Use './ninja -C build install' to compile and install SU2

Build targets in project: 17

SU2 8.0.1 "Harrier"

  User defined options
    prefix    : /mnt/e/SU2
    custom-mpi: true
    with-mpi  : enabled

Found ninja-1.10.0.git at /mnt/e/SU2-master/ninja

四、编译安装

使用如下命令进行编译:

 ./ninja -C build install

安装完成后会显示:

Installing SU2_CFD/src/SU2_CFD to /mnt/e/SU2/bin
Installing SU2_DEF/src/SU2_DEF to /mnt/e/SU2/bin
Installing SU2_DOT/src/SU2_DOT to /mnt/e/SU2/bin
Installing SU2_GEO/src/SU2_GEO to /mnt/e/SU2/bin
Installing SU2_SOL/src/SU2_SOL to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/continuous_adjoint.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/compute_uncertainty.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/finite_differences.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/mesh_deformation.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/parallel_computation.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/parallel_computation_fsi.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/shape_optimization.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/merge_solution.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/set_ffd_design_var.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/compute_polar.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/discrete_adjoint.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/direct_differentiation.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/fsi_computation.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/SU2_CFD.py to /mnt/e/SU2/bin
Installing /mnt/e/SU2-master/SU2_PY/SU2/__init__.py to /mnt/e/SU2/bin/SU2
Installing /mnt/e/SU2-master/SU2_PY/SU2/eval/design.py to /mnt/e/SU2/bin/SU2/eval
Installing /mnt/e/SU2-master/SU2_PY/SU2/eval/functions.py to /mnt/e/SU2/bin/SU2/eval
Installing /mnt/e/SU2-master/SU2_PY/SU2/eval/gradients.py to /mnt/e/SU2/bin/SU2/eval
Installing /mnt/e/SU2-master/SU2_PY/SU2/eval/__init__.py to /mnt/e/SU2/bin/SU2/eval
Installing /mnt/e/SU2-master/SU2_PY/SU2/io/config.py to /mnt/e/SU2/bin/SU2/io
Installing /mnt/e/SU2-master/SU2_PY/SU2/io/config_options.py to /mnt/e/SU2/bin/SU2/io
Installing /mnt/e/SU2-master/SU2_PY/SU2/io/data.py to /mnt/e/SU2/bin/SU2/io
Installing /mnt/e/SU2-master/SU2_PY/SU2/io/filelock.py to /mnt/e/SU2/bin/SU2/io
Installing /mnt/e/SU2-master/SU2_PY/SU2/io/redirect.py to /mnt/e/SU2/bin/SU2/io
Installing /mnt/e/SU2-master/SU2_PY/SU2/io/state.py to /mnt/e/SU2/bin/SU2/io
Installing /mnt/e/SU2-master/SU2_PY/SU2/io/tools.py to /mnt/e/SU2/bin/SU2/io
Installing /mnt/e/SU2-master/SU2_PY/SU2/io/historyMap.py to /mnt/e/SU2/bin/SU2/io
Installing /mnt/e/SU2-master/SU2_PY/SU2/io/__init__.py to /mnt/e/SU2/bin/SU2/io
Installing /mnt/e/SU2-master/SU2_PY/SU2/opt/project.py to /mnt/e/SU2/bin/SU2/opt
Installing /mnt/e/SU2-master/SU2_PY/SU2/opt/scipy_tools.py to /mnt/e/SU2/bin/SU2/opt
Installing /mnt/e/SU2-master/SU2_PY/SU2/opt/__init__.py to /mnt/e/SU2/bin/SU2/opt
Installing /mnt/e/SU2-master/SU2_PY/SU2/run/adjoint.py to /mnt/e/SU2/bin/SU2/run
Installing /mnt/e/SU2-master/SU2_PY/SU2/run/deform.py to /mnt/e/SU2/bin/SU2/run
Installing /mnt/e/SU2-master/SU2_PY/SU2/run/direct.py to /mnt/e/SU2/bin/SU2/run
Installing /mnt/e/SU2-master/SU2_PY/SU2/run/interface.py to /mnt/e/SU2/bin/SU2/run
Installing /mnt/e/SU2-master/SU2_PY/SU2/run/merge.py to /mnt/e/SU2/bin/SU2/run
Installing /mnt/e/SU2-master/SU2_PY/SU2/run/geometry.py to /mnt/e/SU2/bin/SU2/run
Installing /mnt/e/SU2-master/SU2_PY/SU2/run/projection.py to /mnt/e/SU2/bin/SU2/run
Installing /mnt/e/SU2-master/SU2_PY/SU2/run/__init__.py to /mnt/e/SU2/bin/SU2/run
Installing /mnt/e/SU2-master/SU2_PY/SU2/util/bunch.py to /mnt/e/SU2/bin/SU2/util
Installing /mnt/e/SU2-master/SU2_PY/SU2/util/filter_adjoint.py to /mnt/e/SU2/bin/SU2/util
Installing /mnt/e/SU2-master/SU2_PY/SU2/util/lhc_unif.py to /mnt/e/SU2/bin/SU2/util
Installing /mnt/e/SU2-master/SU2_PY/SU2/util/misc.py to /mnt/e/SU2/bin/SU2/util
Installing /mnt/e/SU2-master/SU2_PY/SU2/util/mp_eval.py to /mnt/e/SU2/bin/SU2/util
Installing /mnt/e/SU2-master/SU2_PY/SU2/util/ordered_bunch.py to /mnt/e/SU2/bin/SU2/util
Installing /mnt/e/SU2-master/SU2_PY/SU2/util/ordered_dict.py to /mnt/e/SU2/bin/SU2/util
Installing /mnt/e/SU2-master/SU2_PY/SU2/util/plot.py to /mnt/e/SU2/bin/SU2/util
Installing /mnt/e/SU2-master/SU2_PY/SU2/util/polarSweepLib.py to /mnt/e/SU2/bin/SU2/util
Installing /mnt/e/SU2-master/SU2_PY/SU2/util/which.py to /mnt/e/SU2/bin/SU2/util
Installing /mnt/e/SU2-master/SU2_PY/SU2/util/switch.py to /mnt/e/SU2/bin/SU2/util
Installing /mnt/e/SU2-master/SU2_PY/SU2/util/__init__.py to /mnt/e/SU2/bin/SU2/util
Installing /mnt/e/SU2-master/SU2_PY/FSI_tools/__init__.py to /mnt/e/SU2/bin/FSI_tools
Installing /mnt/e/SU2-master/SU2_PY/FSI_tools/FSIInterface.py to /mnt/e/SU2/bin/FSI_tools
Installing /mnt/e/SU2-master/SU2_PY/FSI_tools/FSI_config.py to /mnt/e/SU2/bin/FSI_tools
Installing /mnt/e/SU2-master/SU2_PY/SU2_Nastran/__init__.py to /mnt/e/SU2/bin/SU2_Nastran
Installing /mnt/e/SU2-master/SU2_PY/SU2_Nastran/pysu2_nastran.py to /mnt/e/SU2/bin/SU2_Nastran

五、配置环境变量

配置环境变量后,可以在任意路径下调用SU2相关应用。

在~/.bashrc文件的最后添加:

export SU2_RUN="/mnt/e/SU2/bin"
export SU2_HOME="/mnt/e/SU2-master"
export PATH=$PATH:$SU2_RUN
export PYTHONPATH=$SU2_RUN:$PYTHONPATH

使用source使添加生效。

source ~/.bashrc

六、软件使用及测试

SU2_CFD通过读取算例的.cvg配置文件和.su2网格文件,可以通过SU2安装包中自带的inv_NACA0012算例进行测试。该算例位于E:\SU2-master\QuickStart中。通过下述命令进行测试:

SU2_CFD inv_NACA0012.cfg

测试过程:

-------------------------------------------------------------------------
|    ___ _   _ ___                                                      |
|   / __| | | |_  )   Release 8.0.1 "Harrier"                           |
|   \__ \ |_| |/ /                                                      |
|   |___/\___//___|   Suite (Computational Fluid Dynamics Code)         |
|                                                                       |
-------------------------------------------------------------------------
| SU2 Project Website: https://su2code.github.io                        |
|                                                                       |
| The SU2 Project is maintained by the SU2 Foundation                   |
| (http://su2foundation.org)                                            |
-------------------------------------------------------------------------
| Copyright 2012-2024, SU2 Contributors                                 |
|                                                                       |
| SU2 is free software; you can redistribute it and/or                  |
| modify it under the terms of the GNU Lesser General Public            |
| License as published by the Free Software Foundation; either          |
| version 2.1 of the License, or (at your option) any later version.    |
|                                                                       |
| SU2 is distributed in the hope that it will be useful,                |
| but WITHOUT ANY WARRANTY; without even the implied warranty of        |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
| Lesser General Public License for more details.                       |
|                                                                       |
| You should have received a copy of the GNU Lesser General Public      |
| License along with SU2. If not, see <http://www.gnu.org/licenses/>.   |
-------------------------------------------------------------------------

Parsing config file for zone 0

----------------- Physical Case Definition ( Zone 0 ) -------------------
Compressible Euler equations.
Mach number: 0.8.
Angle of attack (AoA): 1.25 deg, and angle of sideslip (AoS): 0 deg.
No restart solution, use the values at infinity (freestream).
Dimensional simulation.
The reference area is 1 m^2.
The semi-span will be computed using the max y(3D) value.
The reference length is 1 m.
Reference origin for moment evaluation is (0.25, 0, 0).
Surface(s) where the force coefficients are evaluated: airfoil.

Surface(s) where the objective function is evaluated: airfoil.
Surface(s) plotted in the output file: airfoil.
Surface(s) affected by the design variables: airfoil.
Input mesh file name: mesh_NACA0012_inv.su2

测试完成后,在当前文件夹中生成测试结果文件:

可以通过Tecplot等后处理软件查看计算结果flow.vtu文件:

  • 24
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

猿何试Bug个踌

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值