CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[Gmsh] How to import multi-element airfoils for 2d simulations?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 19, 2017, 18:23
Default How to import multi-element airfoils for 2d simulations?
  #1
New Member
 
Join Date: Oct 2017
Posts: 15
Rep Power: 9
CfdIntro is on a distinguished road
Hi everyone,
  • What I'm trying to do:
Import a multi-element airfoil into gmsh for 2d mesh generation.
  • What's my issue:
I can't create the proper .dat file that will let me import the geometry I want.

Anyone has experience with importing multi-element airfoils into gmsh? I have no luck so far when I try to create the .dat file of the multi-element airfoil and I don't really know if it's possible to import multi-element airfoils using .dat files. Any hint on how the structure of the .dat file for multi-element airfoils should look like, would be greatly appreciated.

Thanks in advance and I'm looking forward to hearing from you soon.

gmsh version: 3.0.6 - Linux
OS: Ubuntu 17.04

Edit: https://i.imgur.com/1EqdVdN.png <- This is the geometry I'm interested in importing into gmsh.

Last edited by CfdIntro; November 20, 2017 at 16:18.
CfdIntro is offline   Reply With Quote

Old   November 20, 2017, 09:22
Default
  #2
Senior Member
 
louisgag's Avatar
 
Louis Gagnon
Join Date: Mar 2009
Location: Stuttgart, Germany
Posts: 338
Rep Power: 18
louisgag is on a distinguished road
Send a message via ICQ to louisgag
Hi CfdIntro and welcome to the forum,

I remember struggling when trying to import an airfoil/wing into Gmsh using external data. I recommend you use the publicly available Gmsh function instead: http://www.geuz.org/pipermail/gmsh/2009/004532.html

Copy it to a file you'll call naca.geo, and then in your Gmsh main .geo file insert something like (adapt to your case!):

Code:
NACA4_len_le = clDle ; // decrease to have more points on leading edge
NACA4_len_mp = clDmp ;
NACA4_len_te = clDte ;
NACA4_th = nacaN ;
NACA4_ch = chord ;
curF=1;

NACA4_le_x = oxF[curF] - pAxis ; // origin of foil nose
NACA4_le_y = oyF[curF] ; // origin of foil nose
NACA4_le_z = 0 ; // origin of foil nose

Include "naca.geo" ;
Call NACA4 ;
I use a slightly different version because I want 2D extruded airfoils... But you can probably adapt the script to your needs without too much hassle.

Regards,


-Louis
louisgag is offline   Reply With Quote

Old   November 20, 2017, 12:50
Default
  #3
New Member
 
Join Date: Oct 2017
Posts: 15
Rep Power: 9
CfdIntro is on a distinguished road
Quote:
Originally Posted by louisgag View Post
Hi CfdIntro and welcome to the forum,

I remember struggling when trying to import an airfoil/wing into Gmsh using external data. I recommend you use the publicly available Gmsh function instead: http://www.geuz.org/pipermail/gmsh/2009/004532.html

Copy it to a file you'll call naca.geo, and then in your Gmsh main .geo file insert something like (adapt to your case!):

Code:
NACA4_len_le = clDle ; // decrease to have more points on leading edge
NACA4_len_mp = clDmp ;
NACA4_len_te = clDte ;
NACA4_th = nacaN ;
NACA4_ch = chord ;
curF=1;

NACA4_le_x = oxF[curF] - pAxis ; // origin of foil nose
NACA4_le_y = oyF[curF] ; // origin of foil nose
NACA4_le_z = 0 ; // origin of foil nose

Include "naca.geo" ;
Call NACA4 ;
I use a slightly different version because I want 2D extruded airfoils... But you can probably adapt the script to your needs without too much hassle.

Regards,


-Louis
Hi louisgag and thank you for your answer.

My goal is to import this geometry into gmsh:


Do I use the same method you suggested above if I want to create an overlap with two airfoils or is it different?

Thanks in advance!
CfdIntro is offline   Reply With Quote

Old   November 20, 2017, 13:08
Default
  #4
Senior Member
 
louisgag's Avatar
 
Louis Gagnon
Join Date: Mar 2009
Location: Stuttgart, Germany
Posts: 338
Rep Power: 18
louisgag is on a distinguished road
Send a message via ICQ to louisgag
I can't see your image... Yes you can create two or more airfoils...
-Louis
louisgag is offline   Reply With Quote

Old   November 20, 2017, 14:40
Default
  #5
New Member
 
Join Date: Oct 2017
Posts: 15
Rep Power: 9
CfdIntro is on a distinguished road
Quote:
Originally Posted by louisgag View Post
I can't see your image... Yes you can create two or more airfoils...
-Louis
https://i.imgur.com/1EqdVdN.png <- This is the geometry I'm interested in creating. Let me know if it is visible to you this time and thanks in advance for your answer.
CfdIntro is offline   Reply With Quote

Old   November 21, 2017, 12:25
Default
  #6
Senior Member
 
louisgag's Avatar
 
Louis Gagnon
Join Date: Mar 2009
Location: Stuttgart, Germany
Posts: 338
Rep Power: 18
louisgag is on a distinguished road
Send a message via ICQ to louisgag
Unfortunately no, or at least not out-of-the-box because if you have camber you'll need to modify the NACA4 function, possibly substantially.
If you are in 2D, you may as well import/paste your airfoil points directly in Gmsh as the NACA4_Points object and then proceed similarly to what you see in the Gmsh mailing post from above to create splines between the points.
Good luck,
-Louis
louisgag is offline   Reply With Quote

Old   November 23, 2017, 05:57
Default
  #7
Senior Member
 
Mikko
Join Date: Jul 2014
Location: The Hague, The Netherlands
Posts: 243
Rep Power: 13
Flowkersma is on a distinguished road
Hi,

I think you should use some other format instead of trying to create a .dat file which as far as I know does not support anything but single element airfoils. You could also generate a simple script which converts your airfoil coordinates to GMSH geo file. I can give you an example if you have a coordinate file in some ascii format.

Regards, Mikko
Flowkersma is offline   Reply With Quote

Old   November 23, 2017, 09:48
Default
  #8
New Member
 
Join Date: Oct 2017
Posts: 15
Rep Power: 9
CfdIntro is on a distinguished road
Quote:
Originally Posted by Flowkersma View Post
Hi,

I think you should use some other format instead of trying to create a .dat file which as far as I know does not support anything but single element airfoils. You could also generate a simple script which converts your airfoil coordinates to GMSH geo file. I can give you an example if you have a coordinate file in some ascii format.

Regards, Mikko
Hi Flowkersma,

I have the coordinates of the first airfoil as (x1, y1) and the coordinates for the second airfoil as [(x1)+ω, (y1)+ω]. That way I've managed to import the two airfoils into gmsh. But I have no way, as of now, to precisely manipulate the layout of the two airfoils in the mesh.

Do you have any hint (i.e. a sample script) that would let the user go from this layout https://i.imgur.com/u1OGnIi.png (where ω=2), to this https://i.imgur.com/1EqdVdN.png?

Also, I tried to extract the coordinates of an assembly, which consists of two airfoils, from Solidworks16 but I had no luck doing so.

Thanks in advance for your answer and I hope I can hear from you soon.

Edit: Here is a sample of coordinates for an airfoil with flap - http://www.ae.metu.edu.tr/tuncer/ae546/multi/gaw.txt
CfdIntro is offline   Reply With Quote

Old   November 23, 2017, 10:56
Default
  #9
Senior Member
 
Mikko
Join Date: Jul 2014
Location: The Hague, The Netherlands
Posts: 243
Rep Power: 13
Flowkersma is on a distinguished road
Hi,

I created a small Python script just for convenience.

Code:
# Read the coordinates to two lists
mainCoords = []
flapCoords = []
with open('gaw.txt') as fin:
    fin.readline() # skip header
    fin.readline() # skip header
    for l in fin:
        coords = map(float,l.split())
        mainCoords.append(coords[:2])
        if len(coords) > 2:
            flapCoords.append(coords[2:])

# Create a GMSH file and write the points in GMSH format
with open('multi.geo','w') as fout:
    for i, c in enumerate(mainCoords):
        fout.write('Point (%i) = {%f, %f, 0, 1};\n'%(i+1,c[0],c[1]))
    for i, c in enumerate(flapCoords):
        fout.write('Point (%i) = {%f, %f, 0, 1};\n'%(i+len(mainCoords)+1,c[0],c[1]))

# Create two splines 
    fout.write('Spline (1) = {%s};\n' % ','.join(map(str,range(1,len(mainCoords)+1))))
    fout.write('Spline (2) = {%s};\n' % ','.join(map(str,range(len(mainCoords)+1,len(mainCoords)+len(flapCoords)+1))))
So it opens a file called 'gaw.txt' and creates a file called 'multi.geo' which you can open with GMSH. The geo file contains a script which has the coordinates in gmsh format and also creates two splines which go through the coordinates.

Let me know if it works.

Regards,
Mikko
Flowkersma is offline   Reply With Quote

Old   November 23, 2017, 12:44
Default
  #10
New Member
 
Join Date: Oct 2017
Posts: 15
Rep Power: 9
CfdIntro is on a distinguished road
Quote:
Originally Posted by Flowkersma View Post
Hi,

I created a small Python script just for convenience.

Code:
# Read the coordinates to two lists
mainCoords = []
flapCoords = []
with open('gaw.txt') as fin:
    fin.readline() # skip header
    fin.readline() # skip header
    for l in fin:
        coords = map(float,l.split())
        mainCoords.append(coords[:2])
        if len(coords) > 2:
            flapCoords.append(coords[2:])

# Create a GMSH file and write the points in GMSH format
with open('multi.geo','w') as fout:
    for i, c in enumerate(mainCoords):
        fout.write('Point (%i) = {%f, %f, 0, 1};\n'%(i+1,c[0],c[1]))
    for i, c in enumerate(flapCoords):
        fout.write('Point (%i) = {%f, %f, 0, 1};\n'%(i+len(mainCoords)+1,c[0],c[1]))

# Create two splines 
    fout.write('Spline (1) = {%s};\n' % ','.join(map(str,range(1,len(mainCoords)+1))))
    fout.write('Spline (2) = {%s};\n' % ','.join(map(str,range(len(mainCoords)+1,len(mainCoords)+len(flapCoords)+1))))
So it opens a file called 'gaw.txt' and creates a file called 'multi.geo' which you can open with GMSH. The geo file contains a script which has the coordinates in gmsh format and also creates two splines which go through the coordinates.

Let me know if it works.

Regards,
Mikko
Thank you very much for this script!

I'm getting error though everytime I try to run it.

Code:
Traceback (most recent call last):
  File "./gmsh.py", line 18, in <module>
    fout.write('Point (%i) = {%f, %f, 0, 1};\n'%(i+1,c[0],c[1]))
IndexError: list index out of range
Do you get the same error, if you try to run it on your system?

Thanks in advance and I'm looking forward to hearing from you soon again.
CfdIntro is offline   Reply With Quote

Old   November 24, 2017, 06:38
Default
  #11
Senior Member
 
Mikko
Join Date: Jul 2014
Location: The Hague, The Netherlands
Posts: 243
Rep Power: 13
Flowkersma is on a distinguished road
Hi,

I get no errors. Seems like your coordinate file is different. I attached the file that I used. It is just an example script which works only for this file but you can easily adapt it for other multi-element files.

Regards, Mikko
Attached Files
File Type: txt gaw.txt (3.5 KB, 38 views)
Flowkersma is offline   Reply With Quote

Old   November 24, 2017, 09:28
Default
  #12
New Member
 
Join Date: Oct 2017
Posts: 15
Rep Power: 9
CfdIntro is on a distinguished road
Quote:
Originally Posted by Flowkersma View Post
Hi,

I get no errors. Seems like your coordinate file is different. I attached the file that I used. It is just an example script which works only for this file but you can easily adapt it for other multi-element files.

Regards, Mikko
Hi again,

It works great now! The problem was the coordinate file was different. Thanks again for the help

Regards,
Pavlos
CfdIntro is offline   Reply With Quote

Reply

Tags
airfoil 2d, gmsh, import data, multi-element


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem running simpleFoam on a multi element airfoil vinz OpenFOAM Running, Solving & CFD 18 April 11, 2013 12:26
multi wing element - negative coefficient of drag? Zweeper FLUENT 10 March 11, 2010 13:20
Modelin Multi Element Airfoils Yashwant Ganti FLUENT 0 June 5, 2007 04:50
multi element airfoil data shadi memarpour Main CFD Forum 0 June 20, 2004 05:33
Multi Element Airfoil J.Dumas Main CFD Forum 2 May 13, 2000 08:24


All times are GMT -4. The time now is 08:41.