Skip to content

Commit

Permalink
Rename "interpolate" to "interpToScalar", and add a note about the fu…
Browse files Browse the repository at this point in the history
…ture removal of "interpToReal".
  • Loading branch information
BrendanKKrueger committed Oct 30, 2024
1 parent 99cf011 commit 7b22602
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
9 changes: 9 additions & 0 deletions doc/sphinx/src/databox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,15 @@ so on. These interpolation routines are hand-tuned for performance.
or try to interpolate on indices that are not interpolatable.
This is checked with an ``assert`` statement.

.. warning::
The ``DataBox::interpToReal`` method is deprecated, and will be replaced by
the ``DataBox::interpToScalar`` method. The ``DataBox::interpToScalar``
method is already available, so we recommend changing your code to use that
instead so as to future-proof your code against the upcoming removal of
``DataBox::interpToReal``. The semantics of the two functions are
identical, but the change to ``DataBox::interpToScalar`` will enable new
features and improve maintainability of Spiner.

Mixed interpolation and indexing
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
23 changes: 9 additions & 14 deletions spiner/databox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@ class DataBox {

// Interpolates whole DataBox to a real number,
// x1 is fastest index. xN is slowest.
// TODO: We _might_ be able to get rid of all the interpToReal wrappers and
// just use interpolate directly. If we do, then we should rename
// interpolate back to interpToReal despite my concerns noted below.
// -- If we keep the interpToReal wrappers, then should interpolate be
// made private?
PORTABLE_FORCEINLINE_FUNCTION T interpToReal(const T x) const noexcept;
PORTABLE_FORCEINLINE_FUNCTION T interpToReal(const T x2,
const T x1) const noexcept;
Expand All @@ -220,9 +215,9 @@ class DataBox {
// * T : a coordinate to interpolate to that point on that axis
template <typename... Coords>
PORTABLE_FORCEINLINE_FUNCTION T
interpolate(const Coords... coords) const noexcept;
interpToScalar(const Coords... coords) const noexcept;

// TODO: In principle, the logic for interpolate and interp_core could be
// TODO: In principle, the logic for interpToScalar and interp_core could be
// extended to work on these routines. I've not looked at how easy it
// would be, so it may be more work than it's worth?
// Interpolates SLOWEST indices of databox to a new
Expand Down Expand Up @@ -502,7 +497,7 @@ inline void DataBox<T, Grid_t, Concept>::setArray(PortableMDArray<T> &A) {

template <typename T, typename Grid_t, typename Concept>
template <typename... Coords>
PORTABLE_INLINE_FUNCTION T DataBox<T, Grid_t, Concept>::interpolate(
PORTABLE_INLINE_FUNCTION T DataBox<T, Grid_t, Concept>::interpToScalar(
const Coords... coords) const noexcept {
constexpr std::size_t N = sizeof...(Coords);
assert(canInterpToReal_(N));
Expand Down Expand Up @@ -541,40 +536,40 @@ PORTABLE_FORCEINLINE_FUNCTION T DataBox<T, Grid_t, Concept>::interp_core(
template <typename T, typename Grid_t, typename Concept>
PORTABLE_INLINE_FUNCTION T
DataBox<T, Grid_t, Concept>::interpToReal(const T x) const noexcept {
return interpolate(x);
return interpToScalar(x);
}

template <typename T, typename Grid_t, typename Concept>
PORTABLE_FORCEINLINE_FUNCTION T DataBox<T, Grid_t, Concept>::interpToReal(
const T x2, const T x1) const noexcept {
return interpolate(x2, x1);
return interpToScalar(x2, x1);
}

template <typename T, typename Grid_t, typename Concept>
PORTABLE_FORCEINLINE_FUNCTION T DataBox<T, Grid_t, Concept>::interpToReal(
const T x3, const T x2, const T x1) const noexcept {
return interpolate(x3, x2, x1);
return interpToScalar(x3, x2, x1);
}

template <typename T, typename Grid_t, typename Concept>
PORTABLE_FORCEINLINE_FUNCTION T DataBox<T, Grid_t, Concept>::interpToReal(
const T x3, const T x2, const T x1, const int idx) const noexcept {
return interpolate(x3, x2, x1, idx);
return interpToScalar(x3, x2, x1, idx);
}

// DH: this is a large function to force an inline, perhaps just make it a
// suggestion to the compiler?
template <typename T, typename Grid_t, typename Concept>
PORTABLE_FORCEINLINE_FUNCTION T DataBox<T, Grid_t, Concept>::interpToReal(
const T x4, const T x3, const T x2, const T x1) const noexcept {
return interpolate(x4, x3, x2, x1);
return interpToScalar(x4, x3, x2, x1);
}

template <typename T, typename Grid_t, typename Concept>
PORTABLE_FORCEINLINE_FUNCTION T DataBox<T, Grid_t, Concept>::interpToReal(
const T x4, const T x3, const T x2, const int idx,
const T x1) const noexcept {
return interpolate(x4, x3, x2, idx, x1);
return interpToScalar(x4, x3, x2, idx, x1);
}

template <typename T, typename Grid_t, typename Concept>
Expand Down

0 comments on commit 7b22602

Please sign in to comment.