From 45faa466df61a20dfa563c8fa4a2db6fe8286bce Mon Sep 17 00:00:00 2001 From: "Daniel R. Reynolds" Date: Wed, 30 Oct 2024 17:39:18 -0500 Subject: [PATCH] removed 'if' statement from inside MRISR stage loop --- src/arkode/arkode_mristep.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/arkode/arkode_mristep.c b/src/arkode/arkode_mristep.c index dd74556889..4d2ba58bf9 100644 --- a/src/arkode/arkode_mristep.c +++ b/src/arkode/arkode_mristep.c @@ -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 */ @@ -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 @@ -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);