Skip to content

Commit

Permalink
Merge pull request #22 from AMReX-Combustion/fix_reactorIssues
Browse files Browse the repository at this point in the history
Fix behavior of ReactorNull
  • Loading branch information
nickwimer authored Oct 20, 2021
2 parents 79947b8 + 734d523 commit a03dd80
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
7 changes: 4 additions & 3 deletions Source/PeleLM.H
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ class PeleLM : public amrex::AmrCore {
int m_use_wbar = 1;

// switch on/off different processes
// TODO: actually implement that
int m_do_react = 1;
int m_do_diff = 1;
int m_do_adv = 1;
Expand Down Expand Up @@ -992,9 +993,9 @@ class PeleLM : public amrex::AmrCore {
int m_numDivuIter = 1;
int m_init_iter = 3;

// Chem
amrex::Real m_rtol_chem = 1.0e-10;
amrex::Real m_atol_chem = 1.0e-10;
// Chemistry
int m_skipInstantRR = 0;


// Typical values
int m_resetTypValInt = 10;
Expand Down
17 changes: 11 additions & 6 deletions Source/PeleLMEos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void PeleLM::calcDivU(int is_init,
auto ldata_p = getLevelDataPtr(lev,a_time);

MultiFab RhoYdot;
if ( m_do_react ) {
if ( m_do_react && !m_skipInstantRR ) {
if (is_init) { // Either pre-divU, divU or press initial iterations
if ( m_dt > 0.0 ) { // divU ite -> use I_R
auto ldataR_p = getLevelDataReactPtr(lev);
Expand All @@ -80,7 +80,11 @@ void PeleLM::calcDivU(int is_init,
// TODO Setup covered cells mask
MultiFab mask(grids[lev],dmap[lev],1,0);
mask.setVal(1.0);
#ifdef PLM_USE_EFIELD
computeInstantaneousReactionRateEF(lev, a_time, mask, &RhoYdot);
#else
computeInstantaneousReactionRate(lev, a_time, mask, &RhoYdot);
#endif
}
}

Expand Down Expand Up @@ -110,9 +114,10 @@ void PeleLM::calcDivU(int is_init,
: diffData->Dnp1[lev].const_array(mfi,NUM_SPECIES);
auto const& DiffDiff = ( a_time == AmrOldTime ) ? diffData->Dn[lev].const_array(mfi,NUM_SPECIES+1)
: diffData->Dnp1[lev].const_array(mfi,NUM_SPECIES+1);
auto const& r = (m_do_react) ? RhoYdot.const_array(mfi)
auto const& r = (m_do_react && !m_skipInstantRR) ? RhoYdot.const_array(mfi)
: ldata_p->species.const_array(mfi); // Dummy unused Array4
auto const& divu = ldata_p->divu.array(mfi);
int use_react = (m_do_react && !m_skipInstantRR) ? 1 : 0;

#ifdef AMREX_USE_EB
if (flagfab.getType(bx) == FabType::covered) { // Covered boxes
Expand All @@ -122,22 +127,22 @@ void PeleLM::calcDivU(int is_init,
divu(i,j,k) = 0.0;
});
} else if (flagfab.getType(bx) != FabType::regular ) { // EB containing boxes
amrex::ParallelFor(bx, [ rhoY, T, SpecD, Fourier, DiffDiff, r, divu, do_react=m_do_react, flag]
amrex::ParallelFor(bx, [ rhoY, T, SpecD, Fourier, DiffDiff, r, divu, use_react, flag]
AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
if ( flag(i,j,k).isCovered() ) {
divu(i,j,k) = 0.0;
} else {
compute_divu( i, j, k, rhoY, T, SpecD, Fourier, DiffDiff, r, divu, do_react );
compute_divu( i, j, k, rhoY, T, SpecD, Fourier, DiffDiff, r, divu, use_react );
}
});
} else
#endif
{
amrex::ParallelFor(bx, [ rhoY, T, SpecD, Fourier, DiffDiff, r, divu, do_react=m_do_react]
amrex::ParallelFor(bx, [ rhoY, T, SpecD, Fourier, DiffDiff, r, divu, use_react]
AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
compute_divu( i, j, k, rhoY, T, SpecD, Fourier, DiffDiff, r, divu, do_react );
compute_divu( i, j, k, rhoY, T, SpecD, Fourier, DiffDiff, r, divu, use_react );
});
}
}
Expand Down
3 changes: 1 addition & 2 deletions Source/PeleLMReactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,6 @@ void PeleLM::advanceChemistry(int lev,
void PeleLM::computeInstantaneousReactionRate(const Vector<MultiFab*> &I_R,
const TimeStamp &a_time)
{
BL_PROFILE_VAR("PeleLM::computeInstantaneousReactionRate()", computeInstantaneousReactionRate);

for (int lev = 0; lev <= finest_level; ++lev) {
// TODO EB Setup covered cells mask
MultiFab mask(grids[lev],dmap[lev],1,0);
Expand All @@ -394,6 +392,7 @@ void PeleLM::computeInstantaneousReactionRate(int lev,
const MultiFab &a_mask,
MultiFab* a_I_R)
{
BL_PROFILE("PeleLM::computeInstantaneousReactionRate()");
auto ldata_p = getLevelDataPtr(lev,a_time);

#ifdef AMREX_USE_EB
Expand Down
11 changes: 4 additions & 7 deletions Source/PeleLMSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ void PeleLM::Setup() {
ParmParse pp("peleLM");
pp.query("chem_integrator",m_chem_integrator);
m_reactor = pele::physics::reactions::ReactorBase::create(m_chem_integrator);
#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
{
m_reactor->init(reactor_type, ncells_chem);
m_reactor->init(reactor_type, ncells_chem);
// For ReactorNull, we need to also skip instantaneous RR used in divU
if (m_chem_integrator == "ReactorNull") {
m_skipInstantRR = 1;
}
}

Expand Down Expand Up @@ -279,8 +278,6 @@ void PeleLM::readParameters() {
// Reaction
// -----------------------------------------
pp.query("do_react",m_do_react);
pp.query("chem_rtol",m_rtol_chem);
pp.query("chem_atol",m_atol_chem);
pp.query("use_typ_vals_chem",m_useTypValChem);
pp.query("typical_values_reset_int",m_resetTypValInt);

Expand Down

0 comments on commit a03dd80

Please sign in to comment.