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.
Get the name of all results in the Results Manager |
|
|
Get all data names for a particular result |
|
Get the number of results for a particular result name |
|
Get the name of a result given its ID |
|
Get the documentation string for a result given its ID |
|
Get the documentation string for one entry of a results object. |
|
Find a results ID given its name and index |
|
Find the latest results ID for particular result name |
|
Get the number of data values for a given result ID and data name |
|
Get the data type for a given result ID and data name |
|
Get all integer values for a particular result, name, and index |
|
Get all double values for a particular result, name, and index |
|
Get all matrix (vector<vector<double>>) values for a particular result, name, and index |
|
Get all string values for a particular result, name, and index |
|
Get all vec3d values for a particular result, name, and index |
|
Create a new result for a Geom |
Delete all results |
|
|
Delete a particular result |
|
Export a result to CSV |
|
Print a result's name value pairs to stdout |
|
Print a result's names and documentation to stdout |
Generate some example results for testing. |
Details¶
- openvsp.GetAllResultsNames()[source]¶
Get the name of all results in the Results Manager
#==== Write Some Fake Test Results =====// WriteTestResults() results_array = GetAllResultsNames() assert len( results_array ) > 0, "GetAllResultsNames returned nothing" for i in range(int( len(results_array) )): resid = FindLatestResultsID( results_array[i] ) PrintResults( resid )
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
vector<string> Array of result names
- openvsp.GetAllDataNames(results_id)[source]¶
Get all data names for a particular result
#==== Write Some Fake Test Results =====// WriteTestResults() res_id = FindResultsID( "Test_Results" ) data_names = GetAllDataNames( res_id ) if len(data_names) != 5 : print( "---> Error: API GetAllDataNames" ) assert False, "---> Error: API GetAllDataNames"
- Parameters:
[in] – results_id string Result ID
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
vector<string> Array of result names
- openvsp.GetNumResults(name)[source]¶
Get the number of results for a particular result name
#==== Write Some Fake Test Results =====// WriteTestResults() if ( GetNumResults( "Test_Results" ) != 2 ): print( "---> Error: API GetNumResults" ) assert False, "---> Error: API GetNumResults"
- Parameters:
[in] – name string Input name
- Return type:
int
- Returns:
int Number of results
- openvsp.GetResultsName(results_id)[source]¶
Get the name of a result given its ID
#==== Analysis: VSPAero Compute Geometry ====// analysis_name = "VSPAEROComputeGeometry" # Set defaults SetAnalysisInputDefaults( analysis_name ) 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. assert len( GetResultsName( res_id ) ) > 0, "GetResultsName returned nothing" assert FindLatestResultsID( GetResultsName( res_id ) ) == res_id, "GetResultsName does not round trip through FindLatestResultsID"
- Parameters:
[in] – results_id string Result ID
- Return type:
string
- Returns:
string Result name
- openvsp.GetResultsSetDoc(results_id)[source]¶
Get the documentation string for a result given its ID
#==== Analysis: VSPAero Compute Geometry ====// analysis_name = "VSPAEROComputeGeometry" # Set defaults SetAnalysisInputDefaults( analysis_name ) res_id = ( ExecAnalysis( analysis_name ) ) print( "Results doc: ", False ) print( GetResultsSetDoc( res_id ) ) assert len( GetResultsSetDoc( res_id ) ) > 0, "the result carries no documentation" # Every entry in the result has to be documented too. data_names = GetAllDataNames( res_id ) for data_name in data_names: assert len( GetResultsEntryDoc( res_id, data_name ) ) > 0, data_name + " carries no documentation"
- Parameters:
[in] – results_id string Result ID
- Return type:
string
- Returns:
string Result documentation string
- openvsp.GetResultsEntryDoc(results_id, data_name)[source]¶
Get the documentation string for one entry of a results object.
pid = AddGeom( "POD" ) Update() rid = ExecAnalysis( "CompGeom" ) name_array = GetAllDataNames( rid ) if len( name_array ) > 0: doc = GetResultsEntryDoc( rid, name_array[0] ) assert len( doc ) > 0, "GetResultsEntryDoc returned nothing"
See also: GetResultsDoc, GetAllDataNames :param [in]: results_id string Results ID :param [in]: data_name string Name of the entry in that results object :rtype: string :return: string Documentation for that entry
- openvsp.FindResultsID(name, index=0)[source]¶
Find a results ID given its name and index
#==== Write Some Fake Test Results =====// WriteTestResults() res_id = FindResultsID( "Test_Results" ) if len(res_id) == 0 : print( "---> Error: API FindResultsID" ) assert False, "---> Error: API FindResultsID"
- Parameters:
[in] – name string Result name
[in] – index int Result index
- Return type:
string
- Returns:
string Result ID
- openvsp.FindLatestResultsID(name)[source]¶
Find the latest results ID for particular result name
#==== Write Some Fake Test Results =====// WriteTestResults() results_array = GetAllResultsNames() for i in range(int( len(results_array) )): resid = FindLatestResultsID( results_array[i] ) assert len( resid ) > 0, "FindLatestResultsID found nothing" PrintResults( resid )
- Parameters:
[in] – name string Result name
- Return type:
string
- Returns:
string Result ID
- openvsp.GetNumData(results_id, data_name)[source]¶
Get the number of data values for a given result ID and data name
#==== Write Some Fake Test Results =====// WriteTestResults() res_id = FindResultsID( "Test_Results" ) if ( GetNumData( res_id, "Test_Int" ) != 2 ): print( "---> Error: API GetNumData " ) assert False, "---> Error: API GetNumData" int_arr = GetIntResults( res_id, "Test_Int", 0 ) if int_arr[0] != 1 : print( "---> Error: API GetIntResults" ) assert False, "---> Error: API GetIntResults" int_arr = GetIntResults( res_id, "Test_Int", 1 ) if int_arr[0] != 2 : print( "---> Error: API GetIntResults" ) assert False, "---> Error: API GetIntResults"
- Parameters:
[in] – results_id string Result ID
[in] – data_name string Data name
- Return type:
int
- Returns:
int Number of data values
- openvsp.GetResultsType(results_id, data_name)[source]¶
Get the data type for a given result ID and data name
#==== Write Some Fake Test Results =====// WriteTestResults() res_id = FindResultsID( "Test_Results" ) res_array = GetAllDataNames( res_id ) assert len( res_array ) > 0, "GetAllDataNames returned nothing" for j in range(int( len(res_array) )): typ = GetResultsType( res_id, res_array[j] ) # Every entry the result lists has to report a real data type. assert typ != INVALID_TYPE, "GetResultsType returned INVALID_TYPE for " + res_array[j] # The fake results are written with known types. assert GetResultsType( res_id, "Test_Int" ) == INT_DATA, "GetResultsType reported the wrong type" assert GetResultsType( res_id, "Test_Double" ) == DOUBLE_DATA, "GetResultsType reported the wrong type" assert GetResultsType( res_id, "Test_String" ) == STRING_DATA, "GetResultsType reported the wrong type" # An entry that does not exist has to report INVALID_TYPE. assert GetResultsType( res_id, "NoSuchEntry" ) == INVALID_TYPE, "GetResultsType accepted an unknown entry" # That lookup failure was raised deliberately, so take it back off the queue. err_mgr = ErrorMgrSingleton.getInstance() while err_mgr.GetNumTotalErrors() > 0 : err = err_mgr.PopLastError()
See also: RES_DATA_TYPE :param [in]: results_id string Result ID :param [in]: data_name string Data name :rtype: int :return: int Data type enum (i.e. DOUBLE_DATA)
- openvsp.GetIntResults(id, name, index=0)[source]¶
Get all integer values for a particular result, name, and index
#==== Write Some Fake Test Results =====// WriteTestResults() res_id = FindResultsID( "Test_Results" ) if ( GetNumData( res_id, "Test_Int" ) != 2 ): print( "---> Error: API GetNumData " ) assert False, "---> Error: API GetNumData" int_arr = GetIntResults( res_id, "Test_Int", 0 ) if int_arr[0] != 1 : print( "---> Error: API GetIntResults" ) assert False, "---> Error: API GetIntResults" int_arr = GetIntResults( res_id, "Test_Int", 1 ) if int_arr[0] != 2 : print( "---> Error: API GetIntResults" ) assert False, "---> Error: API GetIntResults"
- Parameters:
[in] – id string Result ID
[in] – name string Data name
[in] – index int Data index
- Return type:
std::vector< int,std::allocator< int > >
- Returns:
vector<int> Array of data values
- openvsp.GetDoubleResults(id, name, index=0)[source]¶
Get all double values for a particular result, name, and index
#==== Add Pod Geom ====// pid = AddGeom( "POD", "" ) #==== Run CompGeom And View Results ====// mesh_id = ComputeCompGeom( SET_ALL, False, 0 ) # Half Mesh false and no file export comp_res_id = FindLatestResultsID( "Comp_Geom" ) # Find Results ID double_arr = GetDoubleResults( comp_res_id, "Wet_Area" ) # Extract Results assert len( double_arr ) > 0, "GetDoubleResults returned nothing"
- Parameters:
[in] – id string Result ID
[in] – name string Data name
[in] – index int Data index
- Return type:
std::vector< double,std::allocator< double > >
- Returns:
vector<double> Array of data values
- openvsp.GetDoubleMatResults(id, name, index=0)[source]¶
Get all matrix (vector<vector<double>>) values for a particular result, name, and index
pid = AddGeom( "POD" ) Update() rid = ExecAnalysis( "CompGeom" ) for name in GetAllDataNames( rid ): if GetResultsType( rid, name ) == DOUBLE_MATRIX_DATA: mat = GetDoubleMatResults( rid, name ) assert len( mat ) > 0, "GetDoubleMatResults returned nothing"
- Parameters:
[in] – id string Result ID
[in] – name string Data name
[in] – index int Data index
- Return type:
std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >
- Returns:
vector<vector<double>> 2D array of data values
- openvsp.GetStringResults(id, name, index=0)[source]¶
Get all string values for a particular result, name, and index
#==== Write Some Fake Test Results =====// WriteTestResults() res_id = FindResultsID( "Test_Results" ) str_arr = GetStringResults( res_id, "Test_String" ) if ( str_arr[0] != "This Is A Test" ): print( "---> Error: API GetStringResults" ) assert False, "---> Error: API GetStringResults"
- Parameters:
[in] – id string Result ID
[in] – name string Data name
[in] – index int Data index
- Return type:
std::vector< std::string,std::allocator< std::string > >
- Returns:
vector<string> Array of data values
- openvsp.GetVec3dResults(id, name, index=0)[source]¶
Get all vec3d values for a particular result, name, and index
#==== Write Some Fake Test Results =====// tol = 0.00001 WriteTestResults() res_id = FindLatestResultsID( "Test_Results" ) vec3d_vec = GetVec3dResults( res_id, "Test_Vec3d" ) assert len( vec3d_vec ) > 0, "GetVec3dResults returned nothing" 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() )
- Parameters:
[in] – id string Result ID
[in] – name string Data name
[in] – index int Data index
- Return type:
std::vector< vec3d,std::allocator< vec3d > >
- Returns:
vector<vec3d> Array of data values
- openvsp.CreateGeomResults(geom_id, name)[source]¶
Create a new result for a Geom
#==== Test Comp Geom ====// gid1 = AddGeom( "POD", "" ) mesh_id = ComputeCompGeom( 0, False, 0 ) #==== Test Comp Geom Mesh Results ====// mesh_geom_res_id = CreateGeomResults( mesh_id, "Comp_Mesh" ) int_arr = GetIntResults( mesh_geom_res_id, "Num_Tris" ) if int_arr[0] < 4 : print( "---> Error: API CreateGeomResults" ) assert False, "---> Error: API CreateGeomResults"
- Parameters:
[in] – geom_id string Geom ID
[in] – name string Result name
- Return type:
string
- Returns:
string Result ID
- openvsp.DeleteAllResults()[source]¶
Delete all results
#==== Test Comp Geom ====// gid1 = AddGeom( "POD", "" ) mesh_id = ComputeCompGeom( 0, False, 0 ) #==== Test Comp Geom Mesh Results ====// mesh_geom_res_id = CreateGeomResults( mesh_id, "Comp_Mesh" ) DeleteAllResults() if ( GetNumResults( "Comp_Mesh" ) != 0 ): print( "---> Error: API DeleteAllResults" ) assert False, "---> Error: API DeleteAllResults"
- openvsp.DeleteResult(id)[source]¶
Delete a particular result
#==== Test Comp Geom ====// gid1 = AddGeom( "POD", "" ) mesh_id = ComputeCompGeom( 0, False, 0 ) #==== Test Comp Geom Mesh Results ====// mesh_geom_res_id = CreateGeomResults( mesh_id, "Comp_Mesh" ) DeleteResult( mesh_geom_res_id ) if ( GetNumResults( "Comp_Mesh" ) != 0 ): print( "---> Error: API DeleteResult" ) assert False, "---> Error: API DeleteResult"
- Parameters:
[in] – id string Result ID
- openvsp.WriteResultsCSVFile(id, file_name)[source]¶
Export a result to CSV
# Add Pod Geom pid = AddGeom( "POD" ) analysis_name = "VSPAEROComputeGeometry" rid = ExecAnalysis( analysis_name ) WriteResultsCSVFile( rid, "CompGeomRes.csv" ) # The call above should have produced a file with content in it. import os assert os.path.getsize( "CompGeomRes.csv" ) > 0, "WriteResultsCSVFile wrote no file"
- Parameters:
[in] – id string Rsult ID
[in] – file_name string CSV output file name
- openvsp.PrintResults(results_id)[source]¶
Print a result’s name value pairs to stdout
# Add Pod Geom pid = AddGeom( "POD" ) analysis_name = "VSPAEROComputeGeometry" rid = ExecAnalysis( analysis_name ) # Get & Display Results PrintResults( rid ) # There has to be something to display. assert len( GetAllDataNames( rid ) ) > 0, "the result carries no data to print" # Every entry that gets printed has to have a value behind it. data_names = GetAllDataNames( rid ) for data_name in data_names: assert GetNumData( rid, data_name ) >= 1, data_name + " has no data to print"
- Parameters:
[in] – results_id string Result ID
- openvsp.PrintResultsDocs(results_id)[source]¶
Print a result’s names and documentation to stdout
# Add Pod Geom pid = AddGeom( "POD" ) analysis_name = "VSPAEROComputeGeometry" rid = ExecAnalysis( analysis_name ) # Get & Display Results Docs PrintResultsDocs( rid ) # There has to be documentation to display. assert len( GetResultsSetDoc( rid ) ) > 0, "the result carries no documentation to print" # Every entry that gets printed has to carry documentation of its own. data_names = GetAllDataNames( rid ) for data_name in data_names: assert len( GetResultsEntryDoc( rid, data_name ) ) > 0, data_name + " carries no documentation"
- Parameters:
[in] – results_id string Result ID
- openvsp.WriteTestResults()[source]¶
Generate some example results for testing.
#==== Write Some Fake Test Results =====// WriteTestResults() results_array = GetAllResultsNames() for i in range( len( results_array ) ): resid = FindLatestResultsID( results_array[i] ) PrintResults( resid ) # Two copies of Test_Results are written, carrying five named entries with # known values. assert GetNumResults( "Test_Results" ) == 2, "WriteTestResults did not write two results" res_id = FindResultsID( "Test_Results" ) assert len( GetAllDataNames( res_id ) ) == 5, "WriteTestResults wrote the wrong number of entries" int_arr = GetIntResults( res_id, "Test_Int", 0 ) dbl_arr = GetDoubleResults( res_id, "Test_Double", 0 ) str_arr = GetStringResults( res_id, "Test_String", 0 ) assert int_arr[0] == 1, "WriteTestResults wrote the wrong values" assert abs( dbl_arr[0] - 0.1 ) < 1e-12, "WriteTestResults wrote the wrong values" assert str_arr[0] == "This Is A Test", "WriteTestResults wrote the wrong values" # The second copy carries the next set of values. res_id_1 = FindResultsID( "Test_Results", 1 ) int_arr = GetIntResults( res_id_1, "Test_Int", 0 ) assert int_arr[0] == 2, "WriteTestResults did not vary the second result"