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

Feature: Add option to disable interpolation in ARKODE #474

Merged
merged 27 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9f55d67
update recent changes
gardner48 May 12, 2024
bb790d4
update docs
gardner48 May 12, 2024
d3a92e8
add more subsections to change logs
gardner48 May 12, 2024
2427bba
update arkode and steppers
gardner48 May 12, 2024
5650b89
update tests
gardner48 May 12, 2024
5d3055d
fix formatting
gardner48 May 12, 2024
6660626
update answers submodule
gardner48 May 12, 2024
eebc00e
Merge branch 'develop' into feature/no-interpolation-2
gardner48 May 12, 2024
d8f64f6
fix devault interp type
gardner48 May 12, 2024
b358972
add missing GetDky guard in stop tests
gardner48 May 12, 2024
9395c3d
update out files
gardner48 May 12, 2024
5811b5c
update answers submodule
gardner48 May 12, 2024
e29fe49
fix typo
gardner48 May 12, 2024
d4e4a64
move shared upates outside conditional
gardner48 May 12, 2024
6e0cad2
single quotes in markdown
gardner48 May 12, 2024
fd60b23
Merge branch 'develop' into feature/no-interpolation-2
gardner48 May 12, 2024
30d1397
Merge branch 'develop' into feature/no-interpolation-2
gardner48 May 15, 2024
8f67284
Merge branch 'develop' into feature/no-interpolation-2
gardner48 May 15, 2024
3087d86
Merge branch 'develop' into feature/no-interpolation-2
gardner48 May 20, 2024
d8aca4f
fix merge
gardner48 May 20, 2024
a6bfdae
Merge branch 'develop' into feature/no-interpolation-2
gardner48 May 21, 2024
877ab10
Merge branch 'develop' into feature/no-interpolation-2
balos1 May 21, 2024
6c9582e
Apply suggestions from code review
gardner48 May 21, 2024
1f0a093
Apply suggestions from code review
gardner48 May 21, 2024
47e16b2
update input checks and comments in SetDegree
gardner48 May 21, 2024
795459d
Merge branch 'develop' into feature/no-interpolation-2
gardner48 May 21, 2024
8230f01
Merge branch 'develop' into feature/no-interpolation-2
gardner48 May 23, 2024
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
80 changes: 55 additions & 25 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

## Changes to SUNDIALS in release X.Y.Z

Created shared user interface for ARKODE user-callable routines, to allow more
uniform control over time-stepping algorithms, improved extensibility, and
simplified code maintenance. Marked the corresponding stepper-specific
user-callable routines as deprecated; these will be removed in a future major
release.
### Major Features

Created shared user interface functions for ARKODE to allow more uniform control
over time-stepping algorithms, improved extensibility, and simplified code
maintenance. The corresponding stepper-specific user-callable functions are now
deprecated and will be removed in a future major release.

Added CMake infrastructure that enables externally maintained addons/plugins to
be *optionally* built with SUNDIALS. See the [Contributing
Guide](./CONTRIBUTING.md) for more details.

Added "Resize" capability, as well as missing `SetRootDirection` and
`SetNoInactiveRootWarn` functions, to ARKODE's SPRKStep time-stepping module.
### New Features and Enhancements

Deprecated `ARKStepSetOptimalParams` function; added instructions to user guide
for users who wish to retain the current functionality.
Added support for Kokkos Kernels v4.

Added the following Runge-Kutta Butcher tables
* `ARKODE_FORWARD_EULER_1_1`
Expand All @@ -32,39 +35,66 @@ Added the following MRI coupling tables
* `ARKODE_IMEX_MRI_GARK_TRAPEZOIDAL`
* `ARKODE_IMEX_MRI_GARK_MIDPOINT`

Users may now disable interpolated output in ARKODE by passing `ARK_INTERP_NONE`
to `ARKodeSetInterpolantType`. When interpolation is disabled, rootfinding is
not supported, implicit methods must use the trivial predictor (the default
option), and interpolation at stop times cannot be used (interpolating at stop
times is disabled by default). With interpolation disabled, calling
`ARKodeEvolve` in `ARK_NORMAL` mode will return at or past the requested output
time (setting a stop time may still be used to halt the integrator at a specific
time). Disabling interpolation will reduce the memory footprint of an integrator
by two or more state vectors (depending on the interpolant type and degree)
which can be beneficial when interpolation is not needed e.g., when integrating
to a final time without output in between or using an explicit fast time scale
integrator with an MRI method.

Added "Resize" capability to ARKODE's SPRKStep time-stepping module.

### Bug Fixes

Updated the CMake variable `HIP_PLATFORM` default to `amd` as the previous
default, `hcc`, is no longer recognized in ROCm 5.7.0 or newer. The new default
is also valid in older version of ROCm (at least back to version 4.3.1).

Fixed a bug in the HIP execution policies where `WARP_SIZE` would not be set
with ROCm 6.0.0 or newer.

Changed the CMake version compatibility mode for SUNDIALS to `AnyNewerVersion`
instead of `SameMajorVersion`. This fixes the issue seen
[here](https://github.com/AMReX-Codes/amrex/pull/3835).

Fixed a bug in some Fortran examples where `c_null_ptr` was passed as an argument
to a function pointer instead of `c_null_funptr`. This caused compilation issues
with the Cray Fortran compiler.
Fixed a CMake bug that caused an MPI linking error for our C++ examples in some
instances. Fixes [GitHub Issue
#464](https://github.com/LLNL/sundials/issues/464).

Fixed a bug where `MRIStepEvolve` would not handle a recoverable error produced
from evolving the inner stepper.
Fixed a bug in some Fortran examples where `c_null_ptr` was passed as an
argument to a function pointer instead of `c_null_funptr`. This caused
compilation issues with the Cray Fortran compiler.

Added CMake infrastructure that enables externally maintained addons/plugins
to be *optionally* built with SUNDIALS. See the [Contributing Guide](./CONTRIBUTING.md)
for more details.
Fixed a bug in the HIP execution policies where `WARP_SIZE` would not be set
with ROCm 6.0.0 or newer.

Added support for Kokkos Kernels v4.
Fixed a bug that caused error messages to be cut off in some cases. Fixes
[GitHub Issue #461](https://github.com/LLNL/sundials/issues/461).

Fixed a bug that caused error messages to be cut off in some cases. Fixes [GitHub Issue #461](https://github.com/LLNL/sundials/issues/461).
Fixed a memory leak when an error handler was added to a `SUNContext`. Fixes
[GitHub Issue #466](https://github.com/LLNL/sundials/issues/466).

Fixed a memory leak when an error handler was added to a `SUNContext`. Fixes [GitHub Issue #466](https://github.com/LLNL/sundials/issues/466).
Fixed a bug where `MRIStepEvolve` would not handle a recoverable error produced
from evolving the inner stepper.

Fixed a CMake bug that caused an MPI linking error for our C++ examples in some instances. Fixes [GitHub Issue #464](https://github.com/LLNL/sundials/issues/464).
Added missing `SetRootDirection` and `SetNoInactiveRootWarn` functions to
ARKODE's SPRKStep time-stepping module.

Fixed a bug in `ARKodeSPRKTable_Create` where the coefficient arrays where not
Fixed a bug in `ARKodeSPRKTable_Create` where the coefficient arrays were not
allocated.

### Deprecation Notices

Numerous ARKODE stepper-specific functions are now deprecated in favor of
ARKODE-wide functions.

Deprecated ``ARKStepSetOptimalParams`` function. This functions does not have an
ARKODE-wide equivalent, instructions have been added to the user guide for how
to retain the current functionality using other user-callable functions.

## Changes to SUNDIALS in release v7.0.0

### Major Feature
Expand Down
2 changes: 2 additions & 0 deletions doc/arkode/guide/source/Constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ contains the ARKODE output constants.
+-----------------------------------------------+------------------------------------------------------------+
| **Interpolation module input constants** | |
+-----------------------------------------------+------------------------------------------------------------+
| :index:`ARK_INTERP_NONE` | Disables polynomial interpolation for dense output. |
+-----------------------------------------------+------------------------------------------------------------+
| :index:`ARK_INTERP_HERMITE` | Specifies use of the Hermite polynomial interpolation |
| | module (for non-stiff problems). |
+-----------------------------------------------+------------------------------------------------------------+
Expand Down
balos1 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -552,39 +552,10 @@ Optional inputs for ARKStep

.. c:function:: int ARKStepSetInterpolantType(void* arkode_mem, int itype)

Specifies use of the Lagrange or Hermite interpolation modules (used for
dense output -- interpolation of solution output values and implicit
method predictors).

**Arguments:**
* *arkode_mem* -- pointer to the ARKStep memory block.
* *itype* -- requested interpolant type (``ARK_INTERP_HERMITE`` or ``ARK_INTERP_LAGRANGE``)

**Return value:**
* *ARK_SUCCESS* if successful
* *ARK_MEM_NULL* if the ARKStep memory is ``NULL``
* *ARK_MEM_FAIL* if the interpolation module cannot be allocated
* *ARK_ILL_INPUT* if the *itype* argument is not recognized or the
interpolation module has already been initialized

**Notes:**
The Hermite interpolation module is described in
:numref:`ARKODE.Mathematics.Interpolation.Hermite`, and the Lagrange interpolation module
is described in :numref:`ARKODE.Mathematics.Interpolation.Lagrange`.

This routine frees any previously-allocated interpolation module, and re-creates
one according to the specified argument. Thus any previous calls to
:c:func:`ARKStepSetInterpolantDegree()` will be nullified.

This routine may only be called *after* the call to :c:func:`ARKStepCreate`.
After the first call to :c:func:`ARKStepEvolve()` the interpolation type may
not be changed without first calling :c:func:`ARKStepReInit()`.

If this routine is not called, the Hermite interpolation module will be used.

.. deprecated:: x.y.z

Use :c:func:`ARKodeSetInterpolantType` instead.
This function is now a wrapper to :c:func:`ARKodeSetInterpolantType`, see
the documentation for that function instead.


.. c:function:: int ARKStepSetInterpolantDegree(void* arkode_mem, int degree)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,39 +329,10 @@ Optional inputs for ERKStep

.. c:function:: int ERKStepSetInterpolantType(void* arkode_mem, int itype)

Specifies use of the Lagrange or Hermite interpolation modules (used for
dense output -- interpolation of solution output values and implicit
method predictors).

**Arguments:**
* *arkode_mem* -- pointer to the ERKStep memory block.
* *itype* -- requested interpolant type (``ARK_INTERP_HERMITE`` or ``ARK_INTERP_LAGRANGE``)

**Return value:**
* *ARK_SUCCESS* if successful
* *ARK_MEM_NULL* if the ERKStep memory is ``NULL``
* *ARK_MEM_FAIL* if the interpolation module cannot be allocated
* *ARK_ILL_INPUT* if the *itype* argument is not recognized or the
interpolation module has already been initialized

**Notes:**
The Hermite interpolation module is described in
:numref:`ARKODE.Mathematics.Interpolation.Hermite`, and the Lagrange interpolation module
is described in :numref:`ARKODE.Mathematics.Interpolation.Lagrange`.

This routine frees any previously-allocated interpolation module, and re-creates
one according to the specified argument. Thus any previous calls to
:c:func:`ERKStepSetInterpolantDegree()` will be nullified.

This routine must be called *after* the call to :c:func:`ERKStepCreate`.
After the first call to :c:func:`ERKStepEvolve()` the interpolation type may
not be changed without first calling :c:func:`ERKStepReInit()`.

If this routine is not called, the Hermite interpolation module will be used.

.. deprecated:: x.y.z

Use :c:func:`ARKodeSetInterpolantType` instead.
This function is now a wrapper to :c:func:`ARKodeSetInterpolantType`, see
the documentation for that function instead.



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,44 +462,10 @@ Optional inputs for MRIStep

.. c:function:: int MRIStepSetInterpolantType(void* arkode_mem, int itype)

Specifies use of the Lagrange or Hermite interpolation modules (used for
dense output -- interpolation of solution output values and implicit
method predictors).

**Arguments:**

* *arkode_mem* -- pointer to the MRIStep memory block.

* *itype* -- requested interpolant type (``ARK_INTERP_HERMITE`` or ``ARK_INTERP_LAGRANGE``)

**Return value:**

* *ARK_SUCCESS* if successful

* *ARK_MEM_NULL* if the MRIStep memory is ``NULL``

* *ARK_MEM_FAIL* if the interpolation module cannot be allocated

* *ARK_ILL_INPUT* if the *itype* argument is not recognized or the
interpolation module has already been initialized

**Notes:** The Hermite interpolation module is described in
:numref:`ARKODE.Mathematics.Interpolation.Hermite`, and the Lagrange interpolation module
is described in :numref:`ARKODE.Mathematics.Interpolation.Lagrange`.

This routine frees any previously-allocated interpolation module, and re-creates
one according to the specified argument. Thus any previous calls to
:c:func:`MRIStepSetInterpolantDegree()` will be nullified.

This routine must be called *after* the call to :c:func:`MRIStepCreate()`.
After the first call to :c:func:`MRIStepEvolve()` the interpolation type may
not be changed without first calling :c:func:`MRIStepReInit()`.

If this routine is not called, the Hermite interpolation module will be used.

.. deprecated:: x.y.z

Use :c:func:`ARKodeSetInterpolantType` instead.
This function is now a wrapper to :c:func:`ARKodeSetInterpolantType`, see
the documentation for that function instead.



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,42 +244,10 @@ Optional inputs for SPRKStep

.. c:function:: int SPRKStepSetInterpolantType(void* arkode_mem, int itype)

Specifies use of the Lagrange or Hermite interpolation modules (used for
dense output -- interpolation of solution output values and implicit
method predictors).

:param arkode_mem: pointer to the SPRKStep memory block.
:param itype: requested interpolant type (``ARK_INTERP_HERMITE`` or ``ARK_INTERP_LAGRANGE``)

:retval ARK_SUCCESS: if successful
:retval ARK_MEM_NULL: if the SPRKStep memory is ``NULL``
:retval ARK_MEM_FAIL: if the interpolation module cannot be allocated
:retval ARK_ILL_INPUT: if the *itype* argument is not recognized or the
interpolation module has already been initialized

.. note::

The Hermite interpolation module is described in
:numref:`ARKODE.Mathematics.Interpolation.Hermite`, and the Lagrange interpolation module
is described in :numref:`ARKODE.Mathematics.Interpolation.Lagrange`.

This routine frees any previously-allocated interpolation module, and re-creates
one according to the specified argument. Thus any previous calls to
:c:func:`SPRKStepSetInterpolantDegree()` will be nullified.

This routine must be called *after* the call to :c:func:`SPRKStepCreate`.
After the first call to :c:func:`SPRKStepEvolve()` the interpolation type may
not be changed without first calling :c:func:`SPRKStepReInit()`.

If this routine is not called, the Lagrange interpolation module will be used.

Interpolated outputs may or may not conserve the Hamiltonian. Our testing
has shown that Lagrange interpolation typically performs well in this
regard, while Hermite interpolation does not.

.. deprecated:: x.y.z

Use :c:func:`ARKodeSetInterpolantType` instead.
This function is now a wrapper to :c:func:`ARKodeSetInterpolantType`, see
the documentation for that function instead.


.. c:function:: int SPRKStepSetInterpolantDegree(void* arkode_mem, int degree)
Expand Down
65 changes: 46 additions & 19 deletions doc/arkode/guide/source/Usage/User_callable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -709,9 +709,12 @@ the user has set a stop time (with a call to the optional input function
time, *tout*, in the direction of integration,
i.e. :math:`t_{n-1} <` *tout* :math:`\le t_{n}` for forward
integration, or :math:`t_{n} \le` *tout* :math:`< t_{n-1}` for
backward integration. It will then compute an approximation
to the solution :math:`y(tout)` by interpolation (as described
in :numref:`ARKODE.Mathematics.Interpolation`).
backward integration. If interpolation is enabled (on by
default), it will then compute an approximation to the solution
:math:`y(tout)` by interpolation (as described in
:numref:`ARKODE.Mathematics.Interpolation`). Otherwise, the
solution at the time reached by the solver is returned,
:math:`y(tret)`.

The *ARK_ONE_STEP* option tells the solver to only take a
single internal step, :math:`y_{n-1} \to y_{n}`, and return the solution
Expand Down Expand Up @@ -922,36 +925,60 @@ Set max number of constraint failures :c:func:`ARKodeSetMaxNumConstr

.. c:function:: int ARKodeSetInterpolantType(void* arkode_mem, int itype)

Specifies use of the Lagrange or Hermite interpolation modules (used for
dense output -- interpolation of solution output values and implicit
method predictors).
Specifies the interpolation type used for dense output (interpolation of
solution output values) and implicit method predictors. By default, the
gardner48 marked this conversation as resolved.
Show resolved Hide resolved
Hermite interpolation is used expect with SPRK method where Lagrange
gardner48 marked this conversation as resolved.
Show resolved Hide resolved
interpolation is the default.

This routine must be called *after* the calling a stepper constructor. After
the first call to :c:func:`ARKodeEvolve` the interpolation type may not be
changed without first calling a stepper ``ReInit`` function.

The Hermite interpolation module (``ARK_INTERP_HERMITE``) is described in
:numref:`ARKODE.Mathematics.Interpolation.Hermite`, and the Lagrange
interpolation module (``ARK_INTERP_LAGRANGE``) is described in
:numref:`ARKODE.Mathematics.Interpolation.Lagrange`. ``ARK_INTERP_NONE`` will
disable interpolation.

When interpolation is disabled using, rootfinding is not supported, implicit
methods must use the trivial predictor (the default option), and
interpolation at stop times cannot be used (interpolating at stop times is
disabled by default). With interpolation disabled, calling
:c:func:`ARKodeEvolve` in ``ARK_NORMAL`` mode will return at or past the
requested output time (setting a stop time may still be used to halt the
integrator at a specific time).
gardner48 marked this conversation as resolved.
Show resolved Hide resolved

Disabling interpolation will reduce the memory footprint of an integrator by
two or more state vectors (depending on the interpolant type and degree)
which can be beneficial when interpolation is not needed e.g., when
integrating to a final time without output in between or using ARKStep as an
explicit fast time scale integrator with MRI methods.

This routine frees any previously-allocated interpolation module, and
re-creates one according to the specified argument.

:param arkode_mem: pointer to the ARKODE memory block.
:param itype: requested interpolant type (``ARK_INTERP_HERMITE`` or ``ARK_INTERP_LAGRANGE``).
:param itype: requested interpolant type: ``ARK_INTERP_HERMITE``,
``ARK_INTERP_LAGRANGE``, or ``ARK_INTERP_NONE``

:retval ARK_SUCCESS: the function exited successfully.
:retval ARK_MEM_NULL: ``arkode_mem`` was ``NULL``.
:retval ARK_MEM_FAIL: the interpolation module could not be allocated.
:retval ARK_ILL_INPUT: the *itype* argument is not recognized or the
interpolation module has already been initialized.

.. note::

The Hermite interpolation module is described in
:numref:`ARKODE.Mathematics.Interpolation.Hermite`, and the Lagrange interpolation module
is described in :numref:`ARKODE.Mathematics.Interpolation.Lagrange`.
.. versionchanged:: x.y.z

This routine frees any previously-allocated interpolation module, and re-creates
one according to the specified argument. Thus any previous calls to
:c:func:`ARKodeSetInterpolantDegree` will be nullified.
Added the ``ARK_INTERP_NONE`` option to disable interpolation.

After the first call to :c:func:`ARKodeEvolve` the interpolation type may
not be changed without first calling ``*StepReInit``.

If this routine is not called, the Hermite interpolation module will be used.
Values set by a previous call to :c:func:`ARKStepSetInterpolantDegree` are
no longer nullified by a call to :c:func:`ARKStepSetInterpolantType`.

.. versionadded:: x.y.z

This function replaces stepper specific versions in ARKStep, ERKStep,
MRIStep, and SPRKStep.


.. c:function:: int ARKodeSetInterpolantDegree(void* arkode_mem, int degree)

Expand Down
Loading
Loading