-
Notifications
You must be signed in to change notification settings - Fork 16
/
GlobalUtilities.cpp
1335 lines (1228 loc) · 44.3 KB
/
GlobalUtilities.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
// ---------------------------------------------------------------
// GlobalUtilities.cpp
// ---------------------------------------------------------------
#include <GlobalUtilities.H>
#include <AMReX_FArrayBox.H>
#include <AMReX_FabConv.H>
#include <AMReX_VisMF.H>
#include <fstream>
#include <iostream>
using std::ifstream;
using std::ofstream;
using std::cout;
using std::cerr;
using std::endl;
#include <PltApp.H>
#include <AMReX_ParallelDescriptor.H>
extern void PrintProfParserBatchUsage(std::ostream &os);
using namespace amrex;
const int DEFAULTMAXPICTURESIZE = 600000;
int boundaryWidth;
int skipPltLines;
int boxColor;
int maxPictureSize;
Amrvis::FileType fileType;
bool bAnimation;
bool bAnnotated;
bool bCacheAnimFrames;
Vector<string> comlinefilename;
string initialDerived;
string initialFormat;
string initialPalette;
string initialLightingFile;
bool startWithValueModel;
int fileCount;
int sleepTime;
bool givenBox;
bool givenBoxSlice;
bool createSWFData;
bool makeSWFLight;
bool lowBlack;
bool usePerStreams;
bool dumpSlices;
bool sliceAllVars;
bool givenFilename;
Box comlinebox;
bool verbose;
Vector< std::list<int> > dumpSliceList;
bool specifiedMinMax;
Real specifiedMin;
Real specifiedMax;
bool useMaxLevel(false);
int maxLevel(-1);
int maxPaletteIndex;
bool SGIrgbfile(false);
int fabIOSize;
bool bShowBody(true);
Real bodyOpacity(0.05);
bool givenInitialPlanes(false);
IntVect ivInitialPlanes;
bool givenInitialPlanesReal(false);
Vector< Real > ivInitialPlanesReal;
AVGlobals::ENUserVectorNames givenUserVectorNames(AVGlobals::enUserNone);
Vector<string> userVectorNames(BL_SPACEDIM);
bool newPltSet(false);
const char *FileTypeString[] = {
"invalidtype", "fab", "multifab", "newplt", "profdata"
};
// -------------------------------------------------------------------
const AVGlobals::ENUserVectorNames &AVGlobals::GivenUserVectorNames() {
return givenUserVectorNames;
}
// -------------------------------------------------------------------
const Vector<string> &AVGlobals::UserVectorNames() {
return userVectorNames;
}
// -------------------------------------------------------------------
const string &AVGlobals::GetInitialDerived() {
return initialDerived;
}
// -------------------------------------------------------------------
void AVGlobals::SetInitialDerived(const string &initialderived) {
initialDerived = initialderived;
}
// -------------------------------------------------------------------
const string &AVGlobals::GetPaletteName() {
return initialPalette;
}
// -------------------------------------------------------------------
const string &AVGlobals::GetLightingFileName() {
return initialLightingFile;
}
// -------------------------------------------------------------------
void AddSlices(int dir, char *sliceset) {
int rangeStart(-1), rangeEnd(-1), slice(-1);
bool bRangeSpecified(false);
dumpSlices = true;
for(int ipos(1); ipos <= strlen(sliceset); ++ipos) { // skip first char for neg
if(sliceset[ipos] == '-') { // we have a range of values specified
bRangeSpecified = true;
rangeStart = atoi(sliceset);
rangeEnd = atoi(sliceset + ipos + 1);
sliceset[ipos] = '\0';
break;
}
}
list<int>::iterator dsliter;
if(bRangeSpecified) {
if(BL_SPACEDIM == 2 && dir == Amrvis::ZDIR) {
slice = 0;
dsliter = find(dumpSliceList[dir].begin(), dumpSliceList[dir].end(), slice);
if(dsliter == dumpSliceList[dir].end()) {
dumpSliceList[dir].push_back(slice);
}
} else {
for(slice = rangeStart; slice <= rangeEnd; ++slice) {
dsliter = find(dumpSliceList[dir].begin(),dumpSliceList[dir].end(),slice);
if(dsliter == dumpSliceList[dir].end()) {
dumpSliceList[dir].push_back(slice);
}
}
}
} else {
slice = atoi(sliceset);
if(BL_SPACEDIM == 2 && dir == Amrvis::ZDIR) {
slice = 0;
}
dsliter = find(dumpSliceList[dir].begin(),dumpSliceList[dir].end(),slice);
if(dsliter == dumpSliceList[dir].end()) {
dumpSliceList[dir].push_back(slice);
}
}
}
// -------------------------------------------------------------------
bool AVGlobals::ReadLightingFile(const string &lightdefaultsFile,
Real &ambientDef, Real &diffuseDef, Real &specularDef,
Real &shinyDef,
Real &minRayOpacityDef, Real &maxRayOpacityDef)
{
char defaultString[Amrvis::LINELENGTH], cRealIn[Amrvis::LINELENGTH];
// try to find the defaultsFile
char buffer[Amrvis::BUFSIZE];
ifstream defs(lightdefaultsFile.c_str());
if(defs.fail()) {
if(ParallelDescriptor::IOProcessor()) {
cout << "Cannot find lighting defaults file: " << lightdefaultsFile << endl;
}
return false;
} else {
if(ParallelDescriptor::IOProcessor()) {
cout << "Reading lighting defaults from: " << lightdefaultsFile << endl;
}
ws(defs);
defs.getline(buffer, Amrvis::BUFSIZE, '\n');
while( ! defs.eof()) {
sscanf(buffer,"%s", defaultString);
if(defaultString[0] != '#') { // a comment starts with #
if(strcmp(defaultString,"ambient") == 0) {
sscanf(buffer, "%s%s", defaultString, cRealIn);
ambientDef = atof(cRealIn);
} else if(strcmp(defaultString, "diffuse") == 0) {
sscanf(buffer, "%s%s", defaultString, cRealIn);
diffuseDef = atof(cRealIn);
} else if(strcmp(defaultString, "specular") == 0) {
sscanf(buffer, "%s%s", defaultString, cRealIn);
specularDef = atof(cRealIn);
} else if(strcmp(defaultString, "shiny") == 0) {
sscanf(buffer, "%s%s", defaultString, cRealIn);
shinyDef = atof(cRealIn);
} else if(strcmp(defaultString, "minRayOpacity") == 0) {
sscanf(buffer, "%s%s", defaultString, cRealIn);
minRayOpacityDef = atof(cRealIn);
} else if(strcmp(defaultString, "maxRayOpacity") == 0) {
sscanf(buffer, "%s%s", defaultString, cRealIn);
maxRayOpacityDef = atof(cRealIn);
}
}
defs.getline(buffer, Amrvis::BUFSIZE, '\n');
}
}
return true;
}
// -------------------------------------------------------------------
bool AVGlobals::WriteLightingFile(const string &lightdefaultsFile,
const Real &ambientDef, const Real &diffuseDef,
const Real &specularDef, const Real &shinyDef,
const Real &minRayOpacityDef, const Real &maxRayOpacityDef)
{
// the format of this file is:
//ambient 0.42
//diffuse 0.41
//specular 0.40
//shiny 12.0
//minRayOpacity 0.04
//maxRayOpacity 0.96
if(ParallelDescriptor::IOProcessor()) {
ofstream defs(lightdefaultsFile.c_str());
if(defs.fail()) {
cerr << "***** Error writing lighting file: filename = "
<< lightdefaultsFile << endl;
return false;
} else {
defs << "ambient " << ambientDef << endl;
defs << "diffuse " << diffuseDef << endl;
defs << "specular " << specularDef << endl;
defs << "shiny " << shinyDef << endl;
defs << "minRayOpacity " << minRayOpacityDef << endl;
defs << "maxRayOpacity " << maxRayOpacityDef << endl;
defs.close();
}
}
return true;
}
// -------------------------------------------------------------------
void AVGlobals::GetDefaults(const string &defaultsFile) {
char buffer[Amrvis::BUFSIZE];
char defaultString[Amrvis::LINELENGTH];
char tempString[Amrvis::LINELENGTH];
char tempStringSDim[BL_SPACEDIM][Amrvis::LINELENGTH];
int tempInt;
// standard defaults
PltApp::SetDefaultPalette("Palette");
PltApp::SetDefaultLightingFile("amrvis.lighting");
initialPalette = "Palette";
PltApp::SetInitialDerived("density");
PltApp::SetInitialScale(1);
PltApp::SetInitialFormatString("%7.5f");
PltApp::SetDefaultShowBoxes(true);
PltApp::SetInitialWindowHeight(500);
PltApp::SetInitialWindowWidth(850);
PltApp::SetReserveSystemColors(24);
Dataset::SetInitialColor(true);
maxPictureSize = DEFAULTMAXPICTURESIZE;
boundaryWidth = 0;
skipPltLines = 0;
maxPaletteIndex = 255; // dont clip the top palette index (default)
boxColor = -1; // invalid
fileType = Amrvis::NEWPLT; // default
fabIOSize = 0;
lowBlack = false;
usePerStreams = false;
bShowBody = true;
startWithValueModel = false;
// try to find the defaultsFile
string fullDefaultsFile;
const string homePath = getenv("HOME");
std::vector<string> fullDefaultsFileList;
#ifdef AMRVIS_CONFIG_FILEPATH
string configFilepath(AMRVIS_CONFIG_FILEPATH);
fullDefaultsFileList.push_back(configFilepath + "/" + defaultsFile);
#endif
fullDefaultsFileList.push_back("./" + defaultsFile);
fullDefaultsFileList.push_back(homePath + "/" + defaultsFile);
fullDefaultsFileList.push_back(homePath + "/." + defaultsFile);
ifstream defs;
bool fileFound = false;
for (string const& fileLoc : fullDefaultsFileList){
defs.clear(); // must do this to clear the fail bit
defs.open(fileLoc.c_str());
if(defs.fail()) {
if(ParallelDescriptor::IOProcessor()) {
cout << "Cannot find amrvis defaults file: " << fileLoc << endl;
}
} else {
fullDefaultsFile = fileLoc;
fileFound = true;
break;
}
}
if (!fileFound) {
if(ParallelDescriptor::IOProcessor()) {
cout << "Cannot find amrvis defaults file: " << fullDefaultsFile << endl;
cout << "Using standard defaults." << endl;
}
return;
}
if(ParallelDescriptor::IOProcessor()) {
cout << "Reading defaults from: " << fullDefaultsFile << endl;
}
ws(defs);
defs.getline(buffer, Amrvis::BUFSIZE, '\n');
while( ! defs.eof()) {
sscanf(buffer,"%s", defaultString);
if(defaultString[0] != '#') { // a comment starts with #
if(strcmp(defaultString,"palette") == 0) {
sscanf(buffer, "%s%s",defaultString, tempString);
PltApp::SetDefaultPalette(tempString);
initialPalette = tempString;
}
else if(strcmp(defaultString,"lightingfile") == 0) {
sscanf(buffer, "%s%s",defaultString, tempString);
PltApp::SetDefaultLightingFile(tempString);
initialLightingFile = tempString;
}
else if(strcmp(defaultString, "initialderived") == 0) {
sscanf(buffer, "%s%s", defaultString, tempString);
PltApp::SetInitialDerived(tempString);
initialDerived = tempString;
}
else if(strcmp(defaultString, "initialscale") == 0) {
sscanf(buffer, "%s%d", defaultString, &tempInt);
PltApp::SetInitialScale(tempInt);
}
else if(strcmp(defaultString, "maxmenuitems") == 0) {
sscanf(buffer, "%s%d", defaultString, &tempInt);
PltApp::SetInitialMaxMenuItems(tempInt);
}
else if(strcmp(defaultString, "numberformat") == 0) {
sscanf(buffer, "%s%s", defaultString, tempString);
PltApp::SetInitialFormatString(tempString);
}
else if(strcmp(defaultString, "windowheight") == 0) {
sscanf(buffer, "%s%d", defaultString, &tempInt);
PltApp::SetInitialWindowHeight(tempInt);
}
else if(strcmp(defaultString, "windowwidth") == 0) {
sscanf(buffer, "%s%d", defaultString, &tempInt);
PltApp::SetInitialWindowWidth(tempInt);
}
else if(strcmp(defaultString, "maxpixmapsize") == 0) {
sscanf(buffer, "%s%d", defaultString, &tempInt);
maxPictureSize = tempInt;
}
else if(strcmp(defaultString, "reservesystemcolors") == 0) {
sscanf(buffer, "%s%d", defaultString, &tempInt);
PltApp::SetReserveSystemColors(tempInt);
}
else if(strcmp(defaultString, "extrapalettewidth") == 0) {
sscanf(buffer, "%s%d", defaultString, &tempInt);
PltApp::SetExtraPaletteWidth(tempInt);
}
else if(strcmp(defaultString, "showboxes") == 0) {
sscanf(buffer, "%s%s", defaultString, tempString);
if(*tempString == 't' || *tempString == 'T') {
PltApp::SetDefaultShowBoxes(true);
} else {
PltApp::SetDefaultShowBoxes(false);
}
}
else if(strcmp(defaultString, "showbody") == 0) {
sscanf(buffer, "%s%s", defaultString, tempString);
if(*tempString == 'f' || *tempString == 'F') {
bShowBody = false;
}
}
else if(strcmp(defaultString, "ppm") == 0) {
sscanf(buffer, "%s%s", defaultString, tempString);
if(*tempString == 't' || *tempString == 'T') {
AVGlobals::ClearSGIrgbFile();
}
}
else if(strcmp(defaultString, "rgb") == 0) {
sscanf(buffer, "%s%s", defaultString, tempString);
if(*tempString == 't' || *tempString == 'T') {
AVGlobals::SetSGIrgbFile();
}
}
else if(strcmp(defaultString, "boundarywidth") == 0) {
sscanf(buffer, "%s%d", defaultString, &tempInt);
boundaryWidth = tempInt;
}
else if(strcmp(defaultString, "maxlev") == 0) {
sscanf(buffer, "%s%d", defaultString, &tempInt);
maxLevel = tempInt;
useMaxLevel = true;
if(maxLevel < 0) {
cerr << "Error in defaults file: invalid parameter for maxLevel: "
<< maxLevel << endl;
maxLevel = -1;
useMaxLevel = false;
}
}
else if(strcmp(defaultString, "sleep") == 0) {
sscanf(buffer, "%s%d", defaultString, &tempInt);
sleepTime = tempInt;
}
else if(strcmp(defaultString, "skippltlines") == 0) {
sscanf(buffer, "%s%d", defaultString, &tempInt);
skipPltLines = tempInt;
}
else if(strcmp(defaultString, "boxcolor") == 0) {
sscanf(buffer, "%s%d", defaultString, &tempInt);
boxColor = tempInt;
}
else if(strcmp(defaultString, "datasetinitialcolor") == 0) {
sscanf(buffer, "%s%s", defaultString, tempString);
if(*tempString == 't' || *tempString == 'T') {
Dataset::SetInitialColor(true);
} else {
Dataset::SetInitialColor(false);
}
VisMF::SetUsePersistentIFStreams(usePerStreams);
}
else if(strcmp(defaultString, "filetype") == 0) {
sscanf(buffer, "%s%s", defaultString, tempString);
if(strcmp(tempString, "fab") == 0) {
fileType = Amrvis::FAB;
} else if(strcmp(tempString, "multifab") == 0) {
fileType = Amrvis::MULTIFAB;
} else if(strcmp(tempString, "newplt") == 0) {
fileType = Amrvis::NEWPLT;
#ifdef BL_USE_PROFPARSER
} else if(strcmp(tempString, "profdata") == 0) {
fileType = Amrvis::PROFDATA;
#endif
} else { // error
cerr << "Error in defaults file: invalid parameter for filetype: "
<< tempString << endl;
}
}
else if(strcmp(defaultString, "cliptoppalette") == 0) {
maxPaletteIndex = 254; // clip the top palette index
}
else if(strcmp(defaultString, "fixdenormals") == 0) {
RealDescriptor::SetFixDenormals();
}
else if(strcmp(defaultString, "lowblack") == 0) {
lowBlack = true;
}
#ifdef BL_OPTIO
else if(strcmp(defaultString, "useperstreams") == 0) {
sscanf(buffer, "%s%s", defaultString, tempString);
if(*tempString == 't' || *tempString == 'T') {
usePerStreams = true;
} else {
usePerStreams = false;
}
VisMF::SetUsePersistentIFStreams(usePerStreams);
}
#endif
else if(strcmp(defaultString, "valuemodel") == 0) {
startWithValueModel = true;
}
#if (BL_SPACEDIM == 3)
else if(strcmp(defaultString, "initplanes") == 0) {
int tempX, tempY, tempZ;
sscanf(buffer, "%s%d%d%d", defaultString, &tempX, &tempY, &tempZ);
ivInitialPlanes.setVal(Amrvis::XDIR, tempX);
ivInitialPlanes.setVal(Amrvis::YDIR, tempY);
ivInitialPlanes.setVal(Amrvis::ZDIR, tempZ);
givenInitialPlanes = true;
}
else if(strcmp(defaultString, "initplanesreal") == 0) {
float tempX, tempY, tempZ;
sscanf(buffer, "%s%e%e%e", defaultString, &tempX, &tempY, &tempZ);
ivInitialPlanesReal.resize(BL_SPACEDIM);
ivInitialPlanesReal[Amrvis::XDIR] = tempX;
ivInitialPlanesReal[Amrvis::YDIR] = tempY;
ivInitialPlanesReal[Amrvis::ZDIR] = tempZ;
givenInitialPlanesReal = true;
}
#endif
else if(strcmp(defaultString, "setvelnames") == 0) {
#if (BL_SPACEDIM == 2)
sscanf(buffer, "%s%s%s", defaultString,
tempStringSDim[0], tempStringSDim[1]);
#else
sscanf(buffer, "%s%s%s%s", defaultString,
tempStringSDim[0], tempStringSDim[1], tempStringSDim[2]);
#endif
givenUserVectorNames = enUserVelocities;
for(int ii(0); ii < BL_SPACEDIM; ++ii) {
userVectorNames[ii] = tempStringSDim[ii];
}
if(ParallelDescriptor::IOProcessor()) {
cout << "Using velnames: ";
for(int ii(0); ii < BL_SPACEDIM; ++ii) {
cout << userVectorNames[ii] << " ";
}
cout << endl;
}
}
else if(strcmp(defaultString, "setmomnames") == 0) {
#if (BL_SPACEDIM == 2)
sscanf(buffer, "%s%s%s", defaultString,
tempStringSDim[0], tempStringSDim[1]);
#else
sscanf(buffer, "%s%s%s%s", defaultString,
tempStringSDim[0], tempStringSDim[1], tempStringSDim[2]);
#endif
givenUserVectorNames = enUserMomentums;
for(int ii(0); ii < BL_SPACEDIM; ++ii) {
userVectorNames[ii] = tempStringSDim[ii];
}
if(ParallelDescriptor::IOProcessor()) {
cout << "Using momnames: ";
for(int ii(0); ii < BL_SPACEDIM; ++ii) {
cout << userVectorNames[ii] << " ";
}
cout << endl;
}
} else {
if(ParallelDescriptor::IOProcessor()) {
cout << "bad default argument: " << defaultString << endl;
}
}
}
ws(defs);
defs.getline(buffer, Amrvis::BUFSIZE, '\n');
}
defs.close();
} // end GetDefaults
// -------------------------------------------------------------------
void PrintUsage(char *exname) {
if(ParallelDescriptor::IOProcessor()) {
cout << '\n';
cout << exname << " [<options>] [<filename(s)>]" << '\n';
cout << '\n';
cout << " -help print help and exit." << '\n';
cout << " file type flags: -fab [-fb], -multifab [-mf], -profdata, -newplt (default)" << '\n';
cout << " -v verbose." << '\n';
cout << " -maxpixmapsize n specify maximum allowed picture size in pixels."
<< '\n';
cout << " -subdomain _box_ specify subdomain box (on finest level)." << '\n';
cout << " _box_ format: lox loy loz hix hiy hiz." << '\n';
cout << " -skippltlines n skip n lines at head of the plt file." << '\n';
cout << " -boxcolor n set volumetric box color value [0,255]." << '\n';
#if(BL_SPACEDIM != 3)
cout << " -a load files as an animation." << '\n';
cout << " -aa load files as an animation with annotations." << '\n';
cout << " -anc load files as an animation, dont cache frames." << '\n';
#endif
//cout << " -sleep n specify sleep time (for attaching parallel debuggers)." << '\n';
cout << " -setvelnames xname yname (zname) specify velocity names for" << '\n';
cout << " drawing vector plots." << '\n';
cout << " -setmomnames xname yname (zname) specify momentum names for" << '\n';
cout << " drawing vector plots." << '\n';
cout << " -fabiosize nbits write fabs with nbits (valid values are 1 (ascii), 8 or 32." << '\n';
cout << " the default is native (usually 64)." << '\n';
cout << " -maxlev n specify the maximum drawn level." << '\n';
cout << " -palette palname set the initial palette." << '\n';
cout << " -lightingfile name set the initial lighting parameter file." << '\n';
cout << " -maxmenuitems n set the max menu items per column to n." << '\n';
cout << " -initialderived dername set the initial derived to dername." << '\n';
cout << " -initialscale n set the initial scale to n." << '\n';
cout << " -showboxes tf show boxes (the value of tf is true or false)." << '\n';
cout << " -showbody tf show cartGrid body as body cells (def is true)." << '\n';
cout << " -numberformat fmt set the initial format to fmt (ex: %4.2f)." << '\n';
cout << " -lowblack sets the lowest color in the palette to black." << '\n';
#ifdef BL_OPTIO
cout << " -useperstreams tf use vismf persistent streams." << '\n';
#endif
cout << " -cliptoppalette do not use the top palette index (for exceed)." << '\n';
cout << " -fixdenormals always fix denormals when reading fabs." << '\n';
cout << " -ppm output rasters using PPM file format." << '\n';
cout << " -rgb output rasters using RGB file format." << '\n';
cout << " -useminmax min max use min and max as the global min max values" << '\n';
#ifdef BL_VOLUMERENDER
cout << " -valuemodel start with the value model for rendering." << '\n';
#endif
#if (BL_SPACEDIM == 3)
cout << " -initplanes xp yp zp set initial planes" << '\n';
#endif
cout << '\n';
cout << "-------------------------------------------------------- batch functions" << '\n';
cout << " -xslice n write a fab slice at x = n (n at the finest level)." << '\n';
cout << " -yslice n write a fab slice at y = n (n at the finest level)." << '\n';
cout << " -zslice n write a fab slice at z = n (n at the finest level)." << '\n';
cout << " -sliceallvars write all fab variables instead of just initialderived." << '\n';
cout << " -boxslice _box_ write a fab on the box (box at the finest level)." << '\n';
cout << " _box_ format: lox loy (loz) hix hiy (hiz)." << '\n';
cout << " example: -boxslice 0 0 0 120 42 200." << '\n';
#ifdef BL_VOLUMERENDER
cout << " -makeswf_light make volume rendering data using the" << '\n';
cout << " current transfer function and write data" << '\n';
cout << " to a file, using the lighting model." << '\n'
<< " note: works in batch mode." << '\n';
cout << " -makeswf_value same as above, with value model rendering." << '\n';
#endif
cout << "------------------------------------------------------------------------" << '\n';
cout << '\n';
#ifdef BL_USE_PROFPARSER
cout << "----------------------------------------- amrproparser functions" << '\n';
PrintProfParserBatchUsage(cout);
cout << "----------------------------------------------------------------" << '\n';
#endif
cout << " <filename(s)> must be included if box is specified." << '\n';
cout << endl;
}
exit(0);
}
// -------------------------------------------------------------------
void AVGlobals::ParseCommandLine(int argc, char *argv[]) {
char clsx[32], clsy[32];
char clbx[32], clby[32];
#if (BL_SPACEDIM == 3)
char clsz[32];
char clbz[32];
char clPlaneX[32], clPlaneY[32], clPlaneZ[32];
bool givenInitialPlanesOnComline(false);
char clPlaneXReal[32], clPlaneYReal[32], clPlaneZReal[32];
bool givenInitialPlanesRealOnComline(false);
#endif
givenFilename = false;
givenBox = false;
givenBoxSlice = false;
createSWFData = false;
makeSWFLight = false;
dumpSlices = false;
sliceAllVars = false;
verbose = false;
fileCount = 0;
sleepTime = 0;
bAnimation = false;
bAnnotated = false;
bCacheAnimFrames = false;
specifiedMinMax = false;
specifiedMin = 0.0;
specifiedMax = 1.0;
comlinefilename.resize(argc); // slightly larger than eventual fileCount
dumpSliceList.resize(3); // always use 3 (zslice in 2d is image plane)
int i;
for(i = 1; i <= argc - 1; ++i) {
if(strcmp(argv[i], "-maxpixmapsize") == 0) {
if(argc-1<i+1 || atoi(argv[i+1]) == 0) {
PrintUsage(argv[0]);
} else {
maxPictureSize = atoi(argv[i+1]);
}
++i;
} else if(strcmp(argv[i], "-bw") == 0) {
if(argc-1<i+1 || atoi(argv[i+1]) < 0) {
PrintUsage(argv[0]);
} else {
boundaryWidth = atoi(argv[i+1]);
}
++i;
} else if(strcmp(argv[i], "-maxlev") == 0) {
int imaxlev = atoi(argv[i+1]);
if(argc-1 < i+1) {
PrintUsage(argv[0]);
} else if(imaxlev < 0) {
cerr << "Error: invalid parameter for maxlev: " << imaxlev << endl;
} else {
maxLevel = imaxlev;
useMaxLevel = true;
}
++i;
} else if(strcmp(argv[i], "-sleep") == 0) {
sleepTime = atoi(argv[i+1]);
++i;
} else if(strcmp(argv[i], "-fabiosize") == 0) {
int iSize = atoi(argv[i+1]);
if(iSize == 1 || iSize == 8 || iSize == 32) {
fabIOSize = iSize;
} else {
cerr << "Warning: -fabiosize must be 1, 8 or 32. Defaulting to native."
<< endl;
fabIOSize = 0;
}
++i;
} else if(strcmp(argv[i], "-skippltlines") == 0) {
if(argc-1<i+1 || atoi(argv[i+1]) < 0) {
PrintUsage(argv[0]);
} else {
skipPltLines = atoi(argv[i+1]);
}
++i;
} else if(strcmp(argv[i], "-boxcolor") == 0) {
if(argc-1<i+1 || atoi(argv[i+1]) < 0) {
PrintUsage(argv[0]);
} else {
boxColor = atoi(argv[i+1]);
}
++i;
# if (BL_SPACEDIM != 3)
} else if(strcmp(argv[i],"-a") == 0) {
bAnimation = true;
bAnnotated = false;
bCacheAnimFrames = true;
} else if(strcmp(argv[i],"-aa") == 0) {
bAnimation = true;
bAnnotated = true;
bCacheAnimFrames = true;
} else if(strcmp(argv[i],"-anc") == 0) {
bAnimation = true;
bCacheAnimFrames = false;
bAnnotated = false;
# endif
} else if(strcmp(argv[i],"-fab") == 0) {
fileType = Amrvis::FAB;
} else if(strcmp(argv[i],"-fb") == 0) {
fileType = Amrvis::FAB;
} else if(strcmp(argv[i],"-multifab") == 0) {
fileType = Amrvis::MULTIFAB;
} else if(strcmp(argv[i],"-mf") == 0) {
fileType = Amrvis::MULTIFAB;
} else if(strcmp(argv[i],"-newplt") == 0) {
fileType = Amrvis::NEWPLT;
newPltSet = true;
#ifdef BL_USE_PROFPARSER
} else if(strcmp(argv[i],"-profdata") == 0) {
fileType = Amrvis::PROFDATA;
#endif
} else if(strcmp(argv[i],"-v") == 0) {
verbose = true;
} else if(strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "-subdomain") == 0) {
# if (BL_SPACEDIM == 2 || BL_SPACEDIM == 1)
if(argc-1<i+1 || ! strcpy(clsx, argv[i+1])) {
PrintUsage(argv[0]);
}
if(argc-1<i+2 || ! strcpy(clsy, argv[i+2])) {
PrintUsage(argv[0]);
}
if(argc-1<i+3 || ! strcpy(clbx, argv[i+3])) {
PrintUsage(argv[0]);
}
if(argc-1<i+4 || ! strcpy(clby, argv[i+4])) {
PrintUsage(argv[0]);
}
i += 4;
givenBox = true;
# else
if(argc-1<i+1 || ! strcpy(clsx, argv[i+1])) {
PrintUsage(argv[0]);
}
if(argc-1<i+2 || ! strcpy(clsy, argv[i+2])) {
PrintUsage(argv[0]);
}
if(argc-1<i+3 || ! strcpy(clsz, argv[i+3])) {
PrintUsage(argv[0]);
}
if(argc-1<i+4 || ! strcpy(clbx, argv[i+4])) {
PrintUsage(argv[0]);
}
if(argc-1<i+5 || ! strcpy(clby, argv[i+5])) {
PrintUsage(argv[0]);
}
if(argc-1<i+6 || ! strcpy(clbz, argv[i+6])) {
PrintUsage(argv[0]);
}
i += 6;
givenBox = true;
# endif
} else if(strcmp(argv[i], "-makeswf_light") == 0) {
createSWFData = true;
makeSWFLight = true;
} else if(strcmp(argv[i], "-makeswf_value") == 0) {
createSWFData = true;
makeSWFLight = false;
} else if(strcmp(argv[i], "-valuemodel") == 0) {
startWithValueModel = true;
} else if(strcmp(argv[i], "-lowblack") == 0) {
lowBlack = true;
#ifdef BL_OPTIO
} else if(strcmp(argv[i], "-useperstreams") == 0) {
if(*argv[i+1] == 't' || *argv[i+1] == 'T') {
usePerStreams = true;
} else if(*argv[i+1] == 'f' || *argv[i+1] == 'F') {
usePerStreams = false;
} else {
PrintUsage(argv[0]);
}
VisMF::SetUsePersistentIFStreams(usePerStreams);
++i;
#endif
} else if(strcmp(argv[i], "-setvelnames") == 0) {
if(argc-1<i+BL_SPACEDIM) {
PrintUsage(argv[0]);
} else {
givenUserVectorNames = enUserVelocities;
for(int ii(0); ii < BL_SPACEDIM; ++ii) {
userVectorNames[ii] = argv[i+1 + ii];
}
if(ParallelDescriptor::IOProcessor()) {
cout << "Using velnames: ";
for(int ii(0); ii < BL_SPACEDIM; ++ii) {
cout << userVectorNames[ii] << " ";
}
cout << endl;
}
}
i += BL_SPACEDIM;
} else if(strcmp(argv[i], "-setmomnames") == 0) {
if(argc-1<i+BL_SPACEDIM) {
PrintUsage(argv[0]);
} else {
givenUserVectorNames = enUserMomentums;
for(int ii(0); ii < BL_SPACEDIM; ++ii) {
userVectorNames[ii] = argv[i+1 + ii];
}
if(ParallelDescriptor::IOProcessor()) {
cout << "Using momnames: ";
for(int ii(0); ii < BL_SPACEDIM; ++ii) {
cout << userVectorNames[ii] << " ";
}
cout << endl;
}
}
i += BL_SPACEDIM;
} else if(strcmp(argv[i], "-useminmax") == 0) {
specifiedMinMax = true;
if(argc-1<i+2) {
PrintUsage(argv[0]);
} else {
specifiedMin = atof(argv[i+1]);
specifiedMax = atof(argv[i+2]);
if(ParallelDescriptor::IOProcessor()) {
cout << "******* using min max = " << specifiedMin
<< " " << specifiedMax << endl;
}
}
i += 2;
} else if(strcmp(argv[i],"-help") == 0) {
PrintUsage(argv[0]);
} else if(strcmp(argv[i], "-xslice") == 0) {
if(argc-1<i+1) {
PrintUsage(argv[0]);
} else {
AddSlices(Amrvis::XDIR, argv[i+1]);
}
++i;
} else if(strcmp(argv[i], "-yslice") == 0) {
if(argc-1<i+1) {
PrintUsage(argv[0]);
} else {
AddSlices(Amrvis::YDIR, argv[i+1]);
}
++i;
} else if(strcmp(argv[i], "-zslice") == 0) {
if(argc-1<i+1) {
PrintUsage(argv[0]);
} else {
AddSlices(Amrvis::ZDIR, argv[i+1]);
}
++i;
} else if(strcmp(argv[i], "-boxslice") == 0) {
#if (BL_SPACEDIM == 1)
if(argc-1<i+1 || ! strcpy(clsx, argv[i+1])) {
PrintUsage(argv[0]);
}
if(argc-1<i+2 || ! strcpy(clbx, argv[i+2])) {
PrintUsage(argv[0]);
}
i += 2;
givenBoxSlice = true;
#elif (BL_SPACEDIM == 2)
if(argc-1<i+1 || ! strcpy(clsx, argv[i+1])) {
PrintUsage(argv[0]);
}
if(argc-1<i+2 || ! strcpy(clsy, argv[i+2])) {
PrintUsage(argv[0]);
}
if(argc-1<i+3 || ! strcpy(clbx, argv[i+3])) {
PrintUsage(argv[0]);
}
if(argc-1<i+4 || ! strcpy(clby, argv[i+4])) {
PrintUsage(argv[0]);
}
i += 4;
givenBoxSlice = true;
#else
if(argc-1<i+1 || ! strcpy(clsx, argv[i+1])) {
PrintUsage(argv[0]);
}
if(argc-1<i+2 || ! strcpy(clsy, argv[i+2])) {
PrintUsage(argv[0]);
}
if(argc-1<i+3 || ! strcpy(clsz, argv[i+3])) {
PrintUsage(argv[0]);
}
if(argc-1<i+4 || ! strcpy(clbx, argv[i+4])) {
PrintUsage(argv[0]);
}
if(argc-1<i+5 || ! strcpy(clby, argv[i+5])) {
PrintUsage(argv[0]);
}
if(argc-1<i+6 || ! strcpy(clbz, argv[i+6])) {
PrintUsage(argv[0]);
}
i += 6;
givenBoxSlice = true;
#endif
#if (BL_SPACEDIM == 3)
} else if(strcmp(argv[i], "-initplanes") == 0) {
if(argc-1<i+1 || ! strcpy(clPlaneX, argv[i+1])) {
PrintUsage(argv[0]);
}
if(argc-1<i+2 || ! strcpy(clPlaneY, argv[i+2])) {
PrintUsage(argv[0]);
}
if(argc-1<i+3 || ! strcpy(clPlaneZ, argv[i+3])) {
PrintUsage(argv[0]);
}
i += 3;
givenInitialPlanes = true;
givenInitialPlanesOnComline = true;
} else if(strcmp(argv[i], "-initplanesreal") == 0) {
if(argc-1<i+1 || ! strcpy(clPlaneXReal, argv[i+1])) {
PrintUsage(argv[0]);
}
if(argc-1<i+2 || ! strcpy(clPlaneYReal, argv[i+2])) {
PrintUsage(argv[0]);
}
if(argc-1<i+3 || ! strcpy(clPlaneZReal, argv[i+3])) {
PrintUsage(argv[0]);
}
i += 3;
givenInitialPlanesReal = true;
givenInitialPlanesRealOnComline = true;
#endif
} else if(strcmp(argv[i],"-palette") == 0) {
PltApp::SetDefaultPalette(argv[i+1]);
initialPalette = argv[i+1];
++i;
} else if(strcmp(argv[i],"-lightingfile") == 0) {
PltApp::SetDefaultLightingFile(argv[i+1]);
initialLightingFile = argv[i+1];
++i;
} else if(strcmp(argv[i], "-initialderived") == 0) {
PltApp::SetInitialDerived(argv[i+1]);
initialDerived = argv[i+1];
++i;
} else if(strcmp(argv[i], "-initialscale") == 0) {
int tempiscale = atoi(argv[i+1]);
if(argc-1 < i+1 || tempiscale < 1) {
PrintUsage(argv[0]);
}
PltApp::SetInitialScale(tempiscale);
++i;
} else if(strcmp(argv[i], "-maxmenuitems") == 0) {
int tempimaxmenuitems = atoi(argv[i+1]);
if(argc-1 < i+1 || tempimaxmenuitems < 1) {
PrintUsage(argv[0]);
}
PltApp::SetInitialMaxMenuItems(tempimaxmenuitems);
++i;
} else if(strcmp(argv[i], "-numberformat") == 0) {
PltApp::SetInitialFormatString(argv[i+1]);
++i;
} else if(strcmp(argv[i], "-showboxes") == 0) {
if(*argv[i+1] == 't' || *argv[i+1] == 'T') {