OpenVSPAPI  3.20.0
Functions
VSPAERO Control Surface Group Functions

This group of functions is available for manipulating VSPAERO control surface groups through the API. Note, VSPAERO also includes rectangle type sub-surfaces as possible control surfaces.

Click here to return to the main page. More...

Functions

void AutoGroupVSPAEROControlSurfaces ()
 
int GetNumControlSurfaceGroups ()
 
int CreateVSPAEROControlSurfaceGroup ()
 
void AddAllToVSPAEROControlSurfaceGroup (int CSGroupIndex)
 
void RemoveAllFromVSPAEROControlSurfaceGroup (int CSGroupIndex)
 
string[] GetActiveCSNameVec (int CSGroupIndex)
 
string[] GetCompleteCSNameVec ()
 
string[] GetAvailableCSNameVec (int CSGroupIndex)
 
void SetVSPAEROControlGroupName (const string &in name, int CSGroupIndex)
 
string GetVSPAEROControlGroupName (int CSGroupIndex)
 
void AddSelectedToCSGroup (int[]@ selected, int CSGroupIndex)
 
void RemoveSelectedFromCSGroup (int[]@ selected, int CSGroupIndex)
 

Detailed Description

Function Documentation

◆ AddAllToVSPAEROControlSurfaceGroup()

void AddAllToVSPAEROControlSurfaceGroup ( int  CSGroupIndex)

Add all available control surfaces to the control surface group at the specified index

string wid = AddGeom( "WING", "" ); // Add Wing
string aileron_id = AddSubSurf( wid, SS_CONTROL ); // Add Control Surface Sub-Surface
int group_index = CreateVSPAEROControlSurfaceGroup(); // Empty control surface group
Parameters
[in]CSGroupIndexIndex of the control surface group

◆ AddSelectedToCSGroup()

void AddSelectedToCSGroup ( int@[]  selected,
int  CSGroupIndex 
)

Add each control surfaces in the array of control surface indexes to the control surface group at the specified index.

Warning
The indexes in input "selected" must be matched with available control surfaces identified by GetAvailableCSNameVec. The "selected" input uses one- based indexing to associate available control surfaces.
string wid = AddGeom( "WING", "" ); // Add Wing
string aileron_id = AddSubSurf( wid, SS_CONTROL ); // Add Control Surface Sub-Surface
int group_index = CreateVSPAEROControlSurfaceGroup(); // Empty control surface group
array<string> @cs_name_vec = GetAvailableCSNameVec( group_index );
AddSelectedToCSGroup( cs_name_vec[0], group_index ); // Add the first available control surface to the group
See also
GetAvailableCSNameVec
Parameters
[in]selectedArray of control surface indexes to add to the group. Note, the integer values are one based.
[in]CSGroupIndexIndex of the control surface group

◆ AutoGroupVSPAEROControlSurfaces()

void AutoGroupVSPAEROControlSurfaces ( )

Creates the initial default grouping for the control surfaces. The initial grouping collects all surface copies of the sub-surface into a single group. For example if a wing is defined with an aileron and that wing is symmetrical about the xz plane there will be a surface copy of the master wing surface as well as a copy of the sub-surface. The two sub-surfaces may get deflected differently during analysis routines and can be identified uniquely by their full name.

string wid = AddGeom( "WING", "" ); // Add Wing
string aileron_id = AddSubSurf( wid, SS_CONTROL ); // Add Control Surface Sub-Surface
//==== Add Vertical tail and set some parameters =====//
string vert_id = AddGeom( "WING" );
SetGeomName( vert_id, "Vert" );
SetParmValUpdate( vert_id, "TotalArea", "WingGeom", 10.0 );
SetParmValUpdate( vert_id, "X_Rel_Location", "XForm", 8.5 );
SetParmValUpdate( vert_id, "X_Rel_Rotation", "XForm", 90 );
string rudder_id = AddSubSurf( vert_id, SS_CONTROL ); // Add Control Surface Sub-Surface
TEST_ASSERT( vsp::GetNumControlSurfaceGroups() == 3 );
TEST_ASSERT( !vsp::ErrorMgr.PopErrorAndPrint( stdout ) );
printf( "COMPLETE\n" );
string control_group_settings_container_id = vsp::FindContainer( "VSPAEROSettings", 0 ); // auto grouping produces parm containers within VSPAEROSettings
//==== Set Control Surface Group Deflection Angle ====//
printf( "\tSetting control surface group deflection angles..." );
TEST_ASSERT( !vsp::ErrorMgr.PopErrorAndPrint( stdout ) );
// setup asymetric deflection for aileron
string deflection_gain_id;
// subsurfaces get added to groups with "CSGQualities_[geom_name]_[control_surf_name]"
// subsurfaces gain parm name is "Surf[surfndx]_Gain" starting from 0 to NumSymmetricCopies-1
deflection_gain_id = vsp::FindParm( control_group_settings_container_id, "Surf_" + aileron_id + "_0_Gain", "ControlSurfaceGroup_0" );
TEST_ASSERT_DELTA( vsp::SetParmValUpdate( deflection_gain_id, 0.8 ), 0.8, TEST_TOL );
deflection_gain_id = vsp::FindParm( control_group_settings_container_id, "Surf_" + aileron_id + "_1_Gain", "ControlSurfaceGroup_0" );
TEST_ASSERT_DELTA( vsp::SetParmValUpdate( deflection_gain_id, 1.2 ), 1.2, TEST_TOL );
// deflect aileron
string deflection_angle_id = vsp::FindParm( control_group_settings_container_id, "DeflectionAngle", "ControlSurfaceGroup_0" );
TEST_ASSERT_DELTA( vsp::SetParmValUpdate( deflection_angle_id, 1.0 ), 1.0, TEST_TOL );
See also
CreateVSPAEROControlSurfaceGroup

◆ CreateVSPAEROControlSurfaceGroup()

int CreateVSPAEROControlSurfaceGroup ( )

Add a new VSPAERO control surface group using the default naming convention. The control surface group will not contain any control surfaces until they are added.

string wid = AddGeom( "WING", "" ); // Add Wing
string aileron_id = AddSubSurf( wid, SS_CONTROL ); // Add Control Surface Sub-Surface
int group_index = CreateVSPAEROControlSurfaceGroup(); // Empty control surface group
int num_group = GetNumControlSurfaceGroups();
if ( num_group != 1 ) { Print( "Error: CreateVSPAEROControlSurfaceGroup" ); }
See also
AddSelectedToCSGroup
Returns
Index of the new VSPAERO control surface group

◆ GetActiveCSNameVec()

string [] GetActiveCSNameVec ( int  CSGroupIndex)

Get the names of each active (used) control surface in the control surface group at the specified index

string wid = AddGeom( "WING", "" ); // Add Wing
string aileron_id = AddSubSurf( wid, SS_CONTROL ); // Add Control Surface Sub-Surface
int group_index = CreateVSPAEROControlSurfaceGroup(); // Empty control surface group
array<string> @cs_name_vec = GetActiveCSNameVec( group_index );
Print( "Active CS in Group Index #", false );
Print( group_index );
for ( int i = 0; i < cs_name_vec.size(); i++ )
{
Print( cs_name_vec[i] );
}
Parameters
[in]CSGroupIndexIndex of the control surface group
Returns
Array of active control surface names

◆ GetAvailableCSNameVec()

string [] GetAvailableCSNameVec ( int  CSGroupIndex)

Get the names of each available (not used) control surface in the control surface group at the specified index

string wid = AddGeom( "WING", "" ); // Add Wing
string aileron_id = AddSubSurf( wid, SS_CONTROL ); // Add Control Surface Sub-Surface
int group_index = CreateVSPAEROControlSurfaceGroup(); // Empty control surface group
array<string> @cs_name_vec = GetAvailableCSNameVec( group_index );
AddSelectedToCSGroup( cs_name_vec[0], group_index ); // Add the first available control surface to the group
Parameters
[in]CSGroupIndexIndex of the control surface group
Returns
Array of active control surface names

◆ GetCompleteCSNameVec()

string [] GetCompleteCSNameVec ( )

Get the names of all control surfaces. Some may be active (used) while others may be available.

string wid = AddGeom( "WING", "" ); // Add Wing
string aileron_id = AddSubSurf( wid, SS_CONTROL ); // Add Control Surface Sub-Surface
int group_index = CreateVSPAEROControlSurfaceGroup(); // Empty control surface group
Print( "All Control Surfaces: ", false );
for ( int i = 0; i < cs_name_vec.size(); i++ )
{
Print( cs_name_vec[i] );
}
Returns
Array of all control surface names

◆ GetNumControlSurfaceGroups()

int GetNumControlSurfaceGroups ( )

Get the total number of control surface groups

string wid = AddGeom( "WING", "" ); // Add Wing
string aileron_id = AddSubSurf( wid, SS_CONTROL ); // Add Control Surface Sub-Surface
//==== Add Horizontal tail and set some parameters =====//
string horz_id = AddGeom( "WING" );
SetGeomName( horz_id, "Vert" );
SetParmValUpdate( horiz_id, "TotalArea", "WingGeom", 10.0 );
SetParmValUpdate( horiz_id, "X_Rel_Location", "XForm", 8.5 );
string elevator_id = AddSubSurf( horz_id, SS_CONTROL ); // Add Control Surface Sub-Surface
int num_group = GetNumControlSurfaceGroups();
if ( num_group != 2 ) { Print( "Error: GetNumControlSurfaceGroups" ); }
Returns
Number of control surface groups

◆ GetVSPAEROControlGroupName()

string GetVSPAEROControlGroupName ( int  CSGroupIndex)

Get the name of the control surface group at the specified index

string wid = AddGeom( "WING", "" ); // Add Wing
string aileron_id = AddSubSurf( wid, SS_CONTROL ); // Add Control Surface Sub-Surface
int group_index = CreateVSPAEROControlSurfaceGroup(); // Empty control surface group
SetVSPAEROControlGroupName( "Example_CS_Group", group_index );
Print( "CS Group name: ", false );
Parameters
[in]CSGroupIndexIndex of the control surface group

◆ RemoveAllFromVSPAEROControlSurfaceGroup()

void RemoveAllFromVSPAEROControlSurfaceGroup ( int  CSGroupIndex)

Remove all used control surfaces from the control surface group at the specified index

string wid = AddGeom( "WING", "" ); // Add Wing
string aileron_id = AddSubSurf( wid, SS_CONTROL ); // Add Control Surface Sub-Surface
int group_index = CreateVSPAEROControlSurfaceGroup(); // Empty control surface group
RemoveAllFromVSPAEROControlSurfaceGroup( group_index ); // Empty control surface group
Parameters
[in]CSGroupIndexIndex of the control surface group

◆ RemoveSelectedFromCSGroup()

void RemoveSelectedFromCSGroup ( int@[]  selected,
int  CSGroupIndex 
)

Remove each control surfaces in the array of control surface indexes from the control surface group at the specified index.

Warning
The indexes in input "selected" must be matched with active control surfaces identified by GetActiveCSNameVec. The "selected" input uses one- based indexing to associate available control surfaces.
string wid = AddGeom( "WING", "" ); // Add Wing
string aileron_id = AddSubSurf( wid, SS_CONTROL ); // Add Control Surface Sub-Surface
int group_index = CreateVSPAEROControlSurfaceGroup(); // Empty control surface group
array<string> @cs_name_vec = GetAvailableCSNameVec( group_index );
AddSelectedToCSGroup( cs_name_vec[0], group_index ); // Add the first available control surface to the group
AddSelectedToCSGroup( cs_name_vec[1], group_index ); // Add the second available control surface to the group
RemoveSelectedFromCSGroup( cs_name_vec[0], group_index );
See also
GetActiveCSNameVec
Parameters
[in]selectedArray of control surface indexes to remove from the group. Note, the integer values are one based.
[in]CSGroupIndexIndex of the control surface group

◆ SetVSPAEROControlGroupName()

void SetVSPAEROControlGroupName ( const string &in  name,
int  CSGroupIndex 
)

Set the name for the control surface group at the specified index

string wid = AddGeom( "WING", "" ); // Add Wing
string aileron_id = AddSubSurf( wid, SS_CONTROL ); // Add Control Surface Sub-Surface
int group_index = CreateVSPAEROControlSurfaceGroup(); // Empty control surface group
SetVSPAEROControlGroupName( "Example_CS_Group", group_index );
Print( "CS Group name: ", false );
Parameters
[in]nameName to set for the control surface group
[in]CSGroupIndexIndex of the control surface group
RemoveSelectedFromCSGroup
void RemoveSelectedFromCSGroup(int[]@ selected, int CSGroupIndex)
GetActiveCSNameVec
string[] GetActiveCSNameVec(int CSGroupIndex)
SetVSPAEROControlGroupName
void SetVSPAEROControlGroupName(const string &in name, int CSGroupIndex)
RemoveAllFromVSPAEROControlSurfaceGroup
void RemoveAllFromVSPAEROControlSurfaceGroup(int CSGroupIndex)
GetNumControlSurfaceGroups
int GetNumControlSurfaceGroups()
GetCompleteCSNameVec
string[] GetCompleteCSNameVec()
FindParm
string FindParm(const string &in parm_container_id, const string &in parm_name, const string &in group_name)
GetAvailableCSNameVec
string[] GetAvailableCSNameVec(int CSGroupIndex)
SetParmValUpdate
double SetParmValUpdate(const string &in parm_id, double val)
AddSubSurf
string AddSubSurf(const string &in geom_id, int type, int surfindex=0)
Update
void Update()
FindContainer
string FindContainer(const string &in name, int index)
array
AngelScript ScriptExtension for representing the C++ std::vector.
Definition: openvsp_as.h:244
AddAllToVSPAEROControlSurfaceGroup
void AddAllToVSPAEROControlSurfaceGroup(int CSGroupIndex)
SetGeomName
void SetGeomName(const string &in geom_id, const string &in name)
GetVSPAEROControlGroupName
string GetVSPAEROControlGroupName(int CSGroupIndex)
AddGeom
string AddGeom(const string &in type, const string &in parent=string())
Print
void Print(const string &in data, bool new_line=true)
AutoGroupVSPAEROControlSurfaces
void AutoGroupVSPAEROControlSurfaces()
SS_CONTROL
Definition: openvsp_as.h:1887
AddSelectedToCSGroup
void AddSelectedToCSGroup(int[]@ selected, int CSGroupIndex)
CreateVSPAEROControlSurfaceGroup
int CreateVSPAEROControlSurfaceGroup()