// this file creates a model and mesh of the NACA 0012 airfoil

surface_elem_size = 0.01;
farfield_elem_size = 0.8;
t_by_c = 0.12; chord = 1.0; thickness = 0.5*t_by_c*chord;

le_distance = 10*chord;
te_distance = 10*chord;
upper_distance = 8*chord;

n_pts = 110;

x[0] = 1;
x[1] = 0.95;
x[2] = 0.9;
x[3] = 0.85;
x[4] = 0.8;
x[5] = 0.75;
x[6] = 0.7;
x[7] = 0.65;
x[8] = 0.6;
x[9] = 0.55;
x[10] = 0.5;
x[11] = 0.45;
x[12] = 0.4;
x[13] = 0.35;
x[14] = 0.3;
x[15] = 0.25;
x[16] = 0.2;
x[17] = 0.18;
x[18] = 0.16;
x[19] = 0.14;
x[20] = 0.12;
x[21] = 0.1;
x[22] = 9.00E-02;
x[23] = 8.00E-02;
x[24] = 7.00E-02;
x[25] = 6.00E-02;
x[26] = 5.00E-02;
x[27] = 4.00E-02;
x[28] = 3.00E-02;
x[29] = 2.00E-02;
x[30] = 1.00E-02;
x[31] = 9.50E-03;
x[32] = 9.00E-03;
x[33] = 8.50E-03;
x[34] = 8.00E-03;
x[35] = 7.50E-03;
x[36] = 7.00E-03;
x[37] = 6.50E-03;
x[38] = 6.00E-03;
x[39] = 5.50E-03;
x[40] = 5.00E-03;
x[41] = 4.50E-03;
x[42] = 4.00E-03;
x[43] = 3.50E-03;
x[44] = 3.00E-03;
x[45] = 2.50E-03;
x[46] = 2.25E-03;
x[47] = 2.00E-03;
x[48] = 1.75E-03;
x[49] = 1.50E-03;
x[50] = 1.25E-03;
x[51] = 1.00E-03;
x[52] = 7.50E-04;
x[53] = 5.00E-04;
x[54] = 2.50E-04;
x[55] = 0.00E+00;
x[56] = 2.50E-04;
x[57] = 5.00E-04;
x[58] = 7.50E-04;
x[59] = 1.00E-03;
x[60] = 1.25E-03;
x[61] = 1.50E-03;
x[62] = 1.75E-03;
x[63] = 2.00E-03;
x[64] = 2.25E-03;
x[65] = 2.50E-03;
x[66] = 3.00E-03;
x[67] = 3.50E-03;
x[68] = 4.00E-03;
x[69] = 4.50E-03;
x[70] = 5.00E-03;
x[71] = 5.50E-03;
x[72] = 6.00E-03;
x[73] = 6.50E-03;
x[74] = 7.00E-03;
x[75] = 7.50E-03;
x[76] = 8.00E-03;
x[77] = 8.50E-03;
x[78] = 9.00E-03;
x[79] = 9.50E-03;
x[80] = 1.00E-02;
x[81] = 2.00E-02;
x[82] = 3.00E-02;
x[83] = 4.00E-02;
x[84] = 5.00E-02;
x[85] = 6.00E-02;
x[86] = 7.00E-02;
x[87] = 8.00E-02;
x[88] = 9.00E-02;
x[89] = 0.1	;
x[90] = 0.12	;
x[91] = 0.14	;
x[92] = 0.16	;
x[93] = 0.18	;
x[94] = 0.2	;
x[95] = 0.25	;
x[96] = 0.3	;
x[97] = 0.35	;
x[98] = 0.4	;
x[99] = 0.45	;
x[100] = 0.5	;
x[101] = 0.55	;
x[102] = 0.6	;
x[103] = 0.65	;
x[104] = 0.7	;
x[105] = 0.75	;
x[106] = 0.8	;
x[107] = 0.85	;
x[108] = 0.9	;
x[109] = 0.95	;
x[110] = 1	;

y[0]= 0.00E+00;
y[1]= 5.40E-03;
y[2]= 1.06E-02;
y[3]= 1.58E-02;
y[4]= 2.10E-02;
y[5]= 2.62E-02;
y[6]= 3.12E-02;
y[7]= 3.60E-02;
y[8]= 4.02E-02;
y[9]= 4.39E-02;
y[10]= 4.68E-02;
y[11]= 4.89E-02;
y[12]= 5.00E-02;
y[13]= 4.97E-02;
y[14]= 4.84E-02;
y[15]= 4.61E-02;
y[16]= 4.27E-02;
y[17]= 4.11E-02;
y[18]= 3.92E-02;
y[19]= 3.71E-02;
y[20]= 3.47E-02;
y[21]= 3.20E-02;
y[22]= 3.05E-02;
y[23]= 2.89E-02;
y[24]= 2.72E-02;
y[25]= 2.53E-02;
y[26]= 2.33E-02;
y[27]= 2.10E-02;
y[28]= 1.84E-02;
y[29]= 1.53E-02;
y[30]= 1.12E-02;
y[31]= 1.09E-02;
y[32]= 1.06E-02;
y[33]= 1.04E-02;
y[34]= 1.01E-02;
y[35]= 9.80E-03;
y[36]= 9.50E-03;
y[37]= 9.19E-03;
y[38]= 8.86E-03;
y[39]= 8.51E-03;
y[40]= 8.15E-03;
y[41]= 7.76E-03;
y[42]= 7.35E-03;
y[43]= 6.90E-03;
y[44]= 6.42E-03;
y[45]= 5.88E-03;
y[46]= 5.59E-03;
y[47]= 5.28E-03;
y[48]= 4.95E-03;
y[49]= 4.59E-03;
y[50]= 4.21E-03;
y[51]= 3.77E-03;
y[52]= 3.27E-03;
y[53]= 2.68E-03;
y[54]= 1.89E-03;
y[55]= 0.00E+00;
y[56]= -1.89E-03;
y[57]= -2.68E-03;
y[58]= -3.27E-03;
y[59]= -3.77E-03;
y[60]= -4.21E-03;
y[61]= -4.59E-03;
y[62]= -4.95E-03;
y[63]= -5.28E-03;
y[64]= -5.59E-03;
y[65]= -5.88E-03;
y[66]= -6.42E-03;
y[67]= -6.90E-03;
y[68]= -7.35E-03;
y[69]= -7.76E-03;
y[70]= -8.15E-03;
y[71]= -8.51E-03;
y[72]= -8.86E-03;
y[73]= -9.19E-03;
y[74]= -9.50E-03;
y[75]= -9.80E-03;
y[76]= -1.01E-02;
y[77]= -1.04E-02;
y[78]= -1.06E-02;
y[79]= -1.09E-02;
y[80]= -1.12E-02;
y[81]= -1.53E-02;
y[82]= -1.84E-02;
y[83]= -2.10E-02;
y[84]= -2.33E-02;
y[85]= -2.53E-02;
y[86]= -2.72E-02;
y[87]= -2.89E-02;
y[88]= -3.05E-02;
y[89]= -3.20E-02;
y[90]= -3.47E-02;
y[91]= -3.71E-02;
y[92]= -3.92E-02;
y[93]= -4.11E-02;
y[94]= -4.27E-02;
y[95]= -4.61E-02;
y[96]= -4.84E-02;
y[97]= -4.97E-02;
y[98]= -5.00E-02;
y[99]= -4.89E-02;
y[100]= -4.68E-02;
y[101]= -4.39E-02;
y[102]= -4.02E-02;
y[103]= -3.60E-02;
y[104]= -3.12E-02;
y[105]= -2.62E-02;
y[106]= -2.10E-02;
y[107]= -1.58E-02;
y[108]= -1.06E-02;
y[109]= -5.40E-03;
y[110]= 0.00E+00;

surface_points[] = {};

// use the coords to create the airfoil
For ival In {0:n_pts}
   Point(ival+1) = {x[ival]*chord, y[ival]*chord, 0.0 , surface_elem_size};   
   surface_points[ival] = ival+1;
EndFor


// now create the splines for the upper and lower sufaces
Spline (1) = {surface_points[]};

// now create the airfoil loop 
Line Loop (110) = {-1};

// now define the outer boundary of the meshing region
Point (201) = {-le_distance,  upper_distance, 0, farfield_elem_size};
Point (202) = {chord+te_distance,  upper_distance, 0, farfield_elem_size};
Point (203) = {chord+te_distance, -upper_distance, 0, farfield_elem_size};
Point (204) = {-le_distance, -upper_distance, 0, farfield_elem_size};



// lines for the outer boundary
Line (4) = {201, 202};
Line (5) = {202, 203};
Line (6) = {203, 204};
Line (7) = {204, 201};

// line loop for the outer boundary

Line Loop (111) = {-7, -6, -5, -4};


// surface defining the analysis boundary
Plane Surface (1) = {111, 110};


Physical Line (1) = {-1};
Physical Line (2) = {-7, -6, -5, -4};
Physical Surface (3) = {1};
