OpenVSP API Documentation 3.51.3
Loading...
Searching...
No Matches
XSec and Airfoil Functions

This group of functions provides API control of cross-sections (XSecs). Airfoils are a type of XSec included in this group as well. API functions for Body of Revolution XSecs are included in the Specialized Geometry group. Click here to return to the main page. More...

Functions

void vsp::SetXSecAlias (const std::string &id, const std::string &alias)
std::string vsp::GetXSecAlias (const std::string &id)
void vsp::SetXSecCurveAlias (const std::string &id, const std::string &alias)
std::string vsp::GetXSecCurveAlias (const std::string &id)
void vsp::CutXSec (const std::string &geom_id, int index)
void vsp::CopyXSec (const std::string &geom_id, int index)
void vsp::PasteXSec (const std::string &geom_id, int index)
void vsp::InsertXSec (const std::string &geom_id, int index, int type)
void vsp::FitCSTAirfoil (const std::string &xsec_surf_id, int xsec_index, int deg)
int vsp::GetXSecShape (const std::string &xsec_id)
double vsp::GetXSecWidth (const std::string &xsec_id)
double vsp::GetXSecHeight (const std::string &xsec_id)
void vsp::SetXSecWidthHeight (const std::string &xsec_id, double w, double h)
void vsp::SetXSecWidth (const std::string &xsec_id, double w)
void vsp::SetXSecHeight (const std::string &xsec_id, double h)
std::vector< std::string > vsp::GetXSecParmIDs (const std::string &xsec_id)
std::string vsp::GetXSecParm (const std::string &xsec_id, const std::string &name)
std::vector< vec3dvsp::ReadFileXSec (const std::string &xsec_id, const std::string &file_name)
std::vector< vec3dvsp::GetXSecPnts (const std::string &xsec_id)
void vsp::CopyXSecCurve (const std::string &geom_id, int index)
void vsp::PasteXSecCurve (const std::string &geom_id, int index)
vec3d vsp::ComputeXSecPnt (const std::string &xsec_id, double fract)
vec3d vsp::ComputeXSecTan (const std::string &xsec_id, double fract)
void vsp::ResetXSecSkinParms (const std::string &xsec_id)
int vsp::GetXSecContinuity (const std::string &xsec_id)
std::vector< double > vsp::GetXSecTanAngles (const std::string &xsec_id, int side)
std::vector< double > vsp::GetXSecTanSlews (const std::string &xsec_id, int side)
std::vector< double > vsp::GetXSecTanStrengths (const std::string &xsec_id, int side)
std::vector< double > vsp::GetXSecCurvatures (const std::string &xsec_id, int side)
void vsp::ReadFileAirfoil (const std::string &xsec_id, const std::string &file_name)
void vsp::SetAirfoilUpperPnts (const std::string &xsec_id, const std::vector< vec3d > &up_pnt_vec)
void vsp::SetAirfoilLowerPnts (const std::string &xsec_id, const std::vector< vec3d > &low_pnt_vec)
void vsp::SetAirfoilPnts (const std::string &xsec_id, const std::vector< vec3d > &up_pnt_vec, const std::vector< vec3d > &low_pnt_vec)
std::vector< vec3dvsp::GetHersheyBarLiftDist (const int &npts, const double &alpha, const double &Vinf, const double &span, bool full_span_flag=false)
std::vector< vec3dvsp::GetHersheyBarDragDist (const int &npts, const double &alpha, const double &Vinf, const double &span, bool full_span_flag=false)
std::vector< vec3dvsp::GetVKTAirfoilPnts (const int &npts, const double &alpha, const double &epsilon, const double &kappa, const double &tau)
std::vector< double > vsp::GetVKTAirfoilCpDist (const double &alpha, const double &epsilon, const double &kappa, const double &tau, const std::vector< vec3d > &xyz_data)
std::vector< vec3dvsp::GetEllipsoidSurfPnts (const vec3d &center, const vec3d &abc_rad, int u_npts=20, int w_npts=20)
std::vector< vec3dvsp::GetFeatureLinePnts (const std::string &geom_id)
std::vector< double > vsp::GetEllipsoidCpDist (const std::vector< vec3d > &surf_pnt_vec, const vec3d &abc_rad, const vec3d &V_inf)
std::vector< vec3dvsp::GetAirfoilUpperPnts (const std::string &xsec_id)
std::vector< vec3dvsp::GetAirfoilLowerPnts (const std::string &xsec_id)
std::vector< double > vsp::GetUpperCSTCoefs (const std::string &xsec_id)
std::vector< double > vsp::GetLowerCSTCoefs (const std::string &xsec_id)
int vsp::GetUpperCSTDegree (const std::string &xsec_id)
int vsp::GetLowerCSTDegree (const std::string &xsec_id)
void vsp::SetUpperCST (const std::string &xsec_id, int deg, const std::vector< double > &coefs)
void vsp::SetLowerCST (const std::string &xsec_id, int deg, const std::vector< double > &coefs)
void vsp::PromoteCSTUpper (const std::string &xsec_id)
void vsp::PromoteCSTLower (const std::string &xsec_id)
void vsp::DemoteCSTUpper (const std::string &xsec_id)
void vsp::DemoteCSTLower (const std::string &xsec_id)
void vsp::FitAfCST (const std::string &xsec_surf_id, int xsec_index, int deg)
void vsp::WriteBezierAirfoil (const std::string &file_name, const std::string &geom_id, const double &foilsurf_u)
void vsp::WriteSeligAirfoil (const std::string &file_name, const std::string &geom_id, const double &foilsurf_u)
std::vector< vec3dvsp::GetAirfoilCoordinates (const std::string &geom_id, const double &foilsurf_u)

Detailed Description

Function Documentation

◆ ComputeXSecPnt()

vec3d vsp::ComputeXSecPnt ( const std::string & xsec_id,
double fract )
extern

Compute 3D coordinate for a point on an XSec curve given the parameter value (U) along the curve

//==== Add Geom ====//
string stack_id = AddGeom( "STACK" );
//==== Get The XSec Surf ====//
string xsec_surf = GetXSecSurf( stack_id, 0 );
string xsec = GetXSec( xsec_surf, 2 );
double u_fract = 0.25;
vec3d pnt = ComputeXSecPnt( xsec, u_fract );
// The section is a closed curve, so the ends meet.
if ( dist( ComputeXSecPnt( xsec, 0.0 ), ComputeXSecPnt( xsec, 1.0 ) ) > 1e-6 )
{
Print( "ERROR: the XSec curve does not close" );
__failure++;
}
// The point has to lie on the section, which is sized by its width and
// height about the section origin.
double w = GetXSecWidth( xsec );
double h = GetXSecHeight( xsec );
if ( abs( pnt.y() ) > 0.5 * w + 1e-6 || abs( pnt.z() ) > 0.5 * h + 1e-6 )
{
Print( "ERROR: ComputeXSecPnt returned a point off the section" );
__failure++;
}
Definition Vec3d.h:243
double y() const
Definition Vec3d.h:477
double z() const
Definition Vec3d.h:514
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
double GetXSecWidth(const std::string &xsec_id)
vec3d ComputeXSecPnt(const std::string &xsec_id, double fract)
double GetXSecHeight(const std::string &xsec_id)
std::string GetXSecSurf(const std::string &geom_id, int index)
std::string GetXSec(const std::string &xsec_surf_id, int xsec_index)
double dist(const vec3d &a, const vec3d &b)
Parameters
[in]xsec_idstring XSec ID
[in]fractdouble Curve parameter value (range: 0 - 1)
Returns
vec3d 3D coordinate point

◆ ComputeXSecTan()

vec3d vsp::ComputeXSecTan ( const std::string & xsec_id,
double fract )
extern

Compute the tangent vector of a point on an XSec curve given the parameter value (U) along the curve

//==== Add Geom ====//
string stack_id = AddGeom( "STACK" );
//==== Get The XSec Surf ====//
string xsec_surf = GetXSecSurf( stack_id, 0 );
string xsec = GetXSec( xsec_surf, 2 );
double u_fract = 0.25;
vec3d tan = ComputeXSecTan( xsec, u_fract );
// A tangent is a direction, so it has to have some length.
if ( tan.mag() < 1e-9 )
{
Print( "ERROR: ComputeXSecTan returned a degenerate tangent" );
__failure++;
}
// The tangent has to follow the curve, so stepping along the curve from the
// point has to line up with it.
double du = 1.0e-5;
vec3d p0 = ComputeXSecPnt( xsec, u_fract );
vec3d p1 = ComputeXSecPnt( xsec, u_fract + du );
vec3d fd = p1 - p0;
if ( fd.mag() < 1e-12 )
{
Print( "ERROR: the XSec curve does not advance" );
__failure++;
}
else
{
double align = dot( fd, tan ) / ( fd.mag() * tan.mag() );
if ( align < 0.999 )
{
Print( "ERROR: ComputeXSecTan does not follow the curve" );
__failure++;
}
}
double mag() const
vec3d ComputeXSecTan(const std::string &xsec_id, double fract)
double dot(const vec3d &a, const vec3d &b)
Parameters
[in]xsec_idstring XSec ID
[in]fractdouble Curve parameter value (range: 0 - 1)
Returns
vec3d Tangent vector

◆ CopyXSec()

void vsp::CopyXSec ( const std::string & geom_id,
int index )
extern

Copy a cross-section from the specified geometry and maintain it in memory

// Add Stack
string sid = AddGeom( "STACK", "" );
string xsec_surf = GetXSecSurf( sid, 0 );
// Give XSec 1 a shape that XSec 3 does not have.
int num_start = GetNumXSec( xsec_surf );
// Copy XSec To Clipboard
CopyXSec( sid, 1 );
// Paste To XSec 3
PasteXSec( sid, 3 );
// Pasting replaces the target section, so the count is unchanged and XSec 3
// now carries the shape that was copied.
if ( GetNumXSec( xsec_surf ) != num_start )
{
Print( "ERROR: PasteXSec changed the number of sections" );
__failure++;
}
if ( GetXSecShape( GetXSec( xsec_surf, 3 ) ) != XS_ROUNDED_RECTANGLE )
{
Print( "ERROR: PasteXSec did not paste the copied section" );
__failure++;
}
// The section that was copied has to be left alone.
if ( GetXSecShape( GetXSec( xsec_surf, 1 ) ) != XS_ROUNDED_RECTANGLE )
{
Print( "ERROR: CopyXSec disturbed the section it copied" );
__failure++;
}
@ XS_ROUNDED_RECTANGLE
void Update(bool update_managers=true)
void PasteXSec(const std::string &geom_id, int index)
void CopyXSec(const std::string &geom_id, int index)
int GetXSecShape(const std::string &xsec_id)
int GetNumXSec(const std::string &xsec_surf_id)
void ChangeXSecShape(const std::string &xsec_surf_id, int xsec_index, int type)
See also
PasteXSec
Parameters
[in]geom_idstring Geom ID
[in]indexint XSec index

◆ CopyXSecCurve()

void vsp::CopyXSecCurve ( const std::string & geom_id,
int index )
extern

Copy the XSecCurve of a cross section to the XSecCurve clipboard. This carries the section shape without the section's placement, and works on a body of revolution too, where the index is ignored because it holds only one curve.

// Add Stack
string sid = AddGeom( "STACK", "" );
string xsec_surf = GetXSecSurf( sid, 0 );
CopyXSecCurve( sid, 1 );
PasteXSecCurve( sid, 3 );
// The shape travels to the pasted section.
if ( GetXSecShape( GetXSec( xsec_surf, 3 ) ) != XS_ROUNDED_RECTANGLE )
{
Print( "ERROR: the XSecCurve did not paste" );
__failure++;
}
// A Geom that carries no cross sections has to be rejected.
string pid = AddGeom( "POD" );
CopyXSecCurve( pid, 0 );
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: CopyXSecCurve accepted a Geom with no cross sections" );
__failure++;
}
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
void CopyXSecCurve(const std::string &geom_id, int index)
void PasteXSecCurve(const std::string &geom_id, int index)
See also
PasteXSecCurve, CopyXSec, CopyAirfoil
Parameters
[in]geom_idstring Geom ID
[in]indexint XSec index, ignored for a body of revolution

◆ CutXSec()

void vsp::CutXSec ( const std::string & geom_id,
int index )
extern

Cut a cross-section from the specified geometry and maintain it in memory

string fid = AddGeom( "FUSELAGE", "" ); // Add Fuselage
//==== Insert, Cut, Paste Example ====//
string xsec_surf = GetXSecSurf( fid, 0 );
int num_start = GetNumXSec( xsec_surf );
InsertXSec( fid, 1, XS_ROUNDED_RECTANGLE ); // Insert A Cross-Section
if ( GetNumXSec( xsec_surf ) != num_start + 1 )
{
Print( "ERROR: InsertXSec did not add a section" );
__failure++;
}
if ( GetXSecShape( GetXSec( xsec_surf, 2 ) ) != XS_ROUNDED_RECTANGLE )
{
Print( "ERROR: InsertXSec did not insert after the given index" );
__failure++;
}
CopyXSec( fid, 2 ); // Copy Just Created XSec To Clipboard
PasteXSec( fid, 1 ); // Paste Clipboard
// Pasting replaces a section rather than adding one, and section 1 now
// carries the shape that was copied.
if ( GetNumXSec( xsec_surf ) != num_start + 1 )
{
Print( "ERROR: PasteXSec changed the number of sections" );
__failure++;
}
if ( GetXSecShape( GetXSec( xsec_surf, 1 ) ) != XS_ROUNDED_RECTANGLE )
{
Print( "ERROR: PasteXSec did not paste the copied section" );
__failure++;
}
CutXSec( fid, 2 ); // Cut Created XSec
if ( GetNumXSec( xsec_surf ) != num_start )
{
Print( "ERROR: CutXSec did not remove a section" );
__failure++;
}
void InsertXSec(const std::string &geom_id, int index, int type)
void CutXSec(const std::string &geom_id, int index)
See also
PasteXSec
Parameters
[in]geom_idstring Geom ID
[in]indexint XSec index

◆ DemoteCSTLower()

void vsp::DemoteCSTLower ( const std::string & xsec_id)
extern

Demote the CST for the lower airfoil surface. The XSec must be of type XS_CST_AIRFOIL

See also
GetLowerCSTDegree
Parameters
[in]xsec_idstring XSec ID

◆ DemoteCSTUpper()

void vsp::DemoteCSTUpper ( const std::string & xsec_id)
extern

Demote the CST for the upper airfoil surface. The XSec must be of type XS_CST_AIRFOIL

See also
GetUpperCSTDegree
Parameters
[in]xsec_idstring XSec ID

◆ FitAfCST()

void vsp::FitAfCST ( const std::string & xsec_surf_id,
int xsec_index,
int deg )
extern

Fit a CST airfoil for an existing airfoil of type XS_FOUR_SERIES, XS_SIX_SERIES, XS_FOUR_DIGIT_MOD, XS_FIVE_DIGIT, XS_FIVE_DIGIT_MOD, XS_ONE_SIX_SERIES, or XS_FILE_AIRFOIL.

Parameters
[in]xsec_surf_idstring XsecSurf ID
[in]xsec_indexint XSec index
[in]degint CST degree

◆ FitCSTAirfoil()

void vsp::FitCSTAirfoil ( const std::string & xsec_surf_id,
int xsec_index,
int deg )
extern

Convert an airfoil cross section to a CST airfoil fitted to the shape it already has, the way the Fit CST button on the airfoil panels does. A CST airfoil is described by coefficients rather than by a table or a series designation, which is what makes it useful for optimization; fitting is how an airfoil of any other type is brought into that form without changing shape.

string wing_id = AddGeom( "WING", "" );
string xsec_surf = GetXSecSurf( wing_id, 0 );
FitCSTAirfoil( xsec_surf, 1, 8 );
string xsec = GetXSec( xsec_surf, 1 );
if ( GetXSecShape( xsec ) != XS_CST_AIRFOIL )
{
Print( "ERROR: FitCSTAirfoil did not convert the XSec" );
__failure++;
}
// The fit is carried out at the degree that was asked for.
if ( GetUpperCSTDegree( xsec ) != 8 || GetLowerCSTDegree( xsec ) != 8 )
{
Print( "ERROR: FitCSTAirfoil did not fit at the requested degree" );
__failure++;
}
@ XS_FOUR_SERIES
@ XS_CST_AIRFOIL
int GetLowerCSTDegree(const std::string &xsec_id)
void FitCSTAirfoil(const std::string &xsec_surf_id, int xsec_index, int deg)
int GetUpperCSTDegree(const std::string &xsec_id)
See also
ChangeXSecShape, GetUpperCSTCoefs, PromoteCSTUpper
Parameters
[in]xsec_surf_idstring XSecSurf ID
[in]xsec_indexint XSec index
[in]degint Degree to fit the CST airfoil at

◆ GetAirfoilCoordinates()

std::vector< vec3d > vsp::GetAirfoilCoordinates ( const std::string & geom_id,
const double & foilsurf_u )
extern

Get the untwisted unit-length 2D coordinate points for the specified airfoil

See also
WriteSeligAirfoil
Parameters
[in]geom_idstring Geom ID
[in]foilsurf_udouble U location (range: 0 - 1) along the surface. The foil surface does not include root and tip caps (i.e. 2 section wing -> XSec0 @ u=0, XSec1 @ u=0.5, XSec2 @ u=1.0)

◆ GetAirfoilLowerPnts()

std::vector< vec3d > vsp::GetAirfoilLowerPnts ( const std::string & xsec_id)
extern

Get the coordinate points for the lower surface of an airfoil. The XSec must be of type XS_FILE_AIRFOIL

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
string xsec = GetXSec( xsec_surf, 1 );
ReadFileAirfoil( xsec, "airfoil/N0012_VSP.af" );
array< vec3d > @low_array = GetAirfoilLowerPnts( xsec );
if ( low_array.length() == 0 )
{
Print( "ERROR: GetAirfoilLowerPnts returned nothing" );
__failure++;
}
@ XS_FILE_AIRFOIL
std::vector< vec3d > GetAirfoilLowerPnts(const std::string &xsec_id)
void ReadFileAirfoil(const std::string &xsec_id, const std::string &file_name)
See also
SetAirfoilPnts
Parameters
[in]xsec_idstring XSec ID
Returns
vector<vec3d> Vector of coordinate points for the lower airfoil surface

◆ GetAirfoilUpperPnts()

std::vector< vec3d > vsp::GetAirfoilUpperPnts ( const std::string & xsec_id)
extern

Get the coordinate points for the upper surface of an airfoil. The XSec must be of type XS_FILE_AIRFOIL

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
string xsec = GetXSec( xsec_surf, 1 );
ReadFileAirfoil( xsec, "airfoil/N0012_VSP.af" );
array< vec3d > @up_array = GetAirfoilUpperPnts( xsec );
if ( up_array.length() == 0 )
{
Print( "ERROR: GetAirfoilUpperPnts returned nothing" );
__failure++;
}
std::vector< vec3d > GetAirfoilUpperPnts(const std::string &xsec_id)
See also
SetAirfoilPnts
Parameters
[in]xsec_idstring XSec ID
Returns
vector<vec3d> VectorArray of coordinate points for the upper airfoil surface

◆ GetEllipsoidCpDist()

std::vector< double > vsp::GetEllipsoidCpDist ( const std::vector< vec3d > & surf_pnt_vec,
const vec3d & abc_rad,
const vec3d & V_inf )
extern

Generate Analytical Solution for Potential Flow for specified ellipsoid shape at input surface points for input velocity vector. Based on Munk, M. M., 'Remarks on the Pressure Distribution over the Surface of an Ellipsoid, Moving Translationally Through a Perfect Fluid,' NACA TN-196, June 1924. Function initially created to compare VSPAERO results to theory.

const double pi = 3.14159265358979323846;
const int npts = 101;
const vec3d abc_rad = vec3d(1.0, 2.0, 3.0);
const double alpha = 5; // deg
const double beta = 5; // deg
const double V_inf = 100.0;
array < vec3d > x_slice_pnt_vec(npts);
array<double> theta_vec(npts);
theta_vec[0] = 0;
for ( int i = 1; i < npts; i++ )
{
theta_vec[i] = theta_vec[i-1] + (2 * pi / ( npts - 1) );
}
for ( int i = 0; i < npts; i++ )
{
x_slice_pnt_vec[i] = vec3d( 0, abc_rad[1] * cos( theta_vec[i] ), abc_rad[2] *sin( theta_vec[i] ) );
}
vec3d V_vec = vec3d( ( V_inf * cos( Deg2Rad( alpha ) ) * cos( Deg2Rad( beta ) ) ), ( V_inf * sin( Deg2Rad( beta ) ) ), ( V_inf * sin( Deg2Rad( alpha ) ) * cos( Deg2Rad( beta ) ) ) );
array < double > cp_dist = GetEllipsoidCpDist( x_slice_pnt_vec, abc_rad, V_vec );
if ( cp_dist.length() == 0 )
{
Print( "ERROR: GetEllipsoidCpDist returned nothing" );
__failure++;
}
std::vector< double > GetEllipsoidCpDist(const std::vector< vec3d > &surf_pnt_vec, const vec3d &abc_rad, const vec3d &V_inf)
See also
GetEllipsoidSurfPnts
Parameters
[in]surf_pnt_vecvector<vec3d> Vector of points on the ellipsoid surface to assess
[in]abc_radvec3d Radius along the A (X), B (Y), and C (Z) axes
[in]V_infvec3d 3D components of freestream velocity
Returns
vector<double> Vector of Cp results corresponding to each point in surf_pnt_arr

◆ GetEllipsoidSurfPnts()

std::vector< vec3d > vsp::GetEllipsoidSurfPnts ( const vec3d & center,
const vec3d & abc_rad,
int u_npts = 20,
int w_npts = 20 )
extern

Generate the surface coordinate points for a ellipsoid at specified center of input radius along each axis. Based on the MATLAB function ellipsoid (https://in.mathworks.com/help/matlab/ref/ellipsoid.html).

See also
GetVKTAirfoilPnts
Parameters
[in]centervec3d 3D location of the ellipsoid center
[in]abc_radvec3d Radius along the A (X), B (Y), and C (Z) axes
[in]u_nptsint Number of points in the U direction
[in]w_nptsint Number of points in the W direction
Returns
vector<vec3d> Array of coordinates describing the ellipsoid surface

◆ GetFeatureLinePnts()

std::vector< vec3d > vsp::GetFeatureLinePnts ( const std::string & geom_id)
extern

Get the points along the feature lines of a particular Geom

Parameters
[in]geom_idstring Geom ID
Returns
vector<vec3d> Array of points along the Geom's feature lines

◆ GetHersheyBarDragDist()

std::vector< vec3d > vsp::GetHersheyBarDragDist ( const int & npts,
const double & alpha,
const double & Vinf,
const double & span,
bool full_span_flag = false )
extern

Get the theoretical drag (Cd) distribution for a Hershey Bar wing with unit chord length using Glauert's Method. This function was initially created to compare VSPAERO results to Lifting Line Theory. If full_span_flag is set to true symmetry is applied to the results.

// Compute theoretical lift and drag distributions using 100 points
double Vinf = 100;
double halfAR = 20;
double alpha_deg = 10;
int n_pts = 100;
array<vec3d> cl_dist_theo = GetHersheyBarLiftDist( int( n_pts ), Deg2Rad( alpha_deg ), Vinf, ( 2 * halfAR ), false );
array<vec3d> cd_dist_theo = GetHersheyBarDragDist( int( n_pts ), Deg2Rad( alpha_deg ), Vinf, ( 2 * halfAR ), false );
if ( cd_dist_theo.length() == 0 )
{
Print( "ERROR: GetHersheyBarDragDist returned nothing" );
__failure++;
}
std::vector< vec3d > GetHersheyBarDragDist(const int &npts, const double &alpha, const double &Vinf, const double &span, bool full_span_flag=false)
std::vector< vec3d > GetHersheyBarLiftDist(const int &npts, const double &alpha, const double &Vinf, const double &span, bool full_span_flag=false)
Parameters
[in]nptsint Number of points along the span to assess
[in]alphadouble Wing angle of attack (Radians)
[in]Vinfdouble Freestream velocity
[in]spandouble Hershey Bar full-span. Note, only half is used in the calculation
[in]full_span_flagbool Flag to apply symmetry to results (default: false)
Returns
vector<vec3d> Theoretical coefficient of drag distribution array (size = 2*npts if full_span_flag = true)

◆ GetHersheyBarLiftDist()

std::vector< vec3d > vsp::GetHersheyBarLiftDist ( const int & npts,
const double & alpha,
const double & Vinf,
const double & span,
bool full_span_flag = false )
extern

Get the theoretical lift (Cl) distribution for a Hershey Bar wing with unit chord length using Glauert's Method. This function was initially created to compare VSPAERO results to Lifting Line Theory. If full_span_flag is set to true symmetry is applied to the results.

// Compute theoretical lift and drag distributions using 100 points
double Vinf = 100;
double halfAR = 20;
double alpha_deg = 10;
int n_pts = 100;
array<vec3d> cl_dist_theo = GetHersheyBarLiftDist( int( n_pts ), Deg2Rad( alpha_deg ), Vinf, ( 2 * halfAR ), false );
if ( cl_dist_theo.length() == 0 )
{
Print( "ERROR: GetHersheyBarLiftDist returned nothing" );
__failure++;
}
array<vec3d> cd_dist_theo = GetHersheyBarDragDist( int( n_pts ), Deg2Rad( alpha_deg ), Vinf, ( 2 * halfAR ), false );
Parameters
[in]nptsint Number of points along the span to assess
[in]alphadouble Wing angle of attack (Radians)
[in]Vinfdouble Freestream velocity
[in]spandouble Hershey Bar full-span. Note, only half is used in the calculation
[in]full_span_flagbool Flag to apply symmetry to results
Returns
vector<vec3d> Theoretical coefficient of lift distribution array (size = 2*npts if full_span_flag = true)

◆ GetLowerCSTCoefs()

std::vector< double > vsp::GetLowerCSTCoefs ( const std::string & xsec_id)
extern

Get the CST coefficients for the lower surface of an airfoil. The XSec must be of type XS_CST_AIRFOIL

See also
SetLowerCST
Parameters
[in]xsec_idstring XSec ID
Returns
vector<double> Vector of CST coefficients for the lower airfoil surface

◆ GetLowerCSTDegree()

int vsp::GetLowerCSTDegree ( const std::string & xsec_id)
extern

Get the CST degree for the lower surface of an airfoil. The XSec must be of type XS_CST_AIRFOIL

See also
SetLowerCST
Parameters
[in]xsec_idstring XSec ID
Returns
int CST Degree for lower airfoil surface

◆ GetUpperCSTCoefs()

std::vector< double > vsp::GetUpperCSTCoefs ( const std::string & xsec_id)
extern

Get the CST coefficients for the upper surface of an airfoil. The XSec must be of type XS_CST_AIRFOIL

See also
SetUpperCST
Parameters
[in]xsec_idstring XSec ID
Returns
vector<double> Vector of CST coefficients for the upper airfoil surface

◆ GetUpperCSTDegree()

int vsp::GetUpperCSTDegree ( const std::string & xsec_id)
extern

Get the CST degree for the upper surface of an airfoil. The XSec must be of type XS_CST_AIRFOIL

See also
SetUpperCST
Parameters
[in]xsec_idstring XSec ID
Returns
int CST Degree for upper airfoil surface

◆ GetVKTAirfoilCpDist()

std::vector< double > vsp::GetVKTAirfoilCpDist ( const double & alpha,
const double & epsilon,
const double & kappa,
const double & tau,
const std::vector< vec3d > & xyz_data )
extern

Get the pressure coefficient (Cp) along a Von Kármán-Trefftz airfoil of specified shape at specified points along the airfoil

const double pi = 3.14159265358979323846;
const int npts = 122;
const double alpha = 0.0;
const double epsilon = 0.1;
const double kappa = 0.1;
const double tau = 10;
array<vec3d> xyz_airfoil = GetVKTAirfoilPnts(npts, alpha, epsilon, kappa, tau*(pi/180) );
array<double> cp_dist = GetVKTAirfoilCpDist( alpha, epsilon, kappa, tau*(pi/180), xyz_airfoil );
if ( cp_dist.length() == 0 )
{
Print( "ERROR: GetVKTAirfoilCpDist returned nothing" );
__failure++;
}
std::vector< double > GetVKTAirfoilCpDist(const double &alpha, const double &epsilon, const double &kappa, const double &tau, const std::vector< vec3d > &xyz_data)
std::vector< vec3d > GetVKTAirfoilPnts(const int &npts, const double &alpha, const double &epsilon, const double &kappa, const double &tau)
See also
GetVKTAirfoilPnts
Parameters
[in]alphadouble Airfoil angle of attack (Radians)
[in]epsilondouble Airfoil thickness
[in]kappadouble Airfoil camber
[in]taudouble Airfoil trailing edge angle (Radians)
[in]xyz_datavector<vec3d> Vector of points on the airfoil to evaluate
Returns
vector<double> Vector of Cp values for each point in xydata

◆ GetVKTAirfoilPnts()

std::vector< vec3d > vsp::GetVKTAirfoilPnts ( const int & npts,
const double & alpha,
const double & epsilon,
const double & kappa,
const double & tau )
extern

Get the 2D coordinates an input number of points along a Von K�rm�n-Trefftz airfoil of specified shape

const double pi = 3.14159265358979323846;
const int npts = 122;
const double alpha = 0.0;
const double epsilon = 0.1;
const double kappa = 0.1;
const double tau = 10;
array<vec3d> xyz_airfoil = GetVKTAirfoilPnts(npts, alpha, epsilon, kappa, tau*(pi/180) );
if ( xyz_airfoil.length() == 0 )
{
Print( "ERROR: GetVKTAirfoilPnts returned nothing" );
__failure++;
}
array<double> cp_dist = GetVKTAirfoilCpDist( alpha, epsilon, kappa, tau*(pi/180), xyz_airfoil );
Parameters
[in]nptsint Number of points along the airfoil to return
[in]alphadouble Airfoil angle of attack (Radians)
[in]epsilondouble Airfoil thickness
[in]kappadouble Airfoil camber
[in]taudouble Airfoil trailing edge angle (Radians)
Returns
vector<vec3d> Array of points on the VKT airfoil (size = npts)

◆ GetXSecAlias()

std::string vsp::GetXSecAlias ( const std::string & id)
extern

Get XSec Alias by ID

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
// Identify XSec 1
string xsec_1 = GetXSec( xsec_surf, 1 );
// Set Alias and verify alias match
string alias = "XSec_One_Alias";
SetXSecAlias( xsec_1, alias );
string get_alias = GetXSecAlias( xsec_1 );
if ( alias != get_alias )
{
Print("SetXSecAlias/GetXSecAlias error!");
__failure++;
}
std::string GetXSecAlias(const std::string &id)
void SetXSecAlias(const std::string &id, const std::string &alias)
Parameters
[in]idstring XSec ID
Returns
string Xsec alias

◆ GetXSecContinuity()

int vsp::GetXSecContinuity ( const std::string & xsec_id)
extern

Set C-type continuity enforcement for a particular XSec

string fid = AddGeom( "FUSELAGE", "" ); // Add Fuselage
string xsec_surf = GetXSecSurf( fid, 0 ); // Get First (and Only) XSec Surf
int num_xsecs = GetNumXSec( xsec_surf );
for ( int i = 0 ; i < num_xsecs ; i++ )
{
string xsec = GetXSec( xsec_surf, i );
SetXSecContinuity( xsec, 1 ); // Set Continuity At Cross Section
// The setter is shorthand for the section's continuity Parm.
if ( !closeTo( GetParmVal( GetXSecParm( xsec, "ContinuityTop" ) ), 1.0, 1e-12 ) )
{
Print( "ERROR: SetXSecContinuity did not set section " + i );
__failure++;
}
SetXSecContinuity( xsec, 0 );
if ( !closeTo( GetParmVal( GetXSecParm( xsec, "ContinuityTop" ) ), 0.0, 1e-12 ) )
{
Print( "ERROR: SetXSecContinuity did not clear section " + i );
__failure++;
}
SetXSecContinuity( xsec, 1 );
}
double GetParmVal(const std::string &parm_id)
std::string GetXSecParm(const std::string &xsec_id, const std::string &name)
Parameters
[in]xsec_idstring XSec ID
[in]cxint Continuity level (0, 1, or 2)

Get the C-type continuity enforcement for a particular XSec

string fid = AddGeom( "FUSELAGE", "" ); // Add Fuselage
string xsec_surf = GetXSecSurf( fid, 0 ); // Get First (and Only) XSec Surf
string xsec = GetXSec( xsec_surf, 1 );
SetXSecContinuity( xsec, 1 );
if ( GetXSecContinuity( xsec ) != 1 )
{
Print( "ERROR: GetXSecContinuity did not report the level that was set" );
__failure++;
}
SetXSecContinuity( xsec, 0 );
if ( GetXSecContinuity( xsec ) != 0 )
{
Print( "ERROR: GetXSecContinuity did not follow a second set" );
__failure++;
}
// The level is the section's continuity Parm, so the two have to agree.
if ( !closeTo( GetParmVal( GetXSecParm( xsec, "ContinuityTop" ) ), GetXSecContinuity( xsec ), 1e-12 ) )
{
Print( "ERROR: the continuity level disagrees with its Parm" );
__failure++;
}
int GetXSecContinuity(const std::string &xsec_id)
See also
SetXSecContinuity
Parameters
[in]xsec_idstring XSec ID
Returns
int Continuity level (0, 1, or 2)

◆ GetXSecCurvatures()

std::vector< double > vsp::GetXSecCurvatures ( const std::string & xsec_id,
int side )
extern

Set curvatures for the specified XSec

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
// Flatten ends
int num_xsecs = GetNumXSec( xsec_surf );
for ( int i = 0 ; i < num_xsecs ; i++ )
{
string xsec = GetXSec( xsec_surf, i );
SetXSecCurvatures( xsec, XSEC_BOTH_SIDES, 0.2 ); // Set Tangent Strengths At Cross Section
// The setter is shorthand for the skin Parms, so the value has to show
// up on both sides of the section.
if ( !closeTo( GetParmVal( GetXSecParm( xsec, "TopLCurve" ) ), 0.2, 1e-6 ) ||
!closeTo( GetParmVal( GetXSecParm( xsec, "TopRCurve" ) ), 0.2, 1e-6 ) )
{
Print( "ERROR: SetXSecCurvatures did not set the top of section " + i );
__failure++;
}
}
@ XSEC_BOTH_SIDES
See also
XSEC_SIDES_TYPE
Parameters
[in]xsec_idstring XSec ID
[in]sideint Side type enum (i.e. XSEC_BOTH_SIDES)
[in]topdouble Top curvature
[in]rightdouble Right curvature
[in]bottomdouble Bottom curvature
[in]leftdouble Left curvature

Get the curvatures for one side of the specified XSec. The four values come back in the order the setter takes them: top, right, bottom and left. The two sides can hold different values, so XSEC_BOTH_SIDES is not accepted here.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
string xsec = GetXSec( xsec_surf, 1 );
SetXSecCurvatures( xsec, XSEC_BOTH_SIDES, 0.2 );
array< double > vals = GetXSecCurvatures( xsec, XSEC_LEFT_SIDE );
// Setting both sides at once sets all four positions of each.
if ( vals.size() != 4 )
{
Print( "ERROR: GetXSecCurvatures did not report four values" );
__failure++;
}
else
{
for ( int i = 0; i < 4; i++ )
{
if ( !closeTo( vals[i], 0.2, 1e-6 ) )
{
Print( "ERROR: GetXSecCurvatures did not report the value that was set" );
__failure++;
}
}
}
// Both sides were set, so they agree, and each matches its Parm.
array< double > right_vals = GetXSecCurvatures( xsec, XSEC_RIGHT_SIDE );
if ( right_vals.size() != 4 || !closeTo( right_vals[0], vals[0], 1e-9 ) )
{
Print( "ERROR: the two sides disagree after setting both" );
__failure++;
}
if ( !closeTo( vals[0], GetParmVal( GetXSecParm( xsec, "TopLCurve" ) ), 1e-9 ) )
{
Print( "ERROR: GetXSecCurvatures disagrees with its Parm" );
__failure++;
}
// XSEC_BOTH_SIDES names no single answer, so it has to be rejected.
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: GetXSecCurvatures accepted XSEC_BOTH_SIDES" );
__failure++;
}
// That error was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
@ XSEC_LEFT_SIDE
@ XSEC_RIGHT_SIDE
std::vector< double > GetXSecCurvatures(const std::string &xsec_id, int side)
See also
XSEC_SIDES_TYPE, SetXSecCurvatures
Parameters
[in]xsec_idstring XSec ID
[in]sideint Side type enum (XSEC_LEFT_SIDE or XSEC_RIGHT_SIDE)
Returns
vector<double> Top, right, bottom and left values for that side

◆ GetXSecCurveAlias()

std::string vsp::GetXSecCurveAlias ( const std::string & id)
extern

Get XSecCurve Alias by XSec ID

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
// Identify XSec 1
string xsec_1 = GetXSec( xsec_surf, 1 );
// Set Alias and verify alias match
string alias = "XSecCurve_One_Alias";
SetXSecCurveAlias( xsec_1, alias );
string get_alias = GetXSecCurveAlias( xsec_1 );
if ( alias != get_alias )
{
Print("SetXSecCurveAlias/GetXSecCurveAlias error!");
__failure++;
}
std::string GetXSecCurveAlias(const std::string &id)
void SetXSecCurveAlias(const std::string &id, const std::string &alias)
Parameters
[in]idstring XSec ID

◆ GetXSecHeight()

double vsp::GetXSecHeight ( const std::string & xsec_id)
extern

Get the height of an XSec. Note that POINT type XSecs have a width and height of 0, regardless of what width and height it is set to.

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
string xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 2 ); // Get 2nd to last XSec
SetXSecWidthHeight( xsec, 3.0, 6.0 );
if ( abs( GetXSecHeight( xsec ) - 6.0 ) > 1e-6 ) { Print( "---> Error: API Get/Set Width " ); __failure++; }
void SetXSecWidthHeight(const std::string &xsec_id, double w, double h)
See also
SetXSecHeight
Parameters
[in]xsec_idstring XSec ID
Returns
double Xsec height

◆ GetXSecParm()

std::string vsp::GetXSecParm ( const std::string & xsec_id,
const std::string & name )
extern

Get a specific Parm ID from an Xsec

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
ChangeXSecShape( xsec_surf, GetNumXSec( xsec_surf ) - 1, XS_ROUNDED_RECTANGLE );
string xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 1 );
string wid = GetXSecParm( xsec, "RoundedRect_Width" );
if ( !ValidParm( wid ) ) { Print( "---> Error: API GetXSecParm " ); __failure++; }
bool ValidParm(const std::string &id)
Parameters
[in]xsec_idstring XSec ID
[in]namestring Parm name
Returns
string Parm ID

◆ GetXSecParmIDs()

std::vector< std::string > vsp::GetXSecParmIDs ( const std::string & xsec_id)
extern

Get all Parm IDs for specified XSec Parm Container

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
string xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 1 );
array< string > @parm_array = GetXSecParmIDs( xsec );
if ( parm_array.size() < 1 ) { Print( "---> Error: API GetXSecParmIDs " ); __failure++; }
std::vector< std::string > GetXSecParmIDs(const std::string &xsec_id)
Parameters
[in]xsec_idstring XSec ID
Returns
vector<string> Array of Parm IDs

◆ GetXSecPnts()

std::vector< vec3d > vsp::GetXSecPnts ( const std::string & xsec_id)
extern

Set the coordinate points for a specific XSec. The XSec must be of type XS_FILE_FUSE.

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
ChangeXSecShape( xsec_surf, 2, XS_FILE_FUSE );
string xsec = GetXSec( xsec_surf, 2 );
array< vec3d > @vec_array = ReadFileXSec( xsec, "TestXSec.fxs" );
if ( vec_array.size() == 0 )
{
Print( "ERROR: ReadFileXSec returned no points" );
__failure++;
}
else
{
vec_array[1] = vec_array[1] * 2.0;
vec_array[3] = vec_array[3] * 2.0;
// A file XSec takes its width and height from the extents of the
// points it was given, in X and Y respectively.
double wmin = vec_array[0].x(), wmax = vec_array[0].x();
double hmin = vec_array[0].y(), hmax = vec_array[0].y();
for ( int i = 1; i < int( vec_array.size() ); i++ )
{
if ( vec_array[i].x() < wmin ) { wmin = vec_array[i].x(); }
if ( vec_array[i].x() > wmax ) { wmax = vec_array[i].x(); }
if ( vec_array[i].y() < hmin ) { hmin = vec_array[i].y(); }
if ( vec_array[i].y() > hmax ) { hmax = vec_array[i].y(); }
}
SetXSecPnts( xsec, vec_array );
Update();
if ( !closeTo( GetXSecWidth( xsec ), wmax - wmin, 1e-6 ) )
{
Print( "ERROR: SetXSecPnts did not set the section width" );
__failure++;
}
if ( !closeTo( GetXSecHeight( xsec ), hmax - hmin, 1e-6 ) )
{
Print( "ERROR: SetXSecPnts did not set the section height" );
__failure++;
}
}
@ XS_FILE_FUSE
std::vector< vec3d > ReadFileXSec(const std::string &xsec_id, const std::string &file_name)
Parameters
[in]xsec_idstring XSec ID
[in]pnt_vecvector<vec3d> Vector of XSec coordinate points

Get the coordinate points for a specific XSec. The XSec must be of type XS_FILE_FUSE. The points are returned normalized to the section's width and height.

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
ChangeXSecShape( xsec_surf, 2, XS_FILE_FUSE );
string xsec = GetXSec( xsec_surf, 2 );
array< vec3d > @vec_array = ReadFileXSec( xsec, "TestXSec.fxs" );
// The points that were read are the points the section is carrying.
array< vec3d > @check_array = GetXSecPnts( xsec );
if ( check_array.size() == 0 )
{
Print( "ERROR: GetXSecPnts returned nothing" );
__failure++;
}
else
{
// The stored points are normalized, so they fit in the unit box.
for ( int i = 0; i < int( check_array.size() ); i++ )
{
if ( abs( check_array[i].x() ) > 0.5 + 1e-9 || abs( check_array[i].y() ) > 0.5 + 1e-9 )
{
Print( "ERROR: GetXSecPnts returned a point outside the unit box" );
__failure++;
}
}
// The curve closes on itself.
if ( dist( check_array[0], check_array[check_array.size() - 1] ) > 1e-8 )
{
Print( "ERROR: GetXSecPnts returned an open curve" );
__failure++;
}
}
// Setting points has to be what comes back.
SetXSecPnts( xsec, vec_array );
array< vec3d > @after_array = GetXSecPnts( xsec );
if ( after_array.size() != check_array.size() )
{
Print( "ERROR: GetXSecPnts did not follow SetXSecPnts" );
__failure++;
}
std::vector< vec3d > GetXSecPnts(const std::string &xsec_id)
See also
SetXSecPnts, ReadFileXSec
Parameters
[in]xsec_idstring XSec ID
Returns
vector<vec3d> Vector of XSec coordinate points

◆ GetXSecShape()

int vsp::GetXSecShape ( const std::string & xsec_id)
extern

Get the shape of an XSec

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
ChangeXSecShape( xsec_surf, 1, XS_EDIT_CURVE );
string xsec = GetXSec( xsec_surf, 1 );
if ( GetXSecShape( xsec ) != XS_EDIT_CURVE ) { Print( "ERROR: GetXSecShape" ); __failure++; }
@ XS_EDIT_CURVE
See also
XSEC_CRV_TYPE
Parameters
[in]xsec_idstring XSec ID
Returns
int XSec type enum (i.e. XS_ELLIPSE)

◆ GetXSecTanAngles()

std::vector< double > vsp::GetXSecTanAngles ( const std::string & xsec_id,
int side )
extern

Set the tangent angles for the specified XSec

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
int num_xsecs = GetNumXSec( xsec_surf );
for ( int i = 0 ; i < num_xsecs ; i++ )
{
string xsec = GetXSec( xsec_surf, i );
SetXSecTanAngles( xsec, XSEC_BOTH_SIDES, 10.0 ); // Set Tangent Angles At Cross Section
// The setter is shorthand for the skin Parms, so the value has to show
// up on both sides of the section.
if ( !closeTo( GetParmVal( GetXSecParm( xsec, "TopLAngle" ) ), 10.0, 1e-6 ) ||
!closeTo( GetParmVal( GetXSecParm( xsec, "TopRAngle" ) ), 10.0, 1e-6 ) )
{
Print( "ERROR: SetXSecTanAngles did not set the top of section " + i );
__failure++;
}
}
See also
XSEC_SIDES_TYPE
Parameters
[in]xsec_idstring XSec ID
[in]sideint Side type enum (i.e. XSEC_BOTH_SIDES)
[in]topdouble Top angle (degrees)
[in]rightdouble Right angle (degrees)
[in]bottomdouble Bottom angle (degrees)
[in]leftdouble Left angle (degrees)

Get the tangent angles for one side of the specified XSec. The four values come back in the order the setter takes them: top, right, bottom and left. The two sides can hold different values, so XSEC_BOTH_SIDES is not accepted here.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
string xsec = GetXSec( xsec_surf, 1 );
SetXSecTanAngles( xsec, XSEC_BOTH_SIDES, 10.0 );
array< double > vals = GetXSecTanAngles( xsec, XSEC_LEFT_SIDE );
// Setting both sides at once sets all four positions of each.
if ( vals.size() != 4 )
{
Print( "ERROR: GetXSecTanAngles did not report four values" );
__failure++;
}
else
{
for ( int i = 0; i < 4; i++ )
{
if ( !closeTo( vals[i], 10.0, 1e-6 ) )
{
Print( "ERROR: GetXSecTanAngles did not report the value that was set" );
__failure++;
}
}
}
// Both sides were set, so they agree, and each matches its Parm.
array< double > right_vals = GetXSecTanAngles( xsec, XSEC_RIGHT_SIDE );
if ( right_vals.size() != 4 || !closeTo( right_vals[0], vals[0], 1e-9 ) )
{
Print( "ERROR: the two sides disagree after setting both" );
__failure++;
}
if ( !closeTo( vals[0], GetParmVal( GetXSecParm( xsec, "TopLAngle" ) ), 1e-9 ) )
{
Print( "ERROR: GetXSecTanAngles disagrees with its Parm" );
__failure++;
}
// XSEC_BOTH_SIDES names no single answer, so it has to be rejected.
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: GetXSecTanAngles accepted XSEC_BOTH_SIDES" );
__failure++;
}
// That error was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
std::vector< double > GetXSecTanAngles(const std::string &xsec_id, int side)
See also
XSEC_SIDES_TYPE, SetXSecTanAngles
Parameters
[in]xsec_idstring XSec ID
[in]sideint Side type enum (XSEC_LEFT_SIDE or XSEC_RIGHT_SIDE)
Returns
vector<double> Top, right, bottom and left values for that side

◆ GetXSecTanSlews()

std::vector< double > vsp::GetXSecTanSlews ( const std::string & xsec_id,
int side )
extern

Set the tangent slew angles for the specified XSec

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
int num_xsecs = GetNumXSec( xsec_surf );
for ( int i = 0 ; i < num_xsecs ; i++ )
{
string xsec = GetXSec( xsec_surf, i );
SetXSecTanSlews( xsec, XSEC_BOTH_SIDES, 5.0 ); // Set Tangent Slews At Cross Section
// The setter is shorthand for the skin Parms, so the value has to show
// up on both sides of the section.
if ( !closeTo( GetParmVal( GetXSecParm( xsec, "TopLSlew" ) ), 5.0, 1e-6 ) ||
!closeTo( GetParmVal( GetXSecParm( xsec, "TopRSlew" ) ), 5.0, 1e-6 ) )
{
Print( "ERROR: SetXSecTanSlews did not set the top of section " + i );
__failure++;
}
}
See also
XSEC_SIDES_TYPE
Parameters
[in]xsec_idstring XSec ID
[in]sideint Side type enum (i.e. XSEC_BOTH_SIDES)
[in]topdouble Top angle (degrees)
[in]rightdouble Right angle (degrees)
[in]bottomdouble Bottom angle (degrees)
[in]leftdouble Left angle (degrees)

Get the tangent slew angles for one side of the specified XSec. The four values come back in the order the setter takes them: top, right, bottom and left. The two sides can hold different values, so XSEC_BOTH_SIDES is not accepted here.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
string xsec = GetXSec( xsec_surf, 1 );
SetXSecTanSlews( xsec, XSEC_BOTH_SIDES, 5.0 );
array< double > vals = GetXSecTanSlews( xsec, XSEC_LEFT_SIDE );
// Setting both sides at once sets all four positions of each.
if ( vals.size() != 4 )
{
Print( "ERROR: GetXSecTanSlews did not report four values" );
__failure++;
}
else
{
for ( int i = 0; i < 4; i++ )
{
if ( !closeTo( vals[i], 5.0, 1e-6 ) )
{
Print( "ERROR: GetXSecTanSlews did not report the value that was set" );
__failure++;
}
}
}
// Both sides were set, so they agree, and each matches its Parm.
array< double > right_vals = GetXSecTanSlews( xsec, XSEC_RIGHT_SIDE );
if ( right_vals.size() != 4 || !closeTo( right_vals[0], vals[0], 1e-9 ) )
{
Print( "ERROR: the two sides disagree after setting both" );
__failure++;
}
if ( !closeTo( vals[0], GetParmVal( GetXSecParm( xsec, "TopLSlew" ) ), 1e-9 ) )
{
Print( "ERROR: GetXSecTanSlews disagrees with its Parm" );
__failure++;
}
// XSEC_BOTH_SIDES names no single answer, so it has to be rejected.
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: GetXSecTanSlews accepted XSEC_BOTH_SIDES" );
__failure++;
}
// That error was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
std::vector< double > GetXSecTanSlews(const std::string &xsec_id, int side)
See also
XSEC_SIDES_TYPE, SetXSecTanSlews
Parameters
[in]xsec_idstring XSec ID
[in]sideint Side type enum (XSEC_LEFT_SIDE or XSEC_RIGHT_SIDE)
Returns
vector<double> Top, right, bottom and left values for that side

◆ GetXSecTanStrengths()

std::vector< double > vsp::GetXSecTanStrengths ( const std::string & xsec_id,
int side )
extern

Set the tangent strengths for the specified XSec

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
// Flatten ends
int num_xsecs = GetNumXSec( xsec_surf );
for ( int i = 0 ; i < num_xsecs ; i++ )
{
string xsec = GetXSec( xsec_surf, i );
SetXSecTanStrengths( xsec, XSEC_BOTH_SIDES, 0.8 ); // Set Tangent Strengths At Cross Section
// The setter is shorthand for the skin Parms, so the value has to show
// up on both sides of the section.
if ( !closeTo( GetParmVal( GetXSecParm( xsec, "TopLStrength" ) ), 0.8, 1e-6 ) ||
!closeTo( GetParmVal( GetXSecParm( xsec, "TopRStrength" ) ), 0.8, 1e-6 ) )
{
Print( "ERROR: SetXSecTanStrengths did not set the top of section " + i );
__failure++;
}
}
See also
XSEC_SIDES_TYPE
Parameters
[in]xsec_idstring XSec ID
[in]sideint Side type enum (i.e. XSEC_BOTH_SIDES)
[in]topdouble Top strength
[in]rightdouble Right strength
[in]bottomdouble Bottom strength
[in]leftdouble Left strength

Get the tangent strengths for one side of the specified XSec. The four values come back in the order the setter takes them: top, right, bottom and left. The two sides can hold different values, so XSEC_BOTH_SIDES is not accepted here.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
string xsec = GetXSec( xsec_surf, 1 );
SetXSecTanStrengths( xsec, XSEC_BOTH_SIDES, 0.8 );
array< double > vals = GetXSecTanStrengths( xsec, XSEC_LEFT_SIDE );
// Setting both sides at once sets all four positions of each.
if ( vals.size() != 4 )
{
Print( "ERROR: GetXSecTanStrengths did not report four values" );
__failure++;
}
else
{
for ( int i = 0; i < 4; i++ )
{
if ( !closeTo( vals[i], 0.8, 1e-6 ) )
{
Print( "ERROR: GetXSecTanStrengths did not report the value that was set" );
__failure++;
}
}
}
// Both sides were set, so they agree, and each matches its Parm.
array< double > right_vals = GetXSecTanStrengths( xsec, XSEC_RIGHT_SIDE );
if ( right_vals.size() != 4 || !closeTo( right_vals[0], vals[0], 1e-9 ) )
{
Print( "ERROR: the two sides disagree after setting both" );
__failure++;
}
if ( !closeTo( vals[0], GetParmVal( GetXSecParm( xsec, "TopLStrength" ) ), 1e-9 ) )
{
Print( "ERROR: GetXSecTanStrengths disagrees with its Parm" );
__failure++;
}
// XSEC_BOTH_SIDES names no single answer, so it has to be rejected.
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: GetXSecTanStrengths accepted XSEC_BOTH_SIDES" );
__failure++;
}
// That error was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
std::vector< double > GetXSecTanStrengths(const std::string &xsec_id, int side)
See also
XSEC_SIDES_TYPE, SetXSecTanStrengths
Parameters
[in]xsec_idstring XSec ID
[in]sideint Side type enum (XSEC_LEFT_SIDE or XSEC_RIGHT_SIDE)
Returns
vector<double> Top, right, bottom and left values for that side

◆ GetXSecWidth()

double vsp::GetXSecWidth ( const std::string & xsec_id)
extern

Get the width of an XSec. Note that POINT type XSecs have a width and height of 0, regardless of what width and height it is set to.

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
string xsec = GetXSec( xsec_surf, GetNumXSec( xsec_surf ) - 2 ); // Get 2nd to last XSec
SetXSecWidthHeight( xsec, 3.0, 6.0 );
if ( abs( GetXSecWidth( xsec ) - 3.0 ) > 1e-6 ) { Print( "---> Error: API Get/Set Width " ); __failure++; }
See also
SetXSecWidth
Parameters
[in]xsec_idstring XSec ID
Returns
double Xsec width

◆ InsertXSec()

void vsp::InsertXSec ( const std::string & geom_id,
int index,
int type )
extern

Insert a cross-section of particular type to the specified geometry after the given index

string wing_id = AddGeom( "WING" );
string xsec_surf = GetXSecSurf( wing_id, 0 );
int num_start = GetNumXSec( xsec_surf );
//===== Add XSec ====//
InsertXSec( wing_id, 1, XS_SIX_SERIES );
// The new section lands after the given index.
if ( GetNumXSec( xsec_surf ) != num_start + 1 )
{
Print( "ERROR: InsertXSec did not add a section" );
__failure++;
}
if ( GetXSecShape( GetXSec( xsec_surf, 2 ) ) != XS_SIX_SERIES )
{
Print( "ERROR: InsertXSec did not insert the requested shape" );
__failure++;
}
@ XS_SIX_SERIES
See also
XSEC_CRV_TYPE
Parameters
[in]geom_idstring Geom ID
[in]indexint XSec index
[in]typeint XSec type enum (i.e. XS_GENERAL_FUSE)

◆ PasteXSec()

void vsp::PasteXSec ( const std::string & geom_id,
int index )
extern

Paste the cross-section currently held in memory to the specified geometry

// Add Stack
string sid = AddGeom( "STACK", "" );
string xsec_surf = GetXSecSurf( sid, 0 );
// Give XSec 1 a shape that XSec 3 does not have.
int num_start = GetNumXSec( xsec_surf );
// Copy XSec To Clipboard
CopyXSec( sid, 1 );
// Paste To XSec 3
PasteXSec( sid, 3 );
// Pasting replaces the target section, so the count is unchanged and XSec 3
// now carries the shape that was copied.
if ( GetNumXSec( xsec_surf ) != num_start )
{
Print( "ERROR: PasteXSec changed the number of sections" );
__failure++;
}
if ( GetXSecShape( GetXSec( xsec_surf, 3 ) ) != XS_ROUNDED_RECTANGLE )
{
Print( "ERROR: PasteXSec did not paste the copied section" );
__failure++;
}
// The section that was copied has to be left alone.
if ( GetXSecShape( GetXSec( xsec_surf, 1 ) ) != XS_ROUNDED_RECTANGLE )
{
Print( "ERROR: CopyXSec disturbed the section it copied" );
__failure++;
}
See also
CutXSec, CopyXSec
Parameters
[in]geom_idstring Geom ID
[in]indexint XSec index

◆ PasteXSecCurve()

void vsp::PasteXSecCurve ( const std::string & geom_id,
int index )
extern

Paste the XSecCurve clipboard onto a cross section

// A body of revolution holds one XSecCurve, so its index is ignored.
string sid = AddGeom( "STACK", "" );
string xsec_surf = GetXSecSurf( sid, 0 );
CopyXSecCurve( sid, 1 );
string bor_id = AddGeom( "BODYOFREVOLUTION", "" );
PasteXSecCurve( bor_id, 0 );
{
Print( "ERROR: the XSecCurve did not paste onto the body of revolution" );
__failure++;
}
// An index past the end has to be rejected.
PasteXSecCurve( sid, 100 );
if ( GetNumTotalErrors() == 0 )
{
Print( "ERROR: PasteXSecCurve accepted an index past the end" );
__failure++;
}
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
int GetBORXSecShape(const std::string &bor_id)
See also
CopyXSecCurve, PasteXSec, PasteAirfoil
Parameters
[in]geom_idstring Geom ID
[in]indexint XSec index, ignored for a body of revolution

◆ PromoteCSTLower()

void vsp::PromoteCSTLower ( const std::string & xsec_id)
extern

Promote the CST for the lower airfoil surface. The XSec must be of type XS_CST_AIRFOIL

See also
GetLowerCSTDegree
Parameters
[in]xsec_idstring XSec ID

◆ PromoteCSTUpper()

void vsp::PromoteCSTUpper ( const std::string & xsec_id)
extern

Promote the CST for the upper airfoil surface. The XSec must be of type XS_CST_AIRFOIL

See also
GetUpperCSTDegree
Parameters
[in]xsec_idstring XSec ID

◆ ReadFileAirfoil()

void vsp::ReadFileAirfoil ( const std::string & xsec_id,
const std::string & file_name )
extern

Read in XSec shape from airfoil file and set to the specified XSec. The XSec must be of type XS_FILE_AIRFOIL. Airfoil files may be in Lednicer or Selig format with \*.af or \*.dat extensions.

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
string xsec = GetXSec( xsec_surf, 1 );
ReadFileAirfoil( xsec, "airfoil/N0012_VSP.af" );
array< vec3d > @up_array = GetAirfoilUpperPnts( xsec );
array< vec3d > @low_array = GetAirfoilLowerPnts( xsec );
if ( up_array.size() == 0 || up_array.size() != low_array.size() )
{
Print( "ERROR: ReadFileAirfoil did not read matching surfaces" );
__failure++;
}
else
{
// The points run from the leading edge to the trailing edge on a unit
// chord.
if ( !closeTo( up_array[0].x(), 0.0, 1e-6 ) ||
!closeTo( up_array[up_array.size() - 1].x(), 1.0, 1e-6 ) ||
!closeTo( low_array[0].x(), 0.0, 1e-6 ) )
{
Print( "ERROR: ReadFileAirfoil did not normalize the chord" );
__failure++;
}
// A NACA 0012 is symmetric, so the lower surface mirrors the upper, and
// the section is twelve percent thick.
double max_up = 0.0;
for ( int i = 0; i < int( up_array.size() ); i++ )
{
if ( !closeTo( low_array[i].y(), -up_array[i].y(), 1e-6 ) )
{
Print( "ERROR: ReadFileAirfoil did not read a symmetric section" );
__failure++;
}
if ( up_array[i].y() > max_up )
{
max_up = up_array[i].y();
}
}
if ( !closeTo( 2.0 * max_up, 0.12, 1e-3 ) )
{
Print( "ERROR: ReadFileAirfoil did not read a twelve percent section" );
__failure++;
}
}
Parameters
[in]xsec_idstring XSec ID
[in]file_namestring Airfoil XSec file name

◆ ReadFileXSec()

std::vector< vec3d > vsp::ReadFileXSec ( const std::string & xsec_id,
const std::string & file_name )
extern

Read in XSec shape from fuselage (\*.fsx) file and set to the specified XSec. The XSec must be of type XS_FILE_FUSE.

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
ChangeXSecShape( xsec_surf, 2, XS_FILE_FUSE );
string xsec = GetXSec( xsec_surf, 2 );
array< vec3d > @vec_array = ReadFileXSec( xsec, "TestXSec.fxs" );
// The file holds a closed diamond, so the first and last points coincide
// and the section takes its size from their extents.
if ( vec_array.size() < 3 )
{
Print( "ERROR: ReadFileXSec returned too few points" );
__failure++;
}
else
{
if ( dist( vec_array[0], vec_array[vec_array.size() - 1] ) > 1e-8 )
{
Print( "ERROR: ReadFileXSec returned an open curve" );
__failure++;
}
// The shape is normalized on the way in and then scaled by the
// section's own width and height, so the curve has to fit inside them.
double w = GetXSecWidth( xsec );
double h = GetXSecHeight( xsec );
for ( int i = 0; i < 11; i++ )
{
vec3d p = ComputeXSecPnt( xsec, i * 0.1 );
if ( abs( p.y() ) > 0.5 * w + 1e-6 || abs( p.z() ) > 0.5 * h + 1e-6 )
{
Print( "ERROR: ReadFileXSec left the curve outside the section" );
__failure++;
}
}
}
Parameters
[in]xsec_idstring XSec ID
[in]file_namestring Fuselage XSec file name
Returns
vector<vec3d> Array of coordinate points read from the file and set to the XSec

◆ ResetXSecSkinParms()

void vsp::ResetXSecSkinParms ( const std::string & xsec_id)
extern

Reset all skinning Parms for a specified XSec. Set top, bottom, left, and right strengths, slew, angle, and curvature to 0. Set all symmetry and equality conditions to false.

string fid = AddGeom( "FUSELAGE", "" ); // Add Fuselage
string xsec_surf = GetXSecSurf( fid, 0 ); // Get First (and Only) XSec Surf
int num_xsecs = GetNumXSec( xsec_surf );
string xsec = GetXSec( xsec_surf, 1 );
SetXSecTanAngles( xsec, XSEC_BOTH_SIDES, 15.0 ); // Set Tangent Angles At Cross Section
SetXSecContinuity( xsec, 1 ); // Set Continuity At Cross Section
if ( !closeTo( GetParmVal( GetXSecParm( xsec, "TopLAngle" ) ), 15.0, 1e-6 ) )
{
Print( "ERROR: the skin Parms were never set" );
__failure++;
}
// Resetting zeroes every skin value on all four sides and turns the
// symmetry flags back on. Continuity is left alone.
if ( !closeTo( GetParmVal( GetXSecParm( xsec, "TopLAngle" ) ), 0.0, 1e-6 ) ||
!closeTo( GetParmVal( GetXSecParm( xsec, "TopRAngle" ) ), 0.0, 1e-6 ) ||
!closeTo( GetParmVal( GetXSecParm( xsec, "TopLSlew" ) ), 0.0, 1e-6 ) ||
!closeTo( GetParmVal( GetXSecParm( xsec, "TopLStrength" ) ), 0.0, 1e-6 ) ||
!closeTo( GetParmVal( GetXSecParm( xsec, "TopLCurve" ) ), 0.0, 1e-6 ) ||
!closeTo( GetParmVal( GetXSecParm( xsec, "RightLAngle" ) ), 0.0, 1e-6 ) ||
!closeTo( GetParmVal( GetXSecParm( xsec, "BottomLAngle" ) ), 0.0, 1e-6 ) ||
!closeTo( GetParmVal( GetXSecParm( xsec, "LeftLAngle" ) ), 0.0, 1e-6 ) )
{
Print( "ERROR: ResetXSecSkinParms did not zero the skin Parms" );
__failure++;
}
if ( !closeTo( GetParmVal( GetXSecParm( xsec, "TBSym" ) ), 1.0, 1e-12 ) ||
!closeTo( GetParmVal( GetXSecParm( xsec, "RLSym" ) ), 1.0, 1e-12 ) )
{
Print( "ERROR: ResetXSecSkinParms did not restore the symmetry flags" );
__failure++;
}
void ResetXSecSkinParms(const std::string &xsec_id)
Parameters
[in]xsec_idstring XSec ID

◆ SetAirfoilLowerPnts()

void vsp::SetAirfoilLowerPnts ( const std::string & xsec_id,
const std::vector< vec3d > & low_pnt_vec )
extern

Set the lower points for an airfoil. The XSec must be of type XS_FILE_AIRFOIL.

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
string xsec = GetXSec( xsec_surf, 1 );
ReadFileAirfoil( xsec, "airfoil/N0012_VSP.af" );
array< vec3d > @low_array = GetAirfoilLowerPnts( xsec );
for ( int i = 0 ; i < int( low_array.size() ) ; i++ )
{
low_array[i].scale_y( 0.5 );
}
SetAirfoilLowerPnts( xsec, low_array );
array< vec3d > @check_array = GetAirfoilLowerPnts( xsec );
if ( check_array.length() != low_array.length() )
{
Print( "ERROR: SetAirfoilLowerPnts point count" );
__failure++;
}
else
{
// The halved lower surface has to come back halved, and the upper
// surface has to be left alone.
for ( int i = 0; i < int( low_array.size() ); i++ )
{
if ( dist( check_array[i], low_array[i] ) > 1e-6 )
{
Print( "ERROR: SetAirfoilLowerPnts did not store point " + i );
__failure++;
}
}
array< vec3d > @up_array = GetAirfoilUpperPnts( xsec );
double max_up = 0.0;
double min_low = 0.0;
for ( int i = 0; i < int( check_array.size() ); i++ )
{
if ( up_array[i].y() > max_up ) { max_up = up_array[i].y(); }
if ( check_array[i].y() < min_low ) { min_low = check_array[i].y(); }
}
if ( !closeTo( 0.5 * max_up, -min_low, 1e-6 ) )
{
Print( "ERROR: SetAirfoilLowerPnts did not leave the upper surface alone" );
__failure++;
}
}
void SetAirfoilLowerPnts(const std::string &xsec_id, const std::vector< vec3d > &low_pnt_vec)
Parameters
[in]xsec_idstring XSec ID
[in]low_pnt_vecvector<vec3d> Array of points defining the lower surface of the airfoil

◆ SetAirfoilPnts()

void vsp::SetAirfoilPnts ( const std::string & xsec_id,
const std::vector< vec3d > & up_pnt_vec,
const std::vector< vec3d > & low_pnt_vec )
extern

Set the upper and lower points for an airfoil. The XSec must be of type XS_FILE_AIRFOIL.

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
string xsec = GetXSec( xsec_surf, 1 );
ReadFileAirfoil( xsec, "airfoil/N0012_VSP.af" );
array< vec3d > @up_array = GetAirfoilUpperPnts( xsec );
array< vec3d > @low_array = GetAirfoilLowerPnts( xsec );
for ( int i = 0 ; i < int( up_array.size() ) ; i++ )
{
up_array[i].scale_y( 2.0 );
low_array[i].scale_y( 0.5 );
}
SetAirfoilPnts( xsec, up_array, low_array );
array< vec3d > @check_up = GetAirfoilUpperPnts( xsec );
array< vec3d > @check_low = GetAirfoilLowerPnts( xsec );
if ( check_up.length() != up_array.length() || check_low.length() != low_array.length() )
{
Print( "ERROR: SetAirfoilPnts point count" );
__failure++;
}
else
{
for ( int i = 0; i < int( up_array.size() ); i++ )
{
if ( dist( check_up[i], up_array[i] ) > 1e-6 || dist( check_low[i], low_array[i] ) > 1e-6 )
{
Print( "ERROR: SetAirfoilPnts did not store point " + i );
__failure++;
}
}
// The section started symmetric; doubling the top and halving the
// bottom leaves the top four times as deep as the bottom.
double max_up = 0.0;
double min_low = 0.0;
for ( int i = 0; i < int( check_up.size() ); i++ )
{
if ( check_up[i].y() > max_up ) { max_up = check_up[i].y(); }
if ( check_low[i].y() < min_low ) { min_low = check_low[i].y(); }
}
if ( !closeTo( max_up, -4.0 * min_low, 1e-6 ) )
{
Print( "ERROR: SetAirfoilPnts did not scale the two surfaces apart" );
__failure++;
}
}
void SetAirfoilPnts(const std::string &xsec_id, const std::vector< vec3d > &up_pnt_vec, const std::vector< vec3d > &low_pnt_vec)
Parameters
[in]xsec_idstring XSec ID
[in]up_pnt_vecvector<vec3d> Array of points defining the upper surface of the airfoil
[in]low_pnt_vecvector<vec3d> Array of points defining the lower surface of the airfoil

◆ SetAirfoilUpperPnts()

void vsp::SetAirfoilUpperPnts ( const std::string & xsec_id,
const std::vector< vec3d > & up_pnt_vec )
extern

Set the upper points for an airfoil. The XSec must be of type XS_FILE_AIRFOIL.

// Add Fuselage Geom
string fuseid = AddGeom( "FUSELAGE", "" );
string xsec_surf = GetXSecSurf( fuseid, 0 );
string xsec = GetXSec( xsec_surf, 1 );
ReadFileAirfoil( xsec, "airfoil/N0012_VSP.af" );
array< vec3d > @up_array = GetAirfoilUpperPnts( xsec );
for ( int i = 0 ; i < int( up_array.size() ) ; i++ )
{
up_array[i].scale_y( 2.0 );
}
SetAirfoilUpperPnts( xsec, up_array );
array< vec3d > @check_array = GetAirfoilUpperPnts( xsec );
if ( check_array.length() != up_array.length() )
{
Print( "ERROR: SetAirfoilUpperPnts point count" );
__failure++;
}
else
{
// The doubled upper surface has to come back doubled, and the lower
// surface has to be left alone.
for ( int i = 0; i < int( up_array.size() ); i++ )
{
if ( dist( check_array[i], up_array[i] ) > 1e-6 )
{
Print( "ERROR: SetAirfoilUpperPnts did not store point " + i );
__failure++;
}
}
array< vec3d > @low_array = GetAirfoilLowerPnts( xsec );
double max_up = 0.0;
double min_low = 0.0;
for ( int i = 0; i < int( check_array.size() ); i++ )
{
if ( check_array[i].y() > max_up ) { max_up = check_array[i].y(); }
if ( low_array[i].y() < min_low ) { min_low = low_array[i].y(); }
}
if ( !closeTo( max_up, -2.0 * min_low, 1e-6 ) )
{
Print( "ERROR: SetAirfoilUpperPnts did not leave the lower surface alone" );
__failure++;
}
}
void SetAirfoilUpperPnts(const std::string &xsec_id, const std::vector< vec3d > &up_pnt_vec)
Parameters
[in]xsec_idstring XSec ID
[in]up_pnt_vecvector<vec3d> Array of points defining the upper surface of the airfoil

◆ SetLowerCST()

void vsp::SetLowerCST ( const std::string & xsec_id,
int deg,
const std::vector< double > & coefs )
extern

Set the CST degree and coefficients for the lower surface of an airfoil. The number of coefficients should be one more than the CST degree. The XSec must be of type XS_CST_AIRFOIL

See also
GetLowerCSTDegree, GetLowerCSTCoefs
Parameters
[in]xsec_idstring XSec ID
[in]degint CST degree of lower airfoil surface
[in]coefsvector<double> Vector of CST coefficients for the lower airfoil surface

◆ SetUpperCST()

void vsp::SetUpperCST ( const std::string & xsec_id,
int deg,
const std::vector< double > & coefs )
extern

Set the CST degree and coefficients for the upper surface of an airfoil. The number of coefficients should be one more than the CST degree. The XSec must be of type XS_CST_AIRFOIL

See also
GetUpperCSTDegree, GetUpperCSTCoefs
Parameters
[in]xsec_idstring XSec ID
[in]degint CST degree of upper airfoil surface
[in]coefsvector<double> Vector of CST coefficients for the upper airfoil surface

◆ SetXSecAlias()

void vsp::SetXSecAlias ( const std::string & id,
const std::string & alias )
extern

Set XSec Alias by ID

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
// Identify XSec 1
string xsec_1 = GetXSec( xsec_surf, 1 );
// Set Alias and verify alias match
string alias = "XSec_One_Alias";
SetXSecAlias( xsec_1, alias );
string get_alias = GetXSecAlias( xsec_1 );
if ( alias != get_alias )
{
Print("SetXSecAlias/GetXSecAlias error!");
__failure++;
}
Parameters
[in]idstring XSec ID
[in]aliasstring Xsec alias

◆ SetXSecCurveAlias()

void vsp::SetXSecCurveAlias ( const std::string & id,
const std::string & alias )
extern

Set XSecCurve Alias by XSec ID

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
// Identify XSec 1
string xsec_1 = GetXSec( xsec_surf, 1 );
// Set Alias and verify alias match
string alias = "XSecCurve_One_Alias";
SetXSecCurveAlias( xsec_1, alias );
string get_alias = GetXSecCurveAlias( xsec_1 );
if ( alias != get_alias )
{
Print("SetXSecCurveAlias/GetXSecCurveAlias error!");
__failure++;
}
Parameters
[in]idstring XSec ID
[in]aliasstring XsecCurve alias

◆ SetXSecHeight()

void vsp::SetXSecHeight ( const std::string & xsec_id,
double h )
extern

Set the height of an XSec. Note that POINT type XSecs have a width and height of 0, regardless of what is input to SetXSecHeight.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
// Identify XSec 2
string xsec_2 = GetXSec( xsec_surf, 2 );
SetXSecHeight( xsec_2, 1.5 );
if ( !closeTo( GetXSecHeight( xsec_2 ), 1.5, 1e-9 ) )
{
Print( "ERROR: SetXSecHeight did not take" );
__failure++;
}
void SetXSecHeight(const std::string &xsec_id, double h)
See also
GetXSecHeight
Parameters
[in]xsec_idstring XSec ID
[in]hdouble Xsec height

◆ SetXSecWidth()

void vsp::SetXSecWidth ( const std::string & xsec_id,
double w )
extern

Set the width of an XSec. Note that POINT type XSecs have a width and height of 0, regardless of what is input to SetXSecWidth.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
// Identify XSec 2
string xsec_2 = GetXSec( xsec_surf, 2 );
SetXSecWidth( xsec_2, 1.5 );
if ( !closeTo( GetXSecWidth( xsec_2 ), 1.5, 1e-9 ) )
{
Print( "ERROR: SetXSecWidth did not take" );
__failure++;
}
void SetXSecWidth(const std::string &xsec_id, double w)
See also
GetXSecWidth
Parameters
[in]xsec_idstring XSec ID
[in]wdouble Xsec width

◆ SetXSecWidthHeight()

void vsp::SetXSecWidthHeight ( const std::string & xsec_id,
double w,
double h )
extern

Set the width and height of an XSec. Note, if the XSec is an EDIT_CURVE type and PreserveARFlag is true, the input width value will be ignored and instead set from on the input height and aspect ratio. Use SetXSecWidth and SetXSecHeight directly to avoid this.

// Add Stack
string sid = AddGeom( "STACK", "" );
// Get First (and Only) XSec Surf
string xsec_surf = GetXSecSurf( sid, 0 );
// Identify XSec 2
string xsec_2 = GetXSec( xsec_surf, 2 );
SetXSecWidthHeight( xsec_2, 1.5, 1.5 );
if ( !closeTo( GetXSecWidth( xsec_2 ), 1.5, 1e-6 ) ||
!closeTo( GetXSecHeight( xsec_2 ), 1.5, 1e-6 ) )
{
Print( "ERROR: SetXSecWidthHeight did not take" );
__failure++;
}
// The neighbouring sections have to be left alone.
string xsec_1 = GetXSec( xsec_surf, 1 );
if ( closeTo( GetXSecWidth( xsec_1 ), 1.5, 1e-6 ) &&
closeTo( GetXSecHeight( xsec_1 ), 1.5, 1e-6 ) )
{
Print( "ERROR: SetXSecWidthHeight reached a section it was not given" );
__failure++;
}
See also
SetXSecWidth, SetXSecHeight
Parameters
[in]xsec_idstring XSec ID
[in]wdouble Xsec width
[in]hdouble Xsec height

◆ WriteBezierAirfoil()

void vsp::WriteBezierAirfoil ( const std::string & file_name,
const std::string & geom_id,
const double & foilsurf_u )
extern

Write out the untwisted unit-length 2D Bezier curve for the specified airfoil in custom\*.bz format. The output will describe the analytical shape of the airfoil. See BezierAirfoilExample.m and BezierCtrlToCoordPnts.m for examples of discretizing the Bezier curve and generating a Selig airfoil file.

//==== Add Wing Geometry and Set Parms ====//
string wing_id = AddGeom( "WING", "" );
const double u = 0.5; // export airfoil at mid span location
//==== Write Bezier Airfoil File ====//
WriteBezierAirfoil( "Example_Bezier.bz", wing_id, u );
// The call above should have produced a file with content in it.
file __f;
if ( __f.open( "Example_Bezier.bz", "r" ) < 0 )
{
Print( "ERROR: WriteBezierAirfoil wrote no file" );
__failure++;
}
else
{
if ( __f.getSize() <= 0 )
{
Print( "ERROR: WriteBezierAirfoil wrote an empty file" );
__failure++;
}
__f.close();
}
void WriteBezierAirfoil(const std::string &file_name, const std::string &geom_id, const double &foilsurf_u)
Parameters
[in]file_namestring Airfoil (\*.bz) output file name
[in]geom_idstring Geom ID
[in]foilsurf_udouble U location (range: 0 - 1) along the surface. The foil surface does not include root and tip caps (i.e. 2 section wing -> XSec0 @ u=0, XSec1 @ u=0.5, XSec2 @ u=1.0)

◆ WriteSeligAirfoil()

void vsp::WriteSeligAirfoil ( const std::string & file_name,
const std::string & geom_id,
const double & foilsurf_u )
extern

Write out the untwisted unit-length 2D coordinate points for the specified airfoil in Selig format. Coordinate points follow the on-screen wire frame W tessellation.

//==== Add Wing Geometry and Set Parms ====//
string wing_id = AddGeom( "WING", "" );
const double u = 0.5; // export airfoil at mid span location
//==== Write Selig Airfoil File ====//
WriteSeligAirfoil( "Example_Selig.dat", wing_id, u );
// The call above should have produced a file with content in it.
file __f;
if ( __f.open( "Example_Selig.dat", "r" ) < 0 )
{
Print( "ERROR: WriteSeligAirfoil wrote no file" );
__failure++;
}
else
{
if ( __f.getSize() <= 0 )
{
Print( "ERROR: WriteSeligAirfoil wrote an empty file" );
__failure++;
}
__f.close();
}
void WriteSeligAirfoil(const std::string &file_name, const std::string &geom_id, const double &foilsurf_u)
See also
GetAirfoilCoordinates
Parameters
[in]file_namestring Airfoil (\*.dat) output file name
[in]geom_idstring Geom ID
[in]foilsurf_udouble U location (range: 0 - 1) along the surface. The foil surface does not include root and tip caps (i.e. 2 section wing -> XSec0 @ u=0, XSec1 @ u=0.5, XSec2 @ u=1.0)