-
Notifications
You must be signed in to change notification settings - Fork 842
/
CDriver.cpp
3636 lines (2789 loc) · 146 KB
/
CDriver.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 CDriver.cpp
* \brief The main subroutines for driving single or multi-zone problems.
* \author T. Economon, H. Kline, R. Sanchez, F. Palacios
* \version 8.0.0 "Harrier"
*
* 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/drivers/CDriver.hpp"
#include "../../include/definition_structure.hpp"
#include "../../../Common/include/geometry/CDummyGeometry.hpp"
#include "../../../Common/include/geometry/CPhysicalGeometry.hpp"
#include "../../../Common/include/geometry/CMultiGridGeometry.hpp"
#include "../../include/solvers/CSolverFactory.hpp"
#include "../../include/solvers/CFEM_DG_EulerSolver.hpp"
#include "../../include/output/COutputFactory.hpp"
#include "../../include/output/COutput.hpp"
#include "../../../Common/include/interface_interpolation/CInterpolator.hpp"
#include "../../../Common/include/interface_interpolation/CInterpolatorFactory.hpp"
#include "../../include/interfaces/cfd/CConservativeVarsInterface.hpp"
#include "../../include/interfaces/cfd/CMixingPlaneInterface.hpp"
#include "../../include/interfaces/cfd/CSlidingInterface.hpp"
#include "../../include/interfaces/cht/CConjugateHeatInterface.hpp"
#include "../../include/interfaces/fsi/CDisplacementsInterface.hpp"
#include "../../include/interfaces/fsi/CFlowTractionInterface.hpp"
#include "../../include/interfaces/fsi/CDiscAdjFlowTractionInterface.hpp"
#include "../../include/variables/CEulerVariable.hpp"
#include "../../include/variables/CIncEulerVariable.hpp"
#include "../../include/variables/CNEMOEulerVariable.hpp"
#include "../../include/numerics/template.hpp"
#include "../../include/numerics/radiation.hpp"
#include "../../include/numerics/heat.hpp"
#include "../../include/numerics/flow/convection/roe.hpp"
#include "../../include/numerics/flow/convection/fds.hpp"
#include "../../include/numerics/flow/convection/fvs.hpp"
#include "../../include/numerics/flow/convection/hllc.hpp"
#include "../../include/numerics/flow/convection/ausm_slau.hpp"
#include "../../include/numerics/flow/convection/centered.hpp"
#include "../../include/numerics/flow/flow_diffusion.hpp"
#include "../../include/numerics/flow/flow_sources.hpp"
#include "../../include/numerics/NEMO/convection/roe.hpp"
#include "../../include/numerics/NEMO/convection/lax.hpp"
#include "../../include/numerics/NEMO/convection/ausm_slau.hpp"
#include "../../include/numerics/NEMO/convection/msw.hpp"
#include "../../include/numerics/NEMO/NEMO_diffusion.hpp"
#include "../../include/numerics/NEMO/NEMO_sources.hpp"
#include "../../include/numerics/continuous_adjoint/adj_convection.hpp"
#include "../../include/numerics/continuous_adjoint/adj_diffusion.hpp"
#include "../../include/numerics/continuous_adjoint/adj_sources.hpp"
#include "../../include/numerics/scalar/scalar_convection.hpp"
#include "../../include/numerics/scalar/scalar_diffusion.hpp"
#include "../../include/numerics/scalar/scalar_sources.hpp"
#include "../../include/numerics/turbulent/turb_convection.hpp"
#include "../../include/numerics/turbulent/turb_diffusion.hpp"
#include "../../include/numerics/turbulent/turb_sources.hpp"
#include "../../include/numerics/turbulent/transition/trans_convection.hpp"
#include "../../include/numerics/turbulent/transition/trans_diffusion.hpp"
#include "../../include/numerics/turbulent/transition/trans_sources.hpp"
#include "../../include/numerics/species/species_convection.hpp"
#include "../../include/numerics/species/species_diffusion.hpp"
#include "../../include/numerics/species/species_sources.hpp"
#include "../../include/numerics/elasticity/CFEAElasticity.hpp"
#include "../../include/numerics/elasticity/CFEALinearElasticity.hpp"
#include "../../include/numerics/elasticity/CFEANonlinearElasticity.hpp"
#include "../../include/numerics/elasticity/nonlinear_models.hpp"
#include "../../include/integration/CIntegrationFactory.hpp"
#include "../../include/iteration/CIterationFactory.hpp"
#include "../../../Common/include/parallelization/omp_structure.hpp"
#include <cassert>
#ifdef VTUNEPROF
#include <ittnotify.h>
#endif
#include <cfenv>
CDriver::CDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunicator, bool dummy_geo) :
CDriverBase(confFile, val_nZone, MPICommunicator), StopCalc(false), fsi(false), fem_solver(false), dry_run(dummy_geo) {
/*--- Start timer to track preprocessing for benchmarking. ---*/
StartTime = SU2_MPI::Wtime();
/*--- Initialize containers with null --- */
InitializeContainers();
/*--- Preprocessing of the config files. ---*/
PreprocessInput(config_container, driver_config);
/*--- Retrieve dimension from mesh file ---*/
nDim = CConfig::GetnDim(config_container[ZONE_0]->GetMesh_FileName(),
config_container[ZONE_0]->GetMesh_FileFormat());
/*--- Output preprocessing ---*/
PreprocessOutput(config_container, driver_config, output_container, driver_output);
for (iZone = 0; iZone < nZone; iZone++) {
/*--- Read the number of instances for each zone ---*/
nInst[iZone] = config_container[iZone]->GetnTimeInstances();
geometry_container[iZone] = new CGeometry** [nInst[iZone]] ();
iteration_container[iZone] = new CIteration* [nInst[iZone]] ();
solver_container[iZone] = new CSolver*** [nInst[iZone]] ();
integration_container[iZone] = new CIntegration** [nInst[iZone]] ();
numerics_container[iZone] = new CNumerics**** [nInst[iZone]] ();
grid_movement[iZone] = new CVolumetricMovement* [nInst[iZone]] ();
/*--- Allocate transfer and interpolation container --- */
interface_container[iZone] = new CInterface*[nZone] ();
interpolator_container[iZone].resize(nZone);
for (iInst = 0; iInst < nInst[iZone]; iInst++) {
config_container[iZone]->SetiInst(iInst);
/*--- Preprocessing of the geometry for all zones. In this routine, the edge-
based data structure is constructed, i.e. node and cell neighbors are
identified and linked, face areas and volumes of the dual mesh cells are
computed, and the multigrid levels are created using an agglomeration procedure. ---*/
InitializeGeometry(config_container[iZone], geometry_container[iZone][iInst], dry_run);
}
}
/*--- Before we proceed with the zone loop we have to compute the wall distances.
* This computation depends on all zones at once. ---*/
if (rank == MASTER_NODE)
cout << "Computing wall distances." << endl;
CGeometry::ComputeWallDistance(config_container, geometry_container);
for (iZone = 0; iZone < nZone; iZone++) {
for (iInst = 0; iInst < nInst[iZone]; iInst++){
/*--- Definition of the solver class: solver_container[#ZONES][#INSTANCES][#MG_GRIDS][#EQ_SYSTEMS].
The solver classes are specific to a particular set of governing equations,
and they contain the subroutines with instructions for computing each spatial
term of the PDE, i.e. loops over the edges to compute convective and viscous
fluxes, loops over the nodes to compute source terms, and routines for
imposing various boundary condition type for the PDE. ---*/
InitializeSolver(config_container[iZone], geometry_container[iZone][iInst], solver_container[iZone][iInst]);
/*--- Definition of the numerical method class:
numerics_container[#ZONES][#INSTANCES][#MG_GRIDS][#EQ_SYSTEMS][#EQ_TERMS].
The numerics class contains the implementation of the numerical methods for
evaluating convective or viscous fluxes between any two nodes in the edge-based
data structure (centered, upwind, galerkin), as well as any source terms
(piecewise constant reconstruction) evaluated in each dual mesh volume. ---*/
InitializeNumerics(config_container[iZone], geometry_container[iZone][iInst],
solver_container[iZone][iInst], numerics_container[iZone][iInst]);
/*--- Definition of the integration class: integration_container[#ZONES][#INSTANCES][#EQ_SYSTEMS].
The integration class orchestrates the execution of the spatial integration
subroutines contained in the solver class (including multigrid) for computing
the residual at each node, R(U) and then integrates the equations to a
steady state or time-accurately. ---*/
InitializeIntegration(config_container[iZone], solver_container[iZone][iInst][MESH_0],
integration_container[iZone][iInst]);
/*--- Instantiate the type of physics iteration to be executed within each zone. For
example, one can execute the same physics across multiple zones (mixing plane),
different physics in different zones (fluid-structure interaction), or couple multiple
systems tightly within a single zone by creating a new iteration class (e.g., RANS). ---*/
PreprocessIteration(config_container[iZone], iteration_container[iZone][iInst]);
/*--- Dynamic mesh processing. ---*/
PreprocessDynamicMesh(config_container[iZone], geometry_container[iZone][iInst], solver_container[iZone][iInst],
iteration_container[iZone][iInst], grid_movement[iZone][iInst], surface_movement[iZone]);
/*--- Static mesh processing. ---*/
PreprocessStaticMesh(config_container[iZone], geometry_container[iZone][iInst]);
}
}
/*! --- Compute the wall distance again to correctly compute the derivatives if we are running direct diff mode --- */
if (driver_config->GetDirectDiff() == D_DESIGN){
CGeometry::ComputeWallDistance(config_container, geometry_container);
}
/*--- Definition of the interface and transfer conditions between different zones. ---*/
if (nZone > 1) {
if (rank == MASTER_NODE)
cout << endl <<"------------------- Multizone Interface Preprocessing -------------------" << endl;
InitializeInterface(config_container, solver_container, geometry_container,
interface_types, interface_container, interpolator_container);
}
if (fsi) {
for (iZone = 0; iZone < nZone; iZone++) {
for (iInst = 0; iInst < nInst[iZone]; iInst++){
RestartSolver(solver_container[iZone][iInst], geometry_container[iZone][iInst],
config_container[iZone], true);
}
}
}
if (config_container[ZONE_0]->GetBoolTurbomachinery()){
if (rank == MASTER_NODE)
cout << endl <<"---------------------- Turbomachinery Preprocessing ---------------------" << endl;
PreprocessTurbomachinery(config_container, geometry_container, solver_container, interface_container, dummy_geo);
} else {
mixingplane = false;
}
PreprocessPythonInterface(config_container, geometry_container, solver_container);
/*--- Preprocessing time is reported now, but not included in the next compute portion. ---*/
StopTime = SU2_MPI::Wtime();
/*--- Compute/print the total time for performance benchmarking. ---*/
UsedTime = StopTime-StartTime;
UsedTimePreproc = UsedTime;
UsedTimeCompute = 0.0;
UsedTimeOutput = 0.0;
IterCount = 0;
OutputCount = 0;
MDOFs = 0.0;
MDOFsDomain = 0.0;
Mpoints = 0.0;
MpointsDomain = 0.0;
for (iZone = 0; iZone < nZone; iZone++) {
Mpoints += geometry_container[iZone][INST_0][MESH_0]->GetGlobal_nPoint()/(1.0e6);
MpointsDomain += geometry_container[iZone][INST_0][MESH_0]->GetGlobal_nPointDomain()/(1.0e6);
MDOFs += DOFsPerPoint*geometry_container[iZone][INST_0][MESH_0]->GetGlobal_nPoint()/(1.0e6);
MDOFsDomain += DOFsPerPoint*geometry_container[iZone][INST_0][MESH_0]->GetGlobal_nPointDomain()/(1.0e6);
}
/*--- Reset timer for compute/output performance benchmarking. ---*/
StopTime = SU2_MPI::Wtime();
/*--- Compute/print the total time for performance benchmarking. ---*/
UsedTime = StopTime-StartTime;
UsedTimePreproc = UsedTime;
/*--- Reset timer for compute performance benchmarking. ---*/
StartTime = SU2_MPI::Wtime();
}
void CDriver::InitializeContainers(){
/*--- Create pointers to all of the classes that may be used throughout
the SU2_CFD code. In general, the pointers are instantiated down a
hierarchy over all zones, multigrid levels, equation sets, and equation
terms as described in the comments below. ---*/
iteration_container = nullptr;
output_container = nullptr;
integration_container = nullptr;
geometry_container = nullptr;
solver_container = nullptr;
numerics_container = nullptr;
config_container = nullptr;
surface_movement = nullptr;
grid_movement = nullptr;
FFDBox = nullptr;
interface_container = nullptr;
interface_types = nullptr;
nInst = nullptr;
/*--- Definition and of the containers for all possible zones. ---*/
iteration_container = new CIteration**[nZone] ();
solver_container = new CSolver****[nZone] ();
integration_container = new CIntegration***[nZone] ();
numerics_container = new CNumerics*****[nZone] ();
config_container = new CConfig*[nZone] ();
geometry_container = new CGeometry***[nZone] ();
surface_movement = new CSurfaceMovement*[nZone] ();
grid_movement = new CVolumetricMovement**[nZone] ();
FFDBox = new CFreeFormDefBox**[nZone] ();
interpolator_container.resize(nZone);
interface_container = new CInterface**[nZone] ();
interface_types = new unsigned short*[nZone] ();
output_container = new COutput*[nZone] ();
nInst = new unsigned short[nZone] ();
driver_config = nullptr;
driver_output = nullptr;
for (iZone = 0; iZone < nZone; iZone++) {
interface_types[iZone] = new unsigned short[nZone];
nInst[iZone] = 1;
}
}
void CDriver::Finalize() {
const bool wrt_perf = config_container[ZONE_0]->GetWrt_Performance();
/*--- Output some information to the console. ---*/
if (rank == MASTER_NODE) {
/*--- Print out the number of non-physical points and reconstructions ---*/
if (config_container[ZONE_0]->GetNonphysical_Points() > 0)
cout << "Warning: there are " << config_container[ZONE_0]->GetNonphysical_Points() << " non-physical points in the solution." << endl;
if (config_container[ZONE_0]->GetNonphysical_Reconstr() > 0)
cout << "Warning: " << config_container[ZONE_0]->GetNonphysical_Reconstr() << " reconstructed states for upwinding are non-physical." << endl;
}
if (rank == MASTER_NODE)
cout <<"\n--------------------------- Finalizing Solver ---------------------------" << endl;
for (iZone = 0; iZone < nZone; iZone++) {
for (iInst = 0; iInst < nInst[iZone]; iInst++){
FinalizeNumerics(numerics_container[iZone], solver_container[iZone][iInst],
geometry_container[iZone][iInst], config_container[iZone], iInst);
}
delete [] numerics_container[iZone];
}
delete [] numerics_container;
if (rank == MASTER_NODE) cout << "Deleted CNumerics container." << endl;
for (iZone = 0; iZone < nZone; iZone++) {
for (iInst = 0; iInst < nInst[iZone]; iInst++){
FinalizeIntegration(integration_container[iZone],
geometry_container[iZone][iInst],
config_container[iZone],
iInst);
}
delete [] integration_container[iZone];
}
delete [] integration_container;
if (rank == MASTER_NODE) cout << "Deleted CIntegration container." << endl;
for (iZone = 0; iZone < nZone; iZone++) {
for (iInst = 0; iInst < nInst[iZone]; iInst++){
FinalizeSolver(solver_container[iZone],
geometry_container[iZone][iInst],
config_container[iZone],
iInst);
}
delete [] solver_container[iZone];
}
delete [] solver_container;
if (rank == MASTER_NODE) cout << "Deleted CSolver container." << endl;
for (iZone = 0; iZone < nZone; iZone++) {
for (iInst = 0; iInst < nInst[iZone]; iInst++)
delete iteration_container[iZone][iInst];
delete [] iteration_container[iZone];
}
delete [] iteration_container;
if (rank == MASTER_NODE) cout << "Deleted CIteration container." << endl;
if (interface_container != nullptr) {
for (iZone = 0; iZone < nZone; iZone++) {
if (interface_container[iZone] != nullptr) {
for (unsigned short jZone = 0; jZone < nZone; jZone++)
delete interface_container[iZone][jZone];
delete [] interface_container[iZone];
}
}
delete [] interface_container;
if (rank == MASTER_NODE) cout << "Deleted CInterface container." << endl;
}
if (interface_types != nullptr) {
for (iZone = 0; iZone < nZone; iZone++)
delete [] interface_types[iZone];
delete [] interface_types;
}
for (iZone = 0; iZone < nZone; iZone++) {
if (geometry_container[iZone] != nullptr) {
for (iInst = 0; iInst < nInst[iZone]; iInst++){
for (unsigned short iMGlevel = 0; iMGlevel < config_container[iZone]->GetnMGLevels()+1; iMGlevel++)
delete geometry_container[iZone][iInst][iMGlevel];
delete [] geometry_container[iZone][iInst];
}
delete [] geometry_container[iZone];
}
}
delete [] geometry_container;
if (rank == MASTER_NODE) cout << "Deleted CGeometry container." << endl;
for (iZone = 0; iZone < nZone; iZone++) {
delete [] FFDBox[iZone];
}
delete [] FFDBox;
if (rank == MASTER_NODE) cout << "Deleted CFreeFormDefBox class." << endl;
for (iZone = 0; iZone < nZone; iZone++) {
delete surface_movement[iZone];
}
delete [] surface_movement;
if (rank == MASTER_NODE) cout << "Deleted CSurfaceMovement class." << endl;
for (iZone = 0; iZone < nZone; iZone++) {
for (iInst = 0; iInst < nInst[iZone]; iInst++)
delete grid_movement[iZone][iInst];
delete [] grid_movement[iZone];
}
delete [] grid_movement;
if (rank == MASTER_NODE) cout << "Deleted CVolumetricMovement class." << endl;
/*--- Output profiling information ---*/
// Note that for now this is called only by a single thread, but all
// necessary variables have been made thread private for safety (tick/tock)!!
config_container[ZONE_0]->SetProfilingCSV();
config_container[ZONE_0]->GEMMProfilingCSV();
/*--- Deallocate config container ---*/
if (config_container!= nullptr) {
for (iZone = 0; iZone < nZone; iZone++)
delete config_container[iZone];
delete [] config_container;
}
delete driver_config;
if (rank == MASTER_NODE) cout << "Deleted CConfig container." << endl;
delete [] nInst;
if (rank == MASTER_NODE) cout << "Deleted nInst container." << endl;
/*--- Deallocate output container ---*/
if (output_container!= nullptr) {
for (iZone = 0; iZone < nZone; iZone++)
delete output_container[iZone];
delete [] output_container;
}
delete driver_output;
if (rank == MASTER_NODE) cout << "Deleted COutput class." << endl;
if (rank == MASTER_NODE) cout << "-------------------------------------------------------------------------" << endl;
/*--- Stop the timer and output the final performance summary. ---*/
StopTime = SU2_MPI::Wtime();
UsedTime = StopTime-StartTime;
UsedTimeCompute += UsedTime;
if ((rank == MASTER_NODE) && (wrt_perf)) {
su2double TotalTime = UsedTimePreproc + UsedTimeCompute + UsedTimeOutput;
cout.precision(6);
cout << endl << endl <<"-------------------------- Performance Summary --------------------------" << endl;
cout << "Simulation totals:" << endl;
cout << setw(25) << "Wall-clock time (hrs):" << setw(12) << (TotalTime)/(60.0*60.0) << " | ";
cout << setw(20) << "Core-hrs:" << setw(12) << size*TotalTime/(60.0*60.0) << endl;
cout << setw(25) << "Cores:" << setw(12) << size << " | ";
cout << setw(20) << "DOFs/point:" << setw(12) << DOFsPerPoint << endl;
cout << setw(25) << "Points/core:" << setw(12) << 1.0e6*MpointsDomain/size << " | ";
cout << setw(20) << "Ghost points/core:" << setw(12) << 1.0e6*(Mpoints-MpointsDomain)/size << endl;
cout << setw(25) << "Ghost/Owned Point Ratio:" << setw(12) << (Mpoints-MpointsDomain)/MpointsDomain << " | " << endl;
cout << endl;
cout << "Preprocessing phase:" << endl;
cout << setw(25) << "Preproc. Time (s):" << setw(12)<< UsedTimePreproc << " | ";
cout << setw(20) << "Preproc. Time (%):" << setw(12)<< ((UsedTimePreproc * 100.0) / (TotalTime)) << endl;
cout << endl;
cout << "Compute phase:" << endl;
cout << setw(25) << "Compute Time (s):" << setw(12)<< UsedTimeCompute << " | ";
cout << setw(20) << "Compute Time (%):" << setw(12)<< ((UsedTimeCompute * 100.0) / (TotalTime)) << endl;
cout << setw(25) << "Iteration count:" << setw(12)<< IterCount << " | ";
if (IterCount != 0) {
cout << setw(20) << "Avg. s/iter:" << setw(12)<< UsedTimeCompute/IterCount << endl;
cout << setw(25) << "Core-s/iter/Mpoints:" << setw(12)<< size*UsedTimeCompute/IterCount/Mpoints << " | ";
cout << setw(20) << "Mpoints/s:" << setw(12)<< Mpoints*IterCount/UsedTimeCompute << endl;
} else cout << endl;
cout << endl;
cout << "Output phase:" << endl;
cout << setw(25) << "Output Time (s):" << setw(12)<< UsedTimeOutput << " | ";
cout << setw(20) << "Output Time (%):" << setw(12)<< ((UsedTimeOutput * 100.0) / (TotalTime)) << endl;
cout << setw(25) << "Output count:" << setw(12)<< OutputCount << " | ";
if (OutputCount != 0) {
cout << setw(20)<< "Avg. s/output:" << setw(12)<< UsedTimeOutput/OutputCount << endl;
if (BandwidthSum > 0) {
cout << setw(25)<< "Restart Aggr. BW (MB/s):" << setw(12)<< BandwidthSum/OutputCount << " | ";
cout << setw(20)<< "MB/s/core:" << setw(12)<< BandwidthSum/OutputCount/size << endl;
}
} else cout << endl;
cout << "-------------------------------------------------------------------------" << endl;
cout << endl;
}
/*--- Exit the solver cleanly ---*/
if (rank == MASTER_NODE)
cout << endl <<"------------------------- Exit Success (SU2_CFD) ------------------------" << endl << endl;
}
void CDriver::PreprocessInput(CConfig **&config, CConfig *&driver_config) {
char zone_file_name[MAX_STRING_SIZE];
/*--- Initialize the configuration of the driver ---*/
driver_config = new CConfig(config_file_name, SU2_COMPONENT::SU2_CFD, false);
for (iZone = 0; iZone < nZone; iZone++) {
if (rank == MASTER_NODE){
cout << endl << "Parsing config file for zone " << iZone << endl;
}
/*--- Definition of the configuration option class for all zones. In this
constructor, the input configuration file is parsed and all options are
read and stored. ---*/
if (driver_config->GetnConfigFiles() > 0){
strcpy(zone_file_name, driver_config->GetConfigFilename(iZone).c_str());
config[iZone] = new CConfig(driver_config, zone_file_name, SU2_COMPONENT::SU2_CFD, iZone, nZone, true);
}
else{
config[iZone] = new CConfig(driver_config, config_file_name, SU2_COMPONENT::SU2_CFD, iZone, nZone, true);
}
/*--- Set the MPI communicator ---*/
config[iZone]->SetMPICommunicator(SU2_MPI::GetComm());
}
/*--- Set the multizone part of the problem. ---*/
if (driver_config->GetMultizone_Problem()){
for (iZone = 0; iZone < nZone; iZone++) {
/*--- Set the interface markers for multizone ---*/
config_container[iZone]->SetMultizone(driver_config, config_container);
}
}
/*--- Keep a reference to the main (ZONE 0) config. ---*/
main_config = config_container[ZONE_0];
/*--- Determine whether or not the FEM solver is used, which decides the type of
* geometry classes that are instantiated. Only adapted for single-zone problems ---*/
fem_solver = config_container[ZONE_0]->GetFEMSolver();
fsi = config_container[ZONE_0]->GetFSI_Simulation();
}
void CDriver::InitializeGeometry(CConfig* config, CGeometry **&geometry, bool dummy){
if (!dummy){
if (rank == MASTER_NODE)
cout << endl <<"------------------- Geometry Preprocessing ( Zone " << config->GetiZone() <<" ) -------------------" << endl;
if( fem_solver ) {
switch( config->GetKind_FEM_Flow() ) {
case DG: {
InitializeGeometryDGFEM(config, geometry);
break;
}
}
}
else {
InitializeGeometryFVM(config, geometry);
}
} else {
if (rank == MASTER_NODE)
cout << endl <<"-------------------------- Using Dummy Geometry -------------------------" << endl;
unsigned short iMGlevel;
geometry = new CGeometry*[config->GetnMGLevels()+1] ();
if (!fem_solver){
for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) {
geometry[iMGlevel] = new CDummyGeometry(config);
}
} else {
geometry[MESH_0] = new CDummyMeshFEM_DG(config);
}
nDim = geometry[MESH_0]->GetnDim();
}
/*--- Computation of positive surface area in the z-plane which is used for
the calculation of force coefficient (non-dimensionalization). ---*/
geometry[MESH_0]->SetPositive_ZArea(config);
/*--- Set the actuator disk boundary conditions, if necessary. ---*/
for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) {
geometry[iMesh]->MatchActuator_Disk(config);
}
/*--- If we have any periodic markers in this calculation, we must
match the periodic points found on both sides of the periodic BC.
Note that the current implementation requires a 1-to-1 matching of
periodic points on the pair of periodic faces after the translation
or rotation is taken into account. ---*/
if ((config->GetnMarker_Periodic() != 0) && !fem_solver) {
for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) {
/*--- Note that we loop over pairs of periodic markers individually
so that repeated nodes on adjacent periodic faces are properly
accounted for in multiple places. ---*/
for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) {
geometry[iMesh]->MatchPeriodic(config, iPeriodic);
}
/*--- For Streamwise Periodic flow, find a unique reference node on the dedicated inlet marker. ---*/
if (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE)
geometry[iMesh]->FindUniqueNode_PeriodicBound(config);
/*--- Initialize the communication framework for the periodic BCs. ---*/
geometry[iMesh]->PreprocessPeriodicComms(geometry[iMesh], config);
}
}
/*--- If activated by the compile directive, perform a partition analysis. ---*/
#if PARTITION
if (!dummy){
if( fem_solver ) Partition_Analysis_FEM(geometry[MESH_0], config);
else Partition_Analysis(geometry[MESH_0], config);
}
#endif
/*--- Check if Euler & Symmetry markers are straight/plane. This information
is used in the Euler & Symmetry boundary routines. ---*/
if((config_container[iZone]->GetnMarker_Euler() != 0 ||
config_container[iZone]->GetnMarker_SymWall() != 0) &&
!fem_solver) {
if (rank == MASTER_NODE)
cout << "Checking if Euler & Symmetry markers are straight/plane:" << endl;
for (iMesh = 0; iMesh <= config_container[iZone]->GetnMGLevels(); iMesh++)
geometry_container[iZone][iInst][iMesh]->ComputeSurf_Straightness(config_container[iZone], (iMesh==MESH_0) );
}
/*--- Keep a reference to the main (ZONE_0, INST_0, MESH_0) geometry. ---*/
main_geometry = geometry_container[ZONE_0][INST_0][MESH_0];
}
void CDriver::InitializeGeometryFVM(CConfig *config, CGeometry **&geometry) {
unsigned short iZone = config->GetiZone(), iMGlevel;
unsigned short requestedMGlevels = config->GetnMGLevels();
const bool fea = config->GetStructuralProblem();
/*--- Definition of the geometry class to store the primal grid in the partitioning process.
* All ranks process the grid and call ParMETIS for partitioning ---*/
CGeometry *geometry_aux = new CPhysicalGeometry(config, iZone, nZone);
/*--- Set the dimension --- */
nDim = geometry_aux->GetnDim();
/*--- Color the initial grid and set the send-receive domains (ParMETIS) ---*/
geometry_aux->SetColorGrid_Parallel(config);
/*--- Allocate the memory of the current domain, and divide the grid
between the ranks. ---*/
geometry = new CGeometry *[config->GetnMGLevels()+1] ();
/*--- Build the grid data structures using the ParMETIS coloring. ---*/
geometry[MESH_0] = new CPhysicalGeometry(geometry_aux, config);
/*--- Deallocate the memory of geometry_aux and solver_aux ---*/
delete geometry_aux;
/*--- Add the Send/Receive boundaries ---*/
geometry[MESH_0]->SetSendReceive(config);
/*--- Add the Send/Receive boundaries ---*/
geometry[MESH_0]->SetBoundaries(config);
/*--- Compute elements surrounding points, points surrounding points ---*/
if (rank == MASTER_NODE) cout << "Setting point connectivity." << endl;
geometry[MESH_0]->SetPoint_Connectivity();
/*--- Renumbering points using Reverse Cuthill McKee ordering ---*/
if (rank == MASTER_NODE) cout << "Renumbering points (Reverse Cuthill McKee Ordering)." << endl;
geometry[MESH_0]->SetRCM_Ordering(config);
/*--- recompute elements surrounding points, points surrounding points ---*/
if (rank == MASTER_NODE) cout << "Recomputing point connectivity." << endl;
geometry[MESH_0]->SetPoint_Connectivity();
/*--- Compute elements surrounding elements ---*/
if (rank == MASTER_NODE) cout << "Setting element connectivity." << endl;
geometry[MESH_0]->SetElement_Connectivity();
/*--- Check the orientation before computing geometrical quantities ---*/
geometry[MESH_0]->SetBoundVolume();
if (config->GetReorientElements()) {
if (rank == MASTER_NODE) cout << "Checking the numerical grid orientation." << endl;
geometry[MESH_0]->Check_IntElem_Orientation(config);
geometry[MESH_0]->Check_BoundElem_Orientation(config);
}
/*--- Create the edge structure ---*/
if (rank == MASTER_NODE) cout << "Identifying edges and vertices." << endl;
geometry[MESH_0]->SetEdges();
geometry[MESH_0]->SetVertex(config);
/*--- Create the control volume structures ---*/
if (rank == MASTER_NODE) cout << "Setting the control volume structure." << endl;
SU2_OMP_PARALLEL {
geometry[MESH_0]->SetControlVolume(config, ALLOCATE);
geometry[MESH_0]->SetBoundControlVolume(config, ALLOCATE);
}
END_SU2_OMP_PARALLEL
/*--- Visualize a dual control volume if requested ---*/
if ((config->GetVisualize_CV() >= 0) &&
(config->GetVisualize_CV() < (long)geometry[MESH_0]->GetGlobal_nPointDomain()))
geometry[MESH_0]->VisualizeControlVolume(config);
/*--- Identify closest normal neighbor ---*/
if (rank == MASTER_NODE) cout << "Searching for the closest normal neighbors to the surfaces." << endl;
geometry[MESH_0]->FindNormal_Neighbor(config);
/*--- Store the global to local mapping. ---*/
if (rank == MASTER_NODE) cout << "Storing a mapping from global to local point index." << endl;
geometry[MESH_0]->SetGlobal_to_Local_Point();
/*--- Compute the surface curvature ---*/
if (!fea) {
if (rank == MASTER_NODE) cout << "Compute the surface curvature." << endl;
geometry[MESH_0]->ComputeSurf_Curvature(config);
}
/*--- Compute the global surface areas for all markers. ---*/
geometry[MESH_0]->ComputeSurfaceAreaCfgFile(config);
/*--- Check for periodicity and disable MG if necessary. ---*/
if (rank == MASTER_NODE) cout << "Checking for periodicity." << endl;
geometry[MESH_0]->Check_Periodicity(config);
/*--- Compute mesh quality statistics on the fine grid. ---*/
if (!fea) {
if (rank == MASTER_NODE)
cout << "Computing mesh quality statistics for the dual control volumes." << endl;
geometry[MESH_0]->ComputeMeshQualityStatistics(config);
}
geometry[MESH_0]->SetMGLevel(MESH_0);
if ((config->GetnMGLevels() != 0) && (rank == MASTER_NODE))
cout << "Setting the multigrid structure." << endl;
/*--- Loop over all the new grid ---*/
for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) {
/*--- Create main agglomeration structure ---*/
geometry[iMGlevel] = new CMultiGridGeometry(geometry[iMGlevel-1], config, iMGlevel);
/*--- Compute points surrounding points. ---*/
geometry[iMGlevel]->SetPoint_Connectivity(geometry[iMGlevel-1]);
/*--- Create the edge structure ---*/
geometry[iMGlevel]->SetEdges();
geometry[iMGlevel]->SetVertex(geometry[iMGlevel-1], config);
/*--- Create the control volume structures ---*/
geometry[iMGlevel]->SetControlVolume(geometry[iMGlevel-1], ALLOCATE);
geometry[iMGlevel]->SetBoundControlVolume(geometry[iMGlevel-1], ALLOCATE);
geometry[iMGlevel]->SetCoord(geometry[iMGlevel-1]);
/*--- Find closest neighbor to a surface point ---*/
geometry[iMGlevel]->FindNormal_Neighbor(config);
/*--- Store our multigrid index. ---*/
geometry[iMGlevel]->SetMGLevel(iMGlevel);
/*--- Protect against the situation that we were not able to complete
the agglomeration for this level, i.e., there weren't enough points.
We need to check if we changed the total number of levels and delete
the incomplete CMultiGridGeometry object. ---*/
if (config->GetnMGLevels() != requestedMGlevels) {
delete geometry[iMGlevel];
geometry[iMGlevel] = nullptr;
break;
}
}
if (config->GetWrt_MultiGrid()) geometry[MESH_0]->ColorMGLevels(config->GetnMGLevels(), geometry);
/*--- For unsteady simulations, initialize the grid volumes
and coordinates for previous solutions. Loop over all zones/grids ---*/
if ((config->GetTime_Marching() != TIME_MARCHING::STEADY) && config->GetDynamic_Grid()) {
for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) {
/*--- Update cell volume ---*/
geometry[iMGlevel]->nodes->SetVolume_n();
geometry[iMGlevel]->nodes->SetVolume_nM1();
if (config->GetGrid_Movement()) {
/*--- Update point coordinates ---*/
geometry[iMGlevel]->nodes->SetCoord_n();
geometry[iMGlevel]->nodes->SetCoord_n1();
}
}
}
/*--- Create the data structure for MPI point-to-point communications. ---*/
for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++)
geometry[iMGlevel]->PreprocessP2PComms(geometry[iMGlevel], config);
/*--- Perform a few preprocessing routines and communications. ---*/
for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) {
/*--- Compute the max length. ---*/
if (!fea) {
if ((rank == MASTER_NODE) && (iMGlevel == MESH_0))
cout << "Finding max control volume width." << endl;
geometry[iMGlevel]->SetMaxLength(config);
}
/*--- Communicate the number of neighbors. This is needed for
some centered schemes and for multigrid in parallel. ---*/
if ((rank == MASTER_NODE) && (size > SINGLE_NODE) && (iMGlevel == MESH_0))
cout << "Communicating number of neighbors." << endl;
geometry[iMGlevel]->InitiateComms(geometry[iMGlevel], config, NEIGHBORS);
geometry[iMGlevel]->CompleteComms(geometry[iMGlevel], config, NEIGHBORS);
}
}
void CDriver::InitializeGeometryDGFEM(CConfig* config, CGeometry **&geometry) {
/*--- Definition of the geometry class to store the primal grid in the partitioning process. ---*/
/*--- All ranks process the grid and call ParMETIS for partitioning ---*/
CGeometry *geometry_aux = new CPhysicalGeometry(config, iZone, nZone);
/*--- Set the dimension --- */
nDim = geometry_aux->GetnDim();
/*--- For the FEM solver with time-accurate local time-stepping, use
a dummy solver class to retrieve the initial flow state. ---*/
CSolver *solver_aux = new CFEM_DG_EulerSolver(config, nDim, MESH_0);
/*--- Color the initial grid and set the send-receive domains (ParMETIS) ---*/
geometry_aux->SetColorFEMGrid_Parallel(config);
/*--- Allocate the memory of the current domain, and divide the grid
between the ranks. ---*/
geometry = new CGeometry *[config->GetnMGLevels()+1] ();
geometry[MESH_0] = new CMeshFEM_DG(geometry_aux, config);
/*--- Deallocate the memory of geometry_aux and solver_aux ---*/
delete geometry_aux;
delete solver_aux;
/*--- Add the Send/Receive boundaries ---*/
geometry[MESH_0]->SetSendReceive(config);
/*--- Add the Send/Receive boundaries ---*/
geometry[MESH_0]->SetBoundaries(config);
/*--- Carry out a dynamic cast to CMeshFEM_DG, such that it is not needed to
define all virtual functions in the base class CGeometry. ---*/
auto *DGMesh = dynamic_cast<CMeshFEM_DG *>(geometry[MESH_0]);
/*--- Determine the standard elements for the volume elements. ---*/
if (rank == MASTER_NODE) cout << "Creating standard volume elements." << endl;
DGMesh->CreateStandardVolumeElements(config);
/*--- Create the face information needed to compute the contour integral
for the elements in the Discontinuous Galerkin formulation. ---*/
if (rank == MASTER_NODE) cout << "Creating face information." << endl;
DGMesh->CreateFaces(config);
/*--- Compute the metric terms of the volume elements. ---*/
if (rank == MASTER_NODE) cout << "Computing metric terms volume elements." << endl;
DGMesh->MetricTermsVolumeElements(config);
/*--- Compute the metric terms of the surface elements. ---*/
if (rank == MASTER_NODE) cout << "Computing metric terms surface elements." << endl;
DGMesh->MetricTermsSurfaceElements(config);
/*--- Compute a length scale of the volume elements. ---*/
if (rank == MASTER_NODE) cout << "Computing length scale volume elements." << endl;
DGMesh->LengthScaleVolumeElements();
/*--- Compute the coordinates of the integration points. ---*/
if (rank == MASTER_NODE) cout << "Computing coordinates of the integration points." << endl;
DGMesh->CoordinatesIntegrationPoints();
/*--- Compute the coordinates of the location of the solution DOFs. This is different
from the grid points when a different polynomial degree is used to represent the
geometry and solution. ---*/
if (rank == MASTER_NODE) cout << "Computing coordinates of the solution DOFs." << endl;
DGMesh->CoordinatesSolDOFs();
/*--- Perform the preprocessing tasks when wall functions are used. ---*/
if (rank == MASTER_NODE) cout << "Preprocessing for the wall functions. " << endl;
DGMesh->WallFunctionPreprocessing(config);
/*--- Store the global to local mapping. ---*/
if (rank == MASTER_NODE) cout << "Storing a mapping from global to local DOF index." << endl;
geometry[MESH_0]->SetGlobal_to_Local_Point();