.. _airfoilanalysis_prefoil: *********************** 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 ++++++++++++++++++++++++++++++++ .. literalinclude:: ../tutorial/airfoil/geometry/run_prefoil.py :start-after: # rst Import :end-before: # rst ReadCoords Import the preFoil libraries and numpy. Load the airfoil coordinates ++++++++++++++++++++++++++++++++ .. literalinclude:: ../tutorial/airfoil/geometry/run_prefoil.py :start-after: # rst ReadCoords :end-before: # rst PlotIntial 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 ++++++++++++++++++++++++++++++++ .. literalinclude:: ../tutorial/airfoil/geometry/run_prefoil.py :start-after: # rst PlotIntial :end-before: # rst CreateTE We will now create a plot of our initial coodinates. .. figure:: images/airfoil_NACA0012.png :scale: 15 :align: center :alt: NACA 0012 Airfoil :figclass: align-center Figure 1: NACA0012 Airfoil Adding a blunt trailing edge ++++++++++++++++++++++++++++++++ .. literalinclude:: ../tutorial/airfoil/geometry/run_prefoil.py :start-after: # rst CreateTE :end-before: # rst Sampling 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 ++++++++++++++++++++++++++++++++ .. literalinclude:: ../tutorial/airfoil/geometry/run_prefoil.py :start-after: # rst Sampling :end-before: # rst Output 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 :math:`\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 ++++++++++++++++++++++++++++++++ .. literalinclude:: ../tutorial/airfoil/geometry/run_prefoil.py :start-after: # rst Output :end-before: # rst PlotFinal 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. .. figure:: images/airfoil_p3d_mesh.png :width: 500 :align: center Examining the processed NACA 0012 ++++++++++++++++++++++++++++++++++ .. literalinclude:: ../tutorial/airfoil/geometry/run_prefoil.py :start-after: # rst PlotFinal We will now create a plot of our processed coodinates. .. figure:: images/airfoil_processedNACA0012.png :scale: 15 :align: center :alt: Processed NACA 0012 Airfoil :figclass: align-center Figure 2: Processed NACA0012 Airfoil