-
Notifications
You must be signed in to change notification settings - Fork 0
/
PeleLM.cpp
9947 lines (8699 loc) · 343 KB
/
PeleLM.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
//
// "Divu_Type" means S, where divergence U = S
// "RhoYchemProd_Type" means -omega_l/rho, i.e., the mass rate of decrease of species l due
// to kinetics divided by rho
//
//
#include <unistd.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <time.h>
#include <fstream>
#include <vector>
#include <sys/stat.h>
#include <AMReX_Geometry.H>
#include <AMReX_Extrapolater.H>
#include <AMReX_BoxDomain.H>
#include <AMReX_ParmParse.H>
#include <AMReX_ErrorList.H>
#include <PeleLM.H>
#include <AMReX_ArrayLim.H>
#include <AMReX_SPACE.H>
#include <AMReX_Interpolater.H>
#include <AMReX_ccse-mpi.H>
#include <AMReX_Utility.H>
#include <AMReX_MLABecLaplacian.H>
#include <AMReX_MLMG.H>
#include <NS_util.H>
#include <AMReX_GpuContainers.H>
#include <PPHYS_CONSTANTS.H>
#include <PeleLM_K.H>
#include <pelelm_prob.H>
#include <pelelm_prob_parm.H>
#include <PeleLM_parm.H>
#include <AMReX_DataServices.H>
#include <AMReX_AmrData.H>
#if defined(AMREX_USE_NEWMECH) || defined(AMREX_USE_VELOCITY)
#include <AMReX_DataServices.H>
#include <AMReX_AmrData.H>
#endif
#ifdef AMREX_USE_GPU
#include <AMReX_SUNMemory.H>
#endif
#include <NAVIERSTOKES_F.H>
#include <hydro_godunov.H>
#include <hydro_mol.H>
#ifdef AMREX_USE_EB
#include <AMReX_EBMultiFabUtil.H>
#include <AMReX_EBFArrayBox.H>
#include <AMReX_MLEBABecLap.H>
#include <AMReX_EB_utils.H>
#include <AMReX_EBAmrUtil.H>
#include <hydro_ebgodunov.H>
#include <hydro_ebmol.H>
#include <hydro_redistribution.H>
#endif
#include <AMReX_buildInfo.H>
//fixme, for writesingle level plotfile
#include<AMReX_PlotFileUtil.H>
#ifdef AMREX_PARTICLES
#include <AMReX_Particles.H>
#include "SprayParticles.H"
#endif
#ifdef SOOT_MODEL
#include "SootModel.H"
#endif
using namespace amrex;
static Box stripBox; // used for debugging
#ifdef AMREX_USE_FLOAT
const Real Real_MIN = FLT_MIN;
const Real Real_MAX = FLT_MAX;
#else
const Real Real_MIN = DBL_MIN;
const Real Real_MAX = DBL_MAX;
#endif
const Real bogus_value = 1.e20;
static Real typical_RhoH_value_default = -1.e10;
static const std::string typical_values_filename("typical_values.fab");
namespace
{
bool initialized = false;
}
//
// Set all default values in Initialize()!!!
//
namespace
{
std::set<std::string> ShowMF_Sets;
std::string ShowMF_Dir;
bool ShowMF_Verbose;
bool ShowMF_Check_Nans;
FABio::Format ShowMF_Fab_Format;
bool do_not_use_funccount;
Real crse_dt;
int chem_box_chop_threshold;
int num_deltaT_iters_MAX;
Real deltaT_norm_max;
int num_forkjoin_tasks;
bool forkjoin_verbose;
}
Real PeleLM::p_amb_old;
Real PeleLM::p_amb_new;
Real PeleLM::dp0dt;
Real PeleLM::thetabar;
Real PeleLM::lev0cellCount = -1.0;
Real PeleLM::dpdt_factor;
int PeleLM::closed_chamber;
int PeleLM::num_divu_iters;
int PeleLM::nSpecGroup = NUM_SPECIES;
int PeleLM::init_once_done;
int PeleLM::do_OT_radiation;
int PeleLM::do_heat_sink;
int PeleLM::RhoH;
int PeleLM::do_diffuse_sync;
int PeleLM::do_reflux_visc;
int PeleLM::RhoYdot_Type;
#ifdef AMREX_PARTICLES
int PeleLM::spraydot_Type;
#endif
#ifdef SOOT_MODEL
int PeleLM::sootsrc_Type;
#endif
int PeleLM::FuncCount_Type;
int PeleLM::divu_ceiling;
Real PeleLM::divu_dt_factor;
Real PeleLM::min_rho_divu_ceiling;
int PeleLM::have_rhort;
int PeleLM::RhoRT;
int PeleLM::first_spec;
int PeleLM::last_spec;
bool PeleLM::solve_passives = false;
int PeleLM::first_passive;
Vector<std::string> PeleLM::spec_names;
int PeleLM::floor_species;
int PeleLM::do_set_rho_to_species_sum;
int PeleLM::clipSpeciesOnRegrid;
Real PeleLM::prandtl;
Real PeleLM::schmidt;
Real PeleLM::constant_thick_val;
Array<Real, 4> PeleLM::Beta_mix;
Array<Real, NUM_SPECIES> PeleLM::spec_Bilger_fact;
Real PeleLM::Zfu;
Real PeleLM::Zox;
bool PeleLM::mixture_fraction_ready;
int PeleLM::unity_Le;
int PeleLM::use_wbar;
Real PeleLM::htt_tempmin;
Real PeleLM::htt_tempmax;
Real PeleLM::htt_hmixTYP;
int PeleLM::zeroBndryVisc;
int PeleLM::do_check_divudt;
int PeleLM::hack_nochem;
int PeleLM::hack_nospecdiff;
int PeleLM::hack_noavgdivu;
Real PeleLM::trac_diff_coef;
bool PeleLM::plot_reactions;
bool PeleLM::plot_consumption;
bool PeleLM::plot_heat_release;
int PeleLM::ncells_chem;
bool PeleLM::use_typ_vals_chem = 0;
static bool plot_rhoydot;
int PeleLM::nGrowAdvForcing=1;
#ifdef AMREX_USE_EB
int PeleLM::nGrowDivU=2;
std::string PeleLM::diffusion_redistribution_type = "FluxRedist";
#else
int PeleLM::nGrowDivU=1;
#endif
bool PeleLM::avg_down_chem;
int PeleLM::reset_typical_vals_int=-1;
Real PeleLM::typical_Y_val_min=1.e-10;
std::map<std::string,Real> PeleLM::typical_values_FileVals;
bool PeleLM::def_harm_avg_cen2edge = false;
ProbParm* PeleLM::prob_parm = nullptr;
ProbParm* PeleLM::prob_parm_d = nullptr;
ACParm* PeleLM::ac_parm = nullptr;
ACParm* PeleLM::ac_parm_d = nullptr;
pele::physics::transport::TransportParams<
pele::physics::PhysicsType::transport_type>
PeleLM::trans_parms;
pele::physics::PMF::PmfData PeleLM::pmf_data;
std::string PeleLM::chem_integrator;
std::unique_ptr<pele::physics::reactions::ReactorBase> PeleLM::m_reactor;
#ifdef SOOT_MODEL
int PeleLM::do_soot_solve;
int PeleLM::plot_soot_src;
SootModel* PeleLM::soot_model;
int PeleLM::first_soot;
int PeleLM::NUM_SOOT_VARS;
int PeleLM::num_soot_src;
#endif
std::string PeleLM::turbFile;
std::map<std::string, Vector<std::string> > PeleLM::auxDiag_names;
// Active control defaults
bool PeleLM::ctrl_active = 0;
bool PeleLM::ctrl_use_temp = 0;
Real PeleLM::ctrl_tauControl = -1.0;
Real PeleLM::ctrl_cfix = 0.0;
Real PeleLM::ctrl_coftOld = -1.0;
Real PeleLM::ctrl_sest = 0.0;
Real PeleLM::ctrl_corr = 1.0;
Real PeleLM::ctrl_V_in = 0.0;
Real PeleLM::ctrl_V_in_old = 0.0;
Real PeleLM::ctrl_changeMax = 1.0;
Real PeleLM::ctrl_tBase = 0.0;
Real PeleLM::ctrl_dV = 0.0;
Real PeleLM::ctrl_scale = 1.0;
Real PeleLM::ctrl_zBase = 0.0;
Real PeleLM::ctrl_h = -1.0;
Real PeleLM::ctrl_velMax = 10000.0;
Real PeleLM::ctrl_temperature = -1.0;
int PeleLM::ctrl_verbose = 0;
int PeleLM::ctrl_NavgPts = 3;
int PeleLM::ctrl_flameDir = AMREX_SPACEDIM-1;
int PeleLM::ctrl_pseudoGravity = 0;
int PeleLM::ctrl_nfilled = -1;
int PeleLM::ctrl_method = 3;
std::string PeleLM::ctrl_AChistory = "AC_History.dat";
Vector<Real> PeleLM::ctrl_time_pts;
Vector<Real> PeleLM::ctrl_velo_pts;
Vector<Real> PeleLM::ctrl_cntl_pts;
Vector<Real> PeleLM::typical_values;
int PeleLM::sdc_iterMAX;
int PeleLM::num_mac_sync_iter;
int PeleLM::syncEntireHierarchy = 1;
int PeleLM::deltaT_verbose = 0;
int PeleLM::deltaT_crashOnConvFail = 1;
int PeleLM::mHtoTiterMAX;
Vector<amrex::Real> PeleLM::mTmpData;
Vector<AMRErrorTag> PeleLM::errtags;
static
std::string
to_upper (const std::string& s)
{
std::string rtn = s;
for (unsigned int i=0; i<rtn.length(); i++)
{
rtn[i] = toupper(rtn[i]);
}
return rtn;
}
static std::map<std::string,FABio::Format> ShowMF_Fab_Format_map;
void
PeleLM::compute_rhohmix (Real time,
MultiFab& rhohmix,
int dComp)
{
const Real strt_time = ParallelDescriptor::second();
const TimeLevel whichTime = which_time(State_Type,time);
AMREX_ASSERT(whichTime == AmrOldTime || whichTime == AmrNewTime);
const MultiFab& S = (whichTime == AmrOldTime) ? get_old_data(State_Type): get_new_data(State_Type);
#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
{
for (MFIter mfi(rhohmix, TilingIfNotGPU()); mfi.isValid(); ++mfi)
{
const Box& bx = mfi.tilebox();
auto const& rho = S.const_array(mfi,Density);
auto const& rhoY = S.const_array(mfi,first_spec);
auto const& T = S.const_array(mfi,Temp);
auto const& rhoHm = rhohmix.array(mfi,dComp);
amrex::ParallelFor(bx, [rho, rhoY, T, rhoHm]
AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
getRHmixGivenTY( i, j, k, rho, rhoY, T, rhoHm );
});
}
}
if (verbose > 2)
{
const int IOProc = ParallelDescriptor::IOProcessorNumber();
Real run_time = ParallelDescriptor::second() - strt_time;
ParallelDescriptor::ReduceRealMax(run_time,IOProc);
amrex::Print() << " PeleLM::compute_rhohmix(): lev: " << level << ", time: " << run_time << '\n';
}
}
int
PeleLM::getSpeciesIdx(const std::string& spName)
{
for (int i=0; i<NUM_SPECIES; i++) {
if (spName == spec_names[i]) {
return i;
}
}
return -1;
}
void
PeleLM::Initialize ()
{
if (initialized) return;
#ifdef AMREX_USE_GPU
amrex::sundials::Initialize();
#endif
#ifdef AMREX_PARTICLES
// Ensure default particles in NavierStokesBase aren't used
NavierStokesBase::do_nspc = false;
#endif
PeleLM::Initialize_specific();
NavierStokesBase::Initialize();
//
// Set all default values here!!!
//
ShowMF_Fab_Format_map["ASCII"] = FABio::FAB_ASCII;
ShowMF_Fab_Format_map["IEEE"] = FABio::FAB_IEEE;
ShowMF_Fab_Format_map["NATIVE"] = FABio::FAB_NATIVE;
ShowMF_Fab_Format_map["8BIT"] = FABio::FAB_8BIT;
ShowMF_Fab_Format_map["IEEE_32"] = FABio::FAB_IEEE_32;
ShowMF_Verbose = true;
ShowMF_Check_Nans = true;
ShowMF_Fab_Format = ShowMF_Fab_Format_map["ASCII"];
do_not_use_funccount = false;
crse_dt = -1;
chem_box_chop_threshold = -1;
PeleLM::p_amb_old = -1.0;
PeleLM::p_amb_new = -1.0;
PeleLM::num_divu_iters = 1;
PeleLM::init_once_done = 0;
PeleLM::do_OT_radiation = 0;
PeleLM::do_heat_sink = 0;
PeleLM::RhoH = -1;
PeleLM::do_diffuse_sync = 1;
PeleLM::do_reflux_visc = 1;
PeleLM::RhoYdot_Type = -1;
#ifdef AMREX_PARTICLES
PeleLM::spraydot_Type = -1;
#endif
#ifdef SOOT_MODEL
PeleLM::sootsrc_Type = -1;
PeleLM::do_soot_solve = 1;
PeleLM::plot_soot_src = -1;
PeleLM::NUM_SOOT_VARS = -1;
PeleLM::first_soot = -1;
PeleLM::num_soot_src = -1;
#endif
PeleLM::FuncCount_Type = -1;
PeleLM::divu_ceiling = 0;
PeleLM::divu_dt_factor = .5;
PeleLM::min_rho_divu_ceiling = -1.e20;
PeleLM::have_rhort = 0;
PeleLM::RhoRT = -1;
PeleLM::first_spec = -1;
PeleLM::last_spec = -2;
PeleLM::first_passive = -1;
PeleLM::floor_species = 1;
PeleLM::do_set_rho_to_species_sum = 1;
PeleLM::clipSpeciesOnRegrid = 0;
PeleLM::prandtl = .7;
PeleLM::schmidt = .7;
PeleLM::constant_thick_val = -1;
PeleLM::Beta_mix = {0};
PeleLM::spec_Bilger_fact = {0};
PeleLM::Zfu = -1;
PeleLM::Zox = -1;
PeleLM::mixture_fraction_ready = false;
PeleLM::unity_Le = 0;
PeleLM::use_wbar = 1;
PeleLM::htt_tempmin = 298.0;
PeleLM::htt_tempmax = 40000.;
PeleLM::htt_hmixTYP = -1.;
PeleLM::zeroBndryVisc = 0;
PeleLM::do_check_divudt = 1;
PeleLM::hack_nochem = 0;
PeleLM::hack_nospecdiff = 0;
PeleLM::hack_noavgdivu = 0;
PeleLM::trac_diff_coef = 0.0;
PeleLM::turbFile = "";
PeleLM::plot_reactions = false;
PeleLM::plot_consumption = true;
PeleLM::plot_heat_release = true;
plot_rhoydot = false;
PeleLM::avg_down_chem = false;
PeleLM::reset_typical_vals_int = -1;
PeleLM::typical_values_FileVals.clear();
PeleLM::sdc_iterMAX = 1;
PeleLM::num_mac_sync_iter = 1;
PeleLM::mHtoTiterMAX = 20;
PeleLM::ncells_chem = 1;
ParmParse pp("ns");
pp.query("do_diffuse_sync",do_diffuse_sync);
AMREX_ASSERT(do_diffuse_sync == 0 || do_diffuse_sync == 1);
pp.query("do_reflux_visc",do_reflux_visc);
AMREX_ASSERT(do_reflux_visc == 0 || do_reflux_visc == 1);
verbose = 1;
pp.query("v",verbose);
pp.query("divu_ceiling",divu_ceiling);
AMREX_ASSERT(divu_ceiling >= 0 && divu_ceiling <= 3);
pp.query("divu_dt_factor",divu_dt_factor);
AMREX_ASSERT(divu_dt_factor>0 && divu_dt_factor <= 1.0);
pp.query("min_rho_divu_ceiling",min_rho_divu_ceiling);
if (divu_ceiling) AMREX_ASSERT(min_rho_divu_ceiling >= 0.0);
pp.query("htt_tempmin",htt_tempmin);
pp.query("htt_tempmax",htt_tempmax);
pp.query("floor_species",floor_species);
AMREX_ASSERT(floor_species == 0 || floor_species == 1);
pp.query("do_set_rho_to_species_sum",do_set_rho_to_species_sum);
pp.query("floor_species_on_regrid",clipSpeciesOnRegrid);
pp.query("num_divu_iters",num_divu_iters);
pp.query("do_not_use_funccount",do_not_use_funccount);
#ifdef AMREX_USE_EB
pp.query("diffusion_redistribution_type",diffusion_redistribution_type);
#endif
pp.query("schmidt",schmidt);
pp.query("prandtl",prandtl);
pp.query("unity_Le",unity_Le);
unity_Le = unity_Le ? 1 : 0;
if (unity_Le)
{
schmidt = prandtl;
if (verbose) amrex::Print() << "PeleLM::read_params: Le=1, setting Sc = Pr" << '\n';
}
pp.query("use_wbar",use_wbar);
pp.query("sdc_iterMAX",sdc_iterMAX);
pp.query("num_mac_sync_iter",num_mac_sync_iter);
pp.query("syncEntireHierarchy",syncEntireHierarchy);
pp.query("thickening_factor",constant_thick_val);
if (constant_thick_val != -1)
{
if (verbose)
amrex::Print() << "PeleLM::read_params: using a constant thickening factor = "
<< constant_thick_val << '\n';
}
pp.query("hack_nochem",hack_nochem);
pp.query("hack_nospecdiff",hack_nospecdiff);
pp.query("hack_noavgdivu",hack_noavgdivu);
pp.query("do_check_divudt",do_check_divudt);
pp.query("avg_down_chem",avg_down_chem);
pp.query("reset_typical_vals_int",reset_typical_vals_int);
pp.query("do_OT_radiation",do_OT_radiation);
do_OT_radiation = (do_OT_radiation ? 1 : 0);
pp.query("do_heat_sink",do_heat_sink);
do_heat_sink = (do_heat_sink ? 1 : 0);
pp.query("turbFile",turbFile);
pp.query("zeroBndryVisc",zeroBndryVisc);
//
// Read in scalar value and use it as tracer.
//
pp.query("scal_diff_coefs",trac_diff_coef);
for (int i = 0; i < visc_coef.size(); i++)
visc_coef[i] = bogus_value;
// Get some useful amr inputs
ParmParse ppa("amr");
// Useful for debugging
ParmParse pproot;
if (int nsv=pproot.countval("ShowMF_Sets"))
{
Vector<std::string> ShowMF_set_names(nsv);
pproot.getarr("ShowMF_Sets",ShowMF_set_names);
for (int i=0; i<nsv; ++i) {
ShowMF_Sets.insert(ShowMF_set_names[i]);
}
ShowMF_Dir="."; pproot.query("ShowMF_Dir",ShowMF_Dir);
pproot.query("ShowMF_Verbose",ShowMF_Verbose);
pproot.query("ShowMF_Check_Nans",ShowMF_Check_Nans);
std::string format="NATIVE"; pproot.query("ShowMF_Fab_Format",format);
if (ShowMF_Fab_Format_map.count(to_upper(format)) == 0) {
amrex::Abort("Unknown FABio format label");
}
ShowMF_Fab_Format = ShowMF_Fab_Format_map[format];
if (ShowMF_Verbose>0 && ShowMF_set_names.size()>0) {
amrex::Print() << " ****************************** Debug: ShowMF_Sets: ";
for (int i=0; i<ShowMF_set_names.size(); ++i) {
amrex::Print() << ShowMF_set_names[i] << " ";
}
amrex::Print() << '\n';
}
}
#ifdef AMREX_PARTICLES
readParticleParams();
#endif
#ifdef SOOT_MODEL
{
ParmParse pplm("peleLM");
pplm.query("plot_soot_src", plot_soot_src);
pplm.query("do_soot_solve", do_soot_solve);
if (do_soot_solve != 1) do_soot_solve = 0;
}
soot_model->readSootParams();
#endif
if (verbose > 0)
{
amrex::Print() << "\nDumping ParmParse table:\n \n";
if (ParallelDescriptor::IOProcessor()) {
ParmParse::dumpTable(std::cout);
}
amrex::Print() << "\n... done dumping ParmParse table.\n" << '\n';
const char* githash1 = buildInfoGetGitHash(1);
const char* githash2 = buildInfoGetGitHash(2);
const char* githash3 = buildInfoGetGitHash(3);
const char* githash4 = buildInfoGetGitHash(4);
const char* githash5 = buildInfoGetGitHash(5);
amrex::Print() << " ############### Build infos ###############\n";
amrex::Print() << " PeleLM git hash: " << githash1 << "\n";
amrex::Print() << " AMReX git hash: " << githash2 << "\n";
amrex::Print() << " IAMR git hash: " << githash3 << "\n";
amrex::Print() << " AMReX-Hydro git hash: " << githash4 << "\n";
amrex::Print() << " PelePhysics git hash: " << githash5 << "\n";
amrex::Print() << " ###########################################\n\n";
}
amrex::ExecOnFinalize(PeleLM::Finalize);
initialized = true;
}
void
PeleLM::Initialize_specific ()
{
num_deltaT_iters_MAX = 10;
deltaT_norm_max = 1.e-10;
num_forkjoin_tasks = 1;
forkjoin_verbose = false;
ParmParse pplm("peleLM");
// Number of species in group for multi-component solves
pplm.query("speciesGroupSize",nSpecGroup);
pplm.query("num_forkjoin_tasks",num_forkjoin_tasks);
pplm.query("forkjoin_verbose",forkjoin_verbose);
pplm.query("num_deltaT_iters_MAX",num_deltaT_iters_MAX);
pplm.query("deltaT_norm_max",deltaT_norm_max);
pplm.query("deltaT_verbose",deltaT_verbose);
pplm.query("deltaT_crashOnConvFail",deltaT_crashOnConvFail);
pplm.query("use_typ_vals_chem",use_typ_vals_chem);
pplm.query("harm_avg_cen2edge", def_harm_avg_cen2edge);
// Get boundary conditions
Vector<std::string> lo_bc_char(AMREX_SPACEDIM);
Vector<std::string> hi_bc_char(AMREX_SPACEDIM);
pplm.getarr("lo_bc",lo_bc_char,0,AMREX_SPACEDIM);
pplm.getarr("hi_bc",hi_bc_char,0,AMREX_SPACEDIM);
Vector<int> lo_bc(AMREX_SPACEDIM), hi_bc(AMREX_SPACEDIM);
bool flag_closed_chamber = false;
for (int dir = 0; dir<AMREX_SPACEDIM; dir++){
if (!lo_bc_char[dir].compare("Interior")){
lo_bc[dir] = 0;
} else if (!lo_bc_char[dir].compare("Inflow")){
lo_bc[dir] = 1;
flag_closed_chamber = true;
} else if (!lo_bc_char[dir].compare("Outflow")){
lo_bc[dir] = 2;
flag_closed_chamber = true;
} else if (!lo_bc_char[dir].compare("Symmetry")){
lo_bc[dir] = 3;
} else if (!lo_bc_char[dir].compare("SlipWallAdiab")){
lo_bc[dir] = 4;
} else if (!lo_bc_char[dir].compare("NoSlipWallAdiab")){
lo_bc[dir] = 5;
} else if (!lo_bc_char[dir].compare("SlipWallIsotherm")){
lo_bc[dir] = 6;
} else if (!lo_bc_char[dir].compare("NoSlipWallIsotherm")){
lo_bc[dir] = 7;
} else {
amrex::Abort("Wrong boundary condition word in lo_bc, please use: Interior, Inflow, Outflow, "
"Symmetry, SlipWallAdiab, NoSlipWallAdiab, SlipWallIsotherm, NoSlipWallIsotherm");
}
if (!hi_bc_char[dir].compare("Interior")){
hi_bc[dir] = 0;
} else if (!hi_bc_char[dir].compare("Inflow")){
hi_bc[dir] = 1;
flag_closed_chamber = true;
} else if (!hi_bc_char[dir].compare("Outflow")){
hi_bc[dir] = 2;
flag_closed_chamber = true;
} else if (!hi_bc_char[dir].compare("Symmetry")){
hi_bc[dir] = 3;
} else if (!hi_bc_char[dir].compare("SlipWallAdiab")){
hi_bc[dir] = 4;
} else if (!hi_bc_char[dir].compare("NoSlipWallAdiab")){
hi_bc[dir] = 5;
} else if (!hi_bc_char[dir].compare("SlipWallIsotherm")){
hi_bc[dir] = 6;
} else if (!hi_bc_char[dir].compare("NoSlipWallIsotherm")){
hi_bc[dir] = 7;
} else {
amrex::Abort("Wrong boundary condition word in hi_bc, please use: Interior, UserBC, Symmetry, SlipWall, NoSlipWall");
}
}
for (int i = 0; i < AMREX_SPACEDIM; i++)
{
phys_bc.setLo(i,lo_bc[i]);
phys_bc.setHi(i,hi_bc[i]);
}
read_geometry();
//
// Check phys_bc against possible periodic geometry
// if periodic, must have internal BC marked.
//
if (DefaultGeometry().isAnyPeriodic())
{
//
// Do idiot check. Periodic means interior in those directions.
//
for (int dir = 0; dir < AMREX_SPACEDIM; dir++)
{
if (DefaultGeometry().isPeriodic(dir))
{
if (lo_bc[dir] != Interior)
{
std::cerr << "PeleLM::variableSetUp:periodic in direction "
<< dir
<< " but low BC is not Interior\n";
amrex::Abort("PeleLM::Initialize()");
}
if (hi_bc[dir] != Interior)
{
std::cerr << "PeleLM::variableSetUp:periodic in direction "
<< dir
<< " but high BC is not Interior\n";
amrex::Abort("PeleLM::Initialize()");
}
}
}
}
{
//
// Do idiot check. If not periodic, should be no interior.
//
for (int dir = 0; dir < AMREX_SPACEDIM; dir++)
{
if (!DefaultGeometry().isPeriodic(dir))
{
if (lo_bc[dir] == Interior)
{
std::cerr << "PeleLM::variableSetUp:Interior bc in direction "
<< dir
<< " but not defined as periodic\n";
amrex::Abort("PeleLM::Initialize()");
}
if (hi_bc[dir] == Interior)
{
std::cerr << "PeleLM::variableSetUp:Interior bc in direction "
<< dir
<< " but not defined as periodic\n";
amrex::Abort("PeleLM::Initialize()");
}
}
}
}
PeleLM::closed_chamber = 1;
if (flag_closed_chamber){
PeleLM::closed_chamber = 0;
}
PeleLM::dpdt_factor = 1.0;
pplm.query("dpdt_factor",dpdt_factor);
// Initialize reactor: TODO might do a per level ?
if (!pplm.contains("chem_integrator")) {
Abort(" peleLM.chem_integrator need to be specified");
}
pplm.get("chem_integrator",chem_integrator);
m_reactor = pele::physics::reactions::ReactorBase::create(chem_integrator);
const int nCell = 1;
const int reactType = 2;
m_reactor->init(reactType, nCell);
}
void
PeleLM::Finalize ()
{
initialized = false;
}
static
Box
getStrip(const Geometry& geom)
{
const Box& box = geom.Domain();
IntVect be = box.bigEnd();
IntVect se = box.smallEnd();
se[0] = (int) 0.5*(se[0]+be[0]);
be[0] = se[0];
return Box(se,be);
}
void
showMFsub(const std::string& mySet,
const MultiFab& mf,
const Box& box,
const std::string& name,
int lev = -1,
int iter = -1) // Default value = no append 2nd integer
{
if (ShowMF_Sets.count(mySet)>0)
{
const FABio::Format saved_format = FArrayBox::getFormat();
FArrayBox::setFormat(ShowMF_Fab_Format);
std::string DebugDir(ShowMF_Dir);
if (ParallelDescriptor::IOProcessor())
if (!amrex::UtilCreateDirectory(DebugDir, 0755))
amrex::CreateDirectoryFailed(DebugDir);
ParallelDescriptor::Barrier();
std::string junkname = name;
if (lev>=0) {
junkname = amrex::Concatenate(junkname+"_",lev,1);
}
if (iter>=0) {
junkname = amrex::Concatenate(junkname+"_",iter,1);
}
junkname = DebugDir + "/" + junkname;
if (ShowMF_Verbose>0) {
amrex::Print() << " ****************************** Debug: writing "
<< junkname << '\n';
}
FArrayBox sub(box,mf.nComp());
mf.copyTo(sub,0,0,mf.nComp(),0);
if (ShowMF_Check_Nans)
{
AMREX_ASSERT(!sub.contains_nan<RunOn::Host>(box,0,mf.nComp()));
}
std::ofstream os;
os.precision(15);
os.open(junkname.c_str());
sub.writeOn(os);
os.close();
FArrayBox::setFormat(saved_format);
}
}
void
showMF(const std::string& mySet,
const MultiFab& mf,
const std::string& name,
int lev = -1,
int iter = -1, // Default value = no append 2nd integer
int step = -1) // Default value = no append 3nd integer
{
if (ShowMF_Sets.count(mySet)>0)
{
const FABio::Format saved_format = FArrayBox::getFormat();
FArrayBox::setFormat(ShowMF_Fab_Format);
std::string DebugDir(ShowMF_Dir);
if (ParallelDescriptor::IOProcessor())
if (!amrex::UtilCreateDirectory(DebugDir, 0755))
amrex::CreateDirectoryFailed(DebugDir);
ParallelDescriptor::Barrier();
std::string junkname = name;
if (lev>=0) {
junkname = amrex::Concatenate(junkname+"_",lev,1);
}
if (iter>=0) {
junkname = amrex::Concatenate(junkname+"_",iter,1);
}
if (step>=0) {
junkname = amrex::Concatenate(junkname+"_",step,5);
}
junkname = DebugDir + "/" + junkname;
if (ShowMF_Verbose>0) {
amrex::Print() << " ****************************** Debug: writing "
<< junkname << '\n';
}
#if 0
if (ShowMF_Check_Nans)
{
for (MFIter mfi(mf); mfi.isValid(); ++mfi)
{
// AMREX_ASSERT(!mf[mfi].contains_nan(mfi.validbox(),0,mf.nComp()));
}
}
#endif
VisMF::Write(mf,junkname);
FArrayBox::setFormat(saved_format);
}
}
PeleLM::FPLoc
PeleLM::fpi_phys_loc (int p_bc)
{
//
// Location of data that FillPatchIterator returns at physical boundaries
//
if (p_bc == EXT_DIR || p_bc == HOEXTRAP || p_bc == FOEXTRAP)
{
return HT_Edge;
}
return HT_Center;
}
LM_Error_Value::LM_Error_Value (Real _min_time, Real _max_time, int _max_level)
: lmef(0), lmef_box(0), value(0), min_time(_min_time), max_time(_max_time), max_level(_max_level)
{
}
LM_Error_Value::LM_Error_Value (LMEF _lmef,
Real _value, Real _min_time,
Real _max_time, int _max_level)
: lmef(_lmef), lmef_box(0), value(_value), min_time(_min_time), max_time(_max_time), max_level(_max_level)
{
}
LM_Error_Value::LM_Error_Value (LMEF_BOX _lmef_box, const amrex::RealBox& _box, amrex::Real _min_time,
amrex::Real _max_time, int _max_level)
: lmef(0), lmef_box(_lmef_box), value(0), min_time(_min_time), max_time(_max_time), box(_box), max_level(_max_level)
{
}
void
LM_Error_Value::tagCells(int* tag, const int* tlo, const int* thi,
const int* tagval, const int* clearval,
const Real* data, const int* dlo, const int* dhi,
const int* lo, const int* hi, const int* nvar,
const int* domain_lo, const int* domain_hi,
const Real* dx, const Real* xlo,
const Real* prob_lo, const Real* time,
const int* level) const
{
AMREX_ASSERT(lmef);
bool max_level_applies = ( (max_level < 0) || (*level < max_level) );
bool valid_time_range = (min_time >= 0) && (max_time >= 0) && (min_time <= max_time);
bool in_valid_time_range = valid_time_range && (*time >= min_time ) && (*time <= max_time);
bool one_side_lo = !valid_time_range && (min_time >= 0) && (*time >= min_time);
bool one_side_hi = !valid_time_range && (max_time >= 0) && (*time <= max_time);
bool time_window_applies = in_valid_time_range || one_side_lo || one_side_hi || !valid_time_range;
if (max_level_applies && time_window_applies)
{
lmef(tag, AMREX_ARLIM_ANYD(tlo), AMREX_ARLIM_ANYD(thi),
tagval, clearval,
data, AMREX_ARLIM_ANYD(dlo), AMREX_ARLIM_ANYD(dhi),
lo, hi, nvar,
domain_lo, domain_hi, dx, xlo, prob_lo, time, level, &value);
}
}
void
LM_Error_Value::tagCells1(int* tag, const int* tlo, const int* thi,
const int* tagval, const int* clearval,
const int* lo, const int* hi,
const int* domain_lo, const int* domain_hi,
const Real* dx, const Real* xlo,
const Real* prob_lo, const Real* time,
const int* level) const
{
AMREX_ASSERT(lmef_box);
bool max_level_applies = ( (max_level < 0) || ( *level < max_level ) );
bool valid_time_range = (min_time >= 0) && (max_time >= 0) && (min_time <= max_time);
bool in_valid_time_range = valid_time_range && (*time >= min_time ) && (*time <= max_time);
bool one_side_lo = !valid_time_range && (min_time >= 0) && (*time >= min_time);
bool one_side_hi = !valid_time_range && (max_time >= 0) && (*time <= max_time);
bool time_window_applies = in_valid_time_range || one_side_lo || one_side_hi || !valid_time_range;
if (max_level_applies && time_window_applies)
{
lmef_box(tag, AMREX_ARLIM_ANYD(tlo), AMREX_ARLIM_ANYD(thi),
tagval, clearval,
AMREX_ZFILL(box.lo()), AMREX_ZFILL(box.hi()),
lo, hi, domain_lo, domain_hi, dx, xlo, prob_lo, time, level);
}
}
void
PeleLM::variableCleanUp ()
{
NavierStokesBase::variableCleanUp();
ShowMF_Sets.clear();
auxDiag_names.clear();
typical_values.clear();
delete prob_parm;
delete ac_parm;
The_Arena()->free(prob_parm_d);
The_Arena()->free(ac_parm_d);
#ifdef SOOT_MODEL
delete soot_model;
#endif
trans_parms.deallocate();
//PMF::close();
m_reactor->close();
#ifdef AMREX_USE_GPU
amrex::sundials::Finalize();
#endif
}
PeleLM::PeleLM ()
{
if (!init_once_done)
init_once();
if (!do_temp)
amrex::Abort("do_temp MUST be true");
if (!have_divu)
amrex::Abort("have_divu MUST be true");
// p_amb_old and p_amb_new contain the old-time and new-time
// pressure at level 0. For closed chamber problems they change over time.
// set p_amb_old and new if they haven't been set yet
// to the value in mod_Fvar_def.F90 set in PROB_F.F90
// only the coarse level advance and the level 0-1 mac_sync
// can modify these later
if (p_amb_old == -1.0)
{
p_amb_old = prob_parm->P_mean;
}
if (p_amb_new == -1.0)
{
p_amb_new = prob_parm->P_mean;
}
updateFluxReg = false;
is_predictor = false;
EdgeState = 0;
EdgeFlux = 0;
SpecDiffusionFluxn = 0;
SpecDiffusionFluxnp1 = 0;
if (use_wbar) {