-
Notifications
You must be signed in to change notification settings - Fork 849
/
Copy pathCEulerSolver.cpp
9435 lines (7257 loc) · 385 KB
/
CEulerSolver.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 CEulerSolver.cpp
* \brief Main subroutines for solving Finite-Volume Euler flow problems.
* \author F. Palacios, T. Economon
* \version 7.5.1 "Blackbird"
*
* SU2 Project Website: https://su2code.github.io
*
* The SU2 Project is maintained by the SU2 Foundation
* (http://su2foundation.org)
*
* Copyright 2012-2023, 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/CEulerSolver.hpp"
#include "../../include/variables/CNSVariable.hpp"
#include "../../../Common/include/toolboxes/geometry_toolbox.hpp"
#include "../../../Common/include/toolboxes/printing_toolbox.hpp"
#include "../../include/fluid/CIdealGas.hpp"
#include "../../include/fluid/CVanDerWaalsGas.hpp"
#include "../../include/fluid/CPengRobinson.hpp"
#include "../../include/fluid/CCoolProp.hpp"
#include "../../include/numerics_simd/CNumericsSIMD.hpp"
#include "../../include/limiters/CLimiterDetails.hpp"
CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config,
unsigned short iMesh, const bool navier_stokes) :
CFVMFlowSolverBase<CEulerVariable, ENUM_REGIME::COMPRESSIBLE>(*geometry, *config) {
/*--- Based on the navier_stokes boolean, determine if this constructor is
* being called by itself, or by its derived class CNSSolver. ---*/
string description;
unsigned short nSecVar;
if (navier_stokes) {
description = "Navier-Stokes";
nSecVar = 8;
}
else {
description = "Euler";
nSecVar = 2;
}
const auto nZone = geometry->GetnZone();
const bool restart = (config->GetRestart() || config->GetRestart_Flow());
const bool rans = (config->GetKind_Turb_Model() != TURB_MODEL::NONE);
const auto direct_diff = config->GetDirectDiff();
const bool dual_time = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND);
const bool time_stepping = (config->GetTime_Marching() == TIME_MARCHING::TIME_STEPPING);
const bool adjoint = config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint();
int Unst_RestartIter = 0;
unsigned long iPoint, iMarker, counter_local = 0, counter_global = 0;
unsigned short iDim;
su2double StaticEnergy, Density, Velocity2, Pressure, Temperature;
/*--- A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain ---*/
dynamic_grid = config->GetDynamic_Grid();
/*--- Store the multigrid level. ---*/
MGLevel = iMesh;
/*--- Check for a restart file to evaluate if there is a change in the angle of attack
before computing all the non-dimesional quantities. ---*/
if (restart && (iMesh == MESH_0) && nZone <= 1 && config->GetFixed_CL_Mode()) {
/*--- Modify file name for a dual-time unsteady restart ---*/
if (dual_time) {
if (adjoint) Unst_RestartIter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1;
else if (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST)
Unst_RestartIter = SU2_TYPE::Int(config->GetRestart_Iter())-1;
else Unst_RestartIter = SU2_TYPE::Int(config->GetRestart_Iter())-2;
}
/*--- Modify file name for a time stepping unsteady restart ---*/
if (time_stepping) {
if (adjoint) Unst_RestartIter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1;
else Unst_RestartIter = SU2_TYPE::Int(config->GetRestart_Iter())-1;
}
/*--- Read and store the restart metadata. ---*/
string filename_ = "flow";
filename_ = config->GetFilename(filename_, ".meta", Unst_RestartIter);
Read_SU2_Restart_Metadata(geometry, config, adjoint, filename_);
}
/*--- Set the gamma value ---*/
Gamma = config->GetGamma();
Gamma_Minus_One = Gamma - 1.0;
/*--- Define geometry constants in the solver structure
Compressible flow, primitive variables (T, vx, vy, vz, P, rho, h, c, lamMu, EddyMu, ThCond, Cp).
---*/
nDim = geometry->GetnDim();
nVar = nDim+2;
nPrimVar = nDim+9; nPrimVarGrad = nDim+4;
nSecondaryVar = nSecVar; nSecondaryVarGrad = 2;
/*--- Initialize nVarGrad for deallocation ---*/
nVarGrad = nPrimVarGrad;
nMarker = config->GetnMarker_All();
nPoint = geometry->GetnPoint();
nPointDomain = geometry->GetnPointDomain();
/*--- Store the number of vertices on each marker for deallocation later ---*/
nVertex.resize(nMarker);
for (iMarker = 0; iMarker < nMarker; iMarker++)
nVertex[iMarker] = geometry->nVertex[iMarker];
/*--- Perform the non-dimensionalization for the flow equations using the
specified reference values. ---*/
SetNondimensionalization(config, iMesh);
/*--- Check if we are executing a verification case. If so, the
VerificationSolution object will be instantiated for a particular
option from the available library of verification solutions. Note
that this is done after SetNondim(), as problem-specific initial
parameters are needed by the solution constructors. ---*/
SetVerificationSolution(nDim, nVar, config);
/*--- Allocate base class members. ---*/
Allocate(*config);
/*--- MPI + OpenMP initialization. ---*/
HybridParallelInitialization(*config, *geometry);
/*--- Jacobians and vector structures for implicit computations ---*/
if (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT) {
if (rank == MASTER_NODE)
cout << "Initialize Jacobian structure (" << description << "). MG level: " << iMesh <<"." << endl;
Jacobian.Initialize(nPoint, nPointDomain, nVar, nVar, true, geometry, config, ReducerStrategy);
}
else {
if (rank == MASTER_NODE)
cout << "Explicit scheme. No Jacobian structure (" << description << "). MG level: " << iMesh <<"." << endl;
}
/*--- Store the value of the primitive variables + 2 turb variables at the boundaries,
used for IO with a donor cell ---*/
AllocVectorOfMatrices(nVertex, (rans? nPrimVar+2 : nPrimVar), DonorPrimVar);
/*--- Store the value of the characteristic primitive variables index at the boundaries ---*/
DonorGlobalIndex.resize(nMarker);
for (iMarker = 0; iMarker < nMarker; iMarker++)
DonorGlobalIndex[iMarker].resize(nVertex[iMarker],0);
/*--- Actuator Disk Radius allocation ---*/
ActDisk_R.resize(nMarker);
/*--- Actuator Disk Center allocation ---*/
ActDisk_C.resize(nMarker, MAXNDIM);
/*--- Actuator Disk Axis allocation ---*/
ActDisk_Axis.resize(nMarker, MAXNDIM);
/*--- Actuator Disk Fa, Fx, Fy and Fz allocations ---*/
AllocVectorOfVectors(nVertex, ActDisk_Fa);
AllocVectorOfVectors(nVertex, ActDisk_Fx);
AllocVectorOfVectors(nVertex, ActDisk_Fy);
AllocVectorOfVectors(nVertex, ActDisk_Fz);
/*--- Store the value of the Delta P at the Actuator Disk ---*/
AllocVectorOfVectors(nVertex, ActDisk_DeltaP);
/*--- Store the value of the Delta T at the Actuator Disk ---*/
AllocVectorOfVectors(nVertex, ActDisk_DeltaT);
/*--- Supersonic coefficients ---*/
CEquivArea_Inv.resize(nMarker);
/*--- Engine simulation ---*/
Inflow_MassFlow.resize(nMarker);
Inflow_Pressure.resize(nMarker);
Inflow_Mach.resize(nMarker);
Inflow_Area.resize(nMarker);
Exhaust_Temperature.resize(nMarker);
Exhaust_MassFlow.resize(nMarker);
Exhaust_Pressure.resize(nMarker);
Exhaust_Area.resize(nMarker);
/*--- Read farfield conditions from config ---*/
Temperature_Inf = config->GetTemperature_FreeStreamND();
Velocity_Inf = config->GetVelocity_FreeStreamND();
Pressure_Inf = config->GetPressure_FreeStreamND();
Density_Inf = config->GetDensity_FreeStreamND();
Energy_Inf = config->GetEnergy_FreeStreamND();
Mach_Inf = config->GetMach();
/*--- Initialize the secondary values for direct derivative approxiations ---*/
switch(direct_diff) {
case NO_DERIVATIVE:
/*--- Default ---*/
break;
case D_DENSITY:
SU2_TYPE::SetDerivative(Density_Inf, 1.0);
break;
case D_PRESSURE:
SU2_TYPE::SetDerivative(Pressure_Inf, 1.0);
break;
case D_TEMPERATURE:
SU2_TYPE::SetDerivative(Temperature_Inf, 1.0);
break;
case D_MACH: case D_AOA:
case D_SIDESLIP: case D_REYNOLDS:
case D_TURB2LAM: case D_DESIGN:
/*--- Already done in postprocessing of config ---*/
break;
default:
break;
}
SetReferenceValues(*config);
/*--- Initialize fan face pressure, fan face mach number, and mass flow rate ---*/
for (iMarker = 0; iMarker < nMarker; iMarker++) {
Inflow_MassFlow[iMarker] = 0.0;
Inflow_Mach[iMarker] = Mach_Inf;
Inflow_Pressure[iMarker] = Pressure_Inf;
Inflow_Area[iMarker] = 0.0;
Exhaust_MassFlow[iMarker] = 0.0;
Exhaust_Temperature[iMarker] = Temperature_Inf;
Exhaust_Pressure[iMarker] = Pressure_Inf;
Exhaust_Area[iMarker] = 0.0;
}
/*--- Initialize the solution to the far-field state everywhere. ---*/
if (navier_stokes) {
nodes = new CNSVariable(Density_Inf, Velocity_Inf, Energy_Inf, nPoint, nDim, nVar, config);
} else {
nodes = new CEulerVariable(Density_Inf, Velocity_Inf, Energy_Inf, nPoint, nDim, nVar, config);
}
SetBaseClassPointerToNodes();
if (iMesh == MESH_0) {
nodes->NonPhysicalEdgeCounter.resize(geometry->GetnEdge()) = 0;
}
/*--- Check that the initial solution is physical, report any non-physical nodes ---*/
counter_local = 0;
for (iPoint = 0; iPoint < nPoint; iPoint++) {
Density = nodes->GetDensity(iPoint);
Velocity2 = 0.0;
for (iDim = 0; iDim < nDim; iDim++)
Velocity2 += pow(nodes->GetSolution(iPoint,iDim+1)/Density,2);
StaticEnergy= nodes->GetEnergy(iPoint) - 0.5*Velocity2;
GetFluidModel()->SetTDState_rhoe(Density, StaticEnergy);
Pressure= GetFluidModel()->GetPressure();
Temperature= GetFluidModel()->GetTemperature();
/*--- Use the values at the infinity ---*/
su2double Solution[MAXNVAR] = {0.0};
if ((Pressure < 0.0) || (Density < 0.0) || (Temperature < 0.0)) {
Solution[0] = Density_Inf;
for (iDim = 0; iDim < nDim; iDim++)
Solution[iDim+1] = Velocity_Inf[iDim]*Density_Inf;
Solution[nDim+1] = Energy_Inf*Density_Inf;
nodes->SetSolution(iPoint,Solution);
nodes->SetSolution_Old(iPoint,Solution);
counter_local++;
}
}
/*--- Warning message about non-physical points ---*/
if (config->GetComm_Level() == COMM_FULL) {
SU2_MPI::Reduce(&counter_local, &counter_global, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, SU2_MPI::GetComm());
if ((rank == MASTER_NODE) && (counter_global != 0))
cout << "Warning. The original solution contains " << counter_global << " points that are not physical." << endl;
}
/*--- Initial comms. ---*/
CommunicateInitialState(geometry, config);
/*--- Add the solver name.. ---*/
SolverName = "C.FLOW";
/*--- Finally, check that the static arrays will be large enough (keep this
* check at the bottom to make sure we consider the "final" values). ---*/
if((nDim > MAXNDIM) || (nPrimVar > MAXNVAR) || (nSecondaryVar > MAXNVAR))
SU2_MPI::Error("Oops! The CEulerSolver static array sizes are not large enough.",CURRENT_FUNCTION);
}
CEulerSolver::~CEulerSolver() {
for(auto& model : FluidModel) delete model;
}
void CEulerSolver::InstantiateEdgeNumerics(const CSolver* const* solver_container, const CConfig* config) {
BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS
{
if (config->Low_Mach_Correction())
SU2_MPI::Error("Low-Mach correction is not supported with vectorization.", CURRENT_FUNCTION);
if (solver_container[TURB_SOL])
edgeNumerics = CNumericsSIMD::CreateNumerics(*config, nDim, MGLevel, solver_container[TURB_SOL]->GetNodes());
else
edgeNumerics = CNumericsSIMD::CreateNumerics(*config, nDim, MGLevel);
if (!edgeNumerics)
SU2_MPI::Error("The numerical scheme + gas model in use do not "
"support vectorization.", CURRENT_FUNCTION);
}
END_SU2_OMP_SAFE_GLOBAL_ACCESS
}
void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){
/*--- Initialize quantities for the average process for internal flow ---*/
const auto nSpanWiseSections = config->GetnSpanWiseSections();
AverageVelocity.resize(nMarker);
AverageTurboVelocity.resize(nMarker);
OldAverageTurboVelocity.resize(nMarker);
ExtAverageTurboVelocity.resize(nMarker);
AverageFlux.resize(nMarker);
SpanTotalFlux.resize(nMarker);
AveragePressure.resize(nMarker,nSpanWiseSections+1) = su2double(0.0);
OldAveragePressure = AveragePressure;
RadialEquilibriumPressure = AveragePressure;
ExtAveragePressure = AveragePressure;
AverageDensity = AveragePressure;
OldAverageDensity = AveragePressure;
ExtAverageDensity = AveragePressure;
AverageNu = AveragePressure;
AverageKine = AveragePressure;
AverageOmega = AveragePressure;
ExtAverageNu = AveragePressure;
ExtAverageKine = AveragePressure;
ExtAverageOmega = AveragePressure;
for (unsigned long iMarker = 0; iMarker < nMarker; iMarker++) {
AverageVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0);
AverageTurboVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0);
OldAverageTurboVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0);
ExtAverageTurboVelocity[iMarker].resize(nSpanWiseSections+1,nDim) = su2double(0.0);
AverageFlux[iMarker].resize(nSpanWiseSections+1,nVar) = su2double(0.0);
SpanTotalFlux[iMarker].resize(nSpanWiseSections+1,nVar) = su2double(0.0);
}
/*--- Initialize primitive quantities for turboperformace ---*/
const auto nMarkerTurboPerf = config->GetnMarker_TurboPerformance();
const auto nSpanMax = config->GetnSpanMaxAllZones();
DensityIn.resize(nMarkerTurboPerf,nSpanMax+1) = su2double(0.0);
PressureIn = DensityIn;
TurboVelocityIn.resize(nMarkerTurboPerf);
DensityOut = DensityIn;
PressureOut = DensityIn;
TurboVelocityOut.resize(nMarkerTurboPerf);
KineIn = DensityIn;
OmegaIn = DensityIn;
NuIn = DensityIn;
KineOut = DensityIn;
OmegaOut = DensityIn;
NuOut = DensityIn;
for (unsigned long iMarker = 0; iMarker < nMarkerTurboPerf; iMarker++) {
TurboVelocityIn[iMarker].resize(nSpanMax+1,nDim) = su2double(0.0);
TurboVelocityOut[iMarker].resize(nSpanMax+1,nDim) = su2double(0.0);
}
/*--- Initialize quantities for NR BC ---*/
if(config->GetBoolGiles()){
CkInflow.resize(nMarker);
CkOutflow1.resize(nMarker);
CkOutflow2.resize(nMarker);
for (unsigned long iMarker = 0; iMarker < nMarker; iMarker++) {
CkInflow[iMarker].resize(nSpanWiseSections,2*geometry->GetnFreqSpanMax(INFLOW)+1) = complex<su2double>(0.0,0.0);
CkOutflow1[iMarker].resize(nSpanWiseSections,2*geometry->GetnFreqSpanMax(OUTFLOW)+1) = complex<su2double>(0.0,0.0);
CkOutflow2[iMarker] = CkOutflow1[iMarker];
}
}
}
void CEulerSolver::Set_MPI_ActDisk(CSolver **solver_container, CGeometry *geometry, CConfig *config) {
unsigned long iter, iPoint, iVertex, jVertex, iPointTotal,
Buffer_Send_nPointTotal = 0;
long iGlobalIndex, iGlobal;
unsigned short iVar, iMarker, jMarker;
long nDomain = 0, iDomain, jDomain;
//bool ActDisk_Perimeter;
bool rans = (config->GetKind_Turb_Model() != TURB_MODEL::NONE) && (solver_container[TURB_SOL] != nullptr);
unsigned short nPrimVar_ = nPrimVar;
if (rans) nPrimVar_ += 2; // Add two extra variables for the turbulence.
/*--- MPI status and request arrays for non-blocking communications ---*/
SU2_MPI::Status status;
SU2_MPI::Request req;
/*--- Define buffer vector interior domain ---*/
su2double *Buffer_Send_PrimVar = nullptr;
long *Buffer_Send_Data = nullptr;
auto *nPointTotal_s = new unsigned long[size];
auto *nPointTotal_r = new unsigned long[size];
auto *iPrimVar = new su2double [nPrimVar_];
unsigned long Buffer_Size_PrimVar = 0;
unsigned long Buffer_Size_Data = 0;
unsigned long PointTotal_Counter = 0;
/*--- Allocate the memory that we only need if we have MPI support ---*/
su2double *Buffer_Receive_PrimVar = nullptr;
long *Buffer_Receive_Data = nullptr;
/*--- Basic dimensionalization ---*/
nDomain = size;
/*--- This loop gets the array sizes of points for each
rank to send to each other rank. ---*/
for (iDomain = 0; iDomain < nDomain; iDomain++) {
/*--- Loop over the markers to perform the dimensionalizaton
of the domain variables ---*/
Buffer_Send_nPointTotal = 0;
/*--- Loop over all of the markers and count the number of each
type of point and element that needs to be sent. ---*/
for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
if ((config->GetMarker_All_KindBC(iMarker) == ACTDISK_INLET) ||
(config->GetMarker_All_KindBC(iMarker) == ACTDISK_OUTLET)) {
for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) {
//ActDisk_Perimeter = geometry->vertex[iMarker][iVertex]->GetActDisk_Perimeter();
iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
jDomain = geometry->vertex[iMarker][iVertex]->GetDonorProcessor();
// if ((iDomain == jDomain) && (geometry->nodes->GetDomain(iPoint)) && (!ActDisk_Perimeter)) {
if ((iDomain == jDomain) && (geometry->nodes->GetDomain(iPoint))) {
Buffer_Send_nPointTotal++;
}
}
}
}
/*--- Store the counts on a partition by partition basis. ---*/
nPointTotal_s[iDomain] = Buffer_Send_nPointTotal;
/*--- Total counts for allocating send buffers below ---*/
Buffer_Size_PrimVar += nPointTotal_s[iDomain]*(nPrimVar_);
Buffer_Size_Data += nPointTotal_s[iDomain]*(3);
}
/*--- Allocate the buffer vectors in the appropiate domain (master, iDomain) ---*/
Buffer_Send_PrimVar = new su2double[Buffer_Size_PrimVar];
Buffer_Send_Data = new long[Buffer_Size_Data];
/*--- Now that we know the sizes of the point, we can
allocate and send the information in large chunks to all processors. ---*/
for (iDomain = 0; iDomain < nDomain; iDomain++) {
/*--- A rank does not communicate with itself through MPI ---*/
if (rank != iDomain) {
/*--- Communicate the counts to iDomain with non-blocking sends ---*/
SU2_MPI::Isend(&nPointTotal_s[iDomain], 1, MPI_UNSIGNED_LONG, iDomain, iDomain, SU2_MPI::GetComm(), &req);
SU2_MPI::Request_free(&req);
} else {
/*--- If iDomain = rank, we simply copy values into place in memory ---*/
nPointTotal_r[iDomain] = nPointTotal_s[iDomain];
}
/*--- Receive the counts. All processors are sending their counters to
iDomain up above, so only iDomain needs to perform the recv here from
all other ranks. ---*/
if (rank == iDomain) {
for (jDomain = 0; jDomain < size; jDomain++) {
/*--- A rank does not communicate with itself through MPI ---*/
if (rank != jDomain) {
/*--- Recv the data by probing for the current sender, jDomain,
first and then receiving the values from it. ---*/
SU2_MPI::Recv(&nPointTotal_r[jDomain], 1, MPI_UNSIGNED_LONG, jDomain, rank, SU2_MPI::GetComm(), &status);
}
}
}
}
/*--- Wait for the non-blocking sends to complete. ---*/
SU2_MPI::Barrier(SU2_MPI::GetComm());
/*--- Initialize the counters for the larger send buffers (by domain) ---*/
PointTotal_Counter = 0;
for (iDomain = 0; iDomain < nDomain; iDomain++) {
/*--- Set the value of the interior geometry. Initialize counters. ---*/
iPointTotal = 0;
/*--- Load up the actual values into the buffers for sending. ---*/
for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
if ((config->GetMarker_All_KindBC(iMarker) == ACTDISK_INLET) ||
(config->GetMarker_All_KindBC(iMarker) == ACTDISK_OUTLET)) {
for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) {
iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
jDomain = geometry->vertex[iMarker][iVertex]->GetDonorProcessor();
//ActDisk_Perimeter = geometry->vertex[iMarker][iVertex]->GetActDisk_Perimeter();
// if ((iDomain == jDomain) && (geometry->nodes->GetDomain(iPoint)) && (!ActDisk_Perimeter)) {
if ((iDomain == jDomain) && (geometry->nodes->GetDomain(iPoint))) {
for (iVar = 0; iVar < nPrimVar; iVar++) {
Buffer_Send_PrimVar[(nPrimVar_)*(PointTotal_Counter+iPointTotal)+iVar] = nodes->GetPrimitive(iPoint,iVar);
}
if (rans) {
Buffer_Send_PrimVar[(nPrimVar_)*(PointTotal_Counter+iPointTotal)+nPrimVar] = solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0);
Buffer_Send_PrimVar[(nPrimVar_)*(PointTotal_Counter+iPointTotal)+(nPrimVar+1)] = 0.0;
}
iGlobalIndex = geometry->nodes->GetGlobalIndex(iPoint);
jVertex = geometry->vertex[iMarker][iVertex]->GetDonorVertex();
jMarker = geometry->vertex[iMarker][iVertex]->GetDonorMarker();
Buffer_Send_Data[(3)*(PointTotal_Counter+iPointTotal)+(0)] = iGlobalIndex;
Buffer_Send_Data[(3)*(PointTotal_Counter+iPointTotal)+(1)] = jVertex;
Buffer_Send_Data[(3)*(PointTotal_Counter+iPointTotal)+(2)] = jMarker;
iPointTotal++;
}
}
}
}
/*--- Send the buffers with the geometrical information ---*/
if (iDomain != rank) {
/*--- Communicate the coordinates, global index, colors, and element
date to iDomain with non-blocking sends. ---*/
SU2_MPI::Isend(&Buffer_Send_PrimVar[PointTotal_Counter*(nPrimVar_)],
nPointTotal_s[iDomain]*(nPrimVar_), MPI_DOUBLE, iDomain,
iDomain, SU2_MPI::GetComm(), &req);
SU2_MPI::Request_free(&req);
SU2_MPI::Isend(&Buffer_Send_Data[PointTotal_Counter*(3)],
nPointTotal_s[iDomain]*(3), MPI_LONG, iDomain,
iDomain+nDomain, SU2_MPI::GetComm(), &req);
SU2_MPI::Request_free(&req);
}
else {
/*--- Allocate local memory for the local recv of the elements ---*/
Buffer_Receive_PrimVar = new su2double[nPointTotal_s[iDomain]*(nPrimVar_)];
Buffer_Receive_Data = new long[nPointTotal_s[iDomain]*(3)];
for (iter = 0; iter < nPointTotal_s[iDomain]*(nPrimVar_); iter++)
Buffer_Receive_PrimVar[iter] = Buffer_Send_PrimVar[PointTotal_Counter*(nPrimVar_)+iter];
for (iter = 0; iter < nPointTotal_s[iDomain]*(3); iter++)
Buffer_Receive_Data[iter] = Buffer_Send_Data[PointTotal_Counter*(3)+iter];
/*--- Recv the point data from ourselves (same procedure as above) ---*/
for (iPoint = 0; iPoint < nPointTotal_r[iDomain]; iPoint++) {
for (iVar = 0; iVar < nPrimVar_; iVar++)
iPrimVar[iVar] = Buffer_Receive_PrimVar[iPoint*(nPrimVar_)+iVar];
iGlobal = Buffer_Receive_Data[iPoint*(3)+(0)];
iVertex = Buffer_Receive_Data[iPoint*(3)+(1)];
iMarker = Buffer_Receive_Data[iPoint*(3)+(2)];
for (iVar = 0; iVar < nPrimVar_; iVar++)
DonorPrimVar[iMarker][iVertex][iVar] = iPrimVar[iVar];
SetDonorGlobalIndex(iMarker, iVertex, iGlobal);
}
/*--- Delete memory for recv the point stuff ---*/
delete [] Buffer_Receive_PrimVar;
delete [] Buffer_Receive_Data;
}
/*--- Increment the counters for the send buffers (iDomain loop) ---*/
PointTotal_Counter += iPointTotal;
}
/*--- Wait for the non-blocking sends to complete. ---*/
SU2_MPI::Barrier(SU2_MPI::GetComm());
/*--- The next section begins the recv of all data for the interior
points/elements in the mesh. First, create the domain structures for
the points on this rank. First, we recv all of the point data ---*/
for (iDomain = 0; iDomain < size; iDomain++) {
if (rank != iDomain) {
#ifdef HAVE_MPI
/*--- Allocate the receive buffer vector. Send the colors so that we
know whether what we recv is an owned or halo node. ---*/
Buffer_Receive_PrimVar = new su2double [nPointTotal_r[iDomain]*(nPrimVar_)];
Buffer_Receive_Data = new long [nPointTotal_r[iDomain]*(3)];
/*--- Receive the buffers with the coords, global index, and colors ---*/
SU2_MPI::Recv(Buffer_Receive_PrimVar, nPointTotal_r[iDomain]*(nPrimVar_) , MPI_DOUBLE,
iDomain, rank, SU2_MPI::GetComm(), &status);
SU2_MPI::Recv(Buffer_Receive_Data, nPointTotal_r[iDomain]*(3) , MPI_LONG,
iDomain, rank+nDomain, SU2_MPI::GetComm(), &status);
/*--- Loop over all of the points that we have recv'd and store the
coords, global index vertex and markers ---*/
for (iPoint = 0; iPoint < nPointTotal_r[iDomain]; iPoint++) {
iGlobal = Buffer_Receive_Data[iPoint*(3)+(0)];
iVertex = Buffer_Receive_Data[iPoint*(3)+(1)];
iMarker = Buffer_Receive_Data[iPoint*(3)+(2)];
for (iVar = 0; iVar < nPrimVar_; iVar++)
iPrimVar[iVar] = Buffer_Receive_PrimVar[iPoint*(nPrimVar_)+iVar];
for (iVar = 0; iVar < nPrimVar_; iVar++) {
DonorPrimVar[iMarker][iVertex][iVar] = iPrimVar[iVar];
}
SetDonorGlobalIndex(iMarker, iVertex, iGlobal);
}
/*--- Delete memory for recv the point stuff ---*/
delete [] Buffer_Receive_PrimVar;
delete [] Buffer_Receive_Data;
#endif
}
}
/*--- Wait for the non-blocking sends to complete. ---*/
SU2_MPI::Barrier(SU2_MPI::GetComm());
/*--- Free all of the memory used for communicating points and elements ---*/
delete[] Buffer_Send_PrimVar;
delete[] Buffer_Send_Data;
/*--- Release all of the temporary memory ---*/
delete [] nPointTotal_s;
delete [] nPointTotal_r;
delete [] iPrimVar;
}
void CEulerSolver::SetNondimensionalization(CConfig *config, unsigned short iMesh) {
su2double Temperature_FreeStream = 0.0, Mach2Vel_FreeStream = 0.0, ModVel_FreeStream = 0.0,
Energy_FreeStream = 0.0, ModVel_FreeStreamND = 0.0, Velocity_Reynolds = 0.0,
Omega_FreeStream = 0.0, Omega_FreeStreamND = 0.0, Viscosity_FreeStream = 0.0,
Density_FreeStream = 0.0, Pressure_FreeStream = 0.0, Tke_FreeStream = 0.0, Re_ThetaT_FreeStream = 0.0,
Length_Ref = 0.0, Density_Ref = 0.0, Pressure_Ref = 0.0, Velocity_Ref = 0.0,
Temperature_Ref = 0.0, Time_Ref = 0.0, Omega_Ref = 0.0, Force_Ref = 0.0,
Gas_Constant_Ref = 0.0, Viscosity_Ref = 0.0, Conductivity_Ref = 0.0, Energy_Ref= 0.0,
Froude = 0.0, Pressure_FreeStreamND = 0.0, Density_FreeStreamND = 0.0,
Temperature_FreeStreamND = 0.0, Gas_ConstantND = 0.0,
Velocity_FreeStreamND[3] = {0.0, 0.0, 0.0}, Viscosity_FreeStreamND = 0.0,
Tke_FreeStreamND = 0.0, Energy_FreeStreamND = 0.0,
Total_UnstTimeND = 0.0, Delta_UnstTimeND = 0.0, TgammaR = 0.0, Heat_Flux_Ref = 0.0;
unsigned short iDim;
/*--- Local variables ---*/
su2double Alpha = config->GetAoA()*PI_NUMBER/180.0;
su2double Beta = config->GetAoS()*PI_NUMBER/180.0;
su2double Mach = config->GetMach();
su2double Reynolds = config->GetReynolds();
bool unsteady = (config->GetTime_Marching() != TIME_MARCHING::STEADY);
bool viscous = config->GetViscous();
bool gravity = config->GetGravityForce();
bool turbulent = (config->GetKind_Turb_Model() != TURB_MODEL::NONE);
bool tkeNeeded = (turbulent && config->GetKind_Turb_Model() == TURB_MODEL::SST);
bool free_stream_temp = (config->GetKind_FreeStreamOption() == FREESTREAM_OPTION::TEMPERATURE_FS);
bool reynolds_init = (config->GetKind_InitOption() == REYNOLDS);
bool aeroelastic = config->GetAeroelastic_Simulation();
/*--- Set temperature via the flutter speed index ---*/
if (aeroelastic) {
su2double vf = config->GetAeroelastic_Flutter_Speed_Index();
su2double w_alpha = config->GetAeroelastic_Frequency_Pitch();
su2double b = config->GetLength_Reynolds()/2.0; // airfoil semichord, Reynolds length is by defaul 1.0
su2double mu = config->GetAeroelastic_Airfoil_Mass_Ratio();
// The temperature times gamma times the gas constant. Depending on the FluidModel temp is calculated below.
TgammaR = ((vf*vf)*(b*b)*(w_alpha*w_alpha)*mu) / (Mach*Mach);
}
/*--- Compressible non dimensionalization ---*/
/*--- Compute the Free Stream velocity, using the Mach number ---*/
Pressure_FreeStream = config->GetPressure_FreeStream();
Density_FreeStream = config->GetDensity_FreeStream();
Temperature_FreeStream = config->GetTemperature_FreeStream();
/*--- The dimensional viscosity is needed to determine the free-stream conditions.
To accomplish this, simply set the non-dimensional coefficients to the
dimensional ones. This will be overruled later.---*/
config->SetTemperature_Ref(1.0);
config->SetViscosity_Ref(1.0);
config->SetConductivity_Ref(1.0);
CFluidModel* auxFluidModel = nullptr;
switch (config->GetKind_FluidModel()) {
case STANDARD_AIR:
switch (config->GetSystemMeasurements()) {
case SI: config->SetGas_Constant(287.058); break;
case US: config->SetGas_Constant(1716.49); break;
}
auxFluidModel = new CIdealGas(1.4, config->GetGas_Constant());
if (free_stream_temp && aeroelastic) {
Temperature_FreeStream = TgammaR / (config->GetGas_Constant()*1.4);
config->SetTemperature_FreeStream(Temperature_FreeStream);
}
break;
case IDEAL_GAS:
auxFluidModel = new CIdealGas(Gamma, config->GetGas_Constant());
break;
case VW_GAS:
auxFluidModel = new CVanDerWaalsGas(Gamma, config->GetGas_Constant(),
config->GetPressure_Critical(), config->GetTemperature_Critical());
break;
case PR_GAS:
auxFluidModel = new CPengRobinson(Gamma, config->GetGas_Constant(), config->GetPressure_Critical(),
config->GetTemperature_Critical(), config->GetAcentric_Factor());
break;
case COOLPROP:
auxFluidModel = new CCoolProp(config->GetFluid_Name());
break;
default:
SU2_MPI::Error("Unknown fluid model.", CURRENT_FUNCTION);
break;
}
if (free_stream_temp) {
auxFluidModel->SetTDState_PT(Pressure_FreeStream, Temperature_FreeStream);
Density_FreeStream = auxFluidModel->GetDensity();
config->SetDensity_FreeStream(Density_FreeStream);
}
else {
auxFluidModel->SetTDState_Prho(Pressure_FreeStream, Density_FreeStream );
Temperature_FreeStream = auxFluidModel->GetTemperature();
config->SetTemperature_FreeStream(Temperature_FreeStream);
}
Mach2Vel_FreeStream = auxFluidModel->GetSoundSpeed();
/*--- Compute the Free Stream velocity, using the Mach number ---*/
if (nDim == 2) {
config->GetVelocity_FreeStream()[0] = cos(Alpha)*Mach*Mach2Vel_FreeStream;
config->GetVelocity_FreeStream()[1] = sin(Alpha)*Mach*Mach2Vel_FreeStream;
}
if (nDim == 3) {
config->GetVelocity_FreeStream()[0] = cos(Alpha)*cos(Beta)*Mach*Mach2Vel_FreeStream;
config->GetVelocity_FreeStream()[1] = sin(Beta)*Mach*Mach2Vel_FreeStream;
config->GetVelocity_FreeStream()[2] = sin(Alpha)*cos(Beta)*Mach*Mach2Vel_FreeStream;
}
/*--- Compute the modulus of the free stream velocity ---*/
ModVel_FreeStream = 0.0;
for (iDim = 0; iDim < nDim; iDim++)
ModVel_FreeStream += config->GetVelocity_FreeStream()[iDim]*config->GetVelocity_FreeStream()[iDim];
ModVel_FreeStream = sqrt(ModVel_FreeStream); config->SetModVel_FreeStream(ModVel_FreeStream);
/*--- Viscous initialization ---*/
if (viscous) {
/*--- Check if there is mesh motion. If yes, use the Mach
number relative to the body to initialize the flow. ---*/
if (dynamic_grid) Velocity_Reynolds = config->GetMach_Motion()*Mach2Vel_FreeStream;
else Velocity_Reynolds = ModVel_FreeStream;
/*--- Reynolds based initialization ---*/
if (reynolds_init) {
/*--- For viscous flows, pressure will be computed from a density
that is found from the Reynolds number. The viscosity is computed
from the dimensional version of Sutherland's law or the constant
viscosity, depending on the input option.---*/
auxFluidModel->SetLaminarViscosityModel(config);
Viscosity_FreeStream = auxFluidModel->GetLaminarViscosity();
config->SetViscosity_FreeStream(Viscosity_FreeStream);
Density_FreeStream = Reynolds*Viscosity_FreeStream/(Velocity_Reynolds*config->GetLength_Reynolds());
config->SetDensity_FreeStream(Density_FreeStream);
auxFluidModel->SetTDState_rhoT(Density_FreeStream, Temperature_FreeStream);
Pressure_FreeStream = auxFluidModel->GetPressure();
config->SetPressure_FreeStream(Pressure_FreeStream);
Energy_FreeStream = auxFluidModel->GetStaticEnergy() + 0.5*ModVel_FreeStream*ModVel_FreeStream;
}
/*--- Thermodynamics quantities based initialization ---*/
else {
auxFluidModel->SetLaminarViscosityModel(config);
Viscosity_FreeStream = auxFluidModel->GetLaminarViscosity();
config->SetViscosity_FreeStream(Viscosity_FreeStream);
Energy_FreeStream = auxFluidModel->GetStaticEnergy() + 0.5*ModVel_FreeStream*ModVel_FreeStream;
/*--- Compute Reynolds number ---*/
Reynolds = (Density_FreeStream*Velocity_Reynolds*config->GetLength_Reynolds())/Viscosity_FreeStream;
config->SetReynolds(Reynolds);
}
/*--- Turbulence kinetic energy ---*/
Tke_FreeStream = 3.0/2.0*(ModVel_FreeStream*ModVel_FreeStream*config->GetTurbulenceIntensity_FreeStream()*config->GetTurbulenceIntensity_FreeStream());
}
else {
/*--- For inviscid flow, energy is calculated from the specified
FreeStream quantities using the proper gas law. ---*/
Energy_FreeStream = auxFluidModel->GetStaticEnergy() + 0.5*ModVel_FreeStream*ModVel_FreeStream;
}
/*-- Compute the freestream energy. ---*/
if (tkeNeeded) { Energy_FreeStream += Tke_FreeStream; }; config->SetEnergy_FreeStream(Energy_FreeStream);
/*--- Compute non dimensional quantities. By definition,
Lref is one because we have converted the grid to meters. ---*/
if (config->GetRef_NonDim() == DIMENSIONAL) {
Pressure_Ref = 1.0;
Density_Ref = 1.0;
Temperature_Ref = 1.0;
}
else if (config->GetRef_NonDim() == FREESTREAM_PRESS_EQ_ONE) {
Pressure_Ref = Pressure_FreeStream; // Pressure_FreeStream = 1.0
Density_Ref = Density_FreeStream; // Density_FreeStream = 1.0
Temperature_Ref = Temperature_FreeStream; // Temperature_FreeStream = 1.0
}
else if (config->GetRef_NonDim() == FREESTREAM_VEL_EQ_MACH) {
Pressure_Ref = Gamma*Pressure_FreeStream; // Pressure_FreeStream = 1.0/Gamma
Density_Ref = Density_FreeStream; // Density_FreeStream = 1.0
Temperature_Ref = Temperature_FreeStream; // Temp_FreeStream = 1.0
}
else if (config->GetRef_NonDim() == FREESTREAM_VEL_EQ_ONE) {
Pressure_Ref = Mach*Mach*Gamma*Pressure_FreeStream; // Pressure_FreeStream = 1.0/(Gamma*(M_inf)^2)
Density_Ref = Density_FreeStream; // Density_FreeStream = 1.0
Temperature_Ref = Temperature_FreeStream; // Temp_FreeStream = 1.0
}
config->SetPressure_Ref(Pressure_Ref);
config->SetDensity_Ref(Density_Ref);
config->SetTemperature_Ref(Temperature_Ref);
Length_Ref = 1.0; config->SetLength_Ref(Length_Ref);
Velocity_Ref = sqrt(config->GetPressure_Ref()/config->GetDensity_Ref()); config->SetVelocity_Ref(Velocity_Ref);
Time_Ref = Length_Ref/Velocity_Ref; config->SetTime_Ref(Time_Ref);
Omega_Ref = Velocity_Ref/Length_Ref; config->SetOmega_Ref(Omega_Ref);
Force_Ref = config->GetDensity_Ref()*Velocity_Ref*Velocity_Ref*Length_Ref*Length_Ref; config->SetForce_Ref(Force_Ref);
Heat_Flux_Ref = Density_Ref*Velocity_Ref*Velocity_Ref*Velocity_Ref; config->SetHeat_Flux_Ref(Heat_Flux_Ref);
Gas_Constant_Ref = Velocity_Ref*Velocity_Ref/config->GetTemperature_Ref(); config->SetGas_Constant_Ref(Gas_Constant_Ref);
Viscosity_Ref = config->GetDensity_Ref()*Velocity_Ref*Length_Ref; config->SetViscosity_Ref(Viscosity_Ref);
Conductivity_Ref = Viscosity_Ref*Gas_Constant_Ref; config->SetConductivity_Ref(Conductivity_Ref);
Froude = ModVel_FreeStream/sqrt(STANDARD_GRAVITY*Length_Ref); config->SetFroude(Froude);
/*--- Divide by reference values, to compute the non-dimensional free-stream values ---*/