OpenVSP API Documentation 3.41.0
 
Loading...
Searching...
No Matches
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 vsp::AutoGroupVSPAEROControlSurfaces ()
 
int vsp::CreateVSPAEROControlSurfaceGroup ()
 
void vsp::AddAllToVSPAEROControlSurfaceGroup (int CSGroupIndex)
 
void vsp::RemoveAllFromVSPAEROControlSurfaceGroup (int CSGroupIndex)
 
std::vector< std::string > vsp::GetActiveCSNameVec (int CSGroupIndex)
 
std::vector< std::string > vsp::GetCompleteCSNameVec ()
 
std::vector< std::string > vsp::GetAvailableCSNameVec (int CSGroupIndex)
 
void vsp::SetVSPAEROControlGroupName (const string &name, int CSGroupIndex)
 
std::string vsp::GetVSPAEROControlGroupName (int CSGroupIndex)
 
void vsp::AddSelectedToCSGroup (const vector< int > &selected, int CSGroupIndex)
 
void vsp::RemoveSelectedFromCSGroup (const vector< int > &selected, int CSGroupIndex)
 
int vsp::GetNumControlSurfaceGroups ()
 

Detailed Description

Function Documentation

◆ AddAllToVSPAEROControlSurfaceGroup()

void vsp::AddAllToVSPAEROControlSurfaceGroup ( int CSGroupIndex)
extern

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
void AddAllToVSPAEROControlSurfaceGroup(int CSGroupIndex)
int CreateVSPAEROControlSurfaceGroup()
@ SS_CONTROL
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
std::string AddSubSurf(const std::string &geom_id, int type, int surfindex=0)
Parameters
[in]CSGroupIndexIndex of the control surface group

◆ AddSelectedToCSGroup()

void vsp::AddSelectedToCSGroup ( const vector< int > & selected,
int CSGroupIndex )
extern

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 );
array < int > cs_ind_vec( cs_name_vec.size() );
for ( int i = 0; i < int( cs_name_vec.size() ); i++ )
{
cs_ind_vec[i] = i + 1;
}
AddSelectedToCSGroup( cs_ind_vec, group_index ); // Add all available control surfaces to the group
void AddSelectedToCSGroup(const vector< int > &selected, int CSGroupIndex)
std::vector< std::string > GetAvailableCSNameVec(int CSGroupIndex)
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 vsp::AutoGroupVSPAEROControlSurfaces ( )
extern

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
Print( "COMPLETE\n" );
string control_group_settings_container_id = FindContainer( "VSPAEROSettings", 0 ); // auto grouping produces parm containers within VSPAEROSettings
//==== Set Control Surface Group Deflection Angle ====//
Print( "\tSetting control surface group deflection angles..." );
// setup asymmetric 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 = FindParm( control_group_settings_container_id, "Surf_" + aileron_id + "_0_Gain", "ControlSurfaceGroup_0" );
deflection_gain_id = FindParm( control_group_settings_container_id, "Surf_" + aileron_id + "_1_Gain", "ControlSurfaceGroup_0" );
// deflect aileron
string deflection_angle_id = FindParm( control_group_settings_container_id, "DeflectionAngle", "ControlSurfaceGroup_0" );
void AutoGroupVSPAEROControlSurfaces()
void SetGeomName(const std::string &geom_id, const std::string &name)
std::string FindContainer(const std::string &name, int index)
std::string FindParm(const std::string &parm_container_id, const std::string &parm_name, const std::string &group_name)
double SetParmValUpdate(const std::string &parm_id, double val)
void Update(bool update_managers=true)
See also
CreateVSPAEROControlSurfaceGroup

◆ CreateVSPAEROControlSurfaceGroup()

int vsp::CreateVSPAEROControlSurfaceGroup ( )
extern

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" ); }
int GetNumControlSurfaceGroups()
See also
AddSelectedToCSGroup
Returns
Index of the new VSPAERO control surface group

◆ GetActiveCSNameVec()

std::vector< std::string > vsp::GetActiveCSNameVec ( int CSGroupIndex)
extern

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 < int( cs_name_vec.size() ); i++ )
{
Print( cs_name_vec[i] );
}
std::vector< std::string > GetActiveCSNameVec(int CSGroupIndex)
Parameters
[in]CSGroupIndexIndex of the control surface group
Returns
Array of active control surface names

◆ GetAvailableCSNameVec()

std::vector< std::string > vsp::GetAvailableCSNameVec ( int CSGroupIndex)
extern

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 );
array < int > cs_ind_vec(1);
cs_ind_vec[0] = 1;
AddSelectedToCSGroup( cs_ind_vec, 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()

std::vector< std::string > vsp::GetCompleteCSNameVec ( )
extern

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
array<string> @cs_name_vec = GetCompleteCSNameVec();
Print( "All Control Surfaces: ", false );
for ( int i = 0; i < int( cs_name_vec.size() ); i++ )
{
Print( cs_name_vec[i] );
}
std::vector< std::string > GetCompleteCSNameVec()
Returns
Array of all control surface names

◆ GetNumControlSurfaceGroups()

int vsp::GetNumControlSurfaceGroups ( )
extern

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 horiz_id = AddGeom( "WING", "" );
SetGeomName( horiz_id, "Vert" );
SetParmValUpdate( horiz_id, "TotalArea", "WingGeom", 10.0 );
SetParmValUpdate( horiz_id, "X_Rel_Location", "XForm", 8.5 );
string elevator_id = AddSubSurf( horiz_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()

std::string vsp::GetVSPAEROControlGroupName ( int CSGroupIndex)
extern

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 );
Print( GetVSPAEROControlGroupName( group_index ) );
void SetVSPAEROControlGroupName(const string &name, int CSGroupIndex)
std::string GetVSPAEROControlGroupName(int CSGroupIndex)
Parameters
[in]CSGroupIndexIndex of the control surface group

◆ RemoveAllFromVSPAEROControlSurfaceGroup()

void vsp::RemoveAllFromVSPAEROControlSurfaceGroup ( int CSGroupIndex)
extern

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
void RemoveAllFromVSPAEROControlSurfaceGroup(int CSGroupIndex)
Parameters
[in]CSGroupIndexIndex of the control surface group

◆ RemoveSelectedFromCSGroup()

void vsp::RemoveSelectedFromCSGroup ( const vector< int > & selected,
int CSGroupIndex )
extern

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 );
array < int > cs_ind_vec( cs_name_vec.size() );
for ( int i = 0; i < int( cs_name_vec.size() ); i++ )
{
cs_ind_vec[i] = i + 1;
}
AddSelectedToCSGroup( cs_ind_vec, group_index ); // Add the available control surfaces to the group
array < int > remove_cs_ind_vec( 1 );
remove_cs_ind_vec[0] = 1;
RemoveSelectedFromCSGroup( remove_cs_ind_vec, group_index ); // Remove the first control surface
void RemoveSelectedFromCSGroup(const vector< int > &selected, int CSGroupIndex)
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 vsp::SetVSPAEROControlGroupName ( const string & name,
int CSGroupIndex )
extern

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 );
Print( GetVSPAEROControlGroupName( group_index ) );
Parameters
[in]nameName to set for the control surface group
[in]CSGroupIndexIndex of the control surface group