Meshing
Introduction
Now that we have a airfoil geometry and have preprocessed it we can generate a mesh. Our end goal is to generate a structured volume mesh around the airfoil that can be used by ADflow. For an airfoil this is a straightforward automated process where we simply extrude the coordinates we generated using pyHyp.
Note
Remember that ADflow is a 3D finite volume solver. Therefore, 3D meshes are needed even for 2D problems such as airfoil simulations. To do this, we generate a 3D mesh which is one cell wide, and apply symmetry boundary conditions on those two faces.
In this tutorial, we will use pyHyp to generate a 3D mesh in CGNS format. More details on pyHyp can be found in the pyHyp documentation or in the code itself.
Files
Navigate to the directory airfoil/meshing in your tutorial folder.
Create the following empty runscript in the current directory.
run_pyhyp.py
Dissecting the pyHyp runscript
Open the file run_pyhyp.py in your favorite text editor. Then copy the code from each of the following sections into this file.
pyHyp runscript
from pyhyp import pyHyp
Import the pyHyp libraries and numpy.
Options
We will now apply several options for pyHyp in our options dictionary.
General Options
options = {
# ---------------------------
# Input Parameters
# ---------------------------
"inputFile": "../geometry/n0012_processed.xyz",
"unattachedEdgesAreSymmetry": False,
"outerFaceBC": "farfield",
"autoConnect": True,
"BC": {1: {"jLow": "zSymm", "jHigh": "zSymm"}},
"families": "wall",
inputFileName of the surface mesh file.
unattachedEdgesAreSymmetryTells pyHyp to automatically apply symmetry boundary conditions to any unattached edges (those that do not interface with another block).
outerFaceBCTells pyHyp which boundary condition to apply to the outermost face of the extruded mesh. Note that we do not set the inlet or outlet boundaries seperately because they are automatically handled in ADflow consistently with the free stream flow direction.
BCTells pyHyp that, since it is a 2D problem, both sides of the domain
jLowandjHighare set to be symmetry boundary conditions. The input surface is automatically assigned to be a wall boundary.familiesName given to wall surfaces. If a dictionary is submitted, each wall patch can have a different name. This can help the user to apply certain operations to specific wall patches in ADflow.
Grid Parameters
# ---------------------------
# Grid Parameters
# ---------------------------
"N": 129,
"s0": 3e-6,
"marchDist": 100.0,
"nConstantStart": 5,
}
NNumber of nodes in off-wall direction. If multigrid will be used this number should be 2m-1(n+1), where m is the number of multigrid levels and n is the number of layers on the coarsest mesh.
s0Thickness of first off-wall cell layer.
marchDistDistance of the far-field.
nConstantStartNumber of constant off-wall layers before beginning stretch.
Running pyHyp and Writing to File
The following three lines of code extrude the surface mesh and write the resulting volume mesh to a .cgns file.
hyp = pyHyp(options=options)
hyp.run()
hyp.writeCGNS("n0012.cgns")
Run it yourself!
You can now run the python file with the command:
python run_pyhyp.py
For larger meshes, you will want to run pyHyp as a parallel process. This can be done with the command:
mpiexec -n 4 python run_pyhyp.py
where the number of processors is given after -np.
You can open n0012.cgns in Tecplot to view the volume mesh.
The generated airfoil mesh should look like the following.
with a zoomed-in view: