OpenVSP API Documentation 3.51.3
Loading...
Searching...
No Matches
Results Manager Functions

This group is for functions included in the Results Manager. The Results Manager stores analysis results and provides methods to get, print, and export them. Click here to return to the main page. More...

Functions

std::vector< std::string > vsp::GetAllResultsNames ()
std::vector< std::string > vsp::GetAllDataNames (const std::string &results_id)
int vsp::GetNumResults (const std::string &name)
std::string vsp::GetResultsName (const std::string &results_id)
std::string vsp::GetResultsSetDoc (const std::string &results_id)
std::string vsp::FindResultsID (const std::string &name, int index=0)
std::string vsp::FindLatestResultsID (const std::string &name)
int vsp::GetNumData (const std::string &results_id, const std::string &data_name)
int vsp::GetResultsType (const std::string &results_id, const std::string &data_name)
const std::vector< int > & vsp::GetIntResults (const std::string &id, const std::string &name, int index=0)
const std::vector< double > & vsp::GetDoubleResults (const std::string &id, const std::string &name, int index=0)
const std::vector< std::vector< double > > & vsp::GetDoubleMatResults (const std::string &id, const std::string &name, int index=0)
const std::vector< std::string > & vsp::GetStringResults (const std::string &id, const std::string &name, int index=0)
const std::vector< vec3d > & vsp::GetVec3dResults (const std::string &id, const std::string &name, int index=0)
std::string vsp::CreateGeomResults (const std::string &geom_id, const std::string &name)
void vsp::DeleteAllResults ()
void vsp::DeleteResult (const std::string &id)
void vsp::WriteResultsCSVFile (const std::string &id, const std::string &file_name)
void vsp::PrintResults (const std::string &results_id)
void vsp::PrintResultsDocs (const std::string &results_id)
void vsp::WriteTestResults ()

Detailed Description

Function Documentation

◆ CreateGeomResults()

std::string vsp::CreateGeomResults ( const std::string & geom_id,
const std::string & name )
extern

Create a new result for a Geom

//==== Test Comp Geom ====//
string gid1 = AddGeom( "POD", "" );
string mesh_id = ComputeCompGeom( 0, false, 0 );
//==== Test Comp Geom Mesh Results ====//
string mesh_geom_res_id = CreateGeomResults( mesh_id, "Comp_Mesh" );
array<int> @int_arr = GetIntResults( mesh_geom_res_id, "Num_Tris" );
if ( int_arr[0] < 4 ) { Print( "---> Error: API CreateGeomResults" ); __failure++; }
std::string ComputeCompGeom(int set, bool half_mesh, int file_export_types)
std::string AddGeom(const std::string &type, const std::string &parent=std::string())
const std::vector< int > & GetIntResults(const std::string &id, const std::string &name, int index=0)
std::string CreateGeomResults(const std::string &geom_id, const std::string &name)
Parameters
[in]geom_idstring Geom ID
[in]namestring Result name
Returns
string Result ID

◆ DeleteAllResults()

void vsp::DeleteAllResults ( )
extern

Delete all results

//==== Test Comp Geom ====//
string gid1 = AddGeom( "POD", "" );
string mesh_id = ComputeCompGeom( 0, false, 0 );
//==== Test Comp Geom Mesh Results ====//
string mesh_geom_res_id = CreateGeomResults( mesh_id, "Comp_Mesh" );
if ( GetNumResults( "Comp_Mesh" ) != 0 ) { Print( "---> Error: API DeleteAllResults" ); __failure++; }
int GetNumResults(const std::string &name)
void DeleteAllResults()

◆ DeleteResult()

void vsp::DeleteResult ( const std::string & id)
extern

Delete a particular result

//==== Test Comp Geom ====//
string gid1 = AddGeom( "POD", "" );
string mesh_id = ComputeCompGeom( 0, false, 0 );
//==== Test Comp Geom Mesh Results ====//
string mesh_geom_res_id = CreateGeomResults( mesh_id, "Comp_Mesh" );
DeleteResult( mesh_geom_res_id );
if ( GetNumResults( "Comp_Mesh" ) != 0 ) { Print( "---> Error: API DeleteResult" ); __failure++; }
void DeleteResult(const std::string &id)
Parameters
[in]idstring Result ID

◆ FindLatestResultsID()

std::string vsp::FindLatestResultsID ( const std::string & name)
extern

Find the latest results ID for particular result name

//==== Write Some Fake Test Results =====//
array< string > @results_array = GetAllResultsNames();
for ( int i = 0; i < int( results_array.size() ); i++ )
{
string resid = FindLatestResultsID( results_array[i] );
if ( resid.length() == 0 )
{
Print( "ERROR: FindLatestResultsID found nothing" );
__failure++;
}
PrintResults( resid );
}
void PrintResults(const std::string &results_id)
std::vector< std::string > GetAllResultsNames()
std::string FindLatestResultsID(const std::string &name)
void WriteTestResults()
Parameters
[in]namestring Result name
Returns
string Result ID

◆ FindResultsID()

std::string vsp::FindResultsID ( const std::string & name,
int index = 0 )
extern

Find a results ID given its name and index

//==== Write Some Fake Test Results =====//
string res_id = FindResultsID( "Test_Results" );
if ( res_id.size() == 0 ) { Print( "---> Error: API FindResultsID" ); __failure++; }
std::string FindResultsID(const std::string &name, int index=0)
Parameters
[in]namestring Result name
[in]indexint Result index
Returns
string Result ID

◆ GetAllDataNames()

std::vector< std::string > vsp::GetAllDataNames ( const std::string & results_id)
extern

Get all data names for a particular result

//==== Write Some Fake Test Results =====//
string res_id = FindResultsID( "Test_Results" );
array< string > @data_names = GetAllDataNames( res_id );
if ( data_names.size() != 5 ) { Print( "---> Error: API GetAllDataNames" ); __failure++; }
std::vector< std::string > GetAllDataNames(const std::string &results_id)
Parameters
[in]results_idstring Result ID
Returns
vector<string> Array of result names

◆ GetAllResultsNames()

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

Get the name of all results in the Results Manager

//==== Write Some Fake Test Results =====//
array< string > @results_array = GetAllResultsNames();
if ( results_array.length() == 0 )
{
Print( "ERROR: GetAllResultsNames returned nothing" );
__failure++;
}
for ( int i = 0; i < int( results_array.size() ); i++ )
{
string resid = FindLatestResultsID( results_array[i] );
PrintResults( resid );
}
Returns
vector<string> Array of result names

◆ GetDoubleMatResults()

const std::vector< std::vector< double > > & vsp::GetDoubleMatResults ( const std::string & id,
const std::string & name,
int index = 0 )
extern

Get all matrix (vector<vector<double>>) values for a particular result, name, and index

Parameters
[in]idstring Result ID
[in]namestring Data name
[in]indexint Data index
Returns
vector<vector<double>> 2D array of data values

◆ GetDoubleResults()

const std::vector< double > & vsp::GetDoubleResults ( const std::string & id,
const std::string & name,
int index = 0 )
extern

Get all double values for a particular result, name, and index

//==== Add Pod Geom ====//
string pid = AddGeom( "POD", "" );
//==== Run CompGeom And View Results ====//
string mesh_id = ComputeCompGeom( SET_ALL, false, 0 ); // Half Mesh false and no file export
string comp_res_id = FindLatestResultsID( "Comp_Geom" ); // Find Results ID
array<double> @double_arr = GetDoubleResults( comp_res_id, "Wet_Area" ); // Extract Results
if ( double_arr.length() == 0 )
{
Print( "ERROR: GetDoubleResults returned nothing" );
__failure++;
}
@ SET_ALL
const std::vector< double > & GetDoubleResults(const std::string &id, const std::string &name, int index=0)
Parameters
[in]idstring Result ID
[in]namestring Data name
[in]indexint Data index
Returns
vector<double> Array of data values

◆ GetIntResults()

const std::vector< int > & vsp::GetIntResults ( const std::string & id,
const std::string & name,
int index = 0 )
extern

Get all integer values for a particular result, name, and index

//==== Write Some Fake Test Results =====//
string res_id = FindResultsID( "Test_Results" );
if ( GetNumData( res_id, "Test_Int" ) != 2 ) { Print( "---> Error: API GetNumData " ); __failure++; }
array<int> @int_arr = GetIntResults( res_id, "Test_Int", 0 );
if ( int_arr[0] != 1 ) { Print( "---> Error: API GetIntResults" ); __failure++; }
int_arr = GetIntResults( res_id, "Test_Int", 1 );
if ( int_arr[0] != 2 ) { Print( "---> Error: API GetIntResults" ); __failure++; }
int GetNumData(const std::string &results_id, const std::string &data_name)
Parameters
[in]idstring Result ID
[in]namestring Data name
[in]indexint Data index
Returns
vector<int> Array of data values

◆ GetNumData()

int vsp::GetNumData ( const std::string & results_id,
const std::string & data_name )
extern

Get the number of data values for a given result ID and data name

//==== Write Some Fake Test Results =====//
string res_id = FindResultsID( "Test_Results" );
if ( GetNumData( res_id, "Test_Int" ) != 2 ) { Print( "---> Error: API GetNumData " ); __failure++; }
array<int> @int_arr = GetIntResults( res_id, "Test_Int", 0 );
if ( int_arr[0] != 1 ) { Print( "---> Error: API GetIntResults" ); __failure++; }
int_arr = GetIntResults( res_id, "Test_Int", 1 );
if ( int_arr[0] != 2 ) { Print( "---> Error: API GetIntResults" ); __failure++; }
Parameters
[in]results_idstring Result ID
[in]data_namestring Data name
Returns
int Number of data values

◆ GetNumResults()

int vsp::GetNumResults ( const std::string & name)
extern

Get the number of results for a particular result name

//==== Write Some Fake Test Results =====//
if ( GetNumResults( "Test_Results" ) != 2 ) { Print( "---> Error: API GetNumResults" ); __failure++; }
Parameters
[in]namestring Input name
Returns
int Number of results

◆ GetResultsName()

std::string vsp::GetResultsName ( const std::string & results_id)
extern

Get the name of a result given its ID

//==== Analysis: VSPAero Compute Geometry ====//
string analysis_name = "VSPAEROComputeGeometry";
// Set defaults
SetAnalysisInputDefaults( analysis_name );
string res_id = ( ExecAnalysis( analysis_name ) );
Print( "Results Name: ", false );
Print( GetResultsName( res_id ) );
// The name is the Results Manager's handle for this result, so looking the
// name back up has to lead to the same result.
if ( GetResultsName( res_id ).length() == 0 )
{
Print( "ERROR: GetResultsName returned nothing" );
__failure++;
}
if ( FindLatestResultsID( GetResultsName( res_id ) ) != res_id )
{
Print( "ERROR: GetResultsName does not round trip through FindLatestResultsID" );
__failure++;
}
std::string ExecAnalysis(const std::string &analysis)
void SetAnalysisInputDefaults(const std::string &analysis)
std::string GetResultsName(const std::string &results_id)
Parameters
[in]results_idstring Result ID
Returns
string Result name

◆ GetResultsSetDoc()

std::string vsp::GetResultsSetDoc ( const std::string & results_id)
extern

Get the documentation string for a result given its ID

//==== Analysis: VSPAero Compute Geometry ====//
string analysis_name = "VSPAEROComputeGeometry";
// Set defaults
SetAnalysisInputDefaults( analysis_name );
string res_id = ( ExecAnalysis( analysis_name ) );
Print( "Results doc: ", false );
Print( GetResultsSetDoc( res_id ) );
if ( GetResultsSetDoc( res_id ).length() == 0 )
{
Print( "ERROR: the result carries no documentation" );
__failure++;
}
// Every entry in the result has to be documented too.
array< string > @data_names = GetAllDataNames( res_id );
for ( int i = 0; i < int( data_names.size() ); i++ )
{
if ( GetResultsEntryDoc( res_id, data_names[i] ).length() == 0 )
{
Print( "ERROR: " + data_names[i] + " carries no documentation" );
__failure++;
}
}
std::string GetResultsSetDoc(const std::string &results_id)
Parameters
[in]results_idstring Result ID
Returns
string Result documentation string

◆ GetResultsType()

int vsp::GetResultsType ( const std::string & results_id,
const std::string & data_name )
extern

Get the data type for a given result ID and data name

//==== Write Some Fake Test Results =====//
string res_id = FindResultsID( "Test_Results" );
array < string > @ res_array = GetAllDataNames( res_id );
if ( res_array.size() == 0 )
{
Print( "ERROR: GetAllDataNames returned nothing" );
__failure++;
}
for ( int j = 0; j < int( res_array.size() ); j++ )
{
int typ = GetResultsType( res_id, res_array[j] );
// Every entry the result lists has to report a real data type.
if ( typ == INVALID_TYPE )
{
Print( "ERROR: GetResultsType returned INVALID_TYPE for " + res_array[j] );
__failure++;
}
}
// The fake results are written with known types.
if ( GetResultsType( res_id, "Test_Int" ) != INT_DATA ||
GetResultsType( res_id, "Test_Double" ) != DOUBLE_DATA ||
GetResultsType( res_id, "Test_String" ) != STRING_DATA )
{
Print( "ERROR: GetResultsType reported the wrong type" );
__failure++;
}
// An entry that does not exist has to report INVALID_TYPE.
if ( GetResultsType( res_id, "NoSuchEntry" ) != INVALID_TYPE )
{
Print( "ERROR: GetResultsType accepted an unknown entry" );
__failure++;
}
// That lookup failure was raised deliberately, so take it back off the queue.
while ( GetNumTotalErrors() > 0 )
{
ErrorObj err = PopLastError();
}
@ STRING_DATA
@ INVALID_TYPE
@ DOUBLE_DATA
@ INT_DATA
int GetResultsType(const std::string &results_id, const std::string &data_name)
See also
RES_DATA_TYPE
Parameters
[in]results_idstring Result ID
[in]data_namestring Data name
Returns
int Data type enum (i.e. DOUBLE_DATA)

◆ GetStringResults()

const std::vector< std::string > & vsp::GetStringResults ( const std::string & id,
const std::string & name,
int index = 0 )
extern

Get all string values for a particular result, name, and index

//==== Write Some Fake Test Results =====//
string res_id = FindResultsID( "Test_Results" );
array<string> @str_arr = GetStringResults( res_id, "Test_String" );
if ( str_arr[0] != "This Is A Test" ) { Print( "---> Error: API GetStringResults" ); __failure++; }
const std::vector< std::string > & GetStringResults(const std::string &id, const std::string &name, int index=0)
Parameters
[in]idstring Result ID
[in]namestring Data name
[in]indexint Data index
Returns
vector<string> Array of data values

◆ GetVec3dResults()

const std::vector< vec3d > & vsp::GetVec3dResults ( const std::string & id,
const std::string & name,
int index = 0 )
extern

Get all vec3d values for a particular result, name, and index

//==== Write Some Fake Test Results =====//
double tol = 0.00001;
string res_id = FindLatestResultsID( "Test_Results" );
array<vec3d> @vec3d_vec = GetVec3dResults( res_id, "Test_Vec3d" );
if ( vec3d_vec.length() == 0 )
{
Print( "ERROR: GetVec3dResults returned nothing" );
__failure++;
}
Print( "X: ", false );
Print( vec3d_vec[0].x(), false );
Print( "\tY: ", false );
Print( vec3d_vec[0].y(), false );
Print( "\tZ: ", false );
Print( vec3d_vec[0].z() );
const std::vector< vec3d > & GetVec3dResults(const std::string &id, const std::string &name, int index=0)
Parameters
[in]idstring Result ID
[in]namestring Data name
[in]indexint Data index
Returns
vector<vec3d> Array of data values

◆ PrintResults()

void vsp::PrintResults ( const std::string & results_id)
extern

Print a result's name value pairs to stdout

// Add Pod Geom
string pid = AddGeom( "POD" );
string analysis_name = "VSPAEROComputeGeometry";
string rid = ExecAnalysis( analysis_name );
// Get & Display Results
PrintResults( rid );
// There has to be something to display.
if ( GetAllDataNames( rid ).size() == 0 )
{
Print( "ERROR: the result carries no data to print" );
__failure++;
}
// Every entry that gets printed has to have a value behind it.
array< string > @data_names = GetAllDataNames( rid );
for ( int i = 0; i < int( data_names.size() ); i++ )
{
if ( GetNumData( rid, data_names[i] ) < 1 )
{
Print( "ERROR: " + data_names[i] + " has no data to print" );
__failure++;
}
}
Parameters
[in]results_idstring Result ID

◆ PrintResultsDocs()

void vsp::PrintResultsDocs ( const std::string & results_id)
extern

Print a result's names and documentation to stdout

// Add Pod Geom
string pid = AddGeom( "POD" );
string analysis_name = "VSPAEROComputeGeometry";
string rid = ExecAnalysis( analysis_name );
// Get & Display Results Docs
// There has to be documentation to display.
if ( GetResultsSetDoc( rid ).length() == 0 )
{
Print( "ERROR: the result carries no documentation to print" );
__failure++;
}
// Every entry that gets printed has to carry documentation of its own.
array< string > @data_names = GetAllDataNames( rid );
for ( int i = 0; i < int( data_names.size() ); i++ )
{
if ( GetResultsEntryDoc( rid, data_names[i] ).length() == 0 )
{
Print( "ERROR: " + data_names[i] + " carries no documentation" );
__failure++;
}
}
void PrintResultsDocs(const std::string &results_id)
Parameters
[in]results_idstring Result ID

◆ WriteResultsCSVFile()

void vsp::WriteResultsCSVFile ( const std::string & id,
const std::string & file_name )
extern

Export a result to CSV

// Add Pod Geom
string pid = AddGeom( "POD" );
string analysis_name = "VSPAEROComputeGeometry";
string rid = ExecAnalysis( analysis_name );
WriteResultsCSVFile( rid, "CompGeomRes.csv" );
// The call above should have produced a file with content in it.
file __f;
if ( __f.open( "CompGeomRes.csv", "r" ) < 0 )
{
Print( "ERROR: WriteResultsCSVFile wrote no file" );
__failure++;
}
else
{
if ( __f.getSize() <= 0 )
{
Print( "ERROR: WriteResultsCSVFile wrote an empty file" );
__failure++;
}
__f.close();
}
void WriteResultsCSVFile(const std::string &id, const std::string &file_name)
Parameters
[in]idstring Rsult ID
[in]file_namestring CSV output file name

◆ WriteTestResults()

void vsp::WriteTestResults ( )
extern

Generate some example results for testing.

//==== Write Some Fake Test Results =====//
array< string > @results_array = GetAllResultsNames();
for ( int i = 0; i < int( results_array.size() ); i++ )
{
string resid = FindLatestResultsID( results_array[i] );
PrintResults( resid );
}
// Two copies of Test_Results are written, carrying five named entries with
// known values.
if ( GetNumResults( "Test_Results" ) != 2 )
{
Print( "ERROR: WriteTestResults did not write two results" );
__failure++;
}
string res_id = FindResultsID( "Test_Results" );
if ( GetAllDataNames( res_id ).size() != 5 )
{
Print( "ERROR: WriteTestResults wrote the wrong number of entries" );
__failure++;
}
array< int > @int_arr = GetIntResults( res_id, "Test_Int", 0 );
array< double > @dbl_arr = GetDoubleResults( res_id, "Test_Double", 0 );
array< string > @str_arr = GetStringResults( res_id, "Test_String", 0 );
if ( int_arr[0] != 1 || !closeTo( dbl_arr[0], 0.1, 1e-12 ) || str_arr[0] != "This Is A Test" )
{
Print( "ERROR: WriteTestResults wrote the wrong values" );
__failure++;
}
// The second copy carries the next set of values.
string res_id_1 = FindResultsID( "Test_Results", 1 );
int_arr = GetIntResults( res_id_1, "Test_Int", 0 );
if ( int_arr[0] != 2 )
{
Print( "ERROR: WriteTestResults did not vary the second result" );
__failure++;
}