-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathconfig.cpp
More file actions
1408 lines (1235 loc) · 69.3 KB
/
config.cpp
File metadata and controls
1408 lines (1235 loc) · 69.3 KB
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 config.cpp
* \brief Class for different Options in rtsn
* \author S. Schotthoefer
*
* Disclaimer: This class structure was copied and modifed with open source permission from SU2 v7.0.3 https://su2code.github.io/
*/
#ifdef IMPORT_MPI
#include <mpi.h>
#endif
#include "common/config.hpp"
#include "common/globalconstants.hpp"
#include "common/optionstructure.hpp"
#include "quadratures/quadraturebase.hpp"
#include "toolboxes/errormessages.hpp"
#include "toolboxes/textprocessingtoolbox.hpp"
// externals
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/stdout_sinks.h"
#include "spdlog/spdlog.h"
#include <filesystem>
#include <fstream>
using namespace std;
Config::Config( string case_filename ) {
/*--- Set the case name to the base config file name without extension ---*/
auto cwd = std::filesystem::current_path();
auto relPath = std::filesystem::relative( std::filesystem::path( case_filename ), cwd );
_fileName = relPath.filename().string();
_inputDir = cwd.string() + "/" + relPath.parent_path().string();
_baseConfig = true;
/*--- Store MPI rank and size ---*/
// TODO with MPI implementation
/*--- Initialize pointers to Null---*/
SetPointersNull();
/*--- Reading config options ---*/
SetConfigOptions();
/*--- Parsing the config file ---*/
SetConfigParsing( case_filename );
/*--- Set the default values for all of the options that weren't set ---*/
SetDefault();
/*--- Get the Mesh Value--- */
// val_nDim = GetnDim(Mesh_FileName, Mesh_FileFormat);
// TODO
/*--- Configuration file postprocessing ---*/
SetPostprocessing();
/*--- Configuration file boundaries/markers setting ---*/
// SetBoundary(); IDK how boundaries are implemented, but i think this should be treated here
/*--- Configuration file output ---*/
// if ((rank == MASTER_NODE))
SetOutput();
}
Config::~Config( void ) {
// Delete all introduced arrays!
// delete _option map values proberly
for( auto const& x : _optionMap ) {
delete x.second;
//_optionMap.erase( x.first );
}
}
// ---- Add Options ----
// Simple Options
void Config::AddBoolOption( const string name, bool& option_field, bool default_value ) {
// Check if the key is already in the map. If this fails, it is coder error
// and not user error, so throw.
assert( _optionMap.find( name ) == _optionMap.end() );
// Add this option to the list of all the options
_allOptions.insert( pair<string, bool>( name, true ) );
// Create the parser for a bool option with a reference to the option_field and the desired
// default value. This will take the string in the config file, convert it to a bool, and
// place that bool in the memory location specified by the reference.
OptionBase* val = new OptionBool( name, option_field, default_value );
// Create an association between the option name ("CFL") and the parser generated above.
// During configuration, the parsing script will get the option name, and use this map
// to find how to parse that option.
_optionMap.insert( pair<string, OptionBase*>( name, val ) );
}
void Config::AddDoubleOption( const string name, double& option_field, double default_value ) {
assert( _optionMap.find( name ) == _optionMap.end() );
_allOptions.insert( pair<string, bool>( name, true ) );
OptionBase* val = new OptionDouble( name, option_field, default_value );
_optionMap.insert( pair<string, OptionBase*>( name, val ) );
}
void Config::AddIntegerOption( const string name, int& option_field, int default_value ) {
assert( _optionMap.find( name ) == _optionMap.end() );
_allOptions.insert( pair<string, bool>( name, true ) );
OptionBase* val = new OptionInt( name, option_field, default_value );
_optionMap.insert( pair<string, OptionBase*>( name, val ) );
}
void Config::AddLongOption( const string name, long& option_field, long default_value ) {
assert( _optionMap.find( name ) == _optionMap.end() );
_allOptions.insert( pair<string, bool>( name, true ) );
OptionBase* val = new OptionLong( name, option_field, default_value );
_optionMap.insert( pair<string, OptionBase*>( name, val ) );
}
void Config::AddStringOption( const string name, string& option_field, string default_value ) {
assert( _optionMap.find( name ) == _optionMap.end() );
_allOptions.insert( pair<string, bool>( name, true ) );
OptionBase* val = new OptionString( name, option_field, default_value );
_optionMap.insert( pair<string, OptionBase*>( name, val ) );
}
void Config::AddUnsignedLongOption( const string name, unsigned long& option_field, unsigned long default_value ) {
assert( _optionMap.find( name ) == _optionMap.end() );
_allOptions.insert( pair<string, bool>( name, true ) );
OptionBase* val = new OptionULong( name, option_field, default_value );
_optionMap.insert( pair<string, OptionBase*>( name, val ) );
}
void Config::AddUnsignedShortOption( const string name, unsigned short& option_field, unsigned short default_value ) {
assert( _optionMap.find( name ) == _optionMap.end() );
_allOptions.insert( pair<string, bool>( name, true ) );
OptionBase* val = new OptionUShort( name, option_field, default_value );
_optionMap.insert( pair<string, OptionBase*>( name, val ) );
}
// enum types work differently than all of the others because there are a small number of valid
// string entries for the type. One must also provide a list of all the valid strings of that type.
template <class Tenum> void Config::AddEnumOption( const string name, Tenum& option_field, const map<string, Tenum>& enum_map, Tenum default_value ) {
assert( _optionMap.find( name ) == _optionMap.end() );
_allOptions.insert( pair<string, bool>( name, true ) );
OptionBase* val = new OptionEnum<Tenum>( name, enum_map, option_field, default_value );
_optionMap.insert( pair<string, OptionBase*>( name, val ) );
return;
}
// List Options
void Config::AddStringListOption( const string name, unsigned short& num_marker, std::vector<std::string>& option_field ) {
assert( _optionMap.find( name ) == _optionMap.end() );
_allOptions.insert( pair<string, bool>( name, true ) );
OptionBase* val = new OptionStringList( name, num_marker, option_field );
_optionMap.insert( pair<string, OptionBase*>( name, val ) );
}
void Config::AddDoubleListOption( const string name, unsigned short& num_marker, std::vector<double>& option_field ) {
assert( _optionMap.find( name ) == _optionMap.end() );
_allOptions.insert( pair<string, bool>( name, true ) );
OptionBase* val = new OptionDoubleList( name, num_marker, option_field );
_optionMap.insert( pair<string, OptionBase*>( name, val ) );
}
template <class Tenum>
void Config::AddEnumListOption( const std::string name,
unsigned short& input_size,
std::vector<Tenum>& option_field,
const map<std::string, Tenum>& enum_map ) {
input_size = 0;
assert( _optionMap.find( name ) == _optionMap.end() );
_allOptions.insert( pair<string, bool>( name, true ) );
OptionBase* val = new OptionEnumList<Tenum>( name, enum_map, option_field, input_size );
_optionMap.insert( pair<string, OptionBase*>( name, val ) );
}
// ---- Getter Functions ----
BOUNDARY_TYPE Config::GetBoundaryType( std::string name ) const {
for( unsigned i = 0; i < _boundaries.size(); ++i ) {
if( name == _boundaries[i].first ) return _boundaries[i].second;
}
return BOUNDARY_TYPE::INVALID;
}
// ---- Setter Functions ----
void Config::SetDefault() {
/*--- Set the default values for all of the options that weren't set ---*/
for( map<string, bool>::iterator iter = _allOptions.begin(); iter != _allOptions.end(); ++iter ) {
if( _optionMap[iter->first]->GetValue().size() == 0 ) _optionMap[iter->first]->SetDefault();
}
}
void Config::SetConfigOptions() {
/* BEGIN_CONFIG_OPTIONS */
/*! @par CONFIG_CATEGORY: Problem Definition \ingroup Config */
/*--- Options related to problem definition and partitioning ---*/
// File Structure related options
/*! @brief OUTPUT_DIR \n DESCRIPTION: Relative Directory of output files \n DEFAULT "/out" @ingroup Config.*/
AddStringOption( "OUTPUT_DIR", _outputDir, string( "/out" ) );
/*! @brief OUTPUT_FILE \n DESCRIPTION: Name of output file \n DEFAULT "output" @ingroup Config.*/
AddStringOption( "OUTPUT_FILE", _outputFile, string( "output" ) );
/*! @brief LOG_DIR \n DESCRIPTION: Relative Directory of log files \n DEFAULT "/out" @ingroup Config.*/
AddStringOption( "LOG_DIR", _logDir, string( "/out/logs" ) );
/*! @brief LOG_DIR \n DESCRIPTION: Name of log files \n DEFAULT "/out" @ingroup Config.*/
AddStringOption( "LOG_FILE", _logFileName, string( "use_date" ) );
/*! @brief MESH_FILE \n DESCRIPTION: Name of mesh file \n DEFAULT "" \ingroup Config.*/
AddStringOption( "MESH_FILE", _meshFile, string( "mesh.su2" ) );
/*! @brief MESH_FILE \n DESCRIPTION: Name of mesh file \n DEFAULT "" \ingroup Config.*/
AddStringOption( "CT_FILE", _ctFile, string( "/home/pia/kitrt/examples/meshes/phantom.png" ) );
/*! @brief FORCE_CONNECTIVITY_RECOMPUTE \n DESCRIPTION:If true, mesh recomputes connectivity instead of loading from file \n DEFAULT false
* \ingroup Config.*/
AddBoolOption( "FORCE_CONNECTIVITY_RECOMPUTE", _forcedConnectivityWrite, false );
/*! @brief RESTART_SOLUTION \n DESCRIPTION:If true, simulation loads a restart solution from file \n DEFAULT false
* \ingroup Config.*/
AddBoolOption( "LOAD_RESTART_SOLUTION", _loadrestartSolution, false );
AddUnsignedLongOption( "SAVE_RESTART_SOLUTION_FREQUENCY", _saveRestartSolutionFrequency, false );
// Quadrature relatated options
/*! @brief QUAD_TYPE \n DESCRIPTION: Type of Quadrature rule \n Options: see @link QUAD_NAME \endlink \n DEFAULT: QUAD_MonteCarlo
* \ingroup Config
*/
AddEnumOption( "QUAD_TYPE", _quadName, Quadrature_Map, QUAD_MonteCarlo );
/*!\brief QUAD_ORDER \n DESCRIPTION: Order of Quadrature rule \n DEFAULT 2 \ingroup Config.*/
AddUnsignedShortOption( "QUAD_ORDER", _quadOrder, 1 );
// Solver related options
/*! @brief HPC_SOLVER \n DESCRIPTION: If true, the SN Solver uses hpc implementation. \n DEFAULT false \ingroup Config */
AddBoolOption( "HPC_SOLVER", _HPC, false );
/*! @brief MAX_MOMENT_ORDER \n: DESCRIPTON: Specifies the maximal order of Moments for PN and SN Solver */
AddUnsignedShortOption( "MAX_MOMENT_SOLVER", _maxMomentDegree, 1 );
/*! @brief CFL \n DESCRIPTION: CFL number \n DEFAULT 1.0 @ingroup Config.*/
AddDoubleOption( "CFL_NUMBER", _CFL, 1.0 );
/*! @brief TIME_FINAL \n DESCRIPTION: Final time for simulation \n DEFAULT 1.0 @ingroup Config.*/
AddDoubleOption( "TIME_FINAL", _tEnd, 1.0 );
/*! @brief Problem \n DESCRIPTION: Type of problem setting \n DEFAULT PROBLEM_ElectronRT @ingroup Config.*/
AddEnumOption( "PROBLEM", _problemName, Problem_Map, PROBLEM_Linesource );
/*! @brief Solver \n DESCRIPTION: Solver used for problem \n DEFAULT SN_SOLVER @ingroup Config. */
AddEnumOption( "SOLVER", _solverName, Solver_Map, SN_SOLVER );
/*! @brief RECONS_ORDER \n DESCRIPTION: Reconstruction order for solver (spatial flux) \n DEFAULT 1 \ingroup Config.*/
AddUnsignedShortOption( "RECONS_ORDER", _reconsOrder, 1 );
/*! @brief CleanFluxMatrices \n DESCRIPTION: If true, very low entries (10^-10 or smaller) of the flux matrices will be set to zero,
* to improve floating point accuracy \n DEFAULT false \ingroup Config */
AddBoolOption( "CLEAN_FLUX_MATRICES", _cleanFluxMat, false );
/*! @brief Realizability Step for MN solver \n DESCRIPTION: If true, MN solvers use a realizability reconstruction step in each time step. Also
* applicable in regression sampling \n DEFAULT false \ingroup Config */
AddBoolOption( "REALIZABILITY_RECONSTRUCTION", _realizabilityRecons, false );
/*! @brief Runge Kutta Staes \n DESCRIPTION: Sets number of Runge Kutta Stages for time integration \n DEFAULT 1 \ingroup Config */
AddUnsignedShortOption( "TIME_INTEGRATION_ORDER", _rungeKuttaStages, 1 );
// Problem Related Options
/*! @brief MaterialDir \n DESCRIPTION: Relative Path to the data directory (used in the ICRU database class), starting from the directory of the
* cfg file . \n DEFAULT "../data/material/" \ingroup Config */
AddStringOption( "DATA_DIR", _dataDir, string( "../data/" ) );
/*! @brief HydogenFile \n DESCRIPTION: If the continuous slowing down approximation is used, this referes to the cross section file for hydrogen.
* . \n DEFAULT "h.dat" \ingroup Config */
AddStringOption( "HYDROGEN_FILE", _hydrogenFile, string( "ENDL_H.txt" ) );
/*! @brief OxygenFile \n DESCRIPTION: If the continuous slowing down approximation is used, this referes to the cross section file for oxygen.
* . \n DEFAULT "o.dat" \ingroup Config */
AddStringOption( "OXYGEN_FILE", _oxygenFile, string( "ENDL_O.txt" ) );
/*! @brief StoppingPowerFile \n DESCRIPTION: Only temporary added. \ingroup Config */
AddStringOption( "STOPPING_POWER_FILE", _stoppingPowerFile, string( "stopping_power.txt" ) );
/*! @brief SN_ALL_GAUSS_PTS \n DESCRIPTION: If true, the SN Solver uses all Gauss Quadrature Points for 2d. \n DEFAULT false \ingroup Config */
AddBoolOption( "SN_ALL_GAUSS_PTS", _allGaussPts, false );
// Linesource Testcase Options
/*! @brief SCATTER_COEFF \n DESCRIPTION: Sets the scattering coefficient for the Linesource test case. \n DEFAULT 1.0 \ingroup Config */
AddDoubleOption( "SCATTER_COEFF", _sigmaS, 1.0 );
// Checkerboard Testcase Options
/*! @brief SCATTER_COEFF \n DESCRIPTION: Sets the Source magnitude for the checkerboard testcase. \n DEFAULT 1.0 \ingroup Config */
AddDoubleOption( "SOURCE_MAGNITUDE", _magQ, 1.0 );
// CSD related options
/*! @brief MAX_ENERGY_CSD \n DESCRIPTION: Sets maximum energy for the CSD simulation.\n DEFAULT \ingroup Config */
AddDoubleOption( "MAX_ENERGY_CSD", _maxEnergyCSD, 5.0 );
// Lattice related options
/*! @brief LATTICE_DSGN_ABSORPTION_BLUE \n DESCRIPTION: Sets absorption rate for the blue blocks (absorption blocks) in the lattice test case. \n
* DEFAULT 10.0 \ingroup Config */
AddDoubleOption( "LATTICE_DSGN_ABSORPTION_BLUE", _dsgnAbsBlue, 10.0 );
/*! @brief LATTICE_DSGN_SCATTER_WHITE \n DESCRIPTION: Sets absorption rate for the white blocks (scattering blocks) in the lattice test case. \n
* DEFAULT 1.0 \ingroup Config */
AddDoubleOption( "LATTICE_DSGN_SCATTER_WHITE", _dsgnScatterWhite, 1.0 );
/*! @brief LATTICE_DSGN_ABSORPTION_INDIVIDUAL \n DESCRIPTION: Sets absorption rate all 7x7 blocks in the lattice test case. Order from upper left
* to lower right (row major). \n DEFAULT \ingroup Config */
AddDoubleListOption( "LATTICE_DSGN_ABSORPTION_INDIVIDUAL", _nDsgnAbsIndividual, _dsgnAbsIndividual );
/*! @brief LATTICE_DSGN_SCATTER_INDIVIDUAL \n DESCRIPTION: Sets scattering rate all 7x7 blocks in the lattice test case. Order from upper left to
* lower right (row major). \n DEFAULT \ingroup Config */
AddDoubleListOption( "LATTICE_DSGN_SCATTER_INDIVIDUAL", _nDsgnScatterIndividual, _dsgnScatterIndividual );
// Hohlraum related options
AddUnsignedShortOption( "N_SAMPLING_PTS_LINE_GREEN", _nProbingCellsLineGreenHohlraum, 4 );
AddDoubleOption( "POS_CENTER_X", _posCenterXHohlraum, 0.0 );
AddDoubleOption( "POS_CENTER_Y", _posCenterYHohlraum, 0.0 );
AddDoubleOption( "POS_RED_RIGHT_TOP", _posRedRightTop, 0.4 );
AddDoubleOption( "POS_RED_RIGHT_BOTTOM", _posRedRightBottom, -0.4 );
AddDoubleOption( "POS_RED_LEFT_TOP", _posRedLeftTop, 0.4 );
AddDoubleOption( "POS_RED_LEFT_BOTTOM", _posRedLeftBottom, -0.4 );
AddDoubleOption( "POS_BORDER_RED_LEFT", _posRedLeftBorder, -0.65 );
AddDoubleOption( "POS_BORDER_RED_RIGHT", _posRedRightBorder, 0.65 );
// Entropy related options
/*! @brief Entropy Functional \n DESCRIPTION: Entropy functional used for the MN_Solver \n DEFAULT QUADRTATIC @ingroup Config. */
AddEnumOption( "ENTROPY_FUNCTIONAL", _entropyName, Entropy_Map, QUADRATIC );
/*! @brief Optimizer Name \n DESCRIPTION: Optimizer used to determine the minimal Entropy reconstruction \n DEFAULT NEWTON \ingroup Config */
AddEnumOption( "ENTROPY_OPTIMIZER", _entropyOptimizerName, Optimizer_Map, NEWTON );
/*! @brief Sets Flag for dynamic ansatz for normalized mn entropy closure \n DESCRIPTION: True = enable ansatz, False = disable ansatz \n DEFAULT
* false \ingroup Config */
AddBoolOption( "ENTROPY_DYNAMIC_CLOSURE", _entropyDynamicClosure, true );
// Newton optimizer related options
/*! @brief Regularization Parameter \n DESCRIPTION: Regularization Parameter for the regularized entropy closure. Must not be negative \n DEFAULT
* 1e-2 \ingroup Config */
AddDoubleOption( "REGULARIZER_GAMMA", _regularizerGamma, 1e-2 );
/*! @brief Newton Optimizer Epsilon \n DESCRIPTION: Convergencce Epsilon for Newton Optimizer \n DEFAULT 1e-3 \ingroup Config */
AddDoubleOption( "NEWTON_EPSILON", _optimizerEpsilon, 0.001 );
/*! @brief Max Iter Newton Optmizers \n DESCRIPTION: Max number of newton iterations \n DEFAULT 10 \ingroup Config */
AddUnsignedLongOption( "NEWTON_ITER", _newtonIter, 1000 );
/*! @brief Step Size Newton Optmizers \n DESCRIPTION: Step size for Newton optimizer \n DEFAULT 10 \ingroup Config */
AddDoubleOption( "NEWTON_STEP_SIZE", _newtonStepSize, 1 );
/*! @brief Max Iter for line search in Newton Optmizers \n DESCRIPTION: Max number of line search iter for newton optimizer \n DEFAULT 10
* \ingroup Config */
AddUnsignedLongOption( "NEWTON_LINE_SEARCH_ITER", _newtonLineSearchIter, 1000 );
/*! @brief Newton Fast mode \n DESCRIPTION: If true, we skip the Newton optimizer for Quadratic entropy and set alpha = u \n DEFAULT false
* \ingroup Config */
AddBoolOption( "NEWTON_FAST_MODE", _newtonFastMode, false );
// Neural Entropy Closure options
/*! @brief Neural Model \n DESCRIPTION: Specifies the neural netwok architecture \n DEFAULT 11 (values: 11=input convex, 12 non-convex)
* \ingroup Config */
AddUnsignedShortOption( "NEURAL_MODEL_MK", _neuralModel, 11 );
/*! @brief Neural Model Gamma \n DESCRIPTION: Specifies regularization parameter for neural networks \n DEFAULT 0 (values: 0,1,2,3)
\ingroup Config */
AddUnsignedShortOption( "NEURAL_MODEL_GAMMA", _neuralGamma, 0 );
/*! @brief NEURAL_MODEL_ENFORCE_ROTATION_SYMMETRY \n DESCRIPTION: Flag to enforce rotational symmetry \n DEFAULT false \ingroup Config */
AddBoolOption( "NEURAL_MODEL_ENFORCE_ROTATION_SYMMETRY", _enforceNeuralRotationalSymmetry, false );
// Mesh related options
// Boundary Markers
/*!\brief BC_DIRICHLET\n DESCRIPTION: Dirichlet wall boundary marker(s) \ingroup Config*/
AddStringListOption( "BC_DIRICHLET", _nMarkerDirichlet, _MarkerDirichlet );
AddStringListOption( "BC_NEUMANN", _nMarkerNeumann, _MarkerNeumann );
AddUnsignedShortOption( "SPATIAL_DIM", _dim, 3 );
/*! @brief Scattering kernel \n DESCRIPTION: Describes used scattering kernel \n DEFAULT KERNEL_Isotropic \ingroup Config */
AddEnumOption( "KERNEL", _kernelName, Kernel_Map, KERNEL_Isotropic );
/*! @brief Spherical Basis \n DESCRIPTION: Describes the chosen set of basis functions for on the unit sphere (e.g. for Moment methods) \n DEFAULT
* SPHERICAL_HARMONICS \ingroup Config */
AddEnumOption( "SPHERICAL_BASIS", _sphericalBasisName, SphericalBasis_Map, SPHERICAL_HARMONICS );
// Output related options
/*! @brief Volume output \n DESCRIPTION: Describes output groups to write to vtk \ingroup Config */
AddEnumListOption( "VOLUME_OUTPUT", _nVolumeOutput, _volumeOutput, VolOutput_Map );
/*! @brief Volume output Frequency \n DESCRIPTION: Describes output write frequency \n DEFAULT 0 ,i.e. only last value \ingroup Config */
AddUnsignedShortOption( "VOLUME_OUTPUT_FREQUENCY", _volumeOutputFrequency, 0 );
/*! @brief Screen output \n DESCRIPTION: Describes screen output fields \ingroup Config */
AddEnumListOption( "SCREEN_OUTPUT", _nScreenOutput, _screenOutput, ScalarOutput_Map );
/*! @brief Screen output Frequency \n DESCRIPTION: Describes screen output write frequency \n DEFAULT 1 \ingroup Config */
AddUnsignedShortOption( "SCREEN_OUTPUT_FREQUENCY", _screenOutputFrequency, 1 );
/*! @brief History output \n DESCRIPTION: Describes history output fields \ingroup Config */
AddEnumListOption( "HISTORY_OUTPUT", _nHistoryOutput, _historyOutput, ScalarOutput_Map );
/*! @brief History output Frequency \n DESCRIPTION: Describes history output write frequency \n DEFAULT 1 \ingroup Config */
AddUnsignedShortOption( "HISTORY_OUTPUT_FREQUENCY", _historyOutputFrequency, 1 );
// Data generator related options
/*! @brief Choice of sampling method \n DESCRIPTION: Choose between creating a regression and a classification dataset. \ingroup Config */
AddEnumOption( "SAMPLER_NAME", _sampler, SamplerName_MAP, REGRESSION_SAMPLER );
/*! @brief Size of training data set \n DESCRIPTION: Size of training data set \n DEFAULT 1 \ingroup Config */
AddUnsignedLongOption( "TRAINING_SET_SIZE", _tainingSetSize, 1 );
/*! @brief Determines, if TRAINING_SET_SIZE is counted by dimension \n DESCRIPTION: Determines, if TRAINING_SET_SIZE is counted by dimension \n
* DEFAULT true \ingroup Config */
AddBoolOption( "SIZE_BY_DIMENSION", _sizeByDimension, true );
/*! @brief Size of training data set \n DESCRIPTION: Size of training data set \n DEFAULT 10 \ingroup Config */
AddUnsignedLongOption( "MAX_VALUE_FIRST_MOMENT", _maxValFirstMoment, 10 );
/*! @brief Data generator mode \n DESCRIPTION: Check, if data generator mode is active. If yes, no solver is called, but instead the data
* generator is executed \n DEFAULT false \ingroup Config */
AddBoolOption( "DATA_GENERATOR_MODE", _dataGeneratorMode, false );
/*! @brief Distance to 0 of the sampled moments to the boundary of the realizable set \n DESCRIPTION: Distance to the boundary of the
* realizable set \n DEFAULT 0.1 \ingroup Config */
AddDoubleOption( "REALIZABLE_SET_EPSILON_U0", _RealizableSetEpsilonU0, 0.1 );
/*! @brief norm(u_1)/u_0 is enforced to be smaller than _RealizableSetEpsilonU1 \n DESCRIPTION: Distance to the boundary of the realizable set \n
* DEFAULT 0.1 \ingroup Config */
AddDoubleOption( "REALIZABLE_SET_EPSILON_U1", _RealizableSetEpsilonU1, 0.9 );
/*! @brief Flag for sampling of normalized moments, i.e. u_0 =1 \n DESCRIPTION: Flag for sampling of normalized moments, i.e. u_0 =1 \n
* DEFAULT False \ingroup Config */
AddBoolOption( "NORMALIZED_SAMPLING", _normalizedSampling, false );
/*! @brief Flag for sampling the space of Legendre multipliers instead of the moments \n DESCRIPTION: Sample alpha instead of u \n DEFAULT False
* \ingroup Config */
AddBoolOption( "ALPHA_SAMPLING", _alphaSampling, false );
/*! @brief Switch for sampling distribution \n DESCRIPTION: Uniform (true) or trunctaded normal (false) \n DEFAULT true
* \ingroup Config */
AddBoolOption( "UNIFORM_SAMPLING", _sampleUniform, true );
/*! @brief Boundary for the sampling region of the Lagrange multipliers \n DESCRIPTION: Norm sampling boundary for alpha \n DEFAULT 20.0
* \ingroup Config */
AddDoubleOption( "ALPHA_SAMPLING_BOUND", _alphaBound, 20.0 );
/*! @brief Rejection sampling threshold based on the minimal Eigenvalue of the Hessian of the entropy functions \n DESCRIPTION: Rejection
* sampling threshold \n DEFAULT 1e-8 \ingroup Config */
AddDoubleOption( "MIN_EIGENVALUE_THRESHOLD", _minEVAlphaSampling, 1e-8 );
/*! @brief Boundary for the velocity integral \n DESCRIPTION: Upper boundary for the velocity integral \n DEFAULT 5.0 * \ingroup Config */
AddDoubleOption( "MAX_VELOCITY", _maxSamplingVelocity, 5.0 );
///*! @brief Boundary for the velocity integral \n DESCRIPTION: Lower boundary for the velocity integral \n DEFAULT 5.0 * \ingroup Config */
// AddDoubleOption( "MIN_VELOCITY", _minSamplingVelocity, -5.0 );
/*! @brief Boundary for the sampling temperature \n DESCRIPTION: Upper boundary for the sampling temperature \n DEFAULT 1.0 * \ingroup Config */
AddDoubleOption( "MAX_TEMPERATURE", _maxSamplingTemperature, 1 );
/*! @brief Boundary for the sampling temperature \n DESCRIPTION: Lower boundary for the sampling temperature \n DEFAULT 0.1 * \ingroup Config */
AddDoubleOption( "MIN_TEMPERATURE", _minSamplingTemperature, 0.1 );
/*! @brief Number of temperature samples \n DESCRIPTION: Number of temperature samples for the sampler \n DEFAULT 10 * \ingroup Config */
AddUnsignedShortOption( "N_TEMPERATURES", _nTemperatures, 10 );
}
void Config::SetConfigParsing( string case_filename ) {
string text_line, option_name;
ifstream case_file;
vector<string> option_value;
/*--- Read the configuration file ---*/
case_file.open( case_filename, ios::in );
if( case_file.fail() ) {
ErrorMessages::Error( "The configuration file (.cfg) is missing!!", CURRENT_FUNCTION );
}
string errorString;
int err_count = 0; // How many errors have we found in the config file
int max_err_count = 30; // Maximum number of errors to print before stopping
map<string, bool> included_options;
/*--- Parse the configuration file and set the options ---*/
while( getline( case_file, text_line ) ) {
if( err_count >= max_err_count ) {
errorString.append( "too many errors. Stopping parse" );
cout << errorString << endl;
throw( 1 );
}
if( TokenizeString( text_line, option_name, option_value ) ) {
/*--- See if it's a python option ---*/
if( _optionMap.find( option_name ) == _optionMap.end() ) {
string newString;
newString.append( option_name );
newString.append( ": invalid option name" );
newString.append( ". Check current KiT-RT options in config_template.cfg." );
newString.append( "\n" );
errorString.append( newString );
err_count++;
continue;
}
/*--- Option exists, check if the option has already been in the config file ---*/
if( included_options.find( option_name ) != included_options.end() ) {
string newString;
newString.append( option_name );
newString.append( ": option appears twice" );
newString.append( "\n" );
errorString.append( newString );
err_count++;
continue;
}
/*--- New found option. Add it to the map, and delete from all options ---*/
included_options.insert( pair<string, bool>( option_name, true ) );
_allOptions.erase( option_name );
/*--- Set the value and check error ---*/
string out = _optionMap[option_name]->SetValue( option_value );
if( out.compare( "" ) != 0 ) {
errorString.append( out );
errorString.append( "\n" );
err_count++;
}
}
}
/*--- See if there were any errors parsing the config file ---*/
if( errorString.size() != 0 ) {
ErrorMessages::ParsingError( errorString, CURRENT_FUNCTION );
}
case_file.close();
}
void Config::SetPointersNull( void ) {
// All pointer valued options should be set to NULL here
}
void Config::SetPostprocessing() {
// append '/' to all dirs to allow for simple path addition
if( _logDir[_logDir.size() - 1] != '/' ) _logDir.append( "/" );
if( _outputDir[_outputDir.size() - 1] != '/' ) _outputDir.append( "/" );
if( _inputDir[_inputDir.size() - 1] != '/' ) _inputDir.append( "/" );
// setup relative paths
_logDir = std::filesystem::path( _inputDir ).append( _logDir ).lexically_normal();
_outputDir = std::filesystem::path( _inputDir ).append( _outputDir ).lexically_normal();
_meshFile = std::filesystem::path( _inputDir ).append( _meshFile ).lexically_normal();
_outputFile = std::filesystem::path( _outputDir ).append( _outputFile ).lexically_normal();
_ctFile = std::filesystem::path( _inputDir ).append( _ctFile ).lexically_normal();
_hydrogenFile = std::filesystem::path( _inputDir ).append( _hydrogenFile ).lexically_normal();
_oxygenFile = std::filesystem::path( _inputDir ).append( _oxygenFile ).lexically_normal();
_stoppingPowerFile = std::filesystem::path( _inputDir ).append( _stoppingPowerFile ).lexically_normal();
_dataDir = std::filesystem::path( _inputDir ).append( _dataDir ).lexically_normal();
// create directories if they dont exist
if( !std::filesystem::exists( _outputDir ) ) std::filesystem::create_directories( _outputDir );
// init logger
InitLogger();
// Regroup Boundary Conditions to std::vector<std::pair<std::string, BOUNDARY_TYPE>> _boundaries;
for( int i = 0; i < _nMarkerDirichlet; i++ ) {
_boundaries.push_back( std::pair<std::string, BOUNDARY_TYPE>( _MarkerDirichlet[i], DIRICHLET ) );
}
for( int i = 0; i < _nMarkerNeumann; i++ ) {
_boundaries.push_back( std::pair<std::string, BOUNDARY_TYPE>( _MarkerNeumann[i], NEUMANN ) );
}
// Set option ISCSD
switch( _solverName ) {
case CSD_SN_SOLVER: // Fallthrough
case CSD_PN_SOLVER: // Fallthrough
case CSD_MN_SOLVER: // Fallthrough
_csd = true;
break;
default: _csd = false;
}
// Set option MomentSolver
switch( _solverName ) {
case MN_SOLVER:
case MN_SOLVER_NORMALIZED:
case CSD_MN_SOLVER:
case PN_SOLVER:
case CSD_PN_SOLVER: _isMomentSolver = true; break;
default: _isMomentSolver = false;
}
// Quadrature Postprocessing
{
QuadratureBase* quad = QuadratureBase::Create( this );
std::vector<unsigned short> supportedDims = quad->GetSupportedDims();
if( std::find( supportedDims.begin(), supportedDims.end(), _dim ) == supportedDims.end() ) {
// Dimension not supported
std::string msg = "Chosen spatial dimension not supported for this Quadrature.\nChosen spatial dimension " + std::to_string( _dim ) + ".";
ErrorMessages::Error( msg, CURRENT_FUNCTION );
}
delete quad;
}
// Optimizer Postprocessing
{
if( ( _entropyOptimizerName == REDUCED_NEWTON || _entropyOptimizerName == REDUCED_PART_REGULARIZED_NEWTON ) &&
_entropyName != MAXWELL_BOLTZMANN ) {
std::string msg = "Reduction of the optimization problen only possible with Maxwell Boltzmann Entropy" + std::to_string( _dim ) + ".";
ErrorMessages::Error( msg, CURRENT_FUNCTION );
}
}
// --- Solver setup ---
{
if( GetSolverName() == PN_SOLVER && GetSphericalBasisName() != SPHERICAL_HARMONICS ) {
ErrorMessages::Error(
"PN Solver only works with spherical harmonics basis.\nThis should be the default setting for option SPHERICAL_BASIS.",
CURRENT_FUNCTION );
}
if( GetSolverName() == CSD_MN_SOLVER && GetSphericalBasisName() != SPHERICAL_HARMONICS ) {
ErrorMessages::Error( "CSD_MN_SOLVER only works with Spherical Harmonics currently.", CURRENT_FUNCTION );
}
if( GetSpatialOrder() > 2 ) {
ErrorMessages::Error( "Solvers only work with 1st and 2nd order spatial fluxes.", CURRENT_FUNCTION );
}
if( GetOptimizerName() == ML && GetSolverName() != MN_SOLVER_NORMALIZED ) {
ErrorMessages::Error( "ML Optimizer only works with normalized MN Solver.", CURRENT_FUNCTION );
}
if( GetSolverName() == PN_SOLVER || GetSolverName() == CSD_PN_SOLVER ) {
_dim = 3;
auto log = spdlog::get( "event" );
auto logCSV = spdlog::get( "tabular" );
log->info(
"| Spherical harmonics based solver currently use 3D Spherical functions and a projection. Thus spatial dimension is set to 3." );
logCSV->info(
"| Spherical harmonics based solver currently use 3D Spherical functions and a projection. Thus spatial dimension is set to 3." );
}
}
// --- Output Postprocessing ---
// Volume Output Postprocessing
{
// Check for doublicates in VOLUME OUTPUT
std::map<VOLUME_OUTPUT, int> dublicate_map;
for( unsigned short idx_volOutput = 0; idx_volOutput < _nVolumeOutput; idx_volOutput++ ) {
std::map<VOLUME_OUTPUT, int>::iterator it = dublicate_map.find( _volumeOutput[idx_volOutput] );
if( it == dublicate_map.end() ) {
dublicate_map.insert( std::pair<VOLUME_OUTPUT, int>( _volumeOutput[idx_volOutput], 0 ) );
}
else {
it->second++;
}
}
for( auto& e : dublicate_map ) {
if( e.second > 0 ) {
ErrorMessages::Error( "Each output group for option VOLUME_OUTPUT can only be set once.\nPlease check your .cfg file.",
CURRENT_FUNCTION );
}
}
// Check, if the choice of volume output is compatible to the solver
std::vector<VOLUME_OUTPUT> supportedGroups;
for( unsigned short idx_volOutput = 0; idx_volOutput < _nVolumeOutput; idx_volOutput++ ) {
switch( _solverName ) {
case SN_SOLVER:
if( _problemName == PROBLEM_Linesource )
supportedGroups = { MINIMAL, ANALYTIC };
else {
supportedGroups = { MINIMAL };
if( _HPC ) supportedGroups = { MINIMAL, MOMENTS };
}
if( supportedGroups.end() == std::find( supportedGroups.begin(), supportedGroups.end(), _volumeOutput[idx_volOutput] ) ) {
ErrorMessages::Error(
"SN_SOLVER only supports volume output MINIMAL and ANALYTIC (and experimentally MOMENTS).\nPlease check your .cfg file.",
CURRENT_FUNCTION );
}
if( _volumeOutput[idx_volOutput] == ANALYTIC && _problemName != PROBLEM_Linesource ) {
ErrorMessages::Error( "Analytical solution (VOLUME_OUTPUT=ANALYTIC) is only available for the PROBLEM=LINESOURCE.\nPlease "
"check your .cfg file.",
CURRENT_FUNCTION );
}
break;
case MN_SOLVER: // Fallthrough
case MN_SOLVER_NORMALIZED:
if( _problemName == PROBLEM_SymmetricHohlraum )
supportedGroups = { MINIMAL, MOMENTS, DUAL_MOMENTS };
else if( _problemName == PROBLEM_Linesource )
supportedGroups = { MINIMAL, ANALYTIC, MOMENTS, DUAL_MOMENTS };
else
supportedGroups = { MINIMAL, MOMENTS, DUAL_MOMENTS };
if( supportedGroups.end() == std::find( supportedGroups.begin(), supportedGroups.end(), _volumeOutput[idx_volOutput] ) ) {
std::string supportedGroupStr = "";
for( unsigned i = 0; i < supportedGroups.size(); i++ ) {
supportedGroupStr += findKey( VolOutput_Map, supportedGroups[i] ) + ", ";
}
ErrorMessages::Error( "MN_SOLVER supports volume outputs" + supportedGroupStr + ".\nPlease check your .cfg file.",
CURRENT_FUNCTION );
}
break;
case PN_SOLVER:
supportedGroups = { MINIMAL, MOMENTS, ANALYTIC };
if( supportedGroups.end() == std::find( supportedGroups.begin(), supportedGroups.end(), _volumeOutput[idx_volOutput] ) ) {
ErrorMessages::Error( "PN_SOLVER only supports volume output ANALYTIC, MINIMAL and MOMENTS.\nPlease check your .cfg file.",
CURRENT_FUNCTION );
}
if( _volumeOutput[idx_volOutput] == ANALYTIC && _problemName != PROBLEM_Linesource ) {
ErrorMessages::Error( "Analytical solution (VOLUME_OUTPUT=ANALYTIC) is only available for the PROBLEM=LINESOURCE.\nPlease "
"check your .cfg file.",
CURRENT_FUNCTION );
}
break;
case CSD_SN_SOLVER:
supportedGroups = { MINIMAL, MEDICAL };
if( supportedGroups.end() == std::find( supportedGroups.begin(), supportedGroups.end(), _volumeOutput[idx_volOutput] ) ) {
ErrorMessages::Error( "CSD_SN_SOLVER types only supports volume output MEDICAL and MINIMAL.\nPlease check your .cfg file.",
CURRENT_FUNCTION );
}
break;
case CSD_PN_SOLVER:
supportedGroups = { MINIMAL, MEDICAL, MOMENTS };
if( supportedGroups.end() == std::find( supportedGroups.begin(), supportedGroups.end(), _volumeOutput[idx_volOutput] ) ) {
ErrorMessages::Error(
"CSD_PN_SOLVER types only supports volume output MEDICAL, MOMENTS and MINIMAL.\nPlease check your .cfg file.",
CURRENT_FUNCTION );
}
break;
case CSD_MN_SOLVER:
supportedGroups = { MINIMAL, MEDICAL, MOMENTS, DUAL_MOMENTS };
if( supportedGroups.end() == std::find( supportedGroups.begin(), supportedGroups.end(), _volumeOutput[idx_volOutput] ) ) {
ErrorMessages::Error( "CSD_MN_SOLVER types only supports volume output MEDICAL, MOMENTS, DUAL_MOMENTS and MINIMAL.\nPlease "
"check your .cfg file.",
CURRENT_FUNCTION );
}
break;
default:
ErrorMessages::Error( "Solver output check not implemented for this Solver.\nThis is the fault of the coder.", CURRENT_FUNCTION );
}
}
// Set default volume output
if( _nVolumeOutput == 0 ) { // If no specific output is chosen, use "MINIMAL"
_nVolumeOutput = 1;
_volumeOutput.push_back( MINIMAL );
}
}
// Screen Output Postprocessing
{
// Check for doublicates in SCALAR OUTPUT
std::map<SCALAR_OUTPUT, int> dublicate_map;
for( unsigned short idx_screenOutput = 0; idx_screenOutput < _nScreenOutput; idx_screenOutput++ ) {
std::map<SCALAR_OUTPUT, int>::iterator it = dublicate_map.find( _screenOutput[idx_screenOutput] );
if( it == dublicate_map.end() ) {
dublicate_map.insert( std::pair<SCALAR_OUTPUT, int>( _screenOutput[idx_screenOutput], 0 ) );
}
else {
it->second++;
}
}
for( auto& e : dublicate_map ) {
if( e.second > 0 ) {
ErrorMessages::Error( "Each output field for option SCREEN_OUTPUT can only be set once.\nPlease check your .cfg file.",
CURRENT_FUNCTION );
}
}
// Check if the choice of screen output is compatible to the problem
for( unsigned short idx_screenOutput = 0; idx_screenOutput < _nScreenOutput; idx_screenOutput++ ) {
std::vector<SCALAR_OUTPUT> legalOutputs;
std::vector<SCALAR_OUTPUT>::iterator it;
switch( _problemName ) {
case PROBLEM_HalfLattice:
case PROBLEM_Lattice:
legalOutputs = { ITER,
WALL_TIME,
SIM_TIME,
MASS,
RMS_FLUX,
VTK_OUTPUT,
CSV_OUTPUT,
CUR_OUTFLOW,
TOTAL_OUTFLOW,
CUR_OUTFLOW_P1,
TOTAL_OUTFLOW_P1,
CUR_OUTFLOW_P2,
TOTAL_OUTFLOW_P2,
MAX_OUTFLOW,
CUR_PARTICLE_ABSORPTION,
TOTAL_PARTICLE_ABSORPTION,
MAX_PARTICLE_ABSORPTION };
it = std::find( legalOutputs.begin(), legalOutputs.end(), _screenOutput[idx_screenOutput] );
if( it == legalOutputs.end() ) {
std::string foundKey = findKey( ScalarOutput_Map, _screenOutput[idx_screenOutput] );
ErrorMessages::Error(
"Illegal output field <" + foundKey +
"> for option SCREEN_OUTPUT for this test case.\n"
"Supported fields are: ITER, SIM_TIME, WALL_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, FINAL_TIME_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW, "
"FINAL_TIME_PARTICLE_ABSORPTION, TOTAL_PARTICLE_ABSORPTION, MAX_PARTICLE_ABSORPTION\n"
"Please check your .cfg file.",
CURRENT_FUNCTION );
}
break;
case PROBLEM_QuarterHohlraum:
case PROBLEM_SymmetricHohlraum:
legalOutputs = {
ITER,
SIM_TIME,
WALL_TIME,
MASS,
RMS_FLUX,
VTK_OUTPUT,
CSV_OUTPUT,
CUR_OUTFLOW,
TOTAL_OUTFLOW,
MAX_OUTFLOW,
TOTAL_PARTICLE_ABSORPTION_CENTER,
TOTAL_PARTICLE_ABSORPTION_VERTICAL,
TOTAL_PARTICLE_ABSORPTION_HORIZONTAL,
TOTAL_PARTICLE_ABSORPTION,
PROBE_MOMENT_TIME_TRACE,
VAR_ABSORPTION_GREEN,
AVG_ABSORPTION_GREEN_BLOCK_INTEGRATED,
VAR_ABSORPTION_GREEN_BLOCK_INTEGRATED,
};
it = std::find( legalOutputs.begin(), legalOutputs.end(), _screenOutput[idx_screenOutput] );
if( it == legalOutputs.end() ) {
std::string foundKey = findKey( ScalarOutput_Map, _screenOutput[idx_screenOutput] );
ErrorMessages::Error(
"Illegal output field <" + foundKey +
"> for option SCREEN_OUTPUT for this test case.\n"
"Supported fields are: ITER, SIM_TIME, WALL_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, TOTAL_PARTICLE_ABSORPTION_CENTER, \n"
"TOTAL_PARTICLE_ABSORPTION_VERTICAL, TOTAL_PARTICLE_ABSORPTION_HORIZONTAL, PROBE_MOMENT_TIME_TRACE, CUR_OUTFLOW, \n "
"TOTAL_OUTFLOW, MAX_OUTFLOW, VAR_ABSORPTION_GREEN, AVG_ABSORPTION_GREEN_BLOCK_INTEGRATED, "
"VAR_ABSORPTION_GREEN_BLOCK_INTEGRATED \n"
"Please check your .cfg file.",
CURRENT_FUNCTION );
}
break;
default:
legalOutputs = { ITER, SIM_TIME, WALL_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW };
it = std::find( legalOutputs.begin(), legalOutputs.end(), _screenOutput[idx_screenOutput] );
if( it == legalOutputs.end() ) {
std::string foundKey = findKey( ScalarOutput_Map, _screenOutput[idx_screenOutput] );
ErrorMessages::Error(
"Illegal output field <" + foundKey +
"> for option SCREEN_OUTPUT for this test case.\n"
"Supported fields are: ITER, SIM_TIME, WALL_TIME, MASS RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW \n"
"Please check your .cfg file.",
CURRENT_FUNCTION );
}
break;
}
}
// Set ITER always to index 0 . Assume only one instance of iter is chosen
if( _nScreenOutput > 0 ) {
std::vector<SCALAR_OUTPUT>::iterator it;
it = find( _screenOutput.begin(), _screenOutput.end(), ITER );
_screenOutput.erase( it );
_screenOutput.insert( _screenOutput.begin(), ITER );
}
// Set default screen output
if( _nScreenOutput == 0 ) {
_nScreenOutput = 4;
_screenOutput.push_back( ITER );
_screenOutput.push_back( RMS_FLUX );
_screenOutput.push_back( MASS );
_screenOutput.push_back( VTK_OUTPUT );
}
// Postprocessing for probing moments in symmetric Hohlraum. Make it four outputs
if( _problemName == PROBLEM_SymmetricHohlraum ) {
std::vector<SCALAR_OUTPUT>::iterator it;
it = find( _screenOutput.begin(), _screenOutput.end(), PROBE_MOMENT_TIME_TRACE );
if( it != _screenOutput.end() ) {
_screenOutput.erase( it );
_nScreenOutput += 3; // extend the screen output by the number of probing points
for( unsigned i = 0; i < 4; i++ ) _screenOutput.push_back( PROBE_MOMENT_TIME_TRACE );
}
}
if( _problemName == PROBLEM_QuarterHohlraum ) {
std::vector<SCALAR_OUTPUT>::iterator it;
it = find( _screenOutput.begin(), _screenOutput.end(), PROBE_MOMENT_TIME_TRACE );
if( it != _screenOutput.end() ) {
_screenOutput.erase( it );
_nScreenOutput += 1; // extend the screen output by the number of probing points
for( unsigned i = 0; i < 2; i++ ) _screenOutput.push_back( PROBE_MOMENT_TIME_TRACE );
}
}
}
// History Output Postprocessing
{
// Check for doublicates in HISTORY OUTPUT
std::map<SCALAR_OUTPUT, int> dublicate_map;
for( unsigned idx_historyOutput = 0; idx_historyOutput < _nHistoryOutput; idx_historyOutput++ ) {
std::map<SCALAR_OUTPUT, int>::iterator it = dublicate_map.find( _historyOutput[idx_historyOutput] );
if( it == dublicate_map.end() ) {
dublicate_map.insert( std::pair<SCALAR_OUTPUT, int>( _historyOutput[idx_historyOutput], 0 ) );
}
else {
it->second++;
}
}
for( auto& e : dublicate_map ) {
if( e.second > 0 ) {
ErrorMessages::Error( "Each output field for option HISTORY_OUTPUT can only be set once.\nPlease check your .cfg file.",
CURRENT_FUNCTION );
}
}
// Check if the choice of history output is compatible to the problem
for( unsigned short idx_historyOutput = 0; idx_historyOutput < _nHistoryOutput; idx_historyOutput++ ) {
std::vector<SCALAR_OUTPUT> legalOutputs;
std::vector<SCALAR_OUTPUT>::iterator it;
switch( _problemName ) {
case PROBLEM_HalfLattice:
case PROBLEM_Lattice:
legalOutputs = { ITER,
WALL_TIME,
SIM_TIME,
MASS,
RMS_FLUX,
VTK_OUTPUT,
CSV_OUTPUT,
CUR_OUTFLOW,
TOTAL_OUTFLOW,
CUR_OUTFLOW_P1,
TOTAL_OUTFLOW_P1,
CUR_OUTFLOW_P2,
TOTAL_OUTFLOW_P2,
MAX_OUTFLOW,
CUR_PARTICLE_ABSORPTION,
TOTAL_PARTICLE_ABSORPTION,
MAX_PARTICLE_ABSORPTION };
it = std::find( legalOutputs.begin(), legalOutputs.end(), _historyOutput[idx_historyOutput] );
if( it == legalOutputs.end() ) {
std::string foundKey = findKey( ScalarOutput_Map, _historyOutput[idx_historyOutput] );
ErrorMessages::Error(
"Illegal output field <" + foundKey +
"> for option HISTORY_OUTPUT for this test case.\n"
"Supported fields are: ITER, SIM_TIME, WALL_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, FINAL_TIME_OUTFLOW,\n"
"TOTAL_OUTFLOW, MAX_OUTFLOW, FINAL_TIME_PARTICLE_ABSORPTION, TOTAL_PARTICLE_ABSORPTION, MAX_PARTICLE_ABSORPTION\n"
"Please check your .cfg file.",
CURRENT_FUNCTION );
}
break;
case PROBLEM_QuarterHohlraum:
case PROBLEM_SymmetricHohlraum:
legalOutputs = { ITER,
WALL_TIME,
SIM_TIME,
MASS,
RMS_FLUX,
VTK_OUTPUT,
CSV_OUTPUT,
CUR_OUTFLOW,
TOTAL_OUTFLOW,
MAX_OUTFLOW,
TOTAL_PARTICLE_ABSORPTION_CENTER,
TOTAL_PARTICLE_ABSORPTION_VERTICAL,
TOTAL_PARTICLE_ABSORPTION_HORIZONTAL,
TOTAL_PARTICLE_ABSORPTION,
PROBE_MOMENT_TIME_TRACE,
VAR_ABSORPTION_GREEN,
ABSORPTION_GREEN_BLOCK,
AVG_ABSORPTION_GREEN_BLOCK_INTEGRATED,
VAR_ABSORPTION_GREEN_BLOCK_INTEGRATED,
ABSORPTION_GREEN_LINE };
it = std::find( legalOutputs.begin(), legalOutputs.end(), _historyOutput[idx_historyOutput] );
if( it == legalOutputs.end() ) {
std::string foundKey = findKey( ScalarOutput_Map, _historyOutput[idx_historyOutput] );
ErrorMessages::Error(
"Illegal output field <" + foundKey +
"> for option HISTORY_OUTPUT for this test case.\n"
"Supported fields are: ITER, SIM_TIME, WALL_TIME, MASS RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, TOTAL_PARTICLE_ABSORPTION_CENTER, \n "
"TOTAL_PARTICLE_ABSORPTION_VERTICAL, TOTAL_PARTICLE_ABSORPTION_HORIZONTAL,PROBE_MOMENT_TIME_TRACE, CUR_OUTFLOW, \n"
"TOTAL_OUTFLOW, MAX_OUTFLOW , VAR_ABSORPTION_GREEN, ABSORPTION_GREEN_BLOCK, "
"AVG_ABSORPTION_GREEN_BLOCK_INTEGRATED, VAR_ABSORPTION_GREEN_BLOCK_INTEGRATED, ABSORPTION_GREEN_LINE \n"
"Please check your .cfg file.",
CURRENT_FUNCTION );
}
break;
default:
legalOutputs = { ITER, WALL_TIME, SIM_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW };
it = std::find( legalOutputs.begin(), legalOutputs.end(), _historyOutput[idx_historyOutput] );
if( it == legalOutputs.end() ) {
std::string foundKey = findKey( ScalarOutput_Map, _historyOutput[idx_historyOutput] );
ErrorMessages::Error(
"Illegal output field <" + foundKey +
"> for option SCREEN_OUTPUT for this test case.\n"
"Supported fields are: ITER, SIM_TIME, WALL_TIME, MASS RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW \n"
"Please check your .cfg file.",
CURRENT_FUNCTION );
}
break;
}
}
// Set ITER always to index 0 . Assume only one instance of iter is chosen