The Old-Fashioned blockMesh
BlockMesh is the weapon of choice for directly generating rather simple meshes of channels, pipes, 2D-stuff etc. Those are mostly internal flows. With external flows, life gets tough much quicker. Consider a very simple case of a 3D flow past a cube. You now need this many blocks:
- if the cube sits on the floor: 17,
- when the flow surrounds the whole body: 26,
- a cube, tilted in any direction: [sorry, can’t even wrap my head around that one.]
But the cube itself is as simple as it gets – a single block!
I am aware that one could mesh a single block and then remove the cube from the domain. Since a cube doesn’t have a very interesting engineering application, try doing that with a cylinder (or anythine else, for that matter).
Using blockMesh as a External Flows Model Generator
The model in all of the above cases is still very simple. If it was meshed internally, it would take a single block. And that is the exact idea to use for external flows:
- Create an internal mesh with blockMesh
- export patches of the model as .stl
- use the exported geometry for some proper meshing with snappy or whatever you use.
A Sample Script
In a short summary, this script first calls
generate_model.py which writes a
system/blockMeshDict.model dictionary. Another script,
generate_domain.py generates a
blockMesh is run for both dicts, STL files are extracted from generated geometry and fed into
snappyHexMeshDict for a proper mesh generation.
Note that this is a made-up example. For a real-life application, check out this blog post: A Parametric CFD Model: Wind Turbine from Pipes
#!/bin/bash # see https://damogranlabs.com/2020/10/runfunctions-a-quick-cheatsheet/ . $WM_PROJECT_DIR/bin/tools/RunFunctions . $WM_PROJECT_DIR/bin/tools/CleanFunctions # generate blockMeshDict of the model (not domain!) # see https://github.com/damogranlabs/classy_blocks ./generate_model.py # writes system/blockMeshDict.model ./generate_domain.py # writes system/blockMeshDict.domain # generate 'model' mesh and extract STL surface from it runApplication -s model blockMesh -dict system/blockMeshDict.model runApplication surfaceMeshExtract -constant constant/triSurface/model.stl # similarly, generate the 'domain' mesh and extract surface from it runApplication -s domain blockMesh -dict system/blockMeshDict.domain surfaceMeshExtract -constant -patches "(inlet outlet walls)" constant/triSurface/domain.stl # the constant/triSurface now contains STL files for snappy. # continue with your usual snappy routine runApplication surfaceFeatureExtract runApplication decomposePar -force runParallel snappyHexMesh -overwrite ...