MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
eigenvector_derivative.cpp
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2020 Manav Bhatia and MAST authors
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 
21 //#define BOOST_TEST_DYN_LINK
22 //#define BOOST_TEST_MODULE InviscidFluxEigensystemDerivative
23 //#include <boost/test/unit_test.hpp>
24 //
26 //#include "fluid/fluid_elem_initialization.h"
27 //
28 //
29 //
30 //BOOST_FIXTURE_TEST_SUITE(L1Derivative, BuildFluidElem)
31 //
32 //
33 //
35 //BOOST_AUTO_TEST_CASE(L1U1DerivativeGeneralN)
36 //{
37 // DenseRealMatrix eig(5,5), mat(5,5), mat_inv(5,5);
38 // RealMatrixX eig0(5,5), mat0(5,5), mat0_inv(5,5);
39 //
40 // // initialize the analytical derivative for comparison
41 // mat0 <<
42 // 121.74913841611915, 0.5933908290969268, 0.2373563316387707, 875.6885867287625, -655.6885867287625, -1, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
43 // mat0_inv <<
44 // 0, 0, 0, 0, 0, -3.0212393123659325e-6, 0.00003323363243602526, 0.00006646726487205052, 1.5106196561829662e-6, 1.5106196561829662e-6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.00033233632436025255, -0.4176517890908552, -0.16121159632760163, -0.0002974668013716487, 0.0006298031257319012;
45 //
46 // libMesh::Point n(sqrt(1.-.25-.04),0.5,0.2);
47 //
48 // _fluid_elem->calculate_advection_left_eigenvector_and_inverse_u1_derivative_for_normal(*_primitive_sol,
49 // n,
50 // eig,
51 // mat,
52 // mat_inv);
53 // //BOOST_CHECK(compare(eig0, eig));
54 // BOOST_CHECK(compare(mat0, mat));
55 // BOOST_CHECK(compare(mat0_inv, mat_inv));
56 //}
57 //
58 //
60 //BOOST_AUTO_TEST_CASE(L1U2DerivativeGeneralN)
61 //{
62 // DenseRealMatrix eig(5,5), mat(5,5), mat_inv(5,5);
63 // RealMatrixX eig0(5,5), mat0(5,5), mat0_inv(5,5);
64 //
65 // // initialize the analytical derivative for comparison
66 // mat0 <<
67 // 54.27299120066195, -1, 0, 465.35258530903457, -443.3525853090345, -0.5933908290969268, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
68 // mat0_inv <<
69 // 0, 3.0212393123659325e-6, 0, 0, 0, 0, 0.00033233632436025255, 0, 0, 0, -3.0212393123659325e-6, 0.00006646726487205052, 0.00006646726487205052, 1.5106196561829662e-6, 1.5106196561829662e-6, 0, 0.00006646726487205052, 0, 0, 0, -0.00003323363243602526, 0.7695579926886009, -0.09926886008640748, -0.0002584999192022985, 0.0002917335516383238;
70 //
71 // libMesh::Point n(sqrt(1.-.25-.04),0.5,0.2);
72 // _fluid_elem->calculate_advection_left_eigenvector_and_inverse_u2_derivative_for_normal(*_primitive_sol,
73 // n,
74 // eig,
75 // mat,
76 // mat_inv);
77 //
78 // //BOOST_CHECK(compare(eig0, eig));
79 // BOOST_CHECK(compare(mat0, mat));
80 // BOOST_CHECK(compare(mat0_inv, mat_inv));
81 //}
82 //
83 //
85 //BOOST_AUTO_TEST_CASE(L1U3DerivativeGeneralN)
86 //{
87 // DenseRealMatrix eig(5,5), mat(5,5), mat_inv(5,5);
88 // RealMatrixX eig0(5,5), mat0(5,5), mat0_inv(5,5);
89 //
90 // // initialize the analytical derivative for comparison
91 // mat0 <<
92 // 4.109196480264778, 0, -1, 203.74103412361382, -159.74103412361384, -0.2373563316387707, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0;
93 // mat0_inv <<
94 // 0, 0, 3.0212393123659325e-6, 0, 0, 0, 0, 0.00033233632436025255, 0, 0, 0, 0, 0.00003323363243602526, 0, 0, -3.0212393123659325e-6, 0.00003323363243602526, 0.00013293452974410104, 1.5106196561829662e-6, 1.5106196561829662e-6, -0.00006646726487205052, -0.09926886008640748, 0.9806547025589896, -0.00007681306173209923, 0.00014328032660414973;
95 //
96 // libMesh::Point n(sqrt(1.-.25-.04),0.5,0.2);
97 // _fluid_elem->calculate_advection_left_eigenvector_and_inverse_u3_derivative_for_normal(*_primitive_sol,
98 // n,
99 // eig,
100 // mat,
101 // mat_inv);
102 //
103 // //BOOST_CHECK(compare(eig0, eig));
104 // BOOST_CHECK(compare(mat0, mat));
105 // BOOST_CHECK(compare(mat0_inv, mat_inv));
106 //}
107 //
108 //
109 //
111 //BOOST_AUTO_TEST_CASE(L1TDerivativeGeneralN)
112 //{
113 // DenseRealMatrix eig(5,5), mat(5,5), mat_inv(5,5);
114 // RealMatrixX eig0(5,5), mat0(5,5), mat0_inv(5,5);
115 //
116 // // initialize the analytical derivative for comparison
117 // mat0 <<
118 // -1003, 0, 0, 141.24534201406482, -141.24534201406482, 0, 0, 0, -1.1601342223163071, 1.1601342223163071, 0, 0, 0, -0.6884130080439917, 0.6884130080439917, 0, 0, 0, -0.2753652032175967, 0.2753652032175967, 0, 0, 0, 0, 0;
119 // mat0_inv <<
120 // 9.15527064353313e-9, -1.0070797707886442e-7, -2.0141595415772884e-7, -4.577635321766565e-9, -4.577635321766565e-9, 1.0070797707886442e-6, -0.000011077877478675086, -0.000022155754957350172, 1.9893733210836735e-7, -1.2060171028970112e-6, 1.0070797707886442e-7, -1.1077877478675086e-6, -2.2155754957350172e-6, 3.6648954997619075e-7, -4.671975270550552e-7, 2.0141595415772884e-7, -2.2155754957350172e-6, -4.4311509914700345e-6, 6.602943832738479e-8, -2.6744539248511365e-7, 0.0000581588567630442, -0.0006397474243934863, -0.0012794948487869725, 0.00005644656760638308, -0.00011460542436942726;
121 //
122 // libMesh::Point n(sqrt(1.-.25-.04),0.5,0.2);
123 // _fluid_elem->calculate_advection_left_eigenvector_and_inverse_T_derivative_for_normal(*_primitive_sol,
124 // n,
125 // eig,
126 // mat,
127 // mat_inv);
128 //
129 // //BOOST_CHECK(compare(eig0, eig));
130 // BOOST_CHECK(compare(mat0, mat));
131 // BOOST_CHECK(compare(mat0_inv, mat_inv));
132 //}
133 //
134 //
135 //BOOST_AUTO_TEST_SUITE_END()
136 //
137 //
138 //
139 //BOOST_FIXTURE_TEST_SUITE(L2Derivative, BuildFluidElem)
140 //
141 //
143 //BOOST_AUTO_TEST_CASE(L2U1Derivative)
144 //{
145 // DenseRealMatrix eig(5,5), mat(5,5), mat_inv(5,5);
146 // RealMatrixX eig0(5,5), mat0(5,5), mat0_inv(5,5);
147 //
148 // // initialize the analytical derivative for comparison
149 // mat0 <<
150 // -1, -103.47270087993381, 0, 564.3525853090346, -344.3525853090345, 0, 0, 0, -1, -1, 0, -0.5933908290969268, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
151 // mat0_inv <<
152 // 3.0212393123659325e-6, 0, 0, 0, 0, 0.0006646726487205051, -3.0212393123659325e-6, 0.00006646726487205052, 1.5106196561829662e-6, 1.5106196561829662e-6, 0.00003323363243602526, 0, 0, 0, 0, 0.00006646726487205052, 0, 0, 0, 0, 0.8057494184114324, -0.00033233632436025255, -0.09268860086407446, -0.00010894857324018491, 0.0004412848976004374;
153 //
154 // libMesh::Point n(0.5,sqrt(1.-.5*.5-.2*.2),0.2);
155 // _fluid_elem->calculate_advection_left_eigenvector_and_inverse_u1_derivative_for_normal(*_primitive_sol,
156 // n,
157 // eig,
158 // mat,
159 // mat_inv);
160 //
161 // //BOOST_CHECK(compare(eig0, eig));
162 // BOOST_CHECK(compare(mat0, mat));
163 // BOOST_CHECK(compare(mat0_inv, mat_inv));
164 //}
165 //
166 //
168 //BOOST_AUTO_TEST_CASE(L2U2Derivative)
169 //{
170 // DenseRealMatrix eig(5,5), mat(5,5), mat_inv(5,5);
171 // RealMatrixX eig0(5,5), mat0(5,5), mat0_inv(5,5);
172 //
173 // // initialize the analytical derivative for comparison
174 // mat0 <<
175 // 0.5933908290969268, 81.49483049671491, 0.2373563316387707, 776.6885867287626, -754.6885867287625, 0, 0, 0, 0, 0, 0, -1, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
176 // mat0_inv <<
177 // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.00033233632436025255, -3.0212393123659325e-6, 0.00006646726487205052, 1.5106196561829662e-6, 1.5106196561829662e-6, 0, 0, 0, 0, 0, -0.4176517890908552, -0.00003323363243602526, -0.1677918555499347, -0.00044701814733376236, 0.0004802517797697876;
178 //
179 // libMesh::Point n(0.5,sqrt(1.-.5*.5-.2*.2),0.2);
180 // _fluid_elem->calculate_advection_left_eigenvector_and_inverse_u2_derivative_for_normal(*_primitive_sol,
181 // n,
182 // eig,
183 // mat,
184 // mat_inv);
185 //
186 // //BOOST_CHECK(compare(eig0, eig));
187 // BOOST_CHECK(compare(mat0, mat));
188 // BOOST_CHECK(compare(mat0_inv, mat_inv));
189 //}
190 //
191 //
193 //BOOST_AUTO_TEST_CASE(L2U3Derivative)
194 //{
195 // DenseRealMatrix eig(5,5), mat(5,5), mat_inv(5,5);
196 // RealMatrixX eig0(5,5), mat0(5,5), mat0_inv(5,5);
197 //
198 // // initialize the analytical derivative for comparison
199 // mat0 <<
200 // 0, -19.389080351973522, -1, 203.74103412361382, -159.74103412361384, 0, 0, 0, 0, 0, 0, -0.2373563316387707, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0;
201 // mat0_inv <<
202 // 0, 0, 3.0212393123659325e-6, 0, 0, 0, 0, 0.00033233632436025255, 0, 0, 0, 0, 0.00003323363243602526, 0, 0, 0.00033233632436025255, -3.0212393123659325e-6, 0.00013293452974410104, 1.5106196561829662e-6, 1.5106196561829662e-6, -0.09268860086407446, -0.00006646726487205052, 0.9806547025589897, -0.00007681306173209923, 0.00014328032660414973;
203 //
204 // libMesh::Point n(0.5,sqrt(1.-.5*.5-.2*.2),0.2);
205 // _fluid_elem->calculate_advection_left_eigenvector_and_inverse_u3_derivative_for_normal(*_primitive_sol,
206 // n,
207 // eig,
208 // mat,
209 // mat_inv);
210 //
211 // //BOOST_CHECK(compare(eig0, eig));
212 // BOOST_CHECK(compare(mat0, mat));
213 // BOOST_CHECK(compare(mat0_inv, mat_inv));
214 //}
215 //
216 //
218 //BOOST_AUTO_TEST_CASE(L2TDerivative)
219 //{
220 // DenseRealMatrix eig(5,5), mat(5,5), mat_inv(5,5);
221 // RealMatrixX eig0(5,5), mat0(5,5), mat0_inv(5,5);
222 //
223 // // initialize the analytical derivative for comparison
224 // mat0 <<
225 // 0, -1003, 0, 94.54494180110561, -94.54494180110561, 0, 0, 0, -0.6884130080439917, 0.6884130080439917, 0, 0, 0, -1.1601342223163071, 1.1601342223163071, 0, 0, 0, -0.2753652032175967, 0.2753652032175967, 0, 0, 0, 0, 0;
226 // mat0_inv <<
227 // -1.0070797707886442e-6, 9.15527064353313e-9, -2.0141595415772884e-7, -4.577635321766565e-9, -4.577635321766565e-9, -0.00011077877478675086, 1.0070797707886442e-6, -0.000022155754957350172, -8.6696346878699e-8, -9.203834239099449e-7, -0.000011077877478675086, 1.0070797707886442e-7, -2.2155754957350172e-6, 6.521232289632571e-7, -7.528312060421217e-7, -0.000022155754957350172, 2.0141595415772884e-7, -4.4311509914700345e-6, 6.602943832738479e-8, -2.6744539248511365e-7, -0.006397474243934862, 0.0000581588567630442, -0.0012794948487869725, 0.000028168833386663504, -0.0000863276901497077;
228 //
229 // libMesh::Point n(0.5,sqrt(1.-.5*.5-.2*.2),0.2);
230 // _fluid_elem->calculate_advection_left_eigenvector_and_inverse_T_derivative_for_normal(*_primitive_sol,
231 // n,
232 // eig,
233 // mat,
234 // mat_inv);
235 //
236 // //BOOST_CHECK(compare(eig0, eig));
237 // BOOST_CHECK(compare(mat0, mat));
238 // BOOST_CHECK(compare(mat0_inv, mat_inv));
239 //}
240 //
241 //
242 //BOOST_AUTO_TEST_SUITE_END()
243 //
244 //
245 //
246 //BOOST_FIXTURE_TEST_SUITE(L3Derivative, BuildFluidElem)
247 //
248 //
250 //BOOST_AUTO_TEST_CASE(L3U1Derivative)
251 //{
252 // DenseRealMatrix eig(5,5), mat(5,5), mat_inv(5,5);
253 // RealMatrixX eig0(5,5), mat0(5,5), mat0_inv(5,5);
254 //
255 // // initialize the analytical derivative for comparison
256 // mat0 <<
257 // -1, 0, -96.94540175986761, 564.3525853090346, -344.3525853090345, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, -0.5933908290969268, 0, 0, 0, 0, 0, 0, 0;
258 // mat0_inv <<
259 // 3.0212393123659325e-6, 0, 0, 0, 0, 0.0006646726487205051, 0.00003323363243602526, -3.0212393123659325e-6, 1.5106196561829662e-6, 1.5106196561829662e-6, 0.00003323363243602526, 0, 0, 0, 0, 0.00006646726487205052, 0, 0, 0, 0, 0.8057494184114324, -0.09634430043203723, -0.00033233632436025255, -0.00010894857324018491, 0.0004412848976004374;
260 //
261 // libMesh::Point n(0.5,0.2,sqrt(1.-.5*.5-.2*.2));
262 // _fluid_elem->calculate_advection_left_eigenvector_and_inverse_u1_derivative_for_normal(*_primitive_sol,
263 // n,
264 // eig,
265 // mat,
266 // mat_inv);
267 //
268 // //BOOST_CHECK(compare(eig0, eig));
269 // BOOST_CHECK(compare(mat0, mat));
270 // BOOST_CHECK(compare(mat0_inv, mat_inv));
271 //}
272 //
273 //
275 //BOOST_AUTO_TEST_CASE(L3U2Derivative)
276 //{
277 // DenseRealMatrix eig(5,5), mat(5,5), mat_inv(5,5);
278 // RealMatrixX eig0(5,5), mat0(5,5), mat0_inv(5,5);
279 //
280 // // initialize the analytical derivative for comparison
281 // mat0 <<
282 // 0, -1, -5.778160703947044, 192.74103412361382, -170.74103412361382, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, -0.2373563316387707, 0, 0, 0, 0, 0, 0, 0;
283 // mat0_inv <<
284 // 0, 3.0212393123659325e-6, 0, 0, 0, 0, 0.00033233632436025255, 0, 0, 0, 0.00033233632436025255, 0.00006646726487205052, -3.0212393123659325e-6, 1.5106196561829662e-6, 1.5106196561829662e-6, 0, 0.00006646726487205052, 0, 0, 0, -0.09634430043203723, 0.9795579926886008, -0.00003323363243602526, -0.00009342987795011185, 0.00012666351038613708;
285 //
286 // libMesh::Point n(0.5,0.2,sqrt(1.-.5*.5-.2*.2));
287 // _fluid_elem->calculate_advection_left_eigenvector_and_inverse_u2_derivative_for_normal(*_primitive_sol,
288 // n,
289 // eig,
290 // mat,
291 // mat_inv);
292 //
293 // //BOOST_CHECK(compare(eig0, eig));
294 // BOOST_CHECK(compare(mat0, mat));
295 // BOOST_CHECK(compare(mat0_inv, mat_inv));
296 //}
297 //
298 //
300 //BOOST_AUTO_TEST_CASE(L3U3Derivative)
301 //{
302 // DenseRealMatrix eig(5,5), mat(5,5), mat_inv(5,5);
303 // RealMatrixX eig0(5,5), mat0(5,5), mat0_inv(5,5);
304 //
305 // // initialize the analytical derivative for comparison
306 // mat0 <<
307 // 0.5933908290969268, 0.2373563316387707, 89.88391084868843, 787.6885867287626, -743.6885867287626, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0;
308 // mat0_inv <<
309 // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.00033233632436025255, 0.00003323363243602526, -3.0212393123659325e-6, 1.5106196561829662e-6, 1.5106196561829662e-6, -0.4139960895228924, -0.16779185554993467, -0.00006646726487205052, -0.00043040133111574974, 0.0004968685959878003;
310 // libMesh::Point n(0.5,0.2,sqrt(1.-.5*.5-.2*.2));
311 // _fluid_elem->calculate_advection_left_eigenvector_and_inverse_u3_derivative_for_normal(*_primitive_sol,
312 // n,
313 // eig,
314 // mat,
315 // mat_inv);
316 //
317 // //BOOST_CHECK(compare(eig0, eig));
318 // BOOST_CHECK(compare(mat0, mat));
319 // BOOST_CHECK(compare(mat0_inv, mat_inv));
320 //}
321 //
322 //
324 //BOOST_AUTO_TEST_CASE(L3TDerivative)
325 //{
326 // DenseRealMatrix eig(5,5), mat(5,5), mat_inv(5,5);
327 // RealMatrixX eig0(5,5), mat0(5,5), mat0_inv(5,5);
328 //
329 // // initialize the analytical derivative for comparison
330 // mat0 <<
331 // 0, 0, -1003, 104.27740101119142, -104.27740101119142, 0, 0, 0, -0.6884130080439917, 0.6884130080439917, 0, 0, 0, -0.2753652032175967, 0.2753652032175967, 0, 0, 0, -1.1601342223163071, 1.1601342223163071, 0, 0, 0, 0, 0;
332 // mat0_inv <<
333 // -1.0070797707886442e-6, -1.0070797707886442e-7, 9.15527064353313e-9, -4.577635321766565e-9, -4.577635321766565e-9, -0.00011077877478675086, -0.000011077877478675086, 1.0070797707886442e-6, -8.6696346878699e-8, -9.203834239099449e-7, -0.000011077877478675086, -1.1077877478675086e-6, 1.0070797707886442e-7, 1.16383426866817e-7, -2.1709140394568142e-7, -0.000022155754957350172, -2.2155754957350172e-6, 2.0141595415772884e-7, 6.01769240423825e-7, -8.031851945815539e-7, -0.006397474243934862, -0.0006397474243934863, 0.0000581588567630442, 0.000034061971209724335, -0.00009222082797276853;
334 //
335 // libMesh::Point n(0.5,0.2,sqrt(1.-.5*.5-.2*.2));
336 // _fluid_elem->calculate_advection_left_eigenvector_and_inverse_T_derivative_for_normal(*_primitive_sol,
337 // n,
338 // eig,
339 // mat,
340 // mat_inv);
341 //
342 // //BOOST_CHECK(compare(eig0, eig));
343 // BOOST_CHECK(compare(mat0, mat));
344 // BOOST_CHECK(compare(mat0_inv, mat_inv));
345 //}
346 //
347 //
348 //BOOST_AUTO_TEST_SUITE_END()
349 //
350