OpenFOAM for MAC(M1)インストールメモ


**初めに**

とりあえずOpenFOAMの下記URLを参考にしました．

参考URL：https://www.openfoam.com/download/openfoam-installation-on-mac-using-docker

これに従って環境を整えます．

***

**Dockerのインストール**

インストール先URL：https://docs.docker.com/docker-for-mac/install/
Mac with Apple chipをクリックするとダウンロードが始まります．

Mac with Apple silicon
You must install Rosetta 2 as some binaries are still Darwin/AMD64. 
To install Rosetta 2 manually from the command line, run the following command:

```
softwareupdate --install-rosetta
```

For more information, see Docker Desktop for Apple silicon.

とあるので，とりあえずターミナルに打ち込みました．

***

**paraviewのインストール**

インストール先URL：https://www.paraview.org/download/
ParaView-5.9.1-RC1-MPI-OSX10.13-Python3.8-64bit.dmg
容量：333.9M
アップデート日：Apr 22 19:04

はじめは別のバージョンのものを入れて起動しなかったので削除し，上記のバージョンをインストールしたところ起動しました．

***

自分用メモです．
よくわからずにターミナルにコマンドを打ち込んでいたので整理します．ここは後で編集します．
実行後，フォルダが見つからないと出ているところは気にしないでください．

```
$ docker run -d -p 80:80 docker/getting-started
```
Unable to find image 'docker/getting-started:latest' locally
latest: Pulling from docker/getting-started
069a56d6d07f: Pull complete 
2c36e9465b53: Pull complete 
cfcc925340bd: Pull complete 
5280a9b3efa9: Pull complete 
83380a3f4dde: Pull complete 
aedf4ca77dae: Pull complete 
e45379b4b21e: Pull complete 
45643c41063c: Pull complete 
Digest: sha256:67944b53f8a7d16b3d9909315f9d557ade12c4ee4083cd98068f9fe6d9995808
Status: Downloaded newer image for docker/getting-started:latest
fd28b27ccfabb2013e3eb5de92c37ed6bec9f17ecc30f05b6f486f45f5d98e68

```
$ installMacOpenFOAM
```
-bash: installMacOpenFOAM: command not found


```
$ ./installMacOpenFOAM
```

-bash: ./installMacOpenFOAM: No such file or directory

```
$ mkdir test_openfoam
$ cd test_openfoam
$ docker container run -ti --rm -v $PWD:/data -w /data cfdengine/openfoam
```

Unable to find image 'cfdengine/openfoam:latest' locally
latest: Pulling from cfdengine/openfoam
f476d66f5408: Pull complete 
8882c27f669e: Pull complete 
d9af21273955: Pull complete 
f5029279ec12: Pull complete 
11fa9d4443a6: Pull complete 
4d850b7bf9e0: Pull complete 
4fcc360f5c4c: Pull complete 
Digest: sha256:68843b12a73c35740a67dcd71adaaf1853529d6c027222677ac9fca2c2746f7f
Status: Downloaded newer image for cfdengine/openfoam:latest
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

```
$ exit
```
exit

```
$ softwareupdate --install-rosetta
```

I have read and agree to the terms of the software license agreement. A list of Apple SLAs may be found here: http://www.apple.com/legal/sla/
Type A and press return to agree: 

```
$ docker container run -ti --rm -v $PWD:/data -w /data cfdengine/openfoam
```
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

```
$ docker build -t image_name:tag_name directory-of-Dockerfile
```
bash: docker: command not found

```
$ chmod +x installMacOpenFOAM
```
/bin/chmod: cannot access 'installMacOpenFOAM': No such file or directory

```
$ docker build -t nishiys/simple_openfoam-extend-4 .
```

bash: docker: command not found

```
$ touch open.foam
$ cd /home/ofuser/workingDir
```

bash: cd: /home/ofuser/workingDir: No such file or directory

```
$ mkdir test_openfoam
$ cd test_openfoam
$ cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity/cavity .
$ cd cavity
$ blockMesh
```

```C++
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  6
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
Build  : 6-e29811f5dff8
Exec   : /opt/openfoam6/platforms/linux64GccDPInt32Opt/bin/blockMesh
Date   : May 05 2021
Time   : 19:10:41
Host   : "477fea91c506"
PID    : 355
I/O    : uncollated
Case   : /data/test_openfoam/cavity
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Creating block mesh from
    "/data/test_openfoam/cavity/system/blockMeshDict"
Creating block edges
No non-planar block faces defined
Creating topology blocks
Creating topology patches

Creating block mesh topology

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 .

Creating polyMesh from blockMesh
Creating patches
Creating cells
Creating points with scale 0.1
    Block 0 cell size :
        i : 0.005 .. 0.005
        j : 0.005 .. 0.005
        k : 0.01 .. 0.01


Writing polyMesh
----------------
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

```

```
$ icoFoam
```

```C++
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  6
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
Build  : 6-e29811f5dff8
Exec   : /opt/openfoam6/platforms/linux64GccDPInt32Opt/bin/icoFoam
Date   : May 05 2021
Time   : 19:10:57
Host   : "477fea91c506"
PID    : 358
I/O    : uncollated
Case   : /data/test_openfoam/cavity
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

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.09 s  ClockTime = 1 s

*
*
*

Time = 0.5

Courant Number mean: 0.22217 max: 0.852137
smoothSolver:  Solving for Ux, Initial residual = 2.30412e-07, Final residual = 2.30412e-07, No Iterations 0
smoothSolver:  Solving for Uy, Initial residual = 5.07964e-07, Final residual = 5.07964e-07, No Iterations 0
DICPCG:  Solving for p, Initial residual = 5.17142e-07, Final residual = 5.17142e-07, No Iterations 0
time step continuity errors : sum local = 6.00672e-09, global = 5.41142e-19, cumulative = -1.09634e-17
DICPCG:  Solving for p, Initial residual = 6.89807e-07, Final residual = 6.89807e-07, No Iterations 0
time step continuity errors : sum local = 7.40846e-09, global = 5.59174e-20, cumulative = -1.09075e-17
ExecutionTime = 0.69 s  ClockTime = 1 s

End
```

```
$ paraFoam
```
FATAL ERROR: The official reader module for OpenFOAM data does not exist on
your system.  This means that the version of ParaView you are using was not
compiled with OpenFOAM, or distributed with a packaged version of OpenFOAM.

For information on packaged versions of OpenFOAM/ParaView and compilation of
OpenFOAM/ParaView, see https://openfoam.org/download

Alternatively, you might be able to view your OpenFOAM data with the reader
module provided with ParaView by running:
    paraFoam -builtin

```
$ paraFoam -case $FOAM_RUN/tutorials/incompressible/icoFoam/cavity/cavity
```

directory does not exist:  '/home/foam/OpenFOAM/-6/run/tutorials/incompressible/icoFoam/cavity/cavity'

Usage: paraFoam [OPTION] [PARAVIEW_OPTION]
options:
  -block            use blockMesh reader  (uses .blockMesh extension)
  -builtin          use VTK builtin OpenFOAM reader  (uses .foam extension)
  -case <dir>       specify alternative case directory, default is the cwd
  -empty            launch ParaView without opening any data files
  -region <name>    specify alternative mesh region
  -touch            only create the file  (eg, .blockMesh, .OpenFOAM, etc)
  -touchAll         create .blockMesh, .OpenFOAM files (and for all regions)
  -help             print the usage

paraview options start with a double dashes

* start paraview 5.6.0 with the OpenFOAM libraries

```
$ touch open.foam
```