-
Notifications
You must be signed in to change notification settings - Fork 0
/
nozzle.hpp
227 lines (191 loc) · 6.66 KB
/
nozzle.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/**
* \file nozzle.hpp
* \brief header file for Nozzle class
* \author Jason Hicken <[email protected]>
* \version 1.0
*/
#pragma once
#include <math.h>
#include <ostream>
#include <iostream>
#include "./inner_prod_vector.hpp"
#include "./bspline.hpp"
// ======================================================================
/*!
* \class Nozzle
* \brief quasi-1d nozzle geometry definition and manipulation
*/
class Nozzle {
public:
/*!
* \brief default cnstructor
*/
Nozzle();
/*!
* \brief default destructor
*/
virtual ~Nozzle() = 0;
/*!
* \brief set the area at the left and right ends of the domain
* \param[in] area_left - area at the left of domain
* \param[in] area_right - area at the right of domain
*/
void SetAreaAtEnds(const double & area_left,
const double & area_right);
/*!
* \brief set the values of the coefficents that define the nozzle
* \param[in] coeff - values of the design coefficents
*/
virtual void SetCoeff(const InnerProdVector & coeff);
/*!
* \brief returns the (internal) b-spline coefficients
* \param[out] coeff - coefficient values
*/
void GetCoeff(InnerProdVector & coeff) const;
/*!
* \brief returns the nozzle area at a given set of x coordinates
* \param[in] x_coord - x coordinates to evaluate nozzle area
* \returns nozzle area at x_coord
*/
virtual InnerProdVector Area(const InnerProdVector & x_coord) = 0;
/*!
* \brief returns the nozzle area at a given x coordinate
* \param[in] x_min - minimum x coordinate
* \param[in] x_max - maximum x coordinate
* \param[in] x - x coordinate to evaluate nozzle area
* \returns area at x
*/
virtual double Area(const double & x_min, const double & x_max,
const double & x) = 0;
/*!
* \brief calculate the forward mode derivative of area w.r.t. coeff
* \param[in] x_coord - x coordinates to evaluate area derivative
* \param[in] u - the direction that the derivative is desired
* \returns the resulting derivative components
*/
virtual InnerProdVector AreaForwardDerivative(
const InnerProdVector & x_coord, const InnerProdVector & u) = 0;
/*!
* \brief calculate the reverse mode derivative of area w.r.t. coeff
* \param[in] x_coord - x coordinates to evaluate area derivative
* \param[in] u - the direction that the derivative is desired
* \returns the resulting derivative components
*/
virtual InnerProdVector AreaReverseDerivative(
const InnerProdVector & x_coord, const InnerProdVector & u) = 0;
protected:
int num_coeff_; ///< number of design coefficients
double area_left_; ///< area at the left end of the domain
double area_right_; ///< area at the right end of the domai
InnerProdVector coeff_; ///< design coefficients
};
inline Nozzle::~Nozzle() {}
// ======================================================================
/*!
* \class FourierNozzle
* \brief quasi-1d nozzle geometry defined using a Fourier sine series
*/
class FourierNozzle : public Nozzle {
public:
/*!
* \brief default cnstructor
*/
FourierNozzle() : Nozzle() {}
/*!
* \brief default destructor
*/
~FourierNozzle() {}
/*!
* \brief returns the nozzle area at a given set of x coordinates
* \param[in] x_coord - x coordinates to evaluate nozzle area
* \returns nozzle area at x_coord
*/
InnerProdVector Area(const InnerProdVector & x_coord);
/*!
* \brief returns the nozzle area at a given x coordinate
* \param[in] x_min - minimum x coordinate
* \param[in] x_max - maximum x coordinate
* \param[in] x - x coordinate to evaluate nozzle area
* \returns area at x
*/
double Area(const double & x_min, const double & x_max,
const double & x);
/*!
* \brief calculate the forward mode derivative of area w.r.t. coeff
* \param[in] x_coord - x coordinates to evaluate area derivative
* \param[in] u - the direction that the derivative is desired
* \returns the resulting derivative components
*/
InnerProdVector AreaForwardDerivative(
const InnerProdVector & x_coord, const InnerProdVector & u);
/*!
* \brief calculate the reverse mode derivative of area w.r.t. coeff
* \param[in] x_coord - x coordinates to evaluate area derivative
* \param[in] u - the direction that the derivative is desired
* \returns the resulting derivative components
*/
InnerProdVector AreaReverseDerivative(
const InnerProdVector & x_coord, const InnerProdVector & u);
};
// ======================================================================
/*!
* \class BsplineNozzle
* \brief quasi-1d nozzle geometry defined using a Bspline
*/
class BsplineNozzle : public Nozzle {
public:
/*!
* \brief default cnstructor
*/
BsplineNozzle() : Nozzle() {}
/*!
* \brief default destructor
*/
~BsplineNozzle() {}
/*!
* \brief set the b-spline coefficients
* \param[in] coeff - coefficient values
* \param[in] order - order of the bspline
*/
void SetCoeff(const InnerProdVector & coeff); //, const int & order = 4);
/*!
* \brief set the b-spline coefficients by LS fitting to given data
* \param[in] x_coord - set of coordinates where the data are given
* \param[in] y_coord - set of data to fit
*/
void FitNozzle(const InnerProdVector & x_coord,
const InnerProdVector & y_coord);
/*!
* \brief returns the nozzle area at a given set of x coordinates
* \param[in] x_coord - x coordinates to evaluate nozzle area
* \returns nozzle area at x_coord
*/
InnerProdVector Area(const InnerProdVector & x_coord);
/*!
* \brief returns the nozzle area at a given x coordinate
* \param[in] x_min - minimum x coordinate
* \param[in] x_max - maximum x coordinate
* \param[in] x - x coordinate to evaluate nozzle area
* \returns area at x
*/
double Area(const double & x_min, const double & x_max,
const double & x);
/*!
* \brief calculate the forward mode derivative of area w.r.t. coeff
* \param[in] x_coord - x coordinates to evaluate area derivative
* \param[in] u - the direction that the derivative is desired
* \returns the resulting derivative components
*/
InnerProdVector AreaForwardDerivative(
const InnerProdVector & x_coord, const InnerProdVector & u);
/*!
* \brief calculate the reverse mode derivative of area w.r.t. coeff
* \param[in] x_coord - x coordinates to evaluate area derivative
* \param[in] u - the direction that the derivative is desired
* \returns the resulting derivative components
*/
InnerProdVector AreaReverseDerivative(
const InnerProdVector & x_coord, const InnerProdVector & u);
protected:
Bspline spline_;
};