Airfoil simulations - A little contribution for meshing
Posted: Fri Nov 05, 2010 11:23 am
Hi everybody.
Well, this is not directly related to Code_Saturne, but you may find it useful if you want to have a fully hexahedral mesh around an arbitrary airfoil, only for 2D cases. It's a routine I made for Octave, but works without inconvenience in MatLab too (I haven't tried, but SciLab has an import function for .m scripts), which creates a Gmsh script ready for meshing. The tutorial is below:
1) Download the foilgmsh.m script and place it in a directory inside the path of Octave/MatLab
2) To check if it's accesible, type from within Octave:
help foilgmsh
A somewhat lengthy help text should appear. I highly reccomend you to read it. If you get an error, check you copied the script to a valid directory inside Octave's path.
3) Any plain text airfoil coordinate file will do (just check it's made in the same way as in XFoil or JavaFoil softwares, it's a pretty standard structure) but for this example we will use the n23012.dat file provided in the attachments. Copy that file to your current working directory.
4) Let's suppose we want a mesh with 100 elements along the chord (that's 100 along the upper surface and 100 along the lower surface), 40 rows of elements close to the airfoil on both sides, 25 elements before and after the airfoil and 15 elements above and below. The simulation should be run for a case of Re=3e6, Mach=0.3, a stagnation temperature of 15ºC and air as the fluid. We also want our mesh to be finer towards the airfoil edges, and let's suppose we will use the k-epsilon turbulence model, so an y+=50 will do good. The angle of attack is 7.5º. The following line includes all this information:
foilgmsh ('n23012.dat',7.5,50,'a',3000000,0.3,198.16,[100,40,25,15],0.01)
If you don't understand what all this parameters are, read the help as stated in step 2.
5) Look at the output info on the screen, it will be useful for setting up your simulation in CS according to all your input parameters. That info is not saved anywhere, so note it down or copy it to some other textfile.
6) Ok, check your working directory, you should see a new file called "n23012.dat.geo". If you open it with a text editor, you will notice it contains a Gmsh script. You may exit Octave now if you wish.
7) Open Gmsh, go to File-->Open and load the newly created n23012.dat.geo file. You should your airfoil surrounded by a small semiellipse and a bigger box with some ugly inclined lines (don't worry, it's on purpose); if you rotate the view you will see the plane figure is actually extruded by a little amount. Press the "m" key to activate the meshing module, and click on "3D". After a second or less you will see your new pseudo-2D hexahedral mesh. Save it as a MED file without any extra options (UNV and MSH types don't save the group names properly) under File--> Save as (not "save mesh", as strange as it sounds).
8) From now on it's only CS, the mesh and you... If you're going to write the group names in some of the Fortran routines like usproj, usini1, etc., write them enclosed in double quotation marks (the full name is, for example, "walls", not walls, otherwise it's incorrect). Also, as stated in the user guide, check the orientation correction option in the GUI as Gmsh may define them wrongly.
Ok, I hope you find this useful. Happy simulations.
César
Well, this is not directly related to Code_Saturne, but you may find it useful if you want to have a fully hexahedral mesh around an arbitrary airfoil, only for 2D cases. It's a routine I made for Octave, but works without inconvenience in MatLab too (I haven't tried, but SciLab has an import function for .m scripts), which creates a Gmsh script ready for meshing. The tutorial is below:
1) Download the foilgmsh.m script and place it in a directory inside the path of Octave/MatLab
2) To check if it's accesible, type from within Octave:
help foilgmsh
A somewhat lengthy help text should appear. I highly reccomend you to read it. If you get an error, check you copied the script to a valid directory inside Octave's path.
3) Any plain text airfoil coordinate file will do (just check it's made in the same way as in XFoil or JavaFoil softwares, it's a pretty standard structure) but for this example we will use the n23012.dat file provided in the attachments. Copy that file to your current working directory.
4) Let's suppose we want a mesh with 100 elements along the chord (that's 100 along the upper surface and 100 along the lower surface), 40 rows of elements close to the airfoil on both sides, 25 elements before and after the airfoil and 15 elements above and below. The simulation should be run for a case of Re=3e6, Mach=0.3, a stagnation temperature of 15ºC and air as the fluid. We also want our mesh to be finer towards the airfoil edges, and let's suppose we will use the k-epsilon turbulence model, so an y+=50 will do good. The angle of attack is 7.5º. The following line includes all this information:
foilgmsh ('n23012.dat',7.5,50,'a',3000000,0.3,198.16,[100,40,25,15],0.01)
If you don't understand what all this parameters are, read the help as stated in step 2.
5) Look at the output info on the screen, it will be useful for setting up your simulation in CS according to all your input parameters. That info is not saved anywhere, so note it down or copy it to some other textfile.
6) Ok, check your working directory, you should see a new file called "n23012.dat.geo". If you open it with a text editor, you will notice it contains a Gmsh script. You may exit Octave now if you wish.
7) Open Gmsh, go to File-->Open and load the newly created n23012.dat.geo file. You should your airfoil surrounded by a small semiellipse and a bigger box with some ugly inclined lines (don't worry, it's on purpose); if you rotate the view you will see the plane figure is actually extruded by a little amount. Press the "m" key to activate the meshing module, and click on "3D". After a second or less you will see your new pseudo-2D hexahedral mesh. Save it as a MED file without any extra options (UNV and MSH types don't save the group names properly) under File--> Save as (not "save mesh", as strange as it sounds).
8) From now on it's only CS, the mesh and you... If you're going to write the group names in some of the Fortran routines like usproj, usini1, etc., write them enclosed in double quotation marks (the full name is, for example, "walls", not walls, otherwise it's incorrect). Also, as stated in the user guide, check the orientation correction option in the GUI as Gmsh may define them wrongly.
Ok, I hope you find this useful. Happy simulations.
César