-
Notifications
You must be signed in to change notification settings - Fork 0
/
RadMom1DState_Third_Order.cc
452 lines (375 loc) · 18.7 KB
/
RadMom1DState_Third_Order.cc
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
/*!\file RadMom1DState_Third_Order.cc
\brief Header file defining 1D RadMom Solution State Classes. */
#ifndef _RADMOM1D_STATE_THIRD_ORDER_INCLUDED
#include "RadMom1DState_Third_Order.h"
#endif // _RADMOM1D_STATE_THIRD_ORDER_INCLUDED
// /*************************************************************
// * RadMom1D_pState_Third_Order -- Create storage and assign gas constants.*
// *************************************************************/
template <>
int RadMom1D_pState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::closure_type = MOMENT_CLOSURE_P3;
template <>
int RadMom1D_pState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::Absorption_Model = MEDIUM1D_ABSORB_GRAY;
template <>
int RadMom1D_pState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::Scattering_Func = RADIATION_SCATTER_ISO;
template <>
double RadMom1D_pState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::c = SPEED_OF_LIGHT;
template <>
double RadMom1D_pState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::a = RADIATION_CONSTANT;
template <>
double RadMom1D_pState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::C1 = PLANCK_CONSTANT;
int RadMom1D_pState_Third_Order :: NUM_VAR_RADMOM1D_THIRD_ORDER = 0;
// /*************************************************************
// * RadMom1D_cState -- Create storage and assign gas constants.*
// *************************************************************/
template <>
int RadMom1D_cState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::closure_type = MOMENT_CLOSURE_P3;
template <>
int RadMom1D_cState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::Absorption_Model = MEDIUM1D_ABSORB_GRAY;
template <>
int RadMom1D_cState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::Scattering_Func = RADIATION_SCATTER_ISO;
template <>
double RadMom1D_cState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::c = SPEED_OF_LIGHT;
template <>
double RadMom1D_cState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::a = RADIATION_CONSTANT;
template <>
double RadMom1D_cState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::C1 = PLANCK_CONSTANT;
int RadMom1D_cState_Third_Order :: NUM_VAR_RADMOM1D_THIRD_ORDER = 0;
/*********************************************************
* Routine: Rotate *
* *
* This function returns the solution in the local *
* rotated frame (clockwise). *
* *
*********************************************************/
void RadMom1D_pState_Third_Order :: Rotate(const double &norm_dir) {
RadMom1D_pState_Third_Order W_rotated;
W_rotated.m_values[0] = I0();
// Rotate flux vector
W_rotated.m_values[1] = norm_dir*N1x();
// Rotate Pressure tensor
W_rotated.m_values[2] = sqr(norm_dir)*N2xx();
// Rotate third order tensor
W_rotated.m_values[3] = cube(norm_dir)*N3xxx();
Copy(W_rotated);
}
void RadMom1D_cState_Third_Order :: Rotate(const double &norm_dir) {
RadMom1D_cState_Third_Order U_rotated;
U_rotated.m_values[0] = I0();
// Rotate flux vector
U_rotated.m_values[1] = norm_dir*I1x();
// Rotate Pressure tensor
U_rotated.m_values[2] = sqr(norm_dir)*I2xx();
// Rotate third order tensor
U_rotated.m_values[3] = cube(norm_dir)*I3xxx();
Copy(U_rotated);
}
/********************************************************
* Routine: RoeAverage (Roe Averages) *
* *
* This function returns the Roe-averaged (linearized) *
* primitive solution state given left and right *
* primitive solution variables. *
* *
********************************************************/
void RadMom1D_pState_Third_Order :: RoeAverage(const RadMom1D_pState_Third_Order &Wl,
const RadMom1D_pState_Third_Order &Wr) {
RadMom1D_pState_Third_Order Wstar;
Wstar = RadMom1D_pState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::RoeAverage(Wl, Wr);
/* Return the Roe-averged state. */
Copy(Wstar);
}
void RadMom1D_pState_Third_Order :: AverageStates(const RadMom1D_pState_Third_Order &Wl,
const RadMom1D_pState_Third_Order &Wr) {
RadMom1D_pState_Third_Order Wstar;
RadMom1D_pState<RadMom1D_cState_Third_Order,
RadMom1D_pState_Third_Order>::AverageStates(Wstar, Wl, Wr);
/* Return the Roe-averged state. */
Copy(Wstar);
}
/********************************************************
* Routine: Set_ICs *
* *
* This function returns the initial condition state *
* at the left, right, upper or lower boundary or the *
* interior domain given an incoming radiative intensity*
* *
********************************************************/
void RadMom1D_cState_Third_Order :: Set_ICs(const double &Medium_Temperature) {
static Medium1D_State Mwall; // a container
// set wall blackbody intensity
Mwall.setBlackBody(Medium_Temperature);
const double Ib_wall(Mwall.Ib());
m_values[0] = Ib_wall*FOUR*PI;
m_values[1] = ZERO;
m_values[2] = Ib_wall*FOUR*PI/THREE;
m_values[3] = ZERO;
// m_values[0] = Ib_wall*TWO*PI;
// m_values[1] = Ib_wall*PI;
// m_values[2] = Ib_wall*TWO*PI/THREE;
// m_values[3] = HALF*Ib_wall*PI;
}
void RadMom1D_cState_Third_Order :: Set_ICs_Beam(const double &Medium_Temperature) {
static Medium1D_State Mwall; // a container
// set wall blackbody intensity
Mwall.setBlackBody(Medium_Temperature);
const double Ib_wall(Mwall.Ib());
m_values[0] = Ib_wall;
m_values[1] = Ib_wall;
m_values[2] = Ib_wall;
m_values[3] = Ib_wall;
}
void RadMom1D_cState_Third_Order :: Set_ICs_Intensity(const double &Ib_wall) {
m_values[0] = Ib_wall*FOUR*PI;
m_values[1] = ZERO;
m_values[2] = Ib_wall*FOUR*PI/THREE;
m_values[3] = ZERO;
}
/********************************************************
* Routine: Set_BCs *
* *
* This function returns the initial boundary conditions*
* at the left, right, upper or lower boundary or the *
* interior domain given an incoming radiative intensity*
* *
********************************************************/
void RadMom1D_cState_Third_Order :: Set_BCs(const double *Intensity,
const double &norm_dir) {
// m_values[0] = Intensity[0]*FOUR*PI;
// m_values[1] = ZERO;
// m_values[2] = Intensity[0]*FOUR*PI/THREE;
// m_values[3] = ZERO;
m_values[0] = Intensity[0]*TWO*PI;
m_values[1] = -Intensity[0]*PI;
m_values[2] = Intensity[0]*TWO*PI/THREE;
m_values[3] = -Intensity[0]*PI/TWO;
Rotate(norm_dir);
}
void RadMom1D_pState_Third_Order :: Gray_Wall(RadMom1D_pState_Third_Order W_inner,
const double &wall_temperature,
const double &wall_emissivity,
const double &norm_dir) {
RadMom1D_cState_Third_Order U_wall;
static Medium1D_State Mwall; // a container
// set wall blackbody intensity
Mwall.setBlackBody(wall_temperature);
const double Ib_wall(Mwall.Ib());
double Iw;
double Fx_plus;
//------------------------------------------------
// for a black wall
//------------------------------------------------
if (wall_emissivity>MICRO) {
Iw = wall_emissivity * Ib_wall;
} else {
Iw = ZERO;
}
//------------------------------------------------
// For grey wall.
//------------------------------------------------
if ( fabs(1.0-wall_emissivity)>MICRO ) {
cout << "Double-check this implementation for P3 Gray_Wall !!!!" << endl;
Fx_plus = (THREE/THIRTY_TWO)*W_inner.I0() + (ONE/TWO)*W_inner.U().I1x() + (FIFTEEN/THIRTY_TWO)*W_inner.U().I2xx();
Iw = wall_emissivity * Ib_wall;
Iw += (ONE - wall_emissivity) * Fx_plus/PI;
}
U_wall.Set_BCs(&Iw, norm_dir);
Copy(U_wall.W());
}
/********************************************************
* Routine: Reflect *
* *
* This function returns the reflected solution state *
* in a given direction given the primitive solution *
* variables and the unit normal vector in the *
* direction of interest. *
* *
********************************************************/
void RadMom1D_pState_Third_Order :: Reflect(RadMom1D_pState_Third_Order W_inner,
const double &norm_dir) {
double Ibv_val, Fx_plus;
/* Apply the frame rotation and calculate the primitive
solution state variables in the local rotated frame
defined by the unit normal vector. */
W_inner.Rotate(norm_dir);
Fx_plus = (THREE/THIRTY_TWO)*W_inner.I0() + (ONE/TWO)*W_inner.U().I1x() + (FIFTEEN/THIRTY_TWO)*W_inner.U().I2xx();
Ibv_val = Fx_plus/PI;
m_values[0] = Ibv_val*FOUR*PI;
m_values[1] = ZERO;
m_values[2] = Ibv_val*FOUR*PI/THREE;
m_values[3] = ZERO;
Rotate(norm_dir);
}
/********************************************************
* Routine: Characteristic *
* *
* This function returns the boundary values using *
* characteristic wavespeeds in the x-direction given *
* the primitive solution variables at the boundary *
* and just inside the boundary. *
* *
********************************************************/
void RadMom1D_pState_Third_Order :: Characteristic(RadMom1D_pState_Third_Order W_inner,
const double &wall_temperature,
const double &wall_emissivity,
const double &norm_dir) {
double lambda_val;
RadMom1D_pState_Third_Order W_charac, W_ghost, W_star;
static RadMom1D_cState_Third_Order rc_vec, lc_vec;
RadMom1D_cState_Third_Order U_bound;
RadMom1D_cState_Third_Order U_inner, U_ghost;
RadMom1D_pState_Third_Order lambda_W_star;
Eigenstructure_P3 Eig_P3;
double rc_val, lc_val;
W_inner.Rotate(norm_dir);
Gray_Wall(W_inner, wall_temperature, wall_emissivity, norm_dir);
Rotate(norm_dir);
Copy_to_W(W_ghost);
// Compute W_star for the linearization of the flux Jacobian (based on Roe Average)
// Note that, in the rotated frame, the inner solution corresponds to the left solution
// and the ghost cell solution corresponds to the right solution
W_star.RoeAverage(W_inner, W_ghost);
Setup_Eigenstructure_P3(Eig_P3);
U_inner = W_inner.U();
U_ghost = W_ghost.U();
lambda_W_star = W_star.lambda_x();
// Compute characteristic variables at the boundaries
for (int i = 0; i < STATIC_NUM_VAR_RADMOM1D_THIRD_ORDER; i++) {
lambda_val = lambda_W_star[i+1];
W_charac.m_values[i] = ZERO;
if (lambda_val > TOLER) {
// Characteristic variable at the boundary is based on the incoming solution
// which in this case corresponds to the inner solution
for (int j = 0; j < STATIC_NUM_VAR_RADMOM1D_THIRD_ORDER; j++) {
lc_val = Eig_P3.lc_vec[i][j];
W_charac.m_values[i] += lc_val*U_inner[j+1];
}
} else if (lambda_val <= TOLER) {
// Then characteristic variable at the boundary is based on the outgoing solution
// which in this case corresponds to the ghost cell solution
for (int j = 0; j < STATIC_NUM_VAR_RADMOM1D_THIRD_ORDER; j++) {
lc_val = Eig_P3.lc_vec[i][j];
W_charac.m_values[i] += lc_val*U_ghost[j+1];
}
}
// Now compute the solution on the boundary based the vector of characteristic variables
// at that boundary
for (int i = 0; i < STATIC_NUM_VAR_RADMOM1D_THIRD_ORDER; i++) {
// Initialize the primitie variable of interest
U_bound.m_values[i] = ZERO;
for (int j = 0; j < STATIC_NUM_VAR_RADMOM1D_THIRD_ORDER; j++) {
rc_val = Eig_P3.rc_vec[i][j];
U_bound.m_values[i] += rc_val * W_charac.m_values[j];
}
}
m_values[0] = U_bound.W().I0();
m_values[1] = U_bound.W().N1x();
m_values[2] = U_bound.W().N2xx();
m_values[3] = U_bound.W().N3xxx();
}
Rotate(norm_dir);
}
/********************************************************
* Routine: PartialFlux_n *
* *
* This function returns the boundary values in the *
* x-direction using partial fluxes given the primitive *
* solution variables in the cell just inside the *
* boundary. *
* *
********************************************************/
void RadMom1D_pState_Third_Order :: PartialMoments_n(RadMom1D_pState_Third_Order W_inner,
const double &wall_temperature,
const double &wall_emissivity,
const double &norm_dir) {
double E_plus, E_minus, Fx_minus, Fx_plus;
double Pxx_plus, Pxx_minus;
double Qxxx_plus, Qxxx_minus;
W_inner.Rotate(norm_dir);
Gray_Wall(W_inner, wall_temperature, wall_emissivity, norm_dir);
Rotate(norm_dir);
E_minus = I0();
Fx_minus = I0()*N1x();
Pxx_minus = I0()*N2xx();
Qxxx_minus = I0()*N3xxx();
E_plus = (ONE/TWO)*W_inner.I0() + (FORTY_FIVE/THIRTY_TWO)*W_inner.U().I1x() - (THIRTY_FIVE/THIRTY_TWO)*W_inner.U().I3xxx();
Fx_plus = (THREE/THIRTY_TWO)*W_inner.I0() + (ONE/TWO)*W_inner.U().I1x() + (FIFTEEN/THIRTY_TWO)*W_inner.U().I2xx();
Pxx_plus = (FIVE/THIRTY_TWO)*W_inner.U().I1x() + (ONE/TWO)*W_inner.U().I2xx() + (THIRTY_FIVE/NINETY_SIX)*W_inner.U().I3xxx();
Qxxx_plus = -(ONE/THIRTY_TWO)*W_inner.I0() + (FIFTEEN/THIRTY_TWO)*W_inner.U().I2xx()+ (ONE/TWO)*W_inner.U().I3xxx();
m_values[0] = E_plus + E_minus;
m_values[1] = (Fx_plus+Fx_minus)/I0();
m_values[2] = (Pxx_plus+Pxx_minus)/I0();
m_values[3] = (Qxxx_plus+Qxxx_minus)/I0();
Rotate(norm_dir);
}
/********************************************************
* Routine: Markshak_n *
* *
* This function returns the boundary values using *
* standard Markshak condition from P1 method, given *
* the primitive solution variables at the boundary *
* and just inside the boundary. *
* *
********************************************************/
void RadMom1D_pState_Third_Order :: Marshak_n(RadMom1D_pState_Third_Order W_inner,
const double &wall_temperature,
const double &wall_emissivity,
const double &norm_dir) {
double Fx_plus, Fx_minus;
double Qxxx_plus, Qxxx_minus;
W_inner.Rotate(norm_dir);
Gray_Wall(W_inner, wall_temperature, wall_emissivity, norm_dir);
Rotate(norm_dir);
Fx_minus = I0()*N1x();
Qxxx_minus = I0()*N3xxx();
Fx_plus = (THREE/THIRTY_TWO)*W_inner.I0() + (ONE/TWO)*W_inner.U().I1x() + (FIFTEEN/THIRTY_TWO)*W_inner.U().I2xx();
Qxxx_plus = -(ONE/THIRTY_TWO)*W_inner.I0() + (FIFTEEN/THIRTY_TWO)*W_inner.U().I2xx()+ (ONE/TWO)*W_inner.U().I3xxx();
m_values[0] = FOUR*((Fx_plus - Fx_minus) - (Qxxx_plus - Qxxx_minus));
m_values[1] = (Fx_plus + Fx_minus)/I0();
m_values[2] = (FOUR/(FIFTEEN*I0()))*((Fx_plus - Fx_minus) + THREE*(Qxxx_plus - Qxxx_minus));
m_values[3] = (Qxxx_plus + Qxxx_minus)/I0();
Rotate(norm_dir);
}
/********************************************************
* Routine: PartialFlux_n *
* *
* This function returns the boundary values in the *
* x-direction using partial fluxes given the primitive *
* solution variables in the cell just inside the *
* boundary. *
* *
********************************************************/
void RadMom1D_pState_Third_Order :: PartialFlux_n (RadMom1D_pState_Third_Order W_inner,
const double &wall_temperature,
const double &wall_emissivity,
const double &norm_dir) {
double Fx_plus, Fx_minus, Pxx_plus, Pxx_minus;
double Qxxx_plus, Qxxx_minus;
W_inner.Rotate(norm_dir);
Gray_Wall(W_inner, wall_temperature, wall_emissivity, norm_dir);
Rotate(norm_dir);
Fx_minus = I0()*N1x();
Pxx_minus = I0()*N2xx();
Qxxx_minus = I0()*N3xxx();
Fx_plus = (THREE/THIRTY_TWO)*W_inner.I0() + (ONE/TWO)*W_inner.U().I1x() + (FIFTEEN/THIRTY_TWO)*W_inner.U().I2xx();
Pxx_plus = (FIVE/THIRTY_TWO)*W_inner.U().I1x() + (ONE/TWO)*W_inner.U().I2xx() + (THIRTY_FIVE/NINETY_SIX)*W_inner.U().I3xxx();
Qxxx_plus = -(ONE/THIRTY_TWO)*W_inner.I0() + (FIFTEEN/THIRTY_TWO)*W_inner.U().I2xx()+ (ONE/TWO)*W_inner.U().I3xxx();
m_values[0] = FIFTEEN*(Pxx_plus + Pxx_minus) - SIXTEEN*(Qxxx_plus - Qxxx_minus);
m_values[1] = (Fx_plus + Fx_minus)/I0();
m_values[2] = (Pxx_plus + Pxx_minus)/I0();
m_values[3] = (Qxxx_plus + Qxxx_minus)/I0();
Rotate(norm_dir);
}