何度か OpenFOAMを installしたが、 チュートリアル動作までは到達せず。
そんな中、 redhat · Wiki · Development / openfoam · GitLab にて
This information unfortunately no longer applies to CentOS-9/RedHat-9. The PowerTools repository has been replaced with a CBR repository with much limited functionality. In the process, they have removed the metis and scotch libraries which are essential for domain decomposition!
という記載を見つけましたので、
OracleLinux8 on WSL2 に OpenFOAM CFD版 ver.2312 を yumでinstallすることに
目次
Oracle Linux 関連
install Oracle Linux 8.7
CMD> wsl --install OracleLinux_8_7 Installing, this may take a few minutes... Please create a default UNIX user account. The username does not need to match your Windows username. For more information visit: https://aka.ms/wslusers Enter new UNIX username: end0tknr Changing password for user end0tknr. New password: Retype new password: passwd: all authentication tokens updated successfully. Installation successful!
systemd & sshd の有効化
/etc/wsl.conf を以下の内容で作成後、OracleLinux再起動
$ sudo vi /etc/wsl.conf [boot] systemd=true
CMD> wsl --terminate OracleLinux_8_7 CMD> wsl -d OracleLinux_8_7 $ ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 07:16 ? 00:00:00 /sbin/init root 2 1 0 07:16 ? 00:00:00 /init <略> root 30 1 0 07:18 ? 00:00:00 /usr/lib/systemd/systemd-journald <略>
最後にsystemctlでsshdを有効化
$ sudo systemctl enable sshd $ sudo systemctl start sshd
IPアドレスの固定
wsl上のoracle linuxはdefaultでは起動する度にipアドレスが変更され、 sshやsmbでの接続が手間ですので、固定します。
まず、oracle linux側で割当てられているipを確認
$ ip a <略> 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:15:5d:f4:52:da brd ff:ff:ff:ff:ff:ff inet 172.18.129.236/20 brd 172.18.143.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::215:5dff:fef4:52da/64 scope link valid_lft forever preferred_lft forever
次に、power shellを管理者モードで起動し、 vEthernet (WSL)の ifIndex を確認した上で、固定ipを設定。
参考url
PS> Get-NetAdapter -IncludeHidden Name InterfaceDescription ifIndex <略> ---- -------------------- ------- : ローカル エリア接続* 7 WAN Miniport (PPPOE) 22 <略> vEthernet (WSL (Hyper-... Hyper-V Virtual Ethernet Adapter 24 <略> vSwitch (WSL (Hyper-V ... Hyper-V Virtual Switch Extension Ada... 10 <略> <略>
PS> New-NetIPAddress -IPAddress 172.18.129.236 -PrefixLength 24 -InterfaceIndex 24 IPAddress : 172.18.129.236 InterfaceIndex : 24 InterfaceAlias : vEthernet (WSL (Hyper-V firewall)) AddressFamily : IPv4 Type : Unicast PrefixLength : 24 PrefixOrigin : Manual SuffixOrigin : Manual AddressState : Tentative ValidLifetime : PreferredLifetime : SkipAsSource : False PolicyStore : ActiveStore
IPアドレス固定の自動化
先程、固定したipはpcの停止時に無効化されますので、 ps1ファイルとタスクスケジューラでip固定の自動化を行います
CMD> vi c:/Users/end0t/local/AddIPAddress.ps1 New-NetIPAddress -IPAddress 172.18.129.236 -PrefixLength 24 -InterfaceIndex 24
プログラムスクリプト | powershell.exe |
引数の追加 | -ExecutionPolicy Bypass c:\Users\end0t\local\AddIPAddress.ps1 |
開始 | 空欄 |
install samba
$ sudo yum install samba $ sudo systemctl enable smb $ sudo systemctl start smb $ sudo pdbedit -a end0tknr new password: retype new password: Unix username: end0tknr NT username: Account Flags: [U ] User SID: S-1-5-21-3605739558-1094150744-591740496-1000 Primary Group SID: S-1-5-21-3605739558-1094150744-591740496-513 Full Name: Home Directory: \\A64-WSL\end0tknr HomeDir Drive: Logon Script: Profile Path: \\A64-WSL\end0tknr\profile Domain: A64-WSL <略>
OracleLinuxの停止
CMD> wsl --terminate OracleLinux_8_7 CMD> wsl --list --verbose NAME STATE VERSION * OracleLinux_8_7 Stopped 2
OpenFOAM関連のインストール
参考url
yum install
$ sudo yum install dnf-plugins-core $ sudo yum config-manager --set-enabled ol8_codeready_builder $ sudo yum install epel-release $ sudo dnf copr enable openfoam/openfoam $ sudo yum install openfoam-selector $ sudo yum install openfoam2312-default
OpenFOAM付属のcavity(空洞)チュートリアル実行
config by bashrc
$ source /usr/lib/openfoam/openfoam2312/etc/bashrc $ which blockMesh /usr/lib/openfoam/openfoam2312/platforms/linux64GccDPInt32Opt/bin/blockMesh
copy tutorial files
$ cd ~/tmp $ cp -r /usr/lib/openfoam/openfoam2312/tutorials/incompressible/icoFoam/cavity/cavity . $ cd cavity $ tree . |-- 0 | |-- U | `-- p |-- constant | `-- transportProperties `-- system |-- PDRblockMeshDict |-- blockMeshDict |-- controlDict |-- decomposeParDict |-- fvSchemes `-- fvSolution
メッシュ作成
$ pwd /home/end0tknr/tmp/cavity $ blockMesh /*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2312 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Build : _c39a0f64-20231220 OPENFOAM=2312 version=2312 Arch : "LSB;label=32;scalar=64" Exec : blockMesh Date : Jan 02 2024 Time : 16:15:07 Host : a64 PID : 796 I/O : uncollated Case : /home/end0tknr/tmp/cavity nProcs : 1 trapFpe: Floating point exception trapping enabled (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 5, maxFileModificationPolls 20) allowSystemOperations : Allowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Creating block mesh from "system/blockMeshDict" Creating block edges No non-planar block faces defined Creating topology blocks Creating topology patches - from boundary section Creating block mesh topology - scaling/transform applied later Check topology Basic statistics Number of internal faces : 0 Number of boundary faces : 6 Number of defined boundary faces : 6 Number of undefined boundary faces : 0 Checking patch -> block consistency Creating block offsets Creating merge list (topological search)... Creating polyMesh from blockMesh Creating patches Creating cells Creating points with scale (0.1 0.1 0.1) Block 0 cell size : i : 0.005 .. 0.005 j : 0.005 .. 0.005 k : 0.01 .. 0.01 No patch pairs to merge Writing polyMesh with 0 cellZones ---------------- Mesh Information ---------------- boundingBox: (0 0 0) (0.1 0.1 0.01) nPoints: 882 nCells: 400 nFaces: 1640 nInternalFaces: 760 ---------------- Patches ---------------- patch 0 (start: 760 size: 20) name: movingWall patch 1 (start: 780 size: 60) name: fixedWalls patch 2 (start: 840 size: 800) name: frontAndBack End
ソルバ実行
$ pwd /home/end0tknr/tmp/cavity $ icoFoam /*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2312 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Build : _c39a0f64-20231220 OPENFOAM=2312 version=2312 Arch : "LSB;label=32;scalar=64" Exec : icoFoam Date : Jan 02 2024 Time : 16:17:33 Host : a64 PID : 797 I/O : uncollated Case : /home/end0tknr/tmp/cavity nProcs : 1 trapFpe: Floating point exception trapping enabled (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 5, maxFileModificationPolls 20) allowSystemOperations : Allowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0 PISO: Operating solver in PISO mode Reading transportProperties Reading field p Reading field U Reading/calculating face flux field phi Starting time loop Time = 0.005 Courant Number mean: 0 max: 0 smoothSolver: Solving for Ux, Initial residual = 1, Final residual = 8.90511e-06, No Iterations 19 smoothSolver: Solving for Uy, Initial residual = 0, Final residual = 0, No Iterations 0 DICPCG: Solving for p, Initial residual = 1, Final residual = 0.0492854, No Iterations 12 time step continuity errors : sum local = 0.000466513, global = -1.79995e-19, cumulative = -1.79995e-19 DICPCG: Solving for p, Initial residual = 0.590864, Final residual = 2.65225e-07, No Iterations 35 time step continuity errors : sum local = 2.74685e-09, global = -2.6445e-19, cumulative = -4.44444e-19 ExecutionTime = 0.01 s ClockTime = 0 s Time = 0.01 Courant Number mean: 0.0976825 max: 0.585607 smoothSolver: Solving for Ux, Initial residual = 0.160686, Final residual = 6.83031e-06, No Iterations 19 smoothSolver: Solving for Uy, Initial residual = 0.260828, Final residual = 9.65939e-06, No Iterations 18 DICPCG: Solving for p, Initial residual = 0.428925, Final residual = 0.0103739, No Iterations 22 time step continuity errors : sum local = 0.000110788, global = 3.77194e-19, cumulative = -6.72498e-20 DICPCG: Solving for p, Initial residual = 0.30209, Final residual = 5.26569e-07, No Iterations 33 time step continuity errors : sum local = 6.61987e-09, global = -2.74872e-19, cumulative = -3.42122e-19 ExecutionTime = 0.01 s ClockTime = 0 s <略> Time = 0.495 Courant Number mean: 0.222158 max: 0.852134 smoothSolver: Solving for Ux, Initial residual = 2.43518e-07, Final residual = 2.43518e-07, No Iterations 0 smoothSolver: Solving for Uy, Initial residual = 5.33314e-07, Final residual = 5.33314e-07, No Iterations 0 DICPCG: Solving for p, Initial residual = 5.25763e-07, Final residual = 5.25763e-07, No Iterations 0 time step continuity errors : sum local = 6.11228e-09, global = 1.51821e-18, cumulative = 1.09644e-17 DICPCG: Solving for p, Initial residual = 7.01015e-07, Final residual = 7.01015e-07, No Iterations 0 time step continuity errors : sum local = 7.5484e-09, global = -4.1723e-19, cumulative = 1.05471e-17 ExecutionTime = 0.06 s ClockTime = 0 s Time = 0.5 Courant Number mean: 0.222158 max: 0.852134 smoothSolver: Solving for Ux, Initial residual = 2.3091e-07, Final residual = 2.3091e-07, No Iterations 0 smoothSolver: Solving for Uy, Initial residual = 5.0684e-07, Final residual = 5.0684e-07, No Iterations 0 DICPCG: Solving for p, Initial residual = 8.63844e-07, Final residual = 8.63844e-07, No Iterations 0 time step continuity errors : sum local = 8.8828e-09, global = 4.94571e-19, cumulative = 1.10417e-17 DICPCG: Solving for p, Initial residual = 9.59103e-07, Final residual = 9.59103e-07, No Iterations 0 time step continuity errors : sum local = 9.66354e-09, global = 1.13175e-18, cumulative = 1.21735e-17 ExecutionTime = 0.06 s ClockTime = 0 s End
ParaView表示用file作成
$ pwd /home/end0tknr/tmp/cavity $ touch cavity.foam
ParaViewで表示
ParaViewの操作方法は、まだ理解していませんが、 とりあえずの表示は以下のstep