3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

LBM流体解析ツールOpenLBの活用【01:導入方法と動作確認】

Last updated at Posted at 2025-10-24

この文書では、Ubuntu24.04上でLBM(格子ボルツマン法)流体解析ツールOpenLBを活用する方法を紹介します。

「OpenLB」は、格子ボルツマン法(LBM)に基づくオープンソースの流体解析ライブラリで、2007年にカールスルーエ工科大学(KIT)の研究者によって開発が始まりました。主にMathias J. Krause博士らのチームが中心となって開発・保守を続けています。C++で実装され、高い拡張性と並列計算性能を持ち、流体解析や熱・粒子輸送など多様な分野の研究・教育に利用されています。
なお、説明にもあるように流体解析ライブラリですので、アプリケーションとして入力ファイルを用意して解析を実行するのではなく、必要とするLBMアプリケーションをC++で独自に開発して利用します。

OpenLB公式サイト
https://www.openlb.net/

OpenLBを利用する環境

基本的にOpenLBは、Linux系OSでビルドして利用します。ここでは、Windows11のWSL2上での、Ubuntu24.04LTSで試してみます。OracleVirtualBoxなどの仮想環境や実機にインストールされたUbuntuでも同様だと思います。具体的には、以下の解説文書を参考にしています。と言うよりこの文書を下敷きに自分の手順をまとめました。
https://www.openlb.net/wp-content/uploads/2024/05/TR5-v2.pdf

なお、MacOSの場合には、Homebrewを用いることで、以下の手順で利用できるようです。
https://www.openlb.net/wp-content/uploads/2025/05/olb-tr6V2.pdf

さらに、WSL2上のUbuntuや実機のUbuntuでは、PCのNVIDIA GPUを利用することができて、それを活用して、OpenLBの高速計算も可能なようです。
https://www.openlb.net/wp-content/uploads/2023/03/olb-tr7.pdf

OpenLBを構築する手順

解説文書をもとに、構築する手順を説明します。WSL2上のUbuntuは、以下の状態です。

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.3 LTS
Release:        24.04
Codename:       noble

Ubuntuの更新とパッケージの追加

以下のように、更新を完了して、最新の状態にしておきます。

dalab@dalab2502nb02:~$ sudo apt update
Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
(省略)
1 package can be upgraded. Run 'apt list --upgradable' to see it.
dalab@dalab2502nb02:~$ sudo apt upgrade
Reading package lists... Done
(省略)
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

構築に必要なパッケージの追加

コンパイルツールとOpenMPI並列環境を導入します。

$ sudo apt install g++ make
Reading package lists... Done
(省略)
Processing triggers for man-db (2.12.0-4build2) ...
$ sudo apt install openmpi-bin openmpi-doc libopenmpi-dev
Reading package lists... Done
(省略)
Processing triggers for man-db (2.12.0-4build2) ...

インストールファイルの入手

Windows11で、以下のダウンロードページに接続する。
https://www.openlb.net/download/

執筆時点2025/05/16で最新版「1.8–1」の、「olb-1.8r1.tgz」をダウンロードする。Windows11のダウンロードフォルダにファイル「release-1.8.1.tar.gz」が保存される。

このファイルを、ファイルブラウザの左端の「Linux」を用いて、WSL2上のUbuntuに移動します。

Ubuntuのホームディレクトリにファイル「release-1.8.1.tar.gz」が確認できます。なお「...Identifier」のファイルは、Windows側で削除してかまいません。

$ ls -l
-rw-r--r-- 1 dalab dalab 3101969 Oct 25 04:36 release-1.8.1.tar.gz

OpenLBの作業用ディレクトリ「OpenLBwork」を作って、このインストールファイルを移動させ、tarコマンドで展開します。

$ mkdir OpenLBwork
$ mv release-1.8.1.tar.gz OpenLBwork/
$ cd OpenLBwork/
$ ls
release-1.8.1.tar.gz
$ tar xvfz release-1.8.1.tar.gz
$ ls
release-1.8.1  release-1.8.1.tar.gz
$ cd release-1.8.1/
$ ls
AUTHORS.txt       LICENSE    config            default.mk         examples    flake.nix  src
CITATION.cff      Makefile   config.mk         default.single.mk  external    rules.mk
CONTRIBUTORS.txt  README.md  default.mixed.mk  doc                flake.lock  script

Makefileがあるので、makeコマンド一発でビルドしてみます。

$ make
make CXX='g++' CC='gcc' -C external
(省略)
ar rc build/lib/libolbcore.a src/communication/mpiManager.o src/communication/ompManager.o src/core/olbInit.o src/core/expr.o src/io/ostreamManager.o

取り敢えずはエラーは、無いみたいです。例題の2次元Cavity流れのディレクトリに移動して、makeしてみます。

$ cd examples/laminar/cavity2d
$ ls
Makefile  cavity2d.cpp  cavity2d.xml  description_cavity2d.xml
$ make
make -C ../../../external
(省略)
g++ cavity2d.o -o cavity2d -lolbcore -L../../../external/lib -lpthread -lz -ltinyxml2 -L../../../build/lib
$ ls
Makefile  cavity2d  cavity2d.cpp  cavity2d.d  cavity2d.o  cavity2d.xml  description_cavity2d.xml

実行ファイル「cavity2d」ができたので、実行してみます。

$ ./cavity2d
[ThreadPool] Sucessfully initialized, numThreads=1
[Directories] Directory ./tmp/ created.
(省略)
[Timer] ----------------Summary:Timer----------------
[Timer] measured time (rt) : 14.676s
[Timer] measured time (cpu): 14.187s
[Timer] ---------------------------------------------
$ ls
Makefile  cavity2d.cpp  cavity2d.o    description_cavity2d.xml
cavity2d  cavity2d.d    cavity2d.xml  tmp

解析結果として、ディレクトリ「tmp」が作られているので、その内容を確認します。

$ cd tmp
$ ls
cavity2d.dat  gnuplotData  imageData  introspectionData  vtkData
$ cd vtkData/
$ ls
cavity2dvtk.pvd       discreteNormalType_iT0000000.vtm  rank_iT0000000.vtm
cuboid_iT0000000.vtm  discreteNormal_iT0000000.vtm
data                  geometry.pvd

WindowsのParaViewを用いて、可視化ファイル「cavity2dvtk.pvd」を開くと、解析結果が確認できます。

以上で、基本的な動作確認ができました。OpenLBには、以下の充実したマニュアルがあるので、それを参考にしながら活用手順を紹介してゆきます。
https://www.openlb.net/wp-content/uploads/2025/08/olb_ug-1.8r0.pdf

3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?