/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/physics/interpolation/interpolation_stencil.hh Source File#

DiFfRG: /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/physics/interpolation/interpolation_stencil.hh Source File
DiFfRG
Discretization Framework for functional Renormalization Group flows
interpolation_stencil.hh
Go to the documentation of this file.
1#pragma once
2
3// standard library
4#include <cstddef>
5
6// DiFfRG
9
10namespace DiFfRG
11{
15 template <typename CT> struct InterpolationStencil {
16 size_t lower, upper;
17 CT t;
18 };
19
33 template <bool periodic, typename CT>
34 KOKKOS_FORCEINLINE_FUNCTION InterpolationStencil<CT> make_interpolation_stencil(CT idx, const size_t n)
35 {
36 using Kokkos::floor, Kokkos::max, Kokkos::min;
37 if constexpr (periodic) {
38 // backward() folds into [0, n), the min/max only guard against rounding at the seam
39 const size_t lower = min(size_t(max(static_cast<CT>(0), floor(idx))), n - 1);
40 return {lower, (lower + 1) % n, idx - static_cast<CT>(lower)};
41 } else {
42 idx = max(static_cast<CT>(0), min(idx, static_cast<CT>(n - 1)));
43 const size_t lower = min(size_t(floor(idx)), n - 2);
44 return {lower, lower + 1, idx - static_cast<CT>(lower)};
45 }
46 }
47} // namespace DiFfRG
Definition complex_math.hh:10
KOKKOS_FORCEINLINE_FUNCTION InterpolationStencil< CT > make_interpolation_stencil(CT idx, const size_t n)
Resolve a fractional grid index into the linear-interpolation stencil along one axis.
Definition interpolation_stencil.hh:34
The two grid indices and the interpolation weight for one axis of a linear interpolation.
Definition interpolation_stencil.hh:15
CT t
Definition interpolation_stencil.hh:17
size_t upper
Definition interpolation_stencil.hh:16
size_t lower
Definition interpolation_stencil.hh:16