diff --git a/Source/driver/Castro_advance_ctu.cpp b/Source/driver/Castro_advance_ctu.cpp index 911a2780e9..35669ff95d 100644 --- a/Source/driver/Castro_advance_ctu.cpp +++ b/Source/driver/Castro_advance_ctu.cpp @@ -265,6 +265,13 @@ Castro::subcycle_advance_ctu(const Real time, const Real dt, int amr_iteration, Real last_dt_subcycle = 1.e200; +#ifdef NSE_NET + bool do_loosen = true; + bool old_nse_dx_independent = nse_dx_independent; + bool old_nse_molar_independent = nse_molar_independent; + bool old_nse_skip_molar = nse_skip_molar; +#endif + while (subcycle_time < (1.0 - eps) * (time + dt)) { // Save the dt_subcycle before modifying it, we will use it later. @@ -305,10 +312,31 @@ Castro::subcycle_advance_ctu(const Real time, const Real dt, int amr_iteration, int num_subcycles_remaining = int(round(((time + dt) - subcycle_time) / dt_subcycle)); if (num_subcycles_remaining > max_subcycles) { +#ifdef NSE_NET + if (loosen_nse_bailout && do_loosen) { + + // find the smallest allowed dt_subcycle and then loosen nse_net bailout condition + + dt_subcycle = ((time + dt) - subcycle_time) / (max_subcycles); + num_subcycles_remaining = max_subcycles; + + nse_dx_independent = true; + nse_molar_independent = true; + nse_skip_molar = true; + do_loosen = false; + + amrex::Print() << std::endl + << " The subcycle mechanism requested " << num_subcycles_remaining << " subcycled timesteps, which is larger than the maximum of " << max_subcycles << "." << std::endl + << " Reperforming subcycle with smallest possible dt_subcycle and loosen nse bailout conditions." << std::endl; + } else { +#endif amrex::Print() << std::endl << " The subcycle mechanism requested " << num_subcycles_remaining << " subcycled timesteps, which is larger than the maximum of " << max_subcycles << "." << std::endl << " If you would like to override this, increase the parameter castro.max_subcycles." << std::endl; amrex::Abort("Error: too many subcycles."); +#ifdef NSE_NET + } +#endif } // If we get to this point, we survived the sanity checks. Print out the current subcycle iteration. @@ -492,6 +520,14 @@ Castro::subcycle_advance_ctu(const Real time, const Real dt, int amr_iteration, } +#ifdef NSE_NET + // Restore the original nse configuration + + nse_dx_independent = old_nse_dx_independent; + nse_molar_independent = old_nse_molar_independent; + nse_skip_molar = old_nse_skip_molar; +#endif + // We want to return the subcycled timestep as a suggestion. // Let's be sure to return the subcycled timestep that was // unmodified by anything we had to do in the last subcycle diff --git a/Source/driver/_cpp_parameters b/Source/driver/_cpp_parameters index 6b0f006485..ec745371da 100644 --- a/Source/driver/_cpp_parameters +++ b/Source/driver/_cpp_parameters @@ -371,6 +371,9 @@ stopping_criterion_field string "" # Threshold value for determining whether to stop. stopping_criterion_value Real 1.e200 +# whether to loosen nse bailout condition when max_subcycles is reached +loosen_nse_bailout int 0 + #----------------------------------------------------------------------------- # category: reactions #-----------------------------------------------------------------------------