]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGAerodynamics.h
Fix a potention buffer overflow
[flightgear.git] / src / FDM / JSBSim / FGAerodynamics.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGAerodynamics.h
4  Author:       Jon S. Berndt
5  Date started: 09/13/00
6
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
8
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17  details.
18
19  You should have received a copy of the GNU General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA  02111-1307, USA.
22
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28 09/13/00   JSB   Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGAERODYNAMICS_H
35 #define FGAERODYNAMICS_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #ifdef FGFS
42 #  include <simgear/compiler.h>
43 #  ifdef SG_HAVE_STD_INCLUDES
44 #    include <vector>
45 #    include <map>
46 #  else
47 #    include <vector.h>
48 #    include <map.h>
49 #  endif
50 #else
51 #  include <vector>
52 #  include <map>
53 #endif
54
55 #include "FGModel.h"
56 #include "FGConfigFile.h"
57 #include "FGState.h"
58 #include "FGMassBalance.h"
59 #include "FGTranslation.h"
60 #include "FGCoefficient.h"
61 #include "FGFactorGroup.h"
62
63 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 DEFINITIONS
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
66
67 #define ID_AERODYNAMICS "$Id$"
68
69 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70 FORWARD DECLARATIONS
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
72
73 namespace JSBSim {
74
75 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 CLASS DOCUMENTATION
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
78
79 /** Encapsulates the aerodynamic calculations.
80     This class owns and contains the list of coefficients that define the
81     aerodynamic properties of this aircraft. Here also, such unique phenomena
82     as ground effect and maximum lift curve tailoff are handled.
83     @author Jon S. Berndt
84     @author Tony Peden
85     @version $Id$
86 */
87
88 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 CLASS DECLARATION
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
91
92 class FGAerodynamics : public FGModel {
93
94 public:
95   /** Constructor
96       @param Executive a pointer to the parent executive object */
97   FGAerodynamics(FGFDMExec* Executive);
98   /// Destructor
99   ~FGAerodynamics();
100
101   /** Runs the Aerodynamics model; called by the Executive
102       @return false if no error */
103   bool Run(void);
104
105   /** Loads the Aerodynamics model.
106       The Load function for this class expects the configuration file to
107       have found the AERODYNAMICS keyword in the configution file and to
108       have set that line to the current line.
109       @param AC_cfg pointer to the current configuration file.
110       @return true if successful */
111   bool Load(FGConfigFile* AC_cfg);
112
113   /** Gets the total aerodynamic force vector.
114       @return a force vector reference. */
115   FGColumnVector3& GetForces(void) {return vForces;}
116
117   /** Gets the aerodynamic force for an axis.
118       @param n Axis index. This could be 0, 1, or 2, or one of the 
119                axis enums: eX, eY, eZ.
120       @return the force acting on an axis */
121   double GetForces(int n) const {return vForces(n);}
122
123   /** Gets the total aerodynamic moment vector.
124       @return a moment vector reference. */
125   FGColumnVector3& GetMoments(void) {return vMoments;}
126
127   /** Gets the aerodynamic moment for an axis.
128       @return the moment about a single axis (as described also in the
129               similar call to GetForces(int n).*/
130   double GetMoments(int n) const {return vMoments(n);}
131
132   FGColumnVector3& GetvLastFs(void) { return vLastFs; }
133   double GetvLastFs(int axis) const { return vLastFs(axis); }
134   FGColumnVector3& GetvFs(void) { return vFs; }
135   double GetvFs(int axis) const { return vFs(axis); }
136   inline double GetLoD(void) const { return lod; }
137   inline double GetClSquared(void) const { return clsq; } 
138   inline double GetAlphaCLMax(void) const { return alphaclmax; }
139   inline double GetAlphaCLMin(void) const { return alphaclmin; }
140   
141   inline double GetAlphaHystMax(void) const { return alphahystmax; }
142   inline double GetAlphaHystMin(void) const { return alphahystmin; }
143   inline double GetHysteresisParm(void) const { return stall_hyst; }
144   inline double GetStallWarn(void) const { return impending_stall; }
145   double GetAlphaW(void) const { return alphaw; }
146
147   double GetBI2Vel(void) const { return bi2vel; }
148   double GetCI2Vel(void) const { return ci2vel; }
149   
150   inline void SetAlphaCLMax(double tt) { alphaclmax=tt; }
151   inline void SetAlphaCLMin(double tt) { alphaclmin=tt; }
152
153   /** Gets the strings for the current set of coefficients.
154       @return a string containing the descriptive names for all coefficients */
155   string GetCoefficientStrings(void);
156
157   /** Gets the coefficient values.
158       @return a string containing the numeric values for the current set of
159       coefficients */
160   string GetCoefficientValues(void);
161   
162   void bind(void);
163   void bindModel(void);
164   void unbind(void);
165   
166 private:
167   typedef map<string,int> AxisIndex;
168   AxisIndex AxisIdx;
169   typedef vector<FGCoefficient*> CoeffArray;
170   CoeffArray* Coeff;
171   FGColumnVector3 vFs;
172   FGColumnVector3 vForces;
173   FGColumnVector3 vMoments;
174   FGColumnVector3 vLastFs;
175   FGColumnVector3 vDXYZcg;
176   double alphaclmax, alphaclmin;
177   double alphahystmax, alphahystmin;
178   double impending_stall, stall_hyst;
179   double bi2vel, ci2vel,alphaw;
180   double clsq,lod;
181   
182   typedef double (FGAerodynamics::*PMF)(int) const;
183
184   void Debug(int from);
185 };
186
187 } // namespace JSBSim
188
189 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190 #endif
191