Introduction
Yesterday, I installed OpenFOAM and ParaView and tried to simulate and visualize a Poiseuille flow (Hagen-poiseuille flow). This time, I followed the book and ran “cavity” from the OpenFOAM built-in tutorial.
Sources.
- OpenFOAM walkthrough - I bought the Kindle version for the first time last night because I was looking online and wanted the book to understand OpenFOAM properly. It’s cheaper than paperback books and I can read it right away. I also used this book as a reference to implement “cavity”, which I will try this time.
Simulation with OpenFOAM
The simulation was run according to “Chapter 3 Tutorial Cases” in the source book. Please refer to yesterday’s post for the operating environment.
Copy the tutorial to the work area
Copy the “cavity” directory under the “~/tut” directory as follows.
foam@382d42eb836b:~/tut$ cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity/cavity .
foam@382d42eb836b:~/tut$ openfoam2406
openfoam = /usr/lib/openfoam/openfoam2406
* Using: OpenFOAM-v2406 (2406) - visit www.openfoam.com
* Build: _9bfe8264-20241212 (patch=241212)
* Arch: label=32;scalar=64
* Platform: linux64GccDPInt32Opt (mpi=sys-openmpi)
OpenFOAM shell session - use 'exit' to quit
openfoam2406:~/tut/
foam$ cd cavity
openfoam2406:~/tut/cavity/
foam$ ls -l
total 12
drwxr-xr-x 2 foam foam 4096 Jan 6 00:03 0
drwxr-xr-x 2 foam foam 4096 Jan 6 00:03 constant
drwxr-xr-x 2 foam foam 4096 Jan 6 00:03 system
openfoam2406:~/tut/cavity/
foam$ ls -l */*
-rw-r--r-- 1 foam foam 1143 Jan 6 00:03 0/U
-rw-r--r-- 1 foam foam 1104 Jan 6 00:03 0/p
-rw-r--r-- 1 foam foam 867 Jan 6 00:03 constant/transportProperties
-rw-r--r-- 1 foam foam 1262 Jan 6 00:03 system/PDRblockMeshDict
-rw-r--r-- 1 foam foam 1447 Jan 6 00:03 system/blockMeshDict
-rw-r--r-- 1 foam foam 1188 Jan 6 00:03 system/controlDict
-rw-r--r-- 1 foam foam 917 Jan 6 00:03 system/decomposeParDict
-rw-r--r-- 1 foam foam 1210 Jan 6 00:03 system/fvSchemes
-rw-r--r-- 1 foam foam 1314 Jan 6 00:03 system/fvSolution
Create a mesh
The definition of the mesh to be created is described in system/blockMeshDict. Read the description as it follows in the book. After reading, create the mesh as follows
foam$ blockMesh
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2406 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : _9bfe8264-20241212 OPENFOAM=2406 patch=241212 version=2406
Arch : "LSB;label=32;scalar=64"
Exec : blockMesh
Date : Jan 06 2025
Time : 01:16:51
Host : 382d42eb836b
PID : 867
I/O : uncollated
Case : /home/foam/tut/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
Running the Calculation
Execute the solver as follows
foam$ icoFoam
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2406 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : _9bfe8264-20241212 OPENFOAM=2406 patch=241212 version=2406
Arch : "LSB;label=32;scalar=64"
Exec : icoFoam
Date : Jan 06 2025
Time : 02:49:03
Host : 382d42eb836b
PID : 868
I/O : uncollated
Case : /home/foam/tut/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
*** omitted in the middle ***
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.31 s ClockTime = 2 s
End
post-processing
Create a FOAM file to be read by ParaView as follows
foam$ touch cavity.foam
foam$ ls -l
total 32
drwxr-xr-x 2 foam foam 4096 Jan 6 00:03 0
drwxr-xr-x 3 foam foam 4096 Jan 6 02:49 0.1
drwxr-xr-x 3 foam foam 4096 Jan 6 02:49 0.2
drwxr-xr-x 3 foam foam 4096 Jan 6 02:49 0.3
drwxr-xr-x 3 foam foam 4096 Jan 6 02:49 0.4
drwxr-xr-x 3 foam foam 4096 Jan 6 02:49 0.5
-rw-r--r-- 1 foam foam 0 Jan 6 02:53 cavity.foam
drwxr-xr-x 3 foam foam 4096 Jan 6 01:16 constant
drwxr-xr-x 2 foam foam 4096 Jan 6 00:03 system
Visualization with ParaView
Loading cavity.foam
Start ParaView on my Mac and load the NFS-mounted “cavity.foam” file. The following image is a screenshot of ParaView immediately after loading the file.
Display of velocity field
Screenshot of the velocity vector display with the color map changed in the Color Map Editor according to the source, the number of contour map color coded (to 11), and the velocity vector display.
Summary
As described above, I followed the books mentioned in the sources and performed one tutorial. By following the sequence of steps described in the book, I was able to deepen my understanding of OpenFOAM and ParaView.
I would like to follow one more example from the book to further deepen my understanding.