2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

OpenFOAMをM1 Macでビルドしてインストール

Last updated at Posted at 2022-03-12

M1 MacでDocker使ってインストールするのではなくて,ビルドしてインストール方法のまとめ。

基本的にはMac用のpatchが公開されているので,それを使ってビルドすれば大丈夫です。

こことか
https://github.com/mrklein/openfoam-os-x
こことか
https://github.com/BrushXue/OpenFOAM-AppleM1

試しにOpenFOAM-8のビルド。
https://github.com/mrklein/openfoam-os-x
のOpenFOAM-8用のpatch使ったらビルドできました。

試しにblockMeshを実行すると

$ blockMesh 
dyld[8948]: symbol not found in flat namespace '_ompi_mpi_byte'
Abort trap: 6

ライブラリが見つからずに怒られました。Homebrewでopen MPIをインストールしたので,以下のライブラリ設定したら,実行できました。

export DYLD_LIBRARY_PATH=/opt/homebrew/lib

追記

export DYLD_LIBRARY_PATH=/opt/homebrew/libを設定しないと,ライブラリが見つからない件ですが,https://github.com/mrklein/openfoam-os-x のpatchの内容を一部修正することで,ライブラリのパス設定なしで動くようになりました。

etc/config.sh/mac/functionsの一部を以下のようにします。

    # Prefix to DYLD_LIBRARY_PATH and FOAM_DYLD_LIBRARY_PATH                    
    _foamAddLib ()                                                              
    {                                                                           
        while [ $# -ge 1 ]                                                      
        do                                                                      
            export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$1                      
            export FOAM_DYLD_LIBRARY_PATH=$FOAM_DYLD_LIBRARY_PATH:$1            
            shift                                                               
        done                                                                    
    }                       

オリジナルでは

    # Prefix to DYLD_LIBRARY_PATH and FOAM_DYLD_LIBRARY_PATH
    _foamAddLib ()
    {
        while [ $# -ge 1 ]
        do
            export DYLD_LIBRARY_PATH=$1:$DYLD_LIBRARY_PATH
            export FOAM_DYLD_LIBRARY_PATH=$1:$FOAM_DYLD_LIBRARY_PATH
            shift
        done
    }

でした。

追記2

OpenFOAM 8の場合,並列計算しようとすると計算が落ちます。
https://develop.openfoam.com/Development/openfoam/-/issues/1661
この辺りをみるとMacのSIPを無効にすればいいとかありますが,セキュリティ的にあれなのでやってません。
とりあえず,並列なしなら計算できるので,保留してます。

一方で,v2106ならここにあるようにパッチをあてれば並列計算可能な状態になります。
https://ttsyshmz.github.io/howtoFoam/post/build-openfoam-v2106-on-m1mac/

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?