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

Bugfix: RHS eval logic with certain IMEX methods #627

Merged
merged 4 commits into from
Dec 19, 2024
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

### Bug Fixes

Fixed a bug in ARKStep where an extra right-hand side evaluation would occur
each time step when enabling the ``ARKodeSetAutonomous`` option and using an
IMEX method where the DIRK table has an implicit first stage and is not stiffly
accurate.

### Deprecation Notices

## Changes to SUNDIALS in release 7.2.0
Expand Down
5 changes: 5 additions & 0 deletions doc/shared/RecentChanges.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@

**Bug Fixes**

Fixed a bug in ARKStep where an extra right-hand side evaluation would occur
each time step when enabling the :c:func:`ARKodeSetAutonomous` option and using
an IMEX method where the DIRK table has an implicit first stage and is not stiffly
accurate.

**Deprecation Notices**
9 changes: 3 additions & 6 deletions src/arkode/arkode_arkstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -1751,11 +1751,8 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
}
}

/* For a stiffly accurate implicit or ImEx method with an implicit first
stage, save f(tn, yn) if using Hermite interpolation as Fi[0] will be
overwritten during the implicit solve */
save_fn_for_interp = implicit_stage && stiffly_accurate &&
ark_mem->interp_type == ARK_INTERP_HERMITE;
/* Save f(tn, yn) for Hermite interpolation */
save_fn_for_interp = ark_mem->interp_type == ARK_INTERP_HERMITE;

/* For an implicit or ImEx method using the trivial predictor with an
autonomous problem with an identity or fixed mass matrix, save fi(tn, yn)
Expand All @@ -1778,7 +1775,7 @@ int arkStep_TakeStep_Z(ARKodeMem ark_mem, sunrealtype* dsmPtr, int* nflagPtr)
/* If saving the RHS evaluation for reuse in the residual, call the full RHS
for all implicit methods or for ImEx methods with an explicit first
stage. ImEx methods with an implicit first stage may not need to evaluate
fe depending on the interpolation type. */
fe depending on the interpolation type (covered by save_fn_for_interp) */
sunbooleantype res_full_rhs = save_fn_for_residual && implicit_stage &&
!imex_method;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,13 +803,6 @@ int expected_rhs_evals(ProblemOptions& prob_opts, int stages, int order,
nfe_expected += nst;
}
}

if (prob_opts.i_type != interp_type::hermite && save_fn_for_residual &&
!explicit_first_stage)
{
if (stiffly_accurate) { nfe_expected++; }
else { nfe_expected += nst; }
}
}

// Expected number of implicit functions evaluations
Expand Down
Loading