ReadFileAirfoil: a new command in a future release?

294 views
Skip to first unread message

Yohann Delannay

unread,
May 5, 2015, 6:02:37 AM5/5/15
to ope...@googlegroups.com
Hello,

As I am scripting for OpenVSP, I was wondering if it was possible to paste airfoil coordinates from a file (like UIUC .dat ones) to a xsec airfoil on a wing geometry using a vspscript. I don't want to launch VSP then go to the airfoil tab of my wing geometry and click on "Read File" to add my airfoil file manually for each xsec.

I noticed that there are a "ReadFileXSec" API command but the xsection have to be XS_FILE_FUSE type, moreover the file type should be .fxs (for file-xsection)... Indeed my script generates xsections with XS_FILE_AIRFOIL type but I can't paste the airfoil coordinates because there is no such command to read airfoil file.

So, I am asking if it possible to create the same function as ReadFileXSec but for airfoil file? It could be simply named ReadFileAirfoil and the command could be set like this:

extern std::vector<vec3d> ReadFileAirfoil( const string& xsec_id, const string& file_name );

In a nutshell, I am looking for a command which acts like the "Read File" button under the airfoil tab of a wing geometry while using the AF_FILE type.


sources:
https://github.com/OpenVSP/OpenVSP/blob/72a0325b38710520ab238e89078468be2e2827de/src/geom_api/VSP_Geom_API.h
https://github.com/OpenVSP/OpenVSP/blob/ac169e464a51f1bf98b120a61aa4007c7b4b7e3c/src/geom_core/Airfoil.cpp

Rob McDonald

unread,
May 5, 2015, 10:56:18 AM5/5/15
to ope...@googlegroups.com
Yohann,

Sorry for the oversight, that probably should have been included
already. Similarly, SetXSecPnts should probably be extended to also
work on Airfoil types.

I suspect the API stuff is going to have a number of omissions like
this. The API was developed in parallel with a lot of other VSP
features, and not everything kept pace.

I will try to get this added in the next version, but if you are able
to build VSP, this should be a pretty simple addition to make.
Patches accepted.

Rob
> --
> You received this message because you are subscribed to the Google Groups
> "OpenVSP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to openvsp+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Yohann Delannay

unread,
May 26, 2015, 11:05:10 AM5/26/15
to ope...@googlegroups.com
Thank you Rob for adding the 'ReadFileAirfoil' command.
I had a look at your example in TestAll.vspcript, but I don't know why the coordinates don't update. I still have the default circle coordinates instead of my aifoil ones although I get the name of the airfoil updated under OpenVSP GUI.
Should they have to be in your ".af" format or can I use the airfoils from UIUC database? I am trying to generate a simple wing different airfoil profiles at root, kink and tip (I use the B737's airfoils)

Here are the few lines I use in my script (written using Python):

  ReadFileAirfoil( xsec'+str(p)+', "D:/delannay/OpenVSP_Project/'+airfoil_file+'" );

  array
<vec3d> @xsec'+str(p)+'_AirfoilUpperPnts = GetAirfoilUpperPnts( xsec'+str(p)+' );
 

  array
<vec3d> @xsec'+str(p)+'_AirfoilLowerPnts = GetAirfoilLowerPnts( xsec'+str(p)+' );
 

 
SetAirfoilPnts( xsec'+str(p)+', xsec'+str(p)+'_AirfoilUpperPnts, xsec'+str(p)+'_AirfoilLowerPnts );



NOTES:

- "airfoil_file" looks like "BOEING_737_OUTBOARD_AIRFOIL.dat"

- "str(p)" is an index I use in a for loop to set the airfoil for each xsec.


Yohann Delannay

Rob McDonald

unread,
May 26, 2015, 11:08:39 AM5/26/15
to ope...@googlegroups.com
Yohann,

It should work with any airfoil format that VSP will read -- the *.af,
or either of the formats on the UIUC database.

I suspect you need to call Update() after setting the points. The API
does not auto-update the way changing things in the GUI does.

Or, if you poke around in the GUI and change something else to trigger
an Update.

Rob





On Tue, May 26, 2015 at 8:05 AM, Yohann Delannay

Yohann Delannay

unread,
May 27, 2015, 8:57:50 AM5/27/15
to ope...@googlegroups.com
Hi Rob,

I actually do an update() after each like this:

    ReadFileAirfoil( xsec1, "D:/delannay/OpenVSP_Project/BOEING_737_MIDSPAN_AIRFOIL.dat" );
    array<vec3d> @xsec1_AirfoilUpperPnts = GetAirfoilUpperPnts( xsec1 );
    array<vec3d> @xsec1_AirfoilLowerPnts = GetAirfoilLowerPnts( xsec1 );
    SetAirfoilPnts( xsec1, xsec1_AirfoilUpperPnts, xsec1_AirfoilLowerPnts );
    Update();


I don't want to trigger anything with the GUI, but only load the vsp3 file and display the correct geometry directly without having to go into the geometry menu. Indeed I got circular shapes at each xsection just after opening the vsp3 file.
I see what you meant by the way, so I moved those lines just after the insertion of the new xsections then I set the parm values. That way I have my geometry fully updated and it works properly.
I use this for instance, just after setting the airfoil coordinates:
    SetParmVal( wid1, "Span", "XSec_1", 5.0 );

You might add the update() command into ReadFileAirfoil function if it has no consequences with the other API commands.
Thanks for the help!

Yohann Delannay

Rob McDonald

unread,
May 27, 2015, 11:06:21 AM5/27/15
to ope...@googlegroups.com
Ok, I think the problem is that setting the points doesn't trigger the
shape as 'dirty', so when the Update() comes through, it doesn't do
anything.

One solution may be to force an update when the points are set.
However, we purposefully don't Update after every parameter setting --
it would slow down most common API use cases needlessly.

I'll see what I can come up with.

Rob


On Wed, May 27, 2015 at 5:57 AM, Yohann Delannay
Reply all
Reply to author
Forward
0 new messages