ME 58:143 Computational Fluid & Thermal Engineering

Computer Lab #4

## Introduction:

We will model flow over a 2-D airfoil at some arbitrary angle of attack with respect to the freestream flow. The computational domain is bounded on the inside by an airfoil shaped closed path, and by a rectangular box on the outside, as sketched (drawing not to scale).

1. The airfoil is assumed to have a chord length of 1.0 meters (all dimensions in this module are in the standard MKS system of units), with the front-most part of the airfoil at (0,0,0) and the trailing edge at (1,0,0).
2. The computational domain extends far upstream of the airfoil where the boundary condition will be a velocity inlet. The angle of attack will be specified in the CFD flow solver, Fluent. We’ll try two angles in this lab: 0oand 10o. The outlet is to the far right.
3. The top and bottom of the computational domain are "periodic" boundary conditions, which means that whatever flows out of the top goes directly into the bottom. Another way of thinking about this is that we are actually modeling an infinite array of airfoils, stacked on top of each other. It is assumed that since the outer limits of the computational domain are so far apart, this airfoil behaves as if in an infinite freestream.
4. In order to adequately resolve the boundary layer along the airfoil wall, grid points will be clustered near the wall. Far away from walls, where the flow does not have large velocity gradients, the grid points can be very far apart. A hybrid grid will be used in this problem, i.e. a structured quadratic (rectangular cells) grid around the airfoil and outward to an ellipse, connected to an unstructured (triangular cells) grid out to the limits of the computational domain. Grid adaptation within the flow solver, Fluent, will increase the grid density even more near the wall and wherever else needed.

Generate data points defining the airfoil:

1. Using an internet browser, go to the NACA 4-Digits Series web page at This site enables users to generate any standard NACA 4-digit 2-D airfoil. Note: On some computers, Java may be disabled by default. In some of the older versions of Netscape, Options-Network References, and turn on Java.
2. Adjust the values to create various airfoil shapes. In this lab, we use a non-symmetric airfoil, i.e. a NACA 4314 airfoil.
3. Change # Points to about 40, which should be sufficient to generate the airfoil shape. Change Point Size to around 3 or 4 so that the points are clearly visible. Show Points.
4. Highlight all the data points with your mouse (left click and drag over the text area). On Windows platforms, copy the data points (Ctrl-C).
5. Open your favorite text editor, and insert (paste - Ctrl-V on Windows platforms) the data points.
6. The very first point of the data should be at the trailing edge, i.e. at (1,0). However, due to resolution and accuracy limits, it may not be exactly correct. If not, change the x value to 1.0 and change the y value to 0.0 on the first line of the data file. This will ensure a nicely defined trailing edge.
7. Do the same thing to the last data point, which should also be at exactly (1,0).
8. Gambit expects to read three-dimensional data, i.e. x, y, and z for each data point or "vertex". Therefore, the z value must be added manually here. Simply add a blank space or two, followed by "0.0" at the end of each line.
9. Save the file (a name such as "NACA4314.dat" is recommended). If using WordPad, save the file type as “Text document –MS-DOS Format”. In Word, save the type as “MS-DOS Text with Layout”. Other file types may cause problems when imported in Gambit.

#### Generation of grid for 2D airfoil with Gambit:

Import the airfoil data points (vertices) into Gambit, and generate other vertices:

1. Launch Gambit. In the upper left of the screen, Solver-Fluent/UNS.
2. From Command at the bottom of the screen, enter "import vertexdata "NACA4314.dat"" Note: include the quotes around the file name, but not around the whole command. Or File-Import-Vertex Data, select NACA4314.dat. If successful, a vertex is created in Gambit for each (x,y,z) data point present in your text file. These should appear as little plus signs on the screen, and the Transcript Windowmay show “WARN: Found decimal points or 3 numbers in first line; Assume raw pint input”. The warning will not affect generation of grid.
3. Now create some more vertices manually. First, we will create a vertex inside the airfoil. In Geometry, Vertex Command Button-R-Create Vertex-From Coordinates. In Create Real Vertex-Global, enter 0.5, 0, and 0 for x, y, and z respectively. Type an appropriate label for this vertex, i.e. "inside airfoil", and Apply. A vertex is created.
4. Create another vertex at (1.5,0,0). You can call it "right of airfoil" or something like that. At this point, you may not be able to see the new vertex, since it may be located off the screen. There are two ways to see it. You can zoom in and move with the right mouse and middle mouse, respectively. Or, to fit all the geometry into the available screen space (a very handy tool!), in Global Control,Fit to Window.
5. In a similar fashion, create three more vertices surrounding the airfoil at the following locations (you can enter some labels if desired, or you can let Gambit name them by default): (-0.5,0,0), (0.5,0.3,0) (0.5,-0.3,0). These will be used to help generate a very fine grid near the airfoil wall.
6. In the main Gambit window near the upper left, File-Save. It is a good idea to do this every so often, especially after a major task is completed.

Create edges from these vertices for the top half of the computational domain:

1. Now some edges will be created to define the airfoil and an elliptical boundary surrounding the airfoil. First, the top half of the airfoil will become an edge. This edge will be a curve fit through the vertices just created, from the trailing edge through the vertices defining the top of the airfoil, to the leading edge. Under Geometry, Edge Command Button.
2. Under Edge, right mouse click the top left icon, which is called Create Edge, and then NURBS. (Denoted by R-Create Edge-NURBS.) NURBS is Gambit's curve-fitting routine, which will fit a smooth curve onto several vertices. NURBS stands for Non-Uniform Rational B-Spline.
3. In Create Edge From Vertices, make sure the text area called Vertices is highlighted - if not, click in that area. Select, in order, the vertices starting from the trailing edge, and continuing counterclockwise along the top of the airfoil, up to and including the leading edge vertex (the one at the origin). You may need to zoom in to pick them properly.
4. In Create Edge From Vertices, type in an appropriate label for the edge about to be created. I suggest "airfoil top" or something equally descriptive. Apply. A yellow line should be drawn on the screen connecting the vertices.
5. Now Close the Create Real Edge From Vertices window.
6. Now we will create the upper half of an ellipse surrounding the airfoil. Under Edge, R-Create Edge-Ellipse.
7. In Create Real Elliptic Arc, the Center of the ellipse should be highlighted. Select the vertex inside the airfoil as the ellipse center. Click inside the text box called Major, and select the vertex to the right of the trailing edge of the airfoil. In a similar fashion select the vertex above the airfoil as On Edge.
8. Change Angle-End to 180 degrees (since we only want to draw the upper half of the ellipse). Label this edge if you like ("upper ellipse") and Apply. The top half of an ellipse surrounding the airfoil will be drawn in yellow if all is well. Close the Create Real Elliptic Arc window.
9. Two more edges are needed to completely define the domain above the airfoil. These edges will be straight lines between vertices. Under Edge, R-Create Edge-Straight.
10. Select the vertex at the trailing edge (should be labeled vertex.1 by default), and also the one just to the right of the trailing edge. Label it if you wish, and Apply.
11. Similarly, create and edge from the leading edge vertex (should be labeled vertex.39 by default) to the vertex to the left of the leading edge.
12. In the main Gambit window near the upper left, File-Save. This will save your work so far. It is a good idea to do this every so often, especially after a major task is completed.

Define node points along the edges:

1. In Operation, Mesh Command Button-Edge Command Button. Mesh Edges should be the default window that opens; if not, Mesh Edges.
2. Select the airfoil top edge, and in Mesh Edges, change the Spacing option from Interval Size to Interval Count. Enter the number 50 as the Interval Count. Apply. Blue circles should appear at each created node point along that edge.
3. Now select the ellipse top, and Apply. 50 node points will appear on that edge as well.
4. On the other two edges (the horizontal ones), we want to bunch up the nodes at the airfoil. Select the edge to the right of the trailing edge of the airfoil. Change Interval Count to 20. Change Ratio to about 1.3 or 1.4 so that nodes are really bunched up near the airfoil. Note: If the bunching is backwards from the way you desire, click on the Reverse button. Apply.
5. In similar fashion, assign 20 bunched-up nodes on the edge to the left of the leading edge of the airfoil. Don't forget to Apply.

Generate a face above the airfoil from the available edges, and mesh the face with quadratic cells:

1. Under Operation, Geometry Command Button, and under Geometry, Face Command Button-R-Form Face-Wireframe.
2. It is important to select the edges in order when creating a face from existing edges. Select the upper ellipse edge first, followed by the edge to the left of the airfoil, the upper airfoil edge itself, and then finally the edge to the right of the airfoil. These four edges outline a closed face.
3. In Create Face From Wireframe, type in a label for this face ("upper airfoil face" is suggested), and Apply. If all went well, a pretty blue outline of the face should appear on the screen; this is a face, which is now ready to be meshed.
4. Under Operation, Mesh Command Button-Face Command Button. The default window that pops up should be Mesh Faces. If not, Mesh Faces.
5. Select the face just created. Elements should be Quad by default; if not, change it. Also change Type to Map. The Spacing options will be ignored since nodes have already been defined on all edges of this face.
6. Generate the mesh by Apply. If all goes well, a structured mesh around the top of the airfoil should appear. Zoom in to see how the cells are nicely clustered near the airfoil surface. This will help Fluent to resolve the boundary layer around the airfoil.
7. You can now Close the Mesh Faces window.

Generate edges, a face, and mesh the face below the airfoil:

1. Duplicate the commands just performed, but this time on the bottom of the airfoil. Specifically, first generate an edge following the bottom half of the airfoil from the trailing edge to the leading edge, as before. (You can zoom in or out anytime.)
2. Generate the bottom half of the ellipse (angle goes from 180 to 360 or 0 to 180 this time, depending on which vertex you select as Major and On Edge).
3. Put 50 uniform points (Ratio = 1) on the bottom of the airfoil, and also on the ellipse edge.
4. Create a face below the airfoil from the four edges.
5. Create the mesh on the bottom face.
6. Caution: Sometimes (I don't know why), the node distribution on an edge will disappear mysteriously. If it does, you must re-assign nodes along that edge before the face can be meshed. In some cases, the mesh on the upper face disappears while meshing the lower face. If this happens, re-mesh the upper face. When all is done, a nice structured grid should appear around the whole airfoil out to the ellipse. We are now ready to define the outer limits of the computational domain, and to generate an unstructured mesh from the ellipse to the outer limits.

Generate the outer limits of the computational domain:

1. In Operation, Geometry Command Button, and then in Geometry, Vertex Command Button-R-Create Vertex-From Coordinates. In Create Real Vertex-Global, enter -10, 10, and 0 for x, y, and z respectively. Type an appropriate label for this vertex, i.e. "top left", and Apply. A vertex is created.
2. In a similar manner, create and label vertices for the bottom left, bottom right, top right, middle left, and middle right, at locations (-10,-10,0), (20,-10,0), (20,10,0), (-10, 0,0), and (20,0,0) respectively. Use the handy Fit to Window command to see your vertices.
3. Now create straight edges between pairs of vertices just created. We will do the top half first, then the bottom half. In Geometry, Edge Command Button-R-Create Edge-Straight.
4. Two vertices are needed to define each straight edge. For example, select the vertex on the right side on the ellipse created previously. Select also the middle right vertex of the outer domain. Label this edge "middle right edge" or something, and Apply.
5. Now select the middle right vertex and the top right vertex. Create an edge between these two vertices (call it "upper right edge").
6. In similar fashion, create edges called "top edge", "upper left edge", and "middle left edge".
7. Now repeat for the three remaining edges on the lower half, i.e. "lower left edge", "bottom edge", and "lower right edge". Finally, Close the Create Straight Edge window.
8. Note: It is important that the top edge and bottom edge have the same direction. In other words, if you created the top edge from left to right, create the bottom edge from left to right as well. If these two are backwards from each other, the periodic boundary condition will not work properly in Fluent.
9. To reduce clutter on the screen, we will hide all the vertices from view, as they are no longer needed. Under Global Control, Specify Model Display Attributes-Vertices and Visible-Off. Apply. This does not delete the vertices, but simply removes them from view. Close the Specify Display Attributes window.

Specify the node distribution along these new edges:

1. In Operation, Mesh Command Button-Edge Command Button. Mesh Edges should be the default window that opens; if not, Mesh Edges.
2. Select the upper left edge, the lower left edge, the upper right edge, and the lower right edge. In Mesh Edges, change the Spacing option, if necessary, from Interval Size to Interval Count. We don't need many nodes this far from the airfoil, so enter 3 as the Interval Count. Apply. Blue circles should appear at each created node point along those edges.
3. Now select the edge that runs from the back of the ellipse to the middle right vertex of the outer domain. Change Interval Count to 30 and change Ratio to about 1.4 so that nodes are clustered near the ellipse. (Depending on how you created this edge, it may be necessary to Reverse.) Apply.
4. In similar fashion, put about 20 nodes on the edge that runs from the front of the ellipse to the vertex we called middle left. These nodes should also be clustered near the ellipse. (Depending on how you created this edge, it may be necessary to Reverse.)
5. The top and bottom edges of the domain will now be meshed. However, they must first be linked, so that the node distribution will be identical. This is necessary in order to define the top and bottom edges with periodic boundary conditions. Note: The arrows on these edges must be in the same direction, or else the periodicity will not work. In Edge, Link/Unlink Edges-R-Link.
6. In Link Edge Meshes, select the top edge and the bottom edge for Edges. Check the box for Periodic if it is not chosen by default. Apply. Close.
7. In Edge, Mesh Edges. In Mesh Edges, select the top edge, enter 6 as the Interval Count in Spacing, Set Ratio back to 1, and Apply. Blue nodes should appear on both the top and bottom edges, since they are linked.
8. Check that all the edges are meshed. If any of the edge meshes have mysteriously disappeared, re-do those.
9. Finally, Close the Mesh Edges window. We are now ready to create faces for the top and bottom, and mesh these faces.

Create an upper face, generate a mesh on the face, and repeat for lower face:

1. In Operation, Geometry Command Button. In Geometry, Face Command Button-R-Form Face-Wireframe.
2. Beginning with the edge that goes from the back of the ellipse to the middle right vertex, and proceeding counterclockwise, select the edges that make up the big upper face, concluding with the top half of the ellipse. Label this face "upper" and Apply.
3. Likewise, generate a face called "lower" on the bottom.
4. In Operation, Mesh Command Button, and in Mesh, Face Command Button. If not already the default, Mesh Faces.
5. Select the upper face, change Elements to Tri, and Apply. After a while, a triangular unstructured mesh should grow from the ellipse to the outer domain.
6. Repeat for the lower face.
7. Zoom in to see how the mesh has been applied around the airfoil. If not satisfied, you can change some of the node distributions and re-create the mesh.

Specify the boundary conditions on all edges: