Skip to content

Commit

Permalink
On burn failure, return immediately before clean_state
Browse files Browse the repository at this point in the history
  • Loading branch information
maxpkatz committed Jul 9, 2023
1 parent 7ba72e5 commit 29afb4a
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions Source/reactions/Castro_react.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,25 @@ Castro::do_old_reactions (Real time, Real dt)
amrex::ignore_unused(time);
amrex::ignore_unused(dt);

bool burn_success = true;
advance_status status {};

#ifndef SIMPLIFIED_SDC
bool burn_success = true;

MultiFab& R_old = get_old_data(Reactions_Type);
MultiFab& R_new = get_new_data(Reactions_Type);

if (time_integration_method != SimplifiedSpectralDeferredCorrections) {
// The result of the reactions is added directly to Sborder.
burn_success = react_state(Sborder, R_old, time, 0.5 * dt, 0);

if (!burn_success) {
status.success = false;
status.reason = "burn unsuccessful";

return status;
}

clean_state(
#ifdef MHD
Bx_old_tmp, By_old_tmp, Bz_old_tmp,
Expand All @@ -36,13 +46,6 @@ Castro::do_old_reactions (Real time, Real dt)
}
#endif

advance_status status {};

if (!burn_success) {
status.success = false;
status.reason = "burn unsuccessful";
}

return status;
}

Expand All @@ -52,6 +55,8 @@ Castro::do_new_reactions (Real time, Real dt)
amrex::ignore_unused(time);
amrex::ignore_unused(dt);

advance_status status {};

bool burn_success = true;

MultiFab& R_new = get_new_data(Reactions_Type);
Expand All @@ -68,6 +73,13 @@ Castro::do_new_reactions (Real time, Real dt)

burn_success = react_state(time, dt);

if (!burn_success) {
status.success = false;
status.reason = "burn unsuccessful";

return status;
}

clean_state(S_new, time + dt, S_new.nGrow());

// Check for NaN's.
Expand All @@ -94,6 +106,14 @@ Castro::do_new_reactions (Real time, Real dt)
if (time_integration_method != SimplifiedSpectralDeferredCorrections) {

burn_success = react_state(S_new, R_new, time - 0.5 * dt, 0.5 * dt, 1);

if (!burn_success) {
status.success = false;
status.reason = "burn unsuccessful";

return status;
}

clean_state(
#ifdef MHD
Bx_new, By_new, Bz_new,
Expand All @@ -104,15 +124,7 @@ Castro::do_new_reactions (Real time, Real dt)

#endif // SIMPLIFIED_SDC

advance_status status {};

if (!burn_success) {
status.success = false;
status.reason = "burn unsuccessful";
}

return status;

}

// Strang version
Expand Down

0 comments on commit 29afb4a

Please sign in to comment.