Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] loosen nse constraint only after max subcycle is reached #2435

Draft
wants to merge 18 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Source/driver/Castro_advance_ctu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Source/driver/_cpp_parameters
Original file line number Diff line number Diff line change
Expand Up @@ -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
#-----------------------------------------------------------------------------
Expand Down
Loading