Skip to content

Commit

Permalink
removed 'if' statement from inside MRISR stage loop
Browse files Browse the repository at this point in the history
  • Loading branch information
drreynolds committed Oct 30, 2024
1 parent bf07627 commit 45faa46
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/arkode/arkode_mristep.c
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,7 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
sunrealtype cstage; /* current stage abscissa */
sunbooleantype need_inner_dsm;
sunbooleantype force_reset = (*dsmPtr == PREV_ERR_FAIL);
int nvec;
int nvec, max_stages;
const sunrealtype tol = SUN_RCONST(100.0) * SUN_UNIT_ROUNDOFF;

/* access the MRIStep mem structure */
Expand Down Expand Up @@ -2368,8 +2368,12 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
/* The first stage is the previous time-step solution, so its RHS
is the [already-computed] slow RHS from the start of the step */

/* Determine how many stages will be needed */
max_stages = (ark_mem->fixedstep && (ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE)) ?
step_mem->stages : step_mem->stages+1;

/* Loop over stages */
for (stage = 1; stage <= step_mem->stages; stage++)
for (stage = 1; stage < max_stages; stage++)
{
/* Solver diagnostics reporting */
#if SUNDIALS_LOGGING_LEVEL >= SUNDIALS_LOGGING_DEBUG
Expand All @@ -2382,14 +2386,6 @@ int mriStep_TakeStepMRISR(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
solution = (stage == step_mem->stages - 1);
embedding = (stage == step_mem->stages);

/* Skip the embedding if we're using fixed time-stepping and
temporal error estimation is disabled */
if (ark_mem->fixedstep && embedding &&
(ark_mem->AccumErrorType == ARK_ACCUMERROR_NONE))
{
break;
}

/* Set initial condition for this stage */
N_VScale(ONE, ark_mem->yn, ark_mem->ycur);

Expand Down

0 comments on commit 45faa46

Please sign in to comment.