forked from AMReX-Astro/Castro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCastro_io.cpp
More file actions
1181 lines (947 loc) · 34.3 KB
/
Copy pathCastro_io.cpp
File metadata and controls
1181 lines (947 loc) · 34.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
#ifndef WIN32
#include <unistd.h>
#endif
#include <iomanip>
#include <iostream>
#include <string>
#include <ctime>
#include <AMReX_Utility.H>
#include <Castro.H>
#include <Castro_F.H>
#include <Castro_io.H>
#include <AMReX_ParmParse.H>
#ifdef RADIATION
#include <Radiation.H>
#endif
#ifdef GRAVITY
#include <Gravity.H>
#endif
#ifdef DIFFUSION
#include <Diffusion.H>
#endif
#ifdef _OPENMP
#include <omp.h>
#endif
#include <problem_initialize_state_data.H>
#include <problem_checkpoint.H>
#include <problem_restart.H>
#include <AMReX_buildInfo.H>
using std::string;
using namespace amrex;
// Castro maintains an internal checkpoint version numbering system.
// This allows us to ensure that we don't attempt to restart from a
// checkpoint that is incompatible with the current code. The version
// number is stored in the CastroHeader file inside a checkpoint.
// The following were the changes made in updating version numbers:
// 0: all checkpoints before we began the numbering system (July 27, 2015)
// 1: PhiGrav_Type was added to the checkpoint
// 2: Source_Type was added to the checkpoint
// 3: A ReactHeader file was generated and the maximum de/dt was stored there
// 4: Reactions_Type added to checkpoint; ReactHeader functionality deprecated
// 5: Simplified_SDC_Source_Type and Simplified_SDC_React_Type added to checkpoint
// 6: Simplified_SDC_Source_Type removed from Castro
// 7: A weights field was added to Reactions_Type; number of ghost zones increased to NUM_GROW
// 8: Reactions_Type modified to use rho * omegadot instead of omegadot; rho * auxdot added
// 9: Rotation_Type was removed from Castro
// 10: Reactions_Type was removed from checkpoints
// 11: PhiRot_Type was removed from Castro
namespace
{
int input_version = -1;
int current_version = 11;
}
// I/O routines for Castro
void
Castro::restart (Amr& papa,
istream& is,
bool bReadSpecial)
{
// Let's check Castro checkpoint version first;
// trying to read from checkpoint; if nonexisting, set it to 0.
if (input_version == -1) {
if (ParallelDescriptor::IOProcessor()) {
std::ifstream CastroHeaderFile;
std::string FullPathCastroHeaderFile = papa.theRestartFile();
FullPathCastroHeaderFile += "/CastroHeader";
CastroHeaderFile.open(FullPathCastroHeaderFile.c_str(), std::ios::in);
if (CastroHeaderFile.good()) {
char foo[256];
// first line: Checkpoint version: ?
CastroHeaderFile.getline(foo, 256, ':');
CastroHeaderFile >> input_version;
CastroHeaderFile.close();
} else {
input_version = 0;
}
}
ParallelDescriptor::Bcast(&input_version, 1, ParallelDescriptor::IOProcessorNumber());
}
// Check that the version number matches.
if (input_version != current_version) {
amrex::Error("Checkpoint format incompatible with current code");
}
// Check if there's a file in the header indicating that the
// previous timestep was limited to hit a plot interval. If so,
// read in the value, so that the timestep after this restart is
// limited appropriately.
if (ParallelDescriptor::IOProcessor()) {
std::ifstream dtHeaderFile;
std::string FullPathdtHeaderFile = papa.theRestartFile();
FullPathdtHeaderFile += "/dtHeader";
dtHeaderFile.open(FullPathdtHeaderFile.c_str(), std::ios::in);
if (dtHeaderFile.good()) {
lastDtPlotLimited = 1;
dtHeaderFile >> lastDtBeforePlotLimiting;
dtHeaderFile.close();
}
}
// Check if we have the same state variables
if (ParallelDescriptor::IOProcessor()) {
std::ifstream StateListFile;
std::string FullPathStateList = papa.theRestartFile();
FullPathStateList += "/state_names.txt";
StateListFile.open(FullPathStateList.c_str(), std::ios::in);
if (StateListFile.good()) {
std::string var;
for (int n = 0; n < NUM_STATE; n++) {
StateListFile >> var;
if (var != desc_lst[State_Type].name(n)) {
amrex::Error("state variables do not agree");
}
}
StateListFile.close();
}
}
ParallelDescriptor::Bcast(&lastDtPlotLimited, 1, ParallelDescriptor::IOProcessorNumber());
ParallelDescriptor::Bcast(&lastDtBeforePlotLimiting, 1, ParallelDescriptor::IOProcessorNumber());
// also need to mod checkPoint function to store the new version in a text file
AmrLevel::restart(papa,is,bReadSpecial);
buildMetrics();
initMFs();
// get the elapsed CPU time to now;
if (level == 0 && ParallelDescriptor::IOProcessor())
{
// get ellapsed CPU time
std::ifstream CPUFile;
std::string FullPathCPUFile = parent->theRestartFile();
FullPathCPUFile += "/CPUtime";
CPUFile.open(FullPathCPUFile.c_str(), std::ios::in);
if (CPUFile.good()) {
CPUFile >> previousCPUTimeUsed;
CPUFile.close();
}
std::cout << "read CPU time: " << previousCPUTimeUsed << "\n";
}
#ifdef GRAVITY
if (use_point_mass && level == 0)
{
// get the current value of the point mass
std::ifstream PMFile;
std::string FullPathPMFile = parent->theRestartFile();
FullPathPMFile += "/point_mass";
PMFile.open(FullPathPMFile.c_str(), std::ios::in);
if (PMFile.good()) {
PMFile >> point_mass;
PMFile.close();
}
}
#endif
if (level == 0)
{
// get problem-specific stuff -- note all processors do this,
// eliminating the need for a broadcast
std::string dir = parent->theRestartFile();
problem_restart(dir);
}
const Real* dx = geom.CellSize();
if ( (grown_factor > 1) && (parent->maxLevel() < 1) )
{
std::cout << "grown_factor is " << grown_factor << std::endl;
std::cout << "max_level is " << parent->maxLevel() << std::endl;
amrex::Error("Must have max_level > 0 if doing special restart with grown_factor");
}
if (grown_factor > 1 && level == 0)
{
if (verbose && ParallelDescriptor::IOProcessor()) {
std::cout << "Doing special restart with grown_factor " << grown_factor << std::endl;
}
MultiFab& S_new = get_new_data(State_Type);
Box orig_domain;
if (star_at_center == 0) {
orig_domain = amrex::coarsen(geom.Domain(),grown_factor);
} else if (star_at_center == 1) {
Box domain(geom.Domain());
int lo=0, hi=0;
if (geom.IsRZ()) {
if (grown_factor != 2) {
amrex::Abort("Must have grown_factor = 2");
}
int d = 0;
int dlen = domain.size()[d];
lo = 0;
hi = dlen/2;
orig_domain.setSmall(d,lo);
orig_domain.setBig(d,hi);
d = 1;
dlen = domain.size()[d];
lo = dlen/4 ;
hi = 3*dlen/4 - 1;
orig_domain.setSmall(d,lo);
orig_domain.setBig(d,hi);
} else {
for (int d = 0; d < AMREX_SPACEDIM; d++)
{
int dlen = domain.size()[d];
if (grown_factor == 2) {
lo = dlen/4 ;
hi = 3*dlen/4 - 1;
} else if (grown_factor == 3) {
lo = (dlen)/3 ;
hi = 2*(dlen)/3 - 1;
} else {
amrex::Abort("Must have grown_factor = 2 or 3");
}
orig_domain.setSmall(d,lo);
orig_domain.setBig(d,hi);
}
}
} else {
if (ParallelDescriptor::IOProcessor()) {
std::cout << "... invalid value of star_at_center: " << star_at_center << std::endl;
}
amrex::Abort();
}
for (MFIter mfi(S_new); mfi.isValid(); ++mfi)
{
const Real* prob_lo = geom.ProbLo();
const Box& bx = mfi.validbox();
const int* lo = bx.loVect();
const int* hi = bx.hiVect();
if (! orig_domain.contains(bx)) {
auto s = S_new[mfi].array();
auto geomdata = geom.data();
amrex::ParallelFor(bx,
[=] AMREX_GPU_HOST_DEVICE (int i, int j, int k)
{
// C++ problem initialization; has no effect if not implemented
// by a problem setup (defaults to an empty routine).
problem_initialize_state_data(i, j, k, s, geomdata);
});
}
}
}
if (grown_factor > 1 && level == 1) {
getLevel(0).avgDown();
}
#ifdef GRAVITY
#if (AMREX_SPACEDIM > 1)
if ( (level == 0) && (spherical_star == 1) ) {
MultiFab& S_new = get_new_data(State_Type);
const int nc = S_new.nComp();
const int n1d = get_numpts();
int is_new = 1;
make_radial_data(is_new);
}
#endif
if (do_grav && level == 0) {
BL_ASSERT(gravity == 0);
gravity = new Gravity(parent,parent->finestLevel(),&phys_bc, URHO);
}
#endif
#ifdef DIFFUSION
if (level == 0) {
BL_ASSERT(diffusion == 0);
diffusion = new Diffusion(parent,&phys_bc);
}
#endif
#ifdef RADIATION
if (do_radiation) {
if (radiation == 0) {
// radiation is a static object, only alloc if not already there
int rad_restart = 1; // disables quasi-steady initialization
radiation = new Radiation(parent, this, rad_restart);
}
radiation->regrid(level, grids, dmap);
radiation->restart(level, grids, dmap, parent->theRestartFile(), is);
rad_solver.reset(new RadSolve(parent, level, grids, dmap));
}
#endif
// If we want, we can restart the checkpoint at a new time.
if (reset_checkpoint_time > -1.e199) {
if (!parent->RegridOnRestart()) {
amrex::Error("reset_checkpoint_time only makes sense when amr.regrid_on_restart=1");
}
const Real cur_time = get_state_data(State_Type).curTime();
const Real prev_time = get_state_data(State_Type).prevTime();
const Real dt = cur_time - prev_time;
parent->setStartTime(reset_checkpoint_time);
parent->setCumTime(reset_checkpoint_time);
for (int n = 0; n < num_state_type; ++n) {
StateData& cur_state = get_state_data(n);
cur_state.setOldTimeLevel(reset_checkpoint_time-dt);
cur_state.setNewTimeLevel(reset_checkpoint_time );
}
}
if (reset_checkpoint_step > -1) {
if (!parent->RegridOnRestart()) {
amrex::Error("reset_checkpoint_step only makes sense when amr.regrid_on_restart=1");
}
parent->setLevelSteps(level, reset_checkpoint_step);
parent->setLevelCount(level, reset_checkpoint_step);
}
}
void
Castro::set_state_in_checkpoint (Vector<int>& state_in_checkpoint)
{
for (int i=0; i<num_state_type; ++i) {
state_in_checkpoint[i] = 1;
}
}
void
Castro::checkPoint(const std::string& dir,
std::ostream& os,
VisMF::How how,
bool /*dump_old_default*/)
{
const Real io_start_time = ParallelDescriptor::second();
AmrLevel::checkPoint(dir, os, how, dump_old);
const Real io_time = ParallelDescriptor::second() - io_start_time;
#ifdef RADIATION
if (do_radiation) {
radiation->checkPoint(level, dir, os, how);
}
#endif
#ifdef AMREX_PARTICLES
ParticleCheckPoint(dir);
#endif
if (level == 0 && ParallelDescriptor::IOProcessor())
{
{
std::ofstream CastroHeaderFile;
std::string FullPathCastroHeaderFile = dir;
FullPathCastroHeaderFile += "/CastroHeader";
CastroHeaderFile.open(FullPathCastroHeaderFile.c_str(), std::ios::out);
CastroHeaderFile << "Checkpoint version: " << current_version << std::endl;
CastroHeaderFile.close();
writeJobInfo(dir, io_time);
// output the list of state variables, so we can do a sanity check on restart
std::ofstream StateListFile;
std::string FullPathStateList = dir;
FullPathStateList += "/state_names.txt";
StateListFile.open(FullPathStateList.c_str(), std::ios::out);
for (int n = 0; n < NUM_STATE; n++) {
StateListFile << desc_lst[State_Type].name(n) << "\n";
}
StateListFile.close();
}
// If we have limited this last timestep to hit a plot interval,
// store the timestep we took before limiting. After the restart,
// this dt will be read in and used to limit the next timestep
// appropriately, rather than the shortened timestep.
if (lastDtPlotLimited == 1) {
std::ofstream dtHeaderFile;
std::string FullPathdtHeaderFile = dir;
FullPathdtHeaderFile += "/dtHeader";
dtHeaderFile.open(FullPathdtHeaderFile.c_str(), std::ios::out);
dtHeaderFile << lastDtBeforePlotLimiting << std::endl;
dtHeaderFile.close();
}
{
// store elapsed CPU time
std::ofstream CPUFile;
std::string FullPathCPUFile = dir;
FullPathCPUFile += "/CPUtime";
CPUFile.open(FullPathCPUFile.c_str(), std::ios::out);
CPUFile << std::setprecision(17) << getCPUTime();
CPUFile.close();
}
#ifdef GRAVITY
if (use_point_mass) {
// store current value of the point mass
std::ofstream PMFile;
std::string FullPathPMFile = dir;
FullPathPMFile += "/point_mass";
PMFile.open(FullPathPMFile.c_str(), std::ios::out);
PMFile << std::setprecision(17) << point_mass << std::endl;
PMFile.close();
}
#endif
{
// store any problem-specific stuff
problem_checkpoint(dir);
}
}
}
std::string
Castro::thePlotFileType () const
{
//
// Increment this whenever the writePlotFile() format changes.
//
static const std::string the_plot_file_type("HyperCLaw-V1.1");
return the_plot_file_type;
}
void
Castro::setPlotVariables ()
{
AmrLevel::setPlotVariables();
// Don't add the Source_Type data to the plotfile, we only
// want to store it in the checkpoints.
for (int i = 0; i < desc_lst[Source_Type].nComp(); i++) {
parent->deleteStatePlotVar(desc_lst[Source_Type].name(i));
}
#ifdef SIMPLIFIED_SDC
#ifdef REACTIONS
if (time_integration_method == SimplifiedSpectralDeferredCorrections) {
for (int i = 0; i < desc_lst[Simplified_SDC_React_Type].nComp(); i++) {
parent->deleteStatePlotVar(desc_lst[Simplified_SDC_React_Type].name(i));
}
}
#endif
#endif
}
void
Castro::writeJobInfo (const std::string& dir, const Real io_time)
{
// job_info file with details about the run
std::ofstream jobInfoFile;
std::string FullPathJobInfoFile = dir;
FullPathJobInfoFile += "/job_info";
jobInfoFile.open(FullPathJobInfoFile.c_str(), std::ios::out);
std::string PrettyLine = std::string(78, '=') + "\n";
std::string OtherLine = std::string(78, '-') + "\n";
std::string SkipSpace = std::string(8, ' ');
// job information
jobInfoFile << PrettyLine;
jobInfoFile << " Castro Job Information\n";
jobInfoFile << PrettyLine;
jobInfoFile << "job name: " << job_name << "\n\n";
jobInfoFile << "inputs file: " << inputs_name << "\n\n";
jobInfoFile << "number of MPI processes: " << ParallelDescriptor::NProcs() << "\n";
#ifdef _OPENMP
jobInfoFile << "number of threads: " << omp_get_max_threads() << "\n";
#endif
jobInfoFile << "\n";
jobInfoFile << "hydro tile size: " << hydro_tile_size << "\n";
jobInfoFile << "\n";
jobInfoFile << "CPU time used since start of simulation (CPU-hours): " <<
getCPUTime()/3600.0;
jobInfoFile << "\n\n";
// plotfile information
jobInfoFile << PrettyLine;
jobInfoFile << " Plotfile Information\n";
jobInfoFile << PrettyLine;
time_t now = time(0);
// Convert now to tm struct for local timezone
tm* localtm = localtime(&now);
jobInfoFile << "output date / time: " << asctime(localtm);
char currentDir[FILENAME_MAX];
if (getcwd(currentDir, FILENAME_MAX)) {
jobInfoFile << "output dir: " << currentDir << "\n";
}
jobInfoFile << "I/O time (s): " << io_time << "\n";
jobInfoFile << "\n\n";
#ifdef AMREX_USE_GPU
// This output assumes for simplicity that every rank uses the
// same type of GPU.
jobInfoFile << PrettyLine;
jobInfoFile << "GPU Information: " << "\n";
jobInfoFile << PrettyLine;
jobInfoFile << "GPU model name: " << Gpu::Device::deviceName() << "\n";
jobInfoFile << "Number of GPUs used: " << Gpu::Device::numDevicesUsed() << "\n";
jobInfoFile << "\n\n";
#endif
// build information
jobInfoFile << PrettyLine;
jobInfoFile << " Build Information\n";
jobInfoFile << PrettyLine;
jobInfoFile << "build date: " << buildInfoGetBuildDate() << "\n";
jobInfoFile << "build machine: " << buildInfoGetBuildMachine() << "\n";
jobInfoFile << "build dir: " << buildInfoGetBuildDir() << "\n";
jobInfoFile << "AMReX dir: " << buildInfoGetAMReXDir() << "\n";
jobInfoFile << "\n";
jobInfoFile << "COMP: " << buildInfoGetComp() << "\n";
jobInfoFile << "COMP version: " << buildInfoGetCompVersion() << "\n";
jobInfoFile << "\n";
jobInfoFile << "C++ compiler: " << buildInfoGetCXXName() << "\n";
jobInfoFile << "C++ flags: " << buildInfoGetCXXFlags() << "\n";
jobInfoFile << "\n";
jobInfoFile << "Fortran comp: " << buildInfoGetFName() << "\n";
jobInfoFile << "Fortran flags: " << buildInfoGetFFlags() << "\n";
jobInfoFile << "\n";
jobInfoFile << "Link flags: " << buildInfoGetLinkFlags() << "\n";
jobInfoFile << "Libraries: " << buildInfoGetLibraries() << "\n";
jobInfoFile << "\n";
for (int n = 1; n <= buildInfoGetNumModules(); n++) {
jobInfoFile << buildInfoGetModuleName(n) << ": " << buildInfoGetModuleVal(n) << "\n";
}
jobInfoFile << "\n";
const char* githash1 = buildInfoGetGitHash(1);
const char* githash2 = buildInfoGetGitHash(2);
const char* githash3 = buildInfoGetGitHash(3);
if (strlen(githash1) > 0) {
jobInfoFile << "Castro git describe: " << githash1 << "\n";
}
if (strlen(githash2) > 0) {
jobInfoFile << "AMReX git describe: " << githash2 << "\n";
}
if (strlen(githash3) > 0) {
jobInfoFile << "Microphysics git describe: " << githash3 << "\n";
}
const char* buildgithash = buildInfoGetBuildGitHash();
const char* buildgitname = buildInfoGetBuildGitName();
if (strlen(buildgithash) > 0){
jobInfoFile << buildgitname << " git describe: " << buildgithash << "\n";
}
jobInfoFile << "\n\n";
// grid information
jobInfoFile << PrettyLine;
jobInfoFile << " Grid Information\n";
jobInfoFile << PrettyLine;
int f_lev = parent->finestLevel();
for (int i = 0; i <= f_lev; i++)
{
jobInfoFile << " level: " << i << "\n";
jobInfoFile << " number of boxes = " << parent->numGrids(i) << "\n";
jobInfoFile << " maximum zones = ";
for (int n = 0; n < AMREX_SPACEDIM; n++)
{
jobInfoFile << parent->Geom(i).Domain().length(n) << " ";
//jobInfoFile << parent->Geom(i).ProbHi(n) << " ";
}
jobInfoFile << "\n\n";
}
jobInfoFile << " Boundary conditions\n";
Vector<int> lo_bc_out(AMREX_SPACEDIM), hi_bc_out(AMREX_SPACEDIM);
ParmParse pp("castro");
pp.getarr("lo_bc",lo_bc_out,0,AMREX_SPACEDIM);
pp.getarr("hi_bc",hi_bc_out,0,AMREX_SPACEDIM);
// these names correspond to the integer flags setup in the
// Castro_setup.cpp
const char* names_bc[] =
{ "interior", "inflow", "outflow",
"symmetry", "slipwall", "noslipwall" };
jobInfoFile << " -x: " << names_bc[lo_bc_out[0]] << "\n";
jobInfoFile << " +x: " << names_bc[hi_bc_out[0]] << "\n";
if (AMREX_SPACEDIM >= 2) {
jobInfoFile << " -y: " << names_bc[lo_bc_out[1]] << "\n";
jobInfoFile << " +y: " << names_bc[hi_bc_out[1]] << "\n";
}
if (AMREX_SPACEDIM == 3) {
jobInfoFile << " -z: " << names_bc[lo_bc_out[2]] << "\n";
jobInfoFile << " +z: " << names_bc[hi_bc_out[2]] << "\n";
}
jobInfoFile << "\n\n";
jobInfoFile << " Domain geometry info\n";
jobInfoFile << " center: " << problem::center[0] << " , " << problem::center[1] << " , " << problem::center[2] << "\n";
jobInfoFile << "\n";
jobInfoFile << " geometry.is_periodic: ";
for (int idir = 0; idir < AMREX_SPACEDIM; idir++) {
jobInfoFile << geom.isPeriodic(idir) << " ";
}
jobInfoFile << "\n";
jobInfoFile << " geometry.coord_sys: " << geom.Coord() << "\n";
jobInfoFile << " geometry.prob_lo: ";
for (int idir = 0; idir < AMREX_SPACEDIM; idir++) {
jobInfoFile << geom.ProbLo(idir) << " ";
}
jobInfoFile << "\n";
jobInfoFile << " geometry.prob_hi: ";
for (int idir = 0; idir < AMREX_SPACEDIM; idir++) {
jobInfoFile << geom.ProbHi(idir) << " ";
}
jobInfoFile << "\n";
jobInfoFile << " amr.n_cell: ";
const int* domain_lo = geom.Domain().loVect();
const int* domain_hi = geom.Domain().hiVect();
for (int idir = 0; idir < AMREX_SPACEDIM; idir++) {
jobInfoFile << domain_hi[idir] - domain_lo[idir] + 1 << " ";
}
jobInfoFile << "\n";
int max_level = parent->maxLevel();
jobInfoFile << " amr.max_level: " << max_level << "\n";
jobInfoFile << " amr.ref_ratio: ";
for (int lev = 1; lev <= max_level; lev++) {
IntVect ref_ratio = parent->refRatio(lev-1);
jobInfoFile << ref_ratio[0] << " ";
}
jobInfoFile << "\n";
jobInfoFile << "\n\n";
// species info
int mlen = 20;
jobInfoFile << PrettyLine;
jobInfoFile << " Species Information\n";
jobInfoFile << PrettyLine;
jobInfoFile <<
std::setw(6) << "index" << SkipSpace <<
std::setw(mlen+1) << "name" << SkipSpace <<
std::setw(7) << "A" << SkipSpace <<
std::setw(7) << "Z" << "\n";
jobInfoFile << OtherLine;
for (int i = 0; i < NumSpec; i++)
{
jobInfoFile <<
std::setw(6) << i << SkipSpace <<
std::setw(mlen+1) << std::setfill(' ') << short_spec_names_cxx[i] << SkipSpace <<
std::setw(7) << aion[i] << SkipSpace <<
std::setw(7) << zion[i] << "\n";
}
jobInfoFile << "\n\n";
// runtime parameters
jobInfoFile << PrettyLine;
jobInfoFile << " Inputs File Parameters\n";
jobInfoFile << PrettyLine;
#include <castro_job_info_tests.H>
#ifdef AMREX_PARTICLES
#include <particles_job_info_tests.H>
#endif
#ifdef GRAVITY
gravity->output_job_info_params(jobInfoFile);
#endif
#ifdef DIFFUSION
diffusion->output_job_info_params(jobInfoFile);
#endif
#include <prob_job_info_tests.H>
#include <extern_job_info_tests.H>
jobInfoFile.close();
}
void
Castro::writeBuildInfo ()
{
std::string PrettyLine = std::string(78, '=') + "\n";
std::string OtherLine = std::string(78, '-') + "\n";
std::string SkipSpace = std::string(8, ' ');
// build information
std::cout << PrettyLine;
std::cout << " Castro Build Information\n";
std::cout << PrettyLine;
std::cout << "build date: " << buildInfoGetBuildDate() << "\n";
std::cout << "build machine: " << buildInfoGetBuildMachine() << "\n";
std::cout << "build dir: " << buildInfoGetBuildDir() << "\n";
std::cout << "AMReX dir: " << buildInfoGetAMReXDir() << "\n";
std::cout << "\n";
std::cout << "COMP: " << buildInfoGetComp() << "\n";
std::cout << "COMP version: " << buildInfoGetCompVersion() << "\n";
std::cout << "\n";
std::cout << "C++ compiler: " << buildInfoGetCXXName() << "\n";
std::cout << "C++ flags: " << buildInfoGetCXXFlags() << "\n";
std::cout << "\n";
std::cout << "Fortran comp: " << buildInfoGetFName() << "\n";
std::cout << "Fortran flags: " << buildInfoGetFFlags() << "\n";
std::cout << "\n";
std::cout << "Link flags: " << buildInfoGetLinkFlags() << "\n";
std::cout << "Libraries: " << buildInfoGetLibraries() << "\n";
std::cout << "\n";
for (int n = 1; n <= buildInfoGetNumModules(); n++) {
std::cout << buildInfoGetModuleName(n) << ": " << buildInfoGetModuleVal(n) << "\n";
}
std::cout << "\n";
const char* githash1 = buildInfoGetGitHash(1);
const char* githash2 = buildInfoGetGitHash(2);
const char* githash3 = buildInfoGetGitHash(3);
if (strlen(githash1) > 0) {
std::cout << "Castro git describe: " << githash1 << "\n";
}
if (strlen(githash2) > 0) {
std::cout << "AMReX git describe: " << githash2 << "\n";
}
if (strlen(githash3) > 0) {
std::cout << "Microphysics git describe: " << githash3 << "\n";
}
const char* buildgithash = buildInfoGetBuildGitHash();
const char* buildgitname = buildInfoGetBuildGitName();
if (strlen(buildgithash) > 0){
std::cout << buildgitname << " git describe: " << buildgithash << "\n";
}
std::cout << "\n\n";
}
void
Castro::writePlotFile(const std::string& dir,
ostream& os,
VisMF::How how)
{
plotFileOutput(dir, os, how, 0);
}
void
Castro::writeSmallPlotFile (const std::string& dir,
ostream& os,
VisMF::How how)
{
plotFileOutput(dir, os, how, 1);
}
void
Castro::plotFileOutput(const std::string& dir,
ostream& os,
VisMF::How how,
const int is_small)
{
#ifdef AMREX_PARTICLES
ParticlePlotFile(dir);
#endif
//
// The list of indices of State to write to plotfile.
// first component of pair is state_type,
// second component of pair is component # within the state_type
//
std::vector<std::pair<int,int> > plot_var_map;
for (int typ = 0; typ < desc_lst.size(); typ++) {
for (int comp = 0; comp < desc_lst[typ].nComp(); comp++) {
if (((parent->isStatePlotVar(desc_lst[typ].name(comp)) && is_small == 0) ||
(parent->isStateSmallPlotVar(desc_lst[typ].name(comp)) && is_small == 1)) &&
desc_lst[typ].getType() == IndexType::TheCellType()) {
plot_var_map.push_back(std::pair<int,int>(typ,comp));
}
}
}
int num_derive = 0;
std::list<std::string> derive_names;
const std::list<DeriveRec>& dlist = derive_lst.dlist();
for (auto it = dlist.begin(); it != dlist.end(); ++it)
{
if ((parent->isDerivePlotVar(it->name()) && is_small == 0) ||
(parent->isDeriveSmallPlotVar(it->name()) && is_small == 1))
{
#ifdef AMREX_PARTICLES
if (it->name() == "particle_count" ||
it->name() == "total_particle_count")
{
if (Castro::theTracerPC())
{
derive_names.push_back(it->name());
num_derive = num_derive + it->numDerive();
}
} else
#endif
{
derive_names.push_back(it->name());
num_derive = num_derive + it->numDerive();
}
}
}
int n_data_items = plot_var_map.size() + num_derive;
#ifdef RADIATION
if (Radiation::nplotvar > 0) n_data_items += Radiation::nplotvar;
#endif
#ifdef REACTIONS
#ifndef TRUE_SDC
if (store_burn_weights) {
n_data_items += Castro::burn_weight_names.size();
}
#endif
#endif
Real cur_time = state[State_Type].curTime();
if (level == 0 && ParallelDescriptor::IOProcessor())
{
//
// The first thing we write out is the plotfile type.
//
os << thePlotFileType() << '\n';
if (n_data_items == 0) {
amrex::Error("Must specify at least one valid data item to plot");
}
os << n_data_items << '\n';
//
// Names of variables -- first state, then derived
//
for (int i =0; i < plot_var_map.size(); i++)
{
int typ = plot_var_map[i].first;
int comp = plot_var_map[i].second;
os << desc_lst[typ].name(comp) << '\n';
}
for (auto it = derive_names.begin(); it != derive_names.end(); ++it)
{
const DeriveRec* rec = derive_lst.get(*it);
if (rec->numDerive() > 1) {
for (int i = 0; i < rec->numDerive(); ++i) {
os << rec->variableName(0) + '_' + std::to_string(i) + '\n';
}
}
else {
os << rec->variableName(0) << '\n';
}
}
#ifdef RADIATION
for (int i=0; i<Radiation::nplotvar; ++i) {
os << Radiation::plotvar_names[i] << '\n';
}
#endif
#ifdef REACTIONS
#ifndef TRUE_SDC
if (store_burn_weights) {
for (auto name: Castro::burn_weight_names) {
os << name << '\n';
}
}
#endif
#endif
os << AMREX_SPACEDIM << '\n';
os << parent->cumTime() << '\n';
int f_lev = parent->finestLevel();
os << f_lev << '\n';
for (int i = 0; i < AMREX_SPACEDIM; i++) {
os << geom.ProbLo(i) << ' ';
}
os << '\n';
for (int i = 0; i < AMREX_SPACEDIM; i++) {