Skip to content
  • 最新
  • 版块
  • 东岳流体
  • 随机看[请狂点我]
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(不使用皮肤)
  • 不使用皮肤
折叠
CFD中文网

CFD中文网

  1. CFD中文网
  2. OpenFOAM
  3. Ubuntu 20.04 安装 OpenFOAM-v1712

Ubuntu 20.04 安装 OpenFOAM-v1712

已定时 已固定 已锁定 已移动 OpenFOAM
35 帖子 5 发布者 25.5k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
回复
  • 在新帖中回复
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    写于 最后由 李东岳 编辑
    #1

    安装老版本的gcc

    首先,需要安装老版本的g++/gcc:

    sudo gedit /etc/apt/sources.list
    

    添加下面两行:

    deb http://mirrors.aliyun.com/ubuntu/ xenial main
    deb http://mirrors.aliyun.com/ubuntu/ xenial universe
    

    然后:

    sudo apt-get update
    sudo apt-get install g++-5 gcc-5
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 100
    sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 100
    

    现在,就应该默认选择gcc-5,g++-5了。接着,顺着编译OpenFOAM-v1712就好。

    新版ubuntu适配

    The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5 NO_PUBKEY 3B4FE6ACC0B21F32
    

    则需要运行:

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
    

    上方代码是后面的两个key

    查看已有的版本:

    ls /usr/bin/gcc*
    ls /usr/bin/g++*
    

    选择版本:

    sudo update-alternatives --config gcc
    

    安装老版本的gfortran

    输入

    sudo gedit /etc/apt/sources.list
    

    添加下面两行:

    deb http://mirrors.aliyun.com/ubuntu/ trusty main
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty universe
    

    然后:

    sudo apt-get update
    sudo apt-get install gfortran-4.7 libgfortran-4.7-dev
    sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-4.7 100
    

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    1 条回复 最后回复
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    写于 最后由 李东岳 编辑
    #2

    另外,低版本Ubuntu安装高版本gcc:

    sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    sudo apt update
    sudo apt install gcc-9  g++-9
    

    如果出现unable to fetch这种错误,再运行一下sudo apt install gcc-9 g++-9

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    1 条回复 最后回复
  • chengan.wangC 离线
    chengan.wangC 离线
    chengan.wang
    写于 最后由 编辑
    #3

    李老师您好,
    我按照您的提示:

    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 100
    

    目前默认gcc-5

    gcc (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413
    Copyright (C) 2015 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    

    我想切换回g9,用命令

    sudo update-alternatives --config gcc
    

    得到:

    There is only one alternative in link group gcc (providing /usr/bin/gcc): /usr/bin/gcc-5
    Nothing to configure.
    

    没有切换提示,咋办?

    我用命令

    ls /usr/bin/gcc*
    
    /usr/bin/gcc    /usr/bin/gcc-ar    /usr/bin/gcc-nm    /usr/bin/gcc-ranlib
    /usr/bin/gcc-5  /usr/bin/gcc-ar-5  /usr/bin/gcc-nm-5  /usr/bin/gcc-ranlib-5
    /usr/bin/gcc-9  /usr/bin/gcc-ar-9  /usr/bin/gcc-nm-9  /usr/bin/gcc-ranlib-9
    

    应该是g9也在的,不知道为啥不能切换,跟百度不一样

    李东岳李 1 条回复 最后回复
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    在 中回复了 chengan.wang 最后由 编辑
    #4

    @chengan-wang 我有时候也遇到过这个问题 来回操作几次就解决了 目前不知道原因 不过还可以不算麻烦

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    chengan.wangC 1 条回复 最后回复
  • chengan.wangC 离线
    chengan.wangC 离线
    chengan.wang
    在 中回复了 李东岳 最后由 编辑
    #5

    @李东岳 谢谢李老师,编译器最后安装成功了,也能切换,但是这种方法安装2.4.0版本还是不对

    李东岳李 1 条回复 最后回复
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    在 中回复了 chengan.wang 最后由 编辑
    #6

    @chengan-wang 2.4版本需要安装gcc/g++-4.8 你试试

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    chengan.wangC 1 条回复 最后回复
  • chengan.wangC 离线
    chengan.wangC 离线
    chengan.wang
    在 中回复了 李东岳 最后由 编辑
    #7

    @李东岳 李老师,我安装官网的方法https://openfoam.org/download/2-4-0-source/,还是不行呀,编译出错。又参考了http://openfoamwiki.net/index.php/Installation/Linux/OpenFOAM-2.4.0/Ubuntu#Ubuntu_18.04,ubuntu18.04的安装方法,也不行。

    李东岳李 1 条回复 最后回复
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    在 中回复了 chengan.wang 最后由 编辑
    #8

    @chengan-wang 你用的低版本g++么,我装的更低版本的openfoam-2.1都没问题呢

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    chengan.wangC Y 2 条回复 最后回复
  • chengan.wangC 离线
    chengan.wangC 离线
    chengan.wang
    在 中回复了 李东岳 最后由 编辑
    #9

    @李东岳 李老师好,我分别用了gcc-4.7、g++-4.7;gcc-4.8、g++-4.8;gcc-5.0、g++-5.0在ubuntu20.04安装of2.4.0,按照官网和wiki都不行。您的安装流程能分享一下么?

    李东岳李 1 条回复 最后回复
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    在 中回复了 chengan.wang 最后由 编辑
    #10

    @chengan-wang log提示什么错误

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    1 条回复 最后回复
  • chengan.wangC 离线
    chengan.wangC 离线
    chengan.wang
    写于 最后由 编辑
    #11

    @李东岳 李老师,编译过程出现了很多错误:

    == Generating build files ==
    Configuring libCGAL
    -- Requested component: MPFR
    -- Requested component: GMP
    libCGAL is configured
    -- Sources for CGAL component library 'CGAL_Core/CMakeLists.txt' detected
    CMake Error at src/CMakeLists.txt:81 (add_subdirectory):
      add_subdirectory given source
      "/home/chengan/OpenFOAM/ThirdParty-2.4.0/CGAL-4.6/src/CGAL_Core/CMakeLists.txt"
      which is not an existing directory.
    Call Stack (most recent call first):
      src/CMakeLists.txt:140 (configure_component)
    
    
    -- Sources for CGAL component library 'CGAL_ImageIO/CMakeLists.txt' detected
    CMake Error at src/CMakeLists.txt:81 (add_subdirectory):
      add_subdirectory given source
      "/home/chengan/OpenFOAM/ThirdParty-2.4.0/CGAL-4.6/src/CGAL_ImageIO/CMakeLists.txt"
      which is not an existing directory.
    Call Stack (most recent call first):
      src/CMakeLists.txt:140 (configure_component)
    
    
    -- Sources for CGAL component library 'CGAL_Qt3/CMakeLists.txt' detected
    CMake Error at src/CMakeLists.txt:81 (add_subdirectory):
      add_subdirectory given source
      "/home/chengan/OpenFOAM/ThirdParty-2.4.0/CGAL-4.6/src/CGAL_Qt3/CMakeLists.txt"
      which is not an existing directory.
    Call Stack (most recent call first):
      src/CMakeLists.txt:140 (configure_component)
    
    
    -- Sources for CGAL component library 'CGAL_Qt4/CMakeLists.txt' detected
    CMake Error at src/CMakeLists.txt:81 (add_subdirectory):
      add_subdirectory given source
      "/home/chengan/OpenFOAM/ThirdParty-2.4.0/CGAL-4.6/src/CGAL_Qt4/CMakeLists.txt"
      which is not an existing directory.
    Call Stack (most recent call first):
      src/CMakeLists.txt:140 (configure_component)
    
    
    -- Sources for CGAL component libraries 'CGAL_Core/CMakeLists.txt;CGAL_ImageIO/CMakeLists.txt;CGAL_Qt3/CMakeLists.txt;CGAL_Qt4/CMakeLists.txt' detected
    == Generating build files (DONE) ==
    
    -- Configuring incomplete, errors occurred!
    See also "/home/chengan/OpenFOAM/ThirdParty-2.4.0/build/linux64Gcc/CGAL-4.6/CMakeFiles/CMakeOutput.log".
    See also "/home/chengan/OpenFOAM/ThirdParty-2.4.0/build/linux64Gcc/CGAL-4.6/CMakeFiles/CMakeError.log".
    + exit 1
    

    还有很多这样的:

    /usr/bin/ld: /home/chengan/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/lib/libtriSurface.so: undefined reference to `yyFlexLexer::yywrap()'
    collect2: error: ld returned 1 exit status
    make[2]: *** [/home/chengan/OpenFOAM/OpenFOAM-2.4.0/wmake/Makefile:150: /home/chengan/OpenFOAM/OpenFOAM-2.4.0/platforms/linux64GccDPOpt/bin/interMixingFoam] Error 1
    make[1]: *** [/home/chengan/OpenFOAM/OpenFOAM-2.4.0/wmake/MakefileApps:39: interFoam] Error 2
    make[1]: Target 'application' not remade because of errors.
    make: *** [/home/chengan/OpenFOAM/OpenFOAM-2.4.0/wmake/MakefileApps:39: multiphase] Error 2
    make: Target 'application' not remade because of errors.
    

    log文件如下:
    log.tar.xz
    希望李老师能百忙之中指点一下!

    李东岳李 1 条回复 最后回复
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    在 中回复了 chengan.wang 最后由 编辑
    #12

    @chengan-wang

    第三方包先不用管 你先在终端输入这个编译openfoam应该没问题了

    https://www.cfd-china.com/topic/4859/yyflex-error

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    chengan.wangC 2 条回复 最后回复
  • chengan.wangC 离线
    chengan.wangC 离线
    chengan.wang
    在 中回复了 李东岳 最后由 编辑
    #13

    @李东岳 谢谢李老师,不过命令报错了

    chengan@chengan-MS-7C80:~/OpenFOAM/OpenFOAM-2.4.0$ find src applications -name "*.L" -type f | xargs sed -i -e 's=(YY_FLEX_SUBMINOR_VERSION)=YY_FLEX_MINOR_VERSION < 6 && \1='
    sed: -e expression #1, char 61: invalid reference \1 on `s' command's RHS
    
    1 条回复 最后回复
  • chengan.wangC 离线
    chengan.wangC 离线
    chengan.wang
    在 中回复了 李东岳 最后由 编辑
    #14

    @李东岳 李老师,我在wiki上找到命令如下:

    find src applications -name "*.L" -type f | xargs sed -i -e 's=\(YY\_FLEX\_SUBMINOR\_VERSION\)=YY_FLEX_MINOR_VERSION < 6 \&\& \1='
    

    这个可以用。

    最终我选择gcc-4.8、g++-4.8编译,目前可以运行icoFoam cavity 算例,似乎编译成功了,但是log文件有2522个错误,不知道算是编译成功了没有:143: ,还是可以将就着用?

    log.zip

    李东岳李 1 条回复 最后回复
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    在 中回复了 chengan.wang 最后由 编辑
    #15

    @chengan-wang 没关系,主要是其中做foamQuad网格的,这个用得少

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    chengan.wangC 1 条回复 最后回复
  • chengan.wangC 离线
    chengan.wangC 离线
    chengan.wang
    在 中回复了 李东岳 最后由 编辑
    #16

    @李东岳 谢谢李老师

    李东岳李 1 条回复 最后回复
  • 李东岳李 在线
    李东岳李 在线
    李东岳 管理员
    在 中回复了 chengan.wang 最后由 编辑
    #17

    @chengan-wang 为什么要用openfoam2.4.?

    http://dyfluid.com/index.html
    需要帮助debug算例的看这个 https://cfd-china.com/topic/8018

    chengan.wangC 1 条回复 最后回复
  • chengan.wangC 离线
    chengan.wangC 离线
    chengan.wang
    在 中回复了 李东岳 最后由 编辑
    #18

    @李东岳 之前用了很久,很多求解器也是基于这个版本改的

    1 条回复 最后回复
  • Y 离线
    Y 离线
    Yu_Tian
    在 中回复了 李东岳 最后由 编辑
    #19

    @李东岳 李老师,求详细的2.1.1的安装教程:140:

    永远学习,永远进步

    1 条回复 最后回复
  • 李东岳李 李东岳 被引用 于这个主题
  • 李东岳李 李东岳 被引用 于这个主题
  • liujmL 离线
    liujmL 离线
    liujm
    写于 最后由 编辑
    #20

    @李东岳 李老师,我看了新版waves2foam的教程,参考这篇帖子的gfortran4安装。指令直接复制到终端,出现了报错:
    76c22eae-984f-437f-a12b-a5ed0446a28e-image.png
    77679983-3eb1-47de-8464-65a3c662d894-image.png
    可以请教一下这该怎么解决吗?
    :papa:

    李东岳李 1 条回复 最后回复

  • 登录

  • 登录或注册以进行搜索。
  • 第一个帖子
    最后一个帖子
0
  • 最新
  • 版块
  • 东岳流体
  • 随机看[请狂点我]