X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2Fmodels%2FFGAerodynamics.cpp;h=a793cce2f443df453b2cbc586688f02814c6b14c;hb=edd83dd7e8fd7162ae49da6113ad797c68769f20;hp=e946a5b479defc2fb9315aacc1387fec30eca466;hpb=f7f17a4744aaa1dbcd9e64b1a4bc97de888ed892;p=flightgear.git diff --git a/src/FDM/JSBSim/models/FGAerodynamics.cpp b/src/FDM/JSBSim/models/FGAerodynamics.cpp index e946a5b47..a793cce2f 100644 --- a/src/FDM/JSBSim/models/FGAerodynamics.cpp +++ b/src/FDM/JSBSim/models/FGAerodynamics.cpp @@ -5,7 +5,7 @@ Date started: 09/13/00 Purpose: Encapsulates the aerodynamic forces - ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) ------------- + ------------- Copyright (C) 2000 Jon S. Berndt (jon@jsbsim.org) ------------- This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software @@ -36,12 +36,19 @@ HISTORY INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#include +#include +#include +#include +#include #include "FGAerodynamics.h" #include "FGPropagate.h" #include "FGAircraft.h" #include "FGAuxiliary.h" #include "FGMassBalance.h" -#include +#include "input_output/FGPropertyManager.h" + +using namespace std; namespace JSBSim { @@ -101,9 +108,6 @@ FGAerodynamics::~FGAerodynamics() delete[] Coeff; - for (i=0; iHolding()) return false; // if paused don't execute + RunPreFunctions(); + // calculate some oft-used quantities for speed twovel = 2*Auxiliary->GetVt(); @@ -166,13 +172,6 @@ bool FGAerodynamics::Run(void) vFw.InitMatrix(); vFnative.InitMatrix(); - // Tell the variable functions to cache their values, so while the aerodynamic - // functions are being calculated for each axis, these functions do not get - // calculated each time, but instead use the values that have already - // been calculated for this frame. - - for (i=0; icacheValue(true); - for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) { for (ctr=0; ctr < Coeff[axis_ctr].size(); ctr++) { vFnative(axis_ctr+1) += Coeff[axis_ctr][ctr]->GetValue(); @@ -226,6 +225,8 @@ bool FGAerodynamics::Run(void) } } + RunPostFunctions(); + return false; } @@ -257,15 +258,15 @@ FGMatrix33& FGAerodynamics::GetTw2b(void) cb = cos(beta); sb = sin(beta); - mTw2b(1,1) = ca*cb; + mTw2b(1,1) = ca*cb; mTw2b(1,2) = -ca*sb; mTw2b(1,3) = -sa; - mTw2b(2,1) = sb; - mTw2b(2,2) = cb; - mTw2b(2,3) = 0.0; - mTw2b(3,1) = sa*cb; + mTw2b(2,1) = sb; + mTw2b(2,2) = cb; + mTw2b(2,3) = 0.0; + mTw2b(3,1) = sa*cb; mTw2b(3,2) = -sa*sb; - mTw2b(3,3) = ca; + mTw2b(3,3) = ca; return mTw2b; } @@ -308,9 +309,6 @@ bool FGAerodynamics::Load(Element *element) Element *temp_element, *axis_element, *function_element; string separator = "/"; -#ifdef macintosh - separator = ";"; -#endif fname = element->GetAttributeValue("file"); if (!fname.empty()) { @@ -320,35 +318,31 @@ bool FGAerodynamics::Load(Element *element) document = element; } + FGModel::Load(document); // Perform base class Pre-Load + DetermineAxisSystem(); // Detemine if Lift/Side/Drag, etc. is used. Debug(2); - if (temp_element = document->FindElement("alphalimits")) { + if ((temp_element = document->FindElement("alphalimits"))) { scratch_unit = temp_element->GetAttributeValue("unit"); if (scratch_unit.empty()) scratch_unit = "RAD"; alphaclmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD"); alphaclmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD"); } - if (temp_element = document->FindElement("hysteresis_limits")) { + if ((temp_element = document->FindElement("hysteresis_limits"))) { scratch_unit = temp_element->GetAttributeValue("unit"); if (scratch_unit.empty()) scratch_unit = "RAD"; alphahystmin = temp_element->FindElementValueAsNumberConvertFromTo("min", scratch_unit, "RAD"); alphahystmax = temp_element->FindElementValueAsNumberConvertFromTo("max", scratch_unit, "RAD"); } - if (temp_element = document->FindElement("aero_ref_pt_shift_x")) { + if ((temp_element = document->FindElement("aero_ref_pt_shift_x"))) { function_element = temp_element->FindElement("function"); AeroRPShift = new FGFunction(PropertyManager, function_element); } - function_element = document->FindElement("function"); - while (function_element) { - variables.push_back( new FGFunction(PropertyManager, function_element) ); - function_element = document->FindNextElement("function"); - } - axis_element = document->FindElement("axis"); while (axis_element) { CoeffArray ca; @@ -362,6 +356,8 @@ bool FGAerodynamics::Load(Element *element) axis_element = document->FindNextElement("axis"); } + FGModel::PostLoad(document); // Perform base class Post-Load + return true; } @@ -415,21 +411,12 @@ void FGAerodynamics::DetermineAxisSystem() //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGAerodynamics::GetCoefficientStrings(string delimeter) +string FGAerodynamics::GetCoefficientStrings(const string& delimeter) const { string CoeffStrings = ""; bool firstime = true; unsigned int axis, sd; - for (sd = 0; sd < variables.size(); sd++) { - if (firstime) { - firstime = false; - } else { - CoeffStrings += delimeter; - } - CoeffStrings += variables[sd]->GetName(); - } - for (axis = 0; axis < 6; axis++) { for (sd = 0; sd < Coeff[axis].size(); sd++) { if (firstime) { @@ -445,33 +432,18 @@ string FGAerodynamics::GetCoefficientStrings(string delimeter) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGAerodynamics::GetCoefficientValues(string delimeter) +string FGAerodynamics::GetCoefficientValues(const string& delimeter) const { - string SDValues = ""; - bool firstime = true; - unsigned int sd; - - for (sd = 0; sd < variables.size(); sd++) { - if (firstime) { - firstime = false; - } else { - SDValues += delimeter; - } - SDValues += variables[sd]->GetValueAsString(); - } + ostringstream buf; for (unsigned int axis = 0; axis < 6; axis++) { for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) { - if (firstime) { - firstime = false; - } else { - SDValues += delimeter; - } - SDValues += Coeff[axis][sd]->GetValueAsString(); + if (buf.tellp() > 0) buf << delimeter; + buf << setw(9) << Coeff[axis][sd]->GetValue(); } } - return SDValues; + return buf.str(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -558,6 +530,9 @@ void FGAerodynamics::Debug(int from) case (atBodyXYZ): cout << endl << " Aerodynamics (X|Y|Z axes):" << endl << endl; break; + case (atNone): + cout << endl << " Aerodynamics (undefined axes):" << endl << endl; + break; } } }