From: Bertrand <bco...@us...> - 2016-05-22 17:02:16
|
Update of /cvsroot/jsbsim/JSBSim/src/models In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv26873/src/models Modified Files: FGAerodynamics.cpp Log Message: Fixed the aero functions such that they now cache their result when they are executed. This is to make sure that their output to CSV is the same than the result that has been actually used for computations. The issue arose in particular for induced drag which is computed from aero/cl-squared which is modified between the moment where the induced drag is computed and the output to CSV is run. In some cases these 2 values can be very different. Index: FGAerodynamics.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGAerodynamics.cpp,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -r1.57 -r1.58 *** FGAerodynamics.cpp 31 Jan 2015 14:56:21 -0000 1.57 --- FGAerodynamics.cpp 22 May 2016 17:02:13 -0000 1.58 *************** *** 145,149 **** if (Holding) return false; // if paused don't execute ! unsigned int axis_ctr, ctr; const double twovel=2*in.Vt; --- 145,149 ---- if (Holding) return false; // if paused don't execute ! unsigned int axis_ctr; const double twovel=2*in.Vt; *************** *** 180,192 **** vFnativeAtCG.InitMatrix(); ! for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) { ! for (ctr=0; ctr < AeroFunctions[axis_ctr].size(); ctr++) { ! vFnative(axis_ctr+1) += AeroFunctions[axis_ctr][ctr]->GetValue(); ! } ! } ! for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) { ! for (ctr=0; ctr < AeroFunctionsAtCG[axis_ctr].size(); ctr++) { ! vFnativeAtCG(axis_ctr+1) += AeroFunctionsAtCG[axis_ctr][ctr]->GetValue(); } } --- 180,200 ---- vFnativeAtCG.InitMatrix(); ! for (axis_ctr = 0; axis_ctr < 3; ++axis_ctr) { ! AeroFunctionArray::iterator f; ! AeroFunctionArray* array = &AeroFunctions[axis_ctr]; ! for (f=array->begin(); f != array->end(); ++f) { ! // Tell the Functions to cache values, so when the function values are ! // being requested for output, the functions do not get calculated again ! // in a context that might have changed, but instead use the values that ! // have already been calculated for this frame. ! (*f)->cacheValue(true); ! vFnative(axis_ctr+1) += (*f)->GetValue(); ! } ! ! array = &AeroFunctionsAtCG[axis_ctr]; ! for (f=array->begin(); f != array->end(); ++f) { ! (*f)->cacheValue(true); // Same as above ! vFnativeAtCG(axis_ctr+1) += (*f)->GetValue(); } } *************** *** 265,270 **** for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) { ! for (ctr = 0; ctr < AeroFunctions[axis_ctr+3].size(); ctr++) { ! vMomentsMRC(axis_ctr+1) += AeroFunctions[axis_ctr+3][ctr]->GetValue(); } } --- 273,284 ---- for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) { ! AeroFunctionArray* array = &AeroFunctions[axis_ctr+3]; ! for (AeroFunctionArray::iterator f=array->begin(); f != array->end(); ++f) { ! // Tell the Functions to cache values, so when the function values are ! // being requested for output, the functions do not get calculated again ! // in a context that might have changed, but instead use the values that ! // have already been calculated for this frame. ! (*f)->cacheValue(true); ! vMomentsMRC(axis_ctr+1) += (*f)->GetValue(); } } *************** *** 284,288 **** bool FGAerodynamics::Load(Element *document) { ! string parameter, axis, scratch; string scratch_unit=""; Element *temp_element, *axis_element, *function_element; --- 298,302 ---- bool FGAerodynamics::Load(Element *document) { ! string axis; string scratch_unit=""; Element *temp_element, *axis_element, *function_element; *************** *** 334,338 **** try { ca.push_back( new FGFunction(PropertyManager, function_element) ); ! } catch (string const str) { cerr << endl << fgred << "Error loading aerodynamic function in " << current_func_name << ":" << str << " Aborting." << reset << endl; --- 348,352 ---- try { ca.push_back( new FGFunction(PropertyManager, function_element) ); ! } catch (const string& str) { cerr << endl << fgred << "Error loading aerodynamic function in " << current_func_name << ":" << str << " Aborting." << reset << endl; *************** *** 342,346 **** try { ca_atCG.push_back( new FGFunction(PropertyManager, function_element) ); ! } catch (string const str) { cerr << endl << fgred << "Error loading aerodynamic function in " << current_func_name << ":" << str << " Aborting." << reset << endl; --- 356,360 ---- try { ca_atCG.push_back( new FGFunction(PropertyManager, function_element) ); ! } catch (const string& str) { cerr << endl << fgred << "Error loading aerodynamic function in " << current_func_name << ":" << str << " Aborting." << reset << endl; |