-
Notifications
You must be signed in to change notification settings - Fork 842
/
CTurbSSTSolver.cpp
1043 lines (722 loc) · 38.8 KB
/
CTurbSSTSolver.cpp
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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* \file CTurbSSTSolver.cpp
* \brief Main subrotuines of CTurbSSTSolver class
* \author F. Palacios, A. Bueno
* \version 7.1.1 "Blackbird"
*
* SU2 Project Website: https://su2code.github.io
*
* The SU2 Project is maintained by the SU2 Foundation
* (http://su2foundation.org)
*
* Copyright 2012-2021, SU2 Contributors (cf. AUTHORS.md)
*
* SU2 is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* SU2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../../include/solvers/CTurbSSTSolver.hpp"
#include "../../include/variables/CTurbSSTVariable.hpp"
#include "../../../Common/include/parallelization/omp_structure.hpp"
#include "../../../Common/include/toolboxes/geometry_toolbox.hpp"
CTurbSSTSolver::CTurbSSTSolver(void) : CTurbSolver() { }
CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh)
: CTurbSolver(geometry, config) {
unsigned short nLineLets;
unsigned long iPoint;
ifstream restart_file;
string text_line;
bool multizone = config->GetMultizone_Problem();
/*--- Array initialization ---*/
Gamma = config->GetGamma();
Gamma_Minus_One = Gamma - 1.0;
/*--- Dimension of the problem --> dependent on the turbulence model. ---*/
nVar = 2;
nPrimVar = 2;
nPoint = geometry->GetnPoint();
nPointDomain = geometry->GetnPointDomain();
/*--- Initialize nVarGrad for deallocation ---*/
nVarGrad = nVar;
/*--- Define geometry constants in the solver structure ---*/
nDim = geometry->GetnDim();
/*--- Single grid simulation ---*/
if (iMesh == MESH_0) {
/*--- Define some auxiliary vector related with the residual ---*/
Residual_RMS.resize(nVar,0.0);
Residual_Max.resize(nVar,0.0);
Point_Max.resize(nVar,0);
Point_Max_Coord.resize(nVar,nDim) = su2double(0.0);
/*--- Initialization of the structure of the whole Jacobian ---*/
if (rank == MASTER_NODE) cout << "Initialize Jacobian structure (SST model)." << endl;
Jacobian.Initialize(nPoint, nPointDomain, nVar, nVar, true, geometry, config, ReducerStrategy);
if (config->GetKind_Linear_Solver_Prec() == LINELET) {
nLineLets = Jacobian.BuildLineletPreconditioner(geometry, config);
if (rank == MASTER_NODE) cout << "Compute linelet structure. " << nLineLets << " elements in each line (average)." << endl;
}
LinSysSol.Initialize(nPoint, nPointDomain, nVar, 0.0);
LinSysRes.Initialize(nPoint, nPointDomain, nVar, 0.0);
System.SetxIsZero(true);
if (ReducerStrategy)
EdgeFluxes.Initialize(geometry->GetnEdge(), geometry->GetnEdge(), nVar, nullptr);
/*--- Initialize the BGS residuals in multizone problems. ---*/
if (multizone){
Residual_BGS.resize(nVar,0.0);
Residual_Max_BGS.resize(nVar,0.0);
Point_Max_BGS.resize(nVar,0);
Point_Max_Coord_BGS.resize(nVar,nDim) = su2double(0.0);
}
}
/*--- Initialize value for model constants ---*/
constants[0] = 0.85; //sigma_k1
constants[1] = 1.0; //sigma_k2
constants[2] = 0.5; //sigma_om1
constants[3] = 0.856; //sigma_om2
constants[4] = 0.075; //beta_1
constants[5] = 0.0828; //beta_2
constants[6] = 0.09; //betaStar
constants[7] = 0.31; //a1
constants[8] = constants[4]/constants[6] - constants[2]*0.41*0.41/sqrt(constants[6]); //alfa_1
constants[9] = constants[5]/constants[6] - constants[3]*0.41*0.41/sqrt(constants[6]); //alfa_2
/*--- Initialize lower and upper limits---*/
lowerlimit[0] = 1.0e-10;
upperlimit[0] = 1.0e10;
lowerlimit[1] = 1.0e-4;
upperlimit[1] = 1.0e15;
/*--- Far-field flow state quantities and initialization. ---*/
su2double rhoInf, *VelInf, muLamInf, Intensity, viscRatio, muT_Inf;
rhoInf = config->GetDensity_FreeStreamND();
VelInf = config->GetVelocity_FreeStreamND();
muLamInf = config->GetViscosity_FreeStreamND();
Intensity = config->GetTurbulenceIntensity_FreeStream();
viscRatio = config->GetTurb2LamViscRatio_FreeStream();
su2double VelMag2 = GeometryToolbox::SquaredNorm(nDim, VelInf);
su2double kine_Inf = 3.0/2.0*(VelMag2*Intensity*Intensity);
su2double omega_Inf = rhoInf*kine_Inf/(muLamInf*viscRatio);
Solution_Inf[0] = kine_Inf;
Solution_Inf[1] = omega_Inf;
/*--- Eddy viscosity, initialized without stress limiter at the infinity ---*/
muT_Inf = rhoInf*kine_Inf/omega_Inf;
/*--- Initialize the solution to the far-field state everywhere. ---*/
nodes = new CTurbSSTVariable(kine_Inf, omega_Inf, muT_Inf, nPoint, nDim, nVar, constants, config);
SetBaseClassPointerToNodes();
/*--- MPI solution ---*/
InitiateComms(geometry, config, SOLUTION_EDDY);
CompleteComms(geometry, config, SOLUTION_EDDY);
/*--- Initializate quantities for SlidingMesh Interface ---*/
SlidingState.resize(nMarker);
SlidingStateNodes.resize(nMarker);
for (unsigned long iMarker = 0; iMarker < nMarker; iMarker++) {
if (config->GetMarker_All_KindBC(iMarker) == FLUID_INTERFACE) {
SlidingState[iMarker].resize(nVertex[iMarker], nPrimVar+1) = nullptr;
SlidingStateNodes[iMarker].resize(nVertex[iMarker],0);
}
}
/*-- Allocation of inlets has to happen in derived classes (not CTurbSolver),
due to arbitrary number of turbulence variables ---*/
Inlet_TurbVars.resize(nMarker);
for (unsigned long iMarker = 0; iMarker < nMarker; iMarker++) {
Inlet_TurbVars[iMarker].resize(nVertex[iMarker],nVar);
for (unsigned long iVertex = 0; iVertex < nVertex[iMarker]; ++iVertex) {
Inlet_TurbVars[iMarker](iVertex,0) = kine_Inf;
Inlet_TurbVars[iMarker](iVertex,1) = omega_Inf;
}
}
/*--- The turbulence models are always solved implicitly, so set the
implicit flag in case we have periodic BCs. ---*/
SetImplicitPeriodic(true);
/*--- Store the initial CFL number for all grid points. ---*/
const su2double CFL = config->GetCFL(MGLevel)*config->GetCFLRedCoeff_Turb();
for (iPoint = 0; iPoint < nPoint; iPoint++) {
nodes->SetLocalCFL(iPoint, CFL);
}
Min_CFL_Local = CFL;
Max_CFL_Local = CFL;
Avg_CFL_Local = CFL;
/*--- Add the solver name (max 8 characters) ---*/
SolverName = "K-W SST";
}
void CTurbSSTSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config,
unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) {
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
const bool muscl = config->GetMUSCL_Turb();
const bool limiter = (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) &&
(config->GetInnerIter() <= config->GetLimiterIter());
/*--- Clear residual and system matrix, not needed for
* reducer strategy as we write over the entire matrix. ---*/
if (!ReducerStrategy) {
LinSysRes.SetValZero();
if (implicit) Jacobian.SetValZero();
else {SU2_OMP_BARRIER}
}
/*--- Upwind second order reconstruction and gradients ---*/
if (config->GetReconstructionGradientRequired()) {
if (config->GetKind_Gradient_Method_Recon() == GREEN_GAUSS)
SetSolution_Gradient_GG(geometry, config, true);
if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES)
SetSolution_Gradient_LS(geometry, config, true);
if (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES)
SetSolution_Gradient_LS(geometry, config, true);
}
if (config->GetKind_Gradient_Method() == GREEN_GAUSS)
SetSolution_Gradient_GG(geometry, config);
if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES)
SetSolution_Gradient_LS(geometry, config);
if (limiter && muscl) SetSolution_Limiter(geometry, config);
}
void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_container,
CConfig *config, unsigned short iMesh) {
const su2double a1 = constants[7];
/*--- Compute turbulence gradients. ---*/
if (config->GetKind_Gradient_Method() == GREEN_GAUSS) {
SetSolution_Gradient_GG(geometry, config);
}
if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) {
SetSolution_Gradient_LS(geometry, config);
}
SU2_OMP_FOR_STAT(omp_chunk_size)
for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) {
/*--- Compute blending functions and cross diffusion ---*/
su2double rho = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint);
su2double mu = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint);
su2double dist = geometry->nodes->GetWall_Distance(iPoint);
const su2double *Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint);
su2double VorticityMag = sqrt(Vorticity[0]*Vorticity[0] +
Vorticity[1]*Vorticity[1] +
Vorticity[2]*Vorticity[2]);
nodes->SetBlendingFunc(iPoint, mu, dist, rho);
su2double F2 = nodes->GetF2blending(iPoint);
/*--- Compute the eddy viscosity ---*/
su2double kine = nodes->GetSolution(iPoint,0);
su2double omega = nodes->GetSolution(iPoint,1);
su2double zeta = min(1.0/omega, a1/(VorticityMag*F2));
su2double muT = max(rho*kine*zeta,0.0);
nodes->SetmuT(iPoint,muT);
}
END_SU2_OMP_FOR
}
void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container,
CNumerics **numerics_container, CConfig *config, unsigned short iMesh) {
bool axisymmetric = config->GetAxisymmetric();
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes();
/*--- Pick one numerics object per thread. ---*/
CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS];
/*--- Loop over all points. ---*/
SU2_OMP_FOR_DYN(omp_chunk_size)
for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) {
/*--- Conservative variables w/o reconstruction ---*/
numerics->SetPrimitive(flowNodes->GetPrimitive(iPoint), nullptr);
/*--- Gradient of the primitive and conservative variables ---*/
numerics->SetPrimVarGradient(flowNodes->GetGradient_Primitive(iPoint), nullptr);
/*--- Turbulent variables w/o reconstruction, and its gradient ---*/
numerics->SetTurbVar(nodes->GetSolution(iPoint), nullptr);
numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nullptr);
/*--- Set volume ---*/
numerics->SetVolume(geometry->nodes->GetVolume(iPoint));
/*--- Set distance to the surface ---*/
numerics->SetDistance(geometry->nodes->GetWall_Distance(iPoint), 0.0);
/*--- Menter's first blending function ---*/
numerics->SetF1blending(nodes->GetF1blending(iPoint),0.0);
/*--- Menter's second blending function ---*/
numerics->SetF2blending(nodes->GetF2blending(iPoint),0.0);
/*--- Set vorticity and strain rate magnitude ---*/
numerics->SetVorticity(flowNodes->GetVorticity(iPoint), nullptr);
numerics->SetStrainMag(flowNodes->GetStrainMag(iPoint), 0.0);
/*--- Cross diffusion ---*/
numerics->SetCrossDiff(nodes->GetCrossDiff(iPoint),0.0);
if (axisymmetric){
/*--- Set y coordinate ---*/
numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(iPoint));
}
/*--- Compute the source term ---*/
auto residual = numerics->ComputeResidual(config);
/*--- Subtract residual and the Jacobian ---*/
LinSysRes.SubtractBlock(iPoint, residual);
if (implicit) Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i);
}
END_SU2_OMP_FOR
}
void CTurbSSTSolver::Source_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics,
CConfig *config, unsigned short iMesh) {
}
void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics,
CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) {
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
bool rough_wall = false;
string Marker_Tag = config->GetMarker_All_TagBound(val_marker);
WALL_TYPE WallType; su2double Roughness_Height;
tie(WallType, Roughness_Height) = config->GetWallRoughnessProperties(Marker_Tag);
if (WallType == WALL_TYPE::ROUGH) rough_wall = true;
/*--- Evaluate nu tilde at the closest point to the surface using the wall functions. ---*/
if (config->GetWall_Functions()) {
SU2_OMP_MASTER
SetTurbVars_WF(geometry, solver_container, config, val_marker);
END_SU2_OMP_MASTER
SU2_OMP_BARRIER
return;
}
SU2_OMP_FOR_STAT(OMP_MIN_SIZE)
for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) {
const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode();
/*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/
if (geometry->nodes->GetDomain(iPoint)) {
if (rough_wall) {
/*--- Set wall values ---*/
su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint);
su2double laminar_viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint);
su2double WallShearStress = solver_container[FLOW_SOL]->GetWallShearStress(val_marker, iVertex);
/*--- Compute non-dimensional velocity ---*/
su2double FrictionVel = sqrt(fabs(WallShearStress)/density);
/*--- Compute roughness in wall units. ---*/
//su2double Roughness_Height = config->GetWall_RoughnessHeight(Marker_Tag);
su2double kPlus = FrictionVel*Roughness_Height*density/laminar_viscosity;
su2double S_R= 0.0;
/*--- Reference 1 original Wilcox (1998) ---*/
/*if (kPlus <= 25)
S_R = (50/(kPlus+EPS))*(50/(kPlus+EPS));
else
S_R = 100/(kPlus+EPS);*/
/*--- Reference 2 from D.C. Wilcox Turbulence Modeling for CFD (2006) ---*/
if (kPlus <= 5)
S_R = (200/(kPlus+EPS))*(200/(kPlus+EPS));
else
S_R = 100/(kPlus+EPS) + ((200/(kPlus+EPS))*(200/(kPlus+EPS)) - 100/(kPlus+EPS))*exp(5-kPlus);
/*--- Modify the omega to account for a rough wall. ---*/
su2double solution[2];
solution[0] = 0.0;
solution[1] = FrictionVel*FrictionVel*S_R/(laminar_viscosity/density);
/*--- Set the solution values and zero the residual ---*/
nodes->SetSolution_Old(iPoint,solution);
nodes->SetSolution(iPoint,solution);
LinSysRes.SetBlock_Zero(iPoint);
} else { // smooth wall
/*--- distance to closest neighbor ---*/
const auto jPoint = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor();
su2double distance2 = GeometryToolbox::SquaredDistance(nDim,
geometry->nodes->GetCoord(iPoint),
geometry->nodes->GetCoord(jPoint));
/*--- Set wall values ---*/
su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(jPoint);
su2double laminar_viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(jPoint);
su2double beta_1 = constants[4];
su2double solution[MAXNVAR];
solution[0] = 0.0;
solution[1] = 60.0*laminar_viscosity/(density*beta_1*distance2);
/*--- Set the solution values and zero the residual ---*/
nodes->SetSolution_Old(iPoint,solution);
nodes->SetSolution(iPoint,solution);
LinSysRes.SetBlock_Zero(iPoint);
}
if (implicit) {
/*--- Change rows of the Jacobian (includes 1 in the diagonal) ---*/
Jacobian.DeleteValsRowi(iPoint*nVar);
Jacobian.DeleteValsRowi(iPoint*nVar+1);
}
}
}
END_SU2_OMP_FOR
}
void CTurbSSTSolver::SetTurbVars_WF(CGeometry *geometry, CSolver **solver_container,
const CConfig *config, unsigned short val_marker) {
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
/*--- von Karman constant from boundary layer theory ---*/
const su2double kappa = config->GetwallModelKappa();
/*--- relaxation factor for k-omega values ---*/
const su2double relax = 0.5;
/*--- Loop over all of the vertices on this boundary marker ---*/
for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) {
const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode();
const auto iPoint_Neighbor = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor();
su2double Y_Plus = solver_container[FLOW_SOL]->GetYPlus(val_marker, iVertex);
su2double Lam_Visc_Wall = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint);
/*--- Do not use wall model at the ipoint when y+ < 5.0, use zero flux (Neumann) conditions. ---*/
if (Y_Plus < 5.0) continue;
su2double Eddy_Visc = solver_container[FLOW_SOL]->GetEddyViscWall(val_marker, iVertex);
su2double k = nodes->GetSolution(iPoint_Neighbor,0);
su2double omega = nodes->GetSolution(iPoint_Neighbor,1);
su2double Density_Wall = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint);
su2double U_Tau = solver_container[FLOW_SOL]->GetUTau(val_marker, iVertex);
su2double y = Y_Plus*Lam_Visc_Wall/(Density_Wall*U_Tau);
su2double omega1 = 6.0*Lam_Visc_Wall/(0.075*Density_Wall*y*y); // eq. 19
su2double omega0 = U_Tau/(sqrt(0.09)*kappa*y); // eq. 20
su2double omega_new = sqrt(omega0*omega0 + omega1*omega1); // eq. 21 Nichols & Nelson
su2double k_new = omega_new * Eddy_Visc/Density_Wall; // eq. 22 Nichols & Nelson
// (is this the correct density? paper says rho and not rho_w)
/*--- put some relaxation factor on the k-omega values ---*/
k += relax*(k_new - k);
omega += relax*(omega_new - omega);
su2double solution[MAXNVAR] = {k, omega};
nodes->SetSolution_Old(iPoint_Neighbor,solution);
nodes->SetSolution(iPoint,solution);
LinSysRes.SetBlock_Zero(iPoint_Neighbor);
if (implicit) {
/*--- includes 1 in the diagonal ---*/
Jacobian.DeleteValsRowi(iPoint_Neighbor*nVar);
Jacobian.DeleteValsRowi(iPoint_Neighbor*nVar+1);
}
}
}
void CTurbSSTSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics,
CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) {
BC_HeatFlux_Wall(geometry, solver_container, conv_numerics, visc_numerics, config, val_marker);
}
void CTurbSSTSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics,
CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) {
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
SU2_OMP_FOR_STAT(OMP_MIN_SIZE)
for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) {
const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode();
/*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/
if (geometry->nodes->GetDomain(iPoint)) {
/*--- Allocate the value at the infinity ---*/
auto V_infty = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex);
/*--- Retrieve solution at the farfield boundary node ---*/
auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint);
conv_numerics->SetPrimitive(V_domain, V_infty);
/*--- Set turbulent variable at the wall, and at infinity ---*/
conv_numerics->SetTurbVar(nodes->GetSolution(iPoint), Solution_Inf);
/*--- Set Normal (it is necessary to change the sign) ---*/
su2double Normal[MAXNDIM] = {0.0};
for (auto iDim = 0u; iDim < nDim; iDim++)
Normal[iDim] = -geometry->vertex[val_marker][iVertex]->GetNormal(iDim);
conv_numerics->SetNormal(Normal);
/*--- Grid Movement ---*/
if (dynamic_grid)
conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint),
geometry->nodes->GetGridVel(iPoint));
/*--- Compute residuals and Jacobians ---*/
auto residual = conv_numerics->ComputeResidual(config);
/*--- Add residuals and Jacobians ---*/
LinSysRes.AddBlock(iPoint, residual);
if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i);
}
}
END_SU2_OMP_FOR
}
void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics,
CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) {
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
/*--- Loop over all the vertices on this boundary marker ---*/
SU2_OMP_FOR_STAT(OMP_MIN_SIZE)
for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) {
const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode();
/*--- Check if the node belongs to the domain (i.e., not a halo node) ---*/
if (geometry->nodes->GetDomain(iPoint)) {
/*--- Normal vector for this vertex (negate for outward convention) ---*/
su2double Normal[MAXNDIM] = {0.0};
for (auto iDim = 0u; iDim < nDim; iDim++)
Normal[iDim] = -geometry->vertex[val_marker][iVertex]->GetNormal(iDim);
conv_numerics->SetNormal(Normal);
/*--- Allocate the value at the inlet ---*/
auto V_inlet = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex);
/*--- Retrieve solution at the farfield boundary node ---*/
auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint);
/*--- Set various quantities in the solver class ---*/
conv_numerics->SetPrimitive(V_domain, V_inlet);
/*--- Set the turbulent variable states. Use free-stream SST
values for the turbulent state at the inflow. ---*/
/*--- Load the inlet turbulence variables (uniform by default). ---*/
conv_numerics->SetTurbVar(nodes->GetSolution(iPoint),
Inlet_TurbVars[val_marker][iVertex]);
/*--- Set various other quantities in the solver class ---*/
if (dynamic_grid)
conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint),
geometry->nodes->GetGridVel(iPoint));
/*--- Compute the residual using an upwind scheme ---*/
auto residual = conv_numerics->ComputeResidual(config);
LinSysRes.AddBlock(iPoint, residual);
/*--- Jacobian contribution for implicit integration ---*/
if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i);
// /*--- Viscous contribution, commented out because serious convergence problems ---*/
//
// su2double Coord_Reflected[MAXNDIM];
// GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
// geometry->nodes->GetCoord(iPoint), Coord_Reflected);
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
// visc_numerics->SetNormal(Normal);
//
// /*--- Conservative variables w/o reconstruction ---*/
//
// visc_numerics->SetPrimitive(V_domain, V_inlet);
//
// /*--- Turbulent variables w/o reconstruction, and its gradients ---*/
//
// visc_numerics->SetTurbVar(Solution_i, Solution_j);
// visc_numerics->SetTurbVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient());
//
// /*--- Menter's first blending function ---*/
//
// visc_numerics->SetF1blending(node[iPoint]->GetF1blending(), node[iPoint]->GetF1blending());
//
// /*--- Compute residual, and Jacobians ---*/
//
// auto residual = visc_numerics->ComputeResidual(config);
//
// /*--- Subtract residual, and update Jacobians ---*/
//
// LinSysRes.SubtractBlock(iPoint, residual);
// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i);
}
}
END_SU2_OMP_FOR
}
void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics,
CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) {
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
/*--- Loop over all the vertices on this boundary marker ---*/
SU2_OMP_FOR_STAT(OMP_MIN_SIZE)
for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) {
const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode();
/*--- Check if the node belongs to the domain (i.e., not a halo node) ---*/
if (geometry->nodes->GetDomain(iPoint)) {
/*--- Allocate the value at the outlet ---*/
auto V_outlet = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex);
/*--- Retrieve solution at the farfield boundary node ---*/
auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint);
/*--- Set various quantities in the solver class ---*/
conv_numerics->SetPrimitive(V_domain, V_outlet);
/*--- Set the turbulent variables. Here we use a Neumann BC such
that the turbulent variable is copied from the interior of the
domain to the outlet before computing the residual. ---*/
conv_numerics->SetTurbVar(nodes->GetSolution(iPoint),
nodes->GetSolution(iPoint));
/*--- Set Normal (negate for outward convention) ---*/
su2double Normal[MAXNDIM] = {0.0};
for (auto iDim = 0u; iDim < nDim; iDim++)
Normal[iDim] = -geometry->vertex[val_marker][iVertex]->GetNormal(iDim);
conv_numerics->SetNormal(Normal);
if (dynamic_grid)
conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint),
geometry->nodes->GetGridVel(iPoint));
/*--- Compute the residual using an upwind scheme ---*/
auto residual = conv_numerics->ComputeResidual(config);
LinSysRes.AddBlock(iPoint, residual);
/*--- Jacobian contribution for implicit integration ---*/
if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i);
// /*--- Viscous contribution, commented out because serious convergence problems ---*/
//
// su2double Coord_Reflected[MAXNDIM];
// GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
// geometry->nodes->GetCoord(iPoint), Coord_Reflected);
// visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
// visc_numerics->SetNormal(Normal);
//
// /*--- Conservative variables w/o reconstruction ---*/
//
// visc_numerics->SetPrimitive(V_domain, V_outlet);
//
// /*--- Turbulent variables w/o reconstruction, and its gradients ---*/
//
// visc_numerics->SetTurbVar(Solution_i, Solution_j);
// visc_numerics->SetTurbVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient());
//
// /*--- Menter's first blending function ---*/
//
// visc_numerics->SetF1blending(node[iPoint]->GetF1blending(), node[iPoint]->GetF1blending());
//
// /*--- Compute residual, and Jacobians ---*/
//
// auto residual = visc_numerics->ComputeResidual(config);
//
// /*--- Subtract residual, and update Jacobians ---*/
//
// LinSysRes.SubtractBlock(iPoint, residual);
// Jacobian.SubtractBlock2Diag(iPoint, residual.jacobian_i);
}
}
END_SU2_OMP_FOR
}
void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics,
CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) {
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
const auto nSpanWiseSections = config->GetnSpanWiseSections();
/*--- Loop over all the vertices on this boundary marker ---*/
for (auto iSpan = 0u; iSpan < nSpanWiseSections ; iSpan++){
su2double extAverageKine = solver_container[FLOW_SOL]->GetExtAverageKine(val_marker, iSpan);
su2double extAverageOmega = solver_container[FLOW_SOL]->GetExtAverageOmega(val_marker, iSpan);
su2double solution_j[] = {extAverageKine, extAverageOmega};
/*--- Loop over all the vertices on this boundary marker ---*/
SU2_OMP_FOR_STAT(OMP_MIN_SIZE)
for (auto iVertex = 0u; iVertex < geometry->GetnVertexSpan(val_marker,iSpan); iVertex++) {
/*--- find the node related to the vertex ---*/
const auto iPoint = geometry->turbovertex[val_marker][iSpan][iVertex]->GetNode();
/*--- using the other vertex information for retrieving some information ---*/
const auto oldVertex = geometry->turbovertex[val_marker][iSpan][iVertex]->GetOldVertex();
/*--- Index of the closest interior node ---*/
const auto Point_Normal = geometry->vertex[val_marker][oldVertex]->GetNormal_Neighbor();
/*--- Normal vector for this vertex (negate for outward convention) ---*/
su2double Normal[MAXNDIM] = {0.0};
for (auto iDim = 0u; iDim < nDim; iDim++)
Normal[iDim] = -geometry->vertex[val_marker][oldVertex]->GetNormal(iDim);
conv_numerics->SetNormal(Normal);
/*--- Allocate the value at the inlet ---*/
auto V_inlet = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, oldVertex);
/*--- Retrieve solution at the farfield boundary node ---*/
auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint);
/*--- Set various quantities in the solver class ---*/
conv_numerics->SetPrimitive(V_domain, V_inlet);
/*--- Set the turbulent variable states (prescribed for an inflow) ---*/
conv_numerics->SetTurbVar(nodes->GetSolution(iPoint), solution_j);
if (dynamic_grid)
conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint),
geometry->nodes->GetGridVel(iPoint));
/*--- Compute the residual using an upwind scheme ---*/
auto conv_residual = conv_numerics->ComputeResidual(config);
/*--- Jacobian contribution for implicit integration ---*/
LinSysRes.AddBlock(iPoint, conv_residual);
if (implicit) Jacobian.AddBlock2Diag(iPoint, conv_residual.jacobian_i);
/*--- Viscous contribution ---*/
su2double Coord_Reflected[MAXNDIM];
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
visc_numerics->SetNormal(Normal);
/*--- Conservative variables w/o reconstruction ---*/
visc_numerics->SetPrimitive(V_domain, V_inlet);
/*--- Turbulent variables w/o reconstruction, and its gradients ---*/
visc_numerics->SetTurbVar(nodes->GetSolution(iPoint), solution_j);
visc_numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint));
/*--- Menter's first blending function ---*/
visc_numerics->SetF1blending(nodes->GetF1blending(iPoint), nodes->GetF1blending(iPoint));
/*--- Compute residual, and Jacobians ---*/
auto visc_residual = visc_numerics->ComputeResidual(config);
/*--- Subtract residual, and update Jacobians ---*/
LinSysRes.SubtractBlock(iPoint, visc_residual);
if (implicit) Jacobian.SubtractBlock2Diag(iPoint, visc_residual.jacobian_i);
}
END_SU2_OMP_FOR
}
}
void CTurbSSTSolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics,
CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) {
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
const auto nSpanWiseSections = config->GetnSpanWiseSections();
/*--- Quantities for computing the kine and omega to impose at the inlet boundary. ---*/
CFluidModel *FluidModel = solver_container[FLOW_SOL]->GetFluidModel();
su2double Intensity = config->GetTurbulenceIntensity_FreeStream();
su2double viscRatio = config->GetTurb2LamViscRatio_FreeStream();
for (auto iSpan = 0u; iSpan < nSpanWiseSections ; iSpan++){
/*--- Compute the inflow kine and omega using the span wise averge quntities---*/
su2double rho = solver_container[FLOW_SOL]->GetAverageDensity(val_marker, iSpan);
su2double pressure = solver_container[FLOW_SOL]->GetAveragePressure(val_marker, iSpan);
su2double kine = solver_container[FLOW_SOL]->GetAverageKine(val_marker, iSpan);
FluidModel->SetTDState_Prho(pressure, rho);
su2double muLam = FluidModel->GetLaminarViscosity();
su2double VelMag2 = GeometryToolbox::SquaredNorm(nDim,
solver_container[FLOW_SOL]->GetAverageTurboVelocity(val_marker, iSpan));
su2double kine_b = 3.0/2.0*(VelMag2*Intensity*Intensity);
su2double omega_b = rho*kine/(muLam*viscRatio);
su2double solution_j[] = {kine_b, omega_b};
/*--- Loop over all the vertices on this boundary marker ---*/
SU2_OMP_FOR_STAT(OMP_MIN_SIZE)
for (auto iVertex = 0u; iVertex < geometry->GetnVertexSpan(val_marker,iSpan); iVertex++) {
/*--- find the node related to the vertex ---*/
const auto iPoint = geometry->turbovertex[val_marker][iSpan][iVertex]->GetNode();
/*--- using the other vertex information for retrieving some information ---*/
const auto oldVertex = geometry->turbovertex[val_marker][iSpan][iVertex]->GetOldVertex();
/*--- Index of the closest interior node ---*/
const auto Point_Normal = geometry->vertex[val_marker][oldVertex]->GetNormal_Neighbor();
/*--- Normal vector for this vertex (negate for outward convention) ---*/
su2double Normal[MAXNDIM] = {0.0};
for (auto iDim = 0u; iDim < nDim; iDim++)
Normal[iDim] = -geometry->vertex[val_marker][oldVertex]->GetNormal(iDim);
conv_numerics->SetNormal(Normal);
/*--- Allocate the value at the inlet ---*/
auto V_inlet = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, oldVertex);
/*--- Retrieve solution at the farfield boundary node ---*/
auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint);
/*--- Set various quantities in the solver class ---*/
conv_numerics->SetPrimitive(V_domain, V_inlet);
/*--- Set the turbulent variable states. Use average span-wise values
values for the turbulent state at the inflow. ---*/
conv_numerics->SetTurbVar(nodes->GetSolution(iPoint), solution_j);
if (dynamic_grid)
conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint),
geometry->nodes->GetGridVel(iPoint));
/*--- Compute the residual using an upwind scheme ---*/
auto conv_residual = conv_numerics->ComputeResidual(config);
/*--- Jacobian contribution for implicit integration ---*/
LinSysRes.AddBlock(iPoint, conv_residual);
if (implicit) Jacobian.AddBlock2Diag(iPoint, conv_residual.jacobian_i);
/*--- Viscous contribution ---*/
su2double Coord_Reflected[MAXNDIM];
GeometryToolbox::PointPointReflect(nDim, geometry->nodes->GetCoord(Point_Normal),
geometry->nodes->GetCoord(iPoint), Coord_Reflected);
visc_numerics->SetCoord(geometry->nodes->GetCoord(iPoint), Coord_Reflected);
visc_numerics->SetNormal(Normal);
/*--- Conservative variables w/o reconstruction ---*/
visc_numerics->SetPrimitive(V_domain, V_inlet);
/*--- Turbulent variables w/o reconstruction, and its gradients ---*/
visc_numerics->SetTurbVar(nodes->GetSolution(iPoint), solution_j);
visc_numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint));
/*--- Menter's first blending function ---*/
visc_numerics->SetF1blending(nodes->GetF1blending(iPoint), nodes->GetF1blending(iPoint));
/*--- Compute residual, and Jacobians ---*/
auto visc_residual = visc_numerics->ComputeResidual(config);
/*--- Subtract residual, and update Jacobians ---*/
LinSysRes.SubtractBlock(iPoint, visc_residual);
if (implicit) Jacobian.SubtractBlock2Diag(iPoint, visc_residual.jacobian_i);
}
END_SU2_OMP_FOR
}
}
void CTurbSSTSolver::SetInletAtVertex(const su2double *val_inlet,
unsigned short iMarker,
unsigned long iVertex) {
Inlet_TurbVars[iMarker][iVertex][0] = val_inlet[nDim+2+nDim];
Inlet_TurbVars[iMarker][iVertex][1] = val_inlet[nDim+2+nDim+1];
}
su2double CTurbSSTSolver::GetInletAtVertex(su2double *val_inlet,
unsigned long val_inlet_point,
unsigned short val_kind_marker,
string val_marker,
const CGeometry *geometry,
const CConfig *config) const {
/*--- Local variables ---*/
unsigned short iMarker;
unsigned long iPoint, iVertex;
su2double Area = 0.0;
su2double Normal[3] = {0.0,0.0,0.0};
/*--- Alias positions within inlet file for readability ---*/
if (val_kind_marker == INLET_FLOW) {
unsigned short tke_position = nDim+2+nDim;
unsigned short omega_position = nDim+2+nDim+1;
for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
if ((config->GetMarker_All_KindBC(iMarker) == INLET_FLOW) &&
(config->GetMarker_All_TagBound(iMarker) == val_marker)) {