Debian Codegraph @

src/FDM/UIUCModel/uiuc_flapdata.h

raw symbols SCIP
1 /*flapdata.h
2 This is the interface definition file for the structure that
3 holds the flapping data.
4 Written by Theresa Robinson
5 [email protected]
6 */
7
8 #pragma once
9
10 #include <simgear/compiler.h>
11
12 #include <cstdio>
13 #include <fstream>
14 #include <sstream>
15
16 #include "uiuc_warnings_errors.h"
17 //#include "uiuc_aircraft.h"
18
19
20 class flapStruct {
21 private:
22 double Lift,Thrust,Inertia,Moment;
23 public:
24 flapStruct();
25 flapStruct(const flapStruct &rhs);
26 flapStruct(double newLift, double newThrust, double newMoment, double newInertia);
27 double getLift() const;
28 double getThrust() const;
29 double getInertia() const;
30 double getMoment() const;
31 };
32
33
34 class FlapData {
35
36 //class variables
37 private:
38
39 //the following are the arrays of increasing
40 //data values that were used to generate the lift, thrust
41 //pitch and inertial values
42 double* alphaArray; //angle of attack
43 double* speedArray; //airspeed at the wing
44 double* freqArray; //flapping frequency
45 double* phiArray;
46 //the following four tables are generated (e.g. by FullWing)
47 //using the data in the previous three arrays
48 double**** liftTable; //4D array: holds the lift data
49 double**** thrustTable; //4D array: holds the thrust data
50 double**** momentTable; //4D array: holds the pitching moment data
51 double**** inertiaTable; //4D array: holds the inertia data
52
53 //The values in the tables and arrays are directly related through
54 //their indices, in the following way:
55 //For alpha=alphaArray[i], speed=speedArray[j] and freq=freqArray[k]
56 //phi=phiArray[l]
57 //the lift is equal to liftTable[i][j][k][l]
58 int alphaLength, speedLength, freqLength, phiLength;
59 int lastAlphaIndex, lastSpeedIndex, lastFreqIndex, lastPhiIndex;
60 //since we're assuming the angle of attack, velocity, and frequency
61 //don't change much between calls to flap, we keep the last indices
62 //as a good guess of where to start searching next time
63
64 //public methods
65 public:
66 //Constructors:
67 //The default constructor:
68 //Just sets the arrays to null and the guesses to zero
69 FlapData();
70 //A constructor that takes a file name:
71 //Opens that file and fills all the arrays from it
72 //sets the guesses to zero for the speed and halfway
73 //along the array for the alpha and frequency
74 FlapData(const char* filename);
75 //The destructor:
76 //Frees all memory associated with this object
77 ~FlapData();
78 //An initialization function that does the same thing
79 //as the second constructor
80 //returns zero if it was successful
81 int init(const char* filename);
82 //A function that returns the interpolated values
83 //for all four associated numbers
84 //given the angle of attack, speed, and flapping frequency
85 flapStruct flapper(double alpha, double speed, double frequency, double phi);
86 //private methods
87 private:
88 //A function that returns an index i such that
89 // array[i] < value < array[i+1]
90 //The function returns -1 if
91 // (value < array[0]) OR (value > array[n-1])
92 //(i.e. the value is not within the bounds of the array)
93 //It performs a linear search starting at LastIndex
94 int findIndex(double array[], double n, double value, int LastIndex);
95 //A function that performs a linear interpolation based on the
96 //eight points surrounding the value required
97 double interpolate(double**** table, int alphaIndex, int speedIndex, int freqIndex, int phiIndex, double alpha, double speed, double freq, double phi2);
98 //A function that performs a linear interpolation based on the two nearest points
99 double interpolate(double x1, double y1, double x2, double y2, double x);
100 //A function called by init that reads in the file
101 //of the correct format and stores it in the arrays and tables
102 int readIn(std::ifstream* f);
103 };