OpenVSPAPI  3.23.0
Functions
General API Utility Functions

This group of functions is provided for general API utilities, such as printing to stdout, performing basic math functions, and identifying basic OpenVSP information.

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

Functions

void Print (const string &in data, bool new_line=true)
 
void Print (const vec3d &in data, bool new_line=true)
 
void Print (double data, bool new_line=true)
 
void Print (int data, bool new_line=true)
 
double Min (double x, double y)
 
double Max (double x, double y)
 
double Rad2Deg (double r)
 
double Deg2Rad (double d)
 
string GetVSPVersion ()
 
string GetVSPExePath ()
 
bool SetVSPAEROPath (const string &in path)
 
string GetVSPAEROPath ()
 
bool CheckForVSPAERO (const string &in path)
 
void VSPCheckSetup ()
 
void VSPRenew ()
 

Detailed Description

Function Documentation

◆ CheckForVSPAERO()

bool CheckForVSPAERO ( const string &in  path)

Check if all VSPAERO executables (Solver, Viewer, and Slicer) are in a given directory. Note that this function will return false if only one or two VSPAERO executables are found. An error message will indicate the executables that are missing. This may be acceptable, as only the Solver is needed in all cases. The Viewer and Slicer may not be needed.

string vspaero_path = "C:\Users\example_user\Documents\OpenVSP_3.4.5"; // Note, may need to change to forward slashes
if ( CheckForVSPAERO( vspaero_path ) )
{
SetVSPAEROPath( vspaero_path );
}
See also
GetVSPExePath, GetVSPAEROPath, SetVSPAEROPath
Parameters
[in]pathAbsolute path to check for VSPAERO executables
Returns
Flag that indicates if all VSPAERO executables are found or not

◆ Deg2Rad()

double Deg2Rad ( double  d)

Convert degrees to radians

double deg = 45; // degrees
double rad = Deg2Rad( deg ); // radians
Parameters
[in]dValue in degrees
Returns
Value in radians

◆ GetVSPAEROPath()

string GetVSPAEROPath ( )

Get the path that OpenVSP will use to look for all VSPAERO executables (Solver, Slicer, and Viewer) when attempting to execute VSPAERO. If the VSPAERO executables are not in this location, they must either be copied there or the VSPAERO path must be set using SetVSPAEROPath.

{
Print( "VSPAERO is not where OpenVSP thinks it is. I should move the VSPAERO executable or call SetVSPAEROPath." );
}
See also
GetVSPExePath, CheckForVSPAERO, SetVSPAEROPath
Returns
Path OpenVSP will look for VSPAERO

◆ GetVSPExePath()

string GetVSPExePath ( )

Get the path to the OpenVSP executable. OpenVSP will assume that the VSPAERO, VSPSLICER, and VSPVIEWER are in the same directory unless instructed otherwise.

Print( "The current VSP executable path is: ", false );
See also
SetVSPAEROPath, CheckForVSPAERO, GetVSPAEROPath
Returns
Path to the OpenVSP executable

◆ GetVSPVersion()

string GetVSPVersion ( )

Get the version of the OpenVSP instance currently running

Print( "The current OpenVSP version is: ", false );
Returns
OpenVSP version string (i.e. "OpenVSP 3.17.1")

◆ Max()

double Max ( double  x,
double  y 
)

Get the maximum of two values -> (x > y ) ? x : y

double max_val = Min( 1.0, 2.0 );
if ( abs( 2.0 - max_val ) > 1e-6 ) { Print( "Error: Max" ); }
Parameters
[in]xFirst value
[in]ySecond value
Returns
Largest of x and y

◆ Min()

double Min ( double  x,
double  y 
)

Get the minimum of two values -> (x < y ) ? x : y

double min_val = Min( 1.0, 2.0 );
if ( abs( 1.0 - min_val ) > 1e-6 ) { Print( "Error: Min" ); }
Parameters
[in]xFirst value
[in]ySecond value
Returns
Smallest of x and y

◆ Print() [1/4]

void Print ( const string &in  data,
bool  new_line = true 
)

Print a string to stdout

Print( string( "This is an example of printing a string to stdout." ) );
Parameters
[in]dataValue of string type
[in]new_lineFlag to append a new line escape sequence to data

◆ Print() [2/4]

void Print ( const vec3d &in  data,
bool  new_line = true 
)

Print a vec3d to stdout

Print( vec3d( 1, 2, 3 ) );
Parameters
[in]dataValue of vec3d type
[in]new_lineFlag to append a new line escape sequence to data

◆ Print() [3/4]

void Print ( double  data,
bool  new_line = true 
)

Print a double to stdout

Print( 12.34 );
Parameters
[in]dataValue of double type
[in]new_lineFlag to append a new line escape sequence to data

◆ Print() [4/4]

void Print ( int  data,
bool  new_line = true 
)

Print an integer to stdout

Print( 12 );
Parameters
[in]datainteger value
[in]new_lineflag to append a new line escape sequence to data

◆ Rad2Deg()

double Rad2Deg ( double  r)

Convert radians to degrees

double rad = 0.785; // radians
double deg = Rad2Deg( rad ); // degrees
Parameters
[in]rValue in radians
Returns
Value in degrees

◆ SetVSPAEROPath()

bool SetVSPAEROPath ( const string &in  path)

Set the path to the VSPAERO executables (Solver, Viewer, and Slicer). By default, OpenVSP will assume that the VSPAERO executables are in the same directory as the VSP executable. However, this may need to be changed when using certain API languages like MATLAB and Python. For example, Python may treat the location of the Python executable as the VSP executable path, so either the VSPAERO executable needs to be moved to the same directory or this function can be called to tell Python where to look for VSPAERO.

{
string vspaero_path = "C:\Users\example_user\Documents\OpenVSP_3.4.5"; // Note, may need to change to forward slashes
SetVSPAEROPath( vspaero_path );
}
See also
GetVSPExePath, CheckForVSPAERO, GetVSPAEROPath
Parameters
[in]pathAbsolute path to directory containing VSPAERO executable
Returns
Flag that indicates whether or not the path was set correctly

◆ VSPCheckSetup()

void VSPCheckSetup ( )

Check if OpenVSP has been initialized successfully. If not, the OpenVSP instance will be exited. This call should be placed at the begining of all API scripts.

void main()
{
// Continue to do things...
}

◆ VSPRenew()

void VSPRenew ( )

Clear and reinitialize OpenVSP to all default settings

//==== Add Pod Geometry ====//
string pod_id = AddGeom( "POD" );
SetParmVal( pod_id, "Y_Rel_Location", "XForm", 2.0 );
if ( FindGeoms().size() != 0 ) { Print( "ERROR: VSPRenew" ); }
SetVSPAEROPath
bool SetVSPAEROPath(const string &in path)
GetVSPExePath
string GetVSPExePath()
FindGeoms
string[] FindGeoms()
GetVSPVersion
string GetVSPVersion()
Deg2Rad
double Deg2Rad(double d)
Rad2Deg
double Rad2Deg(double r)
CheckForVSPAERO
bool CheckForVSPAERO(const string &in path)
SetParmVal
double SetParmVal(const string &in parm_id, double val)
GetVSPAEROPath
string GetVSPAEROPath()
vec3d
A class for representing 3D vectors.
Definition: openvsp_as.h:349
AddGeom
string AddGeom(const string &in type, const string &in parent=string())
Print
void Print(const string &in data, bool new_line=true)
Min
double Min(double x, double y)
VSPCheckSetup
void VSPCheckSetup()