Geometry Preprocessing
Before we can analyze an airfoil we need to define an airfoil geometry and preprocess it for meshing.
Airfoil geometries are defined by a set of points or coordinates in 2D space that define a closed curve.
Coordinates for many airfoils can be obtained from the UIUC Data site.
The coordinates for the NACA 0012 airfoil are in the file n0012.dat.
We could just use these coodinates as is to generate our mesh but then we would have no control over the cell count in the mesh or how the cells are distributed. To fix this we will preprocess the airfoil coordiantes using preFoil which will allow us to sample new points on our airfoil at locations that we choose. We will then export the newly sampled points as use them in the next step to generate our mesh.
Files
Navigate to the directory airfoil/geometry in your tutorial folder.
Download a copy of the NACA 0012 coordinates to this folder from the UIUC Data site linked above.
You’ll need to deleted the header (first line in the file) using a text editor.
Create the following empty runscript in the current directory:
run_prefoil.py
Dissecting the preFoil runscript
Open the file run_prefoil.py in your favorite text editor. Then copy the code from each of the following sections into this file.
Import libraries
import numpy as np
from prefoil import airfoil, sampling, utils
Import the preFoil libraries and numpy.
Load the airfoil coordinates
X = utils.readCoordFile("n0012.dat") # load coords
foil = airfoil.Airfoil(X) # create airfoil object
We now load the airfoil coordiantes from the file we just downloaded using readCoordFile function in preFoil’s utils module.
Next, we create the airfoil object using the Airfoil class.
Examining the NACA 0012
fig1 = foil.plot()
fig1.savefig("NACA0012.pdf")
We will now create a plot of our initial coodinates.
Figure 1: NACA0012 Airfoil
Adding a blunt trailing edge
foil.makeBluntTE(0.995) # create blunt TE
foil.normalizeChord() # normalize chord length to 1.0 after cutting airfoil to make blunt TE
We will now add a blunt trailing edge to our airfoil by cutting it off close to the original trailing edge. Then, we normalize it’s coordinates.
Resampling
numsamppts = 277 # number of sampling points
coords = foil.getSampledPts(numsamppts, spacingFunc=[sampling.cosine] * 2, func_args={"m": np.pi}, nTEPts=15)
We then resample our airfoil to have 277 points which is suitable for an L2 mesh.
We use cosine sampling and the parameter m being set to \(\pi\) tells the cosine spacing algorihtm to refine at the leading and trailing edges.
For more on sampling algorithms available in preFoil see its documentation.
Write output
foil.writeCoords("n0012_processed", file_format="dat") # sampled points point cloud
foil.writeCoords("n0012_processed", file_format="plot3d") # intermediate.xyz for pyHyp meshing
We can now write our output coordinates.
preFoil allows us to output to .dat as well as .xyz (PLOT3D) for meshing.
The surface mesh (n0012_processed.xyz) can be visualized in Tecplot.
Examining the processed NACA 0012
fig2 = foil.plot()
fig2.savefig("processedNACA0012.pdf")
We will now create a plot of our processed coodinates.
Figure 2: Processed NACA0012 Airfoil