Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <complex> 7 : #include <cstddef> 8 : 9 : #include "DataStructures/ComplexModalVector.hpp" 10 : #include "DataStructures/DataVector.hpp" 11 : #include "DataStructures/ModalVector.hpp" 12 : #include "Options/String.hpp" 13 : #include "Utilities/Gsl.hpp" 14 : #include "Utilities/Serialization/CharmPupable.hpp" 15 : 16 : namespace intrp { 17 : 18 : class LinearSpanInterpolator; 19 : class CubicSpanInterpolator; 20 : class BarycentricRationalSpanInterpolator; 21 : 22 : /// \brief Base class for interpolators so that the factory options 23 : /// mechanism can be used. 24 : /// 25 : /// \details The virtual functions in this class demand only that the real 26 : /// `interpolate` function, `get_clone` function, and 27 : /// `required_number_of_points_before_and_after` function be overridden in the 28 : /// derived class. The `interpolate` for complex values can just be used from 29 : /// this base class, which calls the real version for each component. If it is 30 : /// possible to make a specialized complex version that avoids allocations, that 31 : /// is probably more efficient. 32 1 : class SpanInterpolator : public PUP::able { 33 : public: 34 0 : using creatable_classes = 35 : tmpl::list<LinearSpanInterpolator, CubicSpanInterpolator, 36 : BarycentricRationalSpanInterpolator>; 37 : 38 0 : WRAPPED_PUPable_abstract(SpanInterpolator); // NOLINT 39 : 40 : /// Produce a `std::unique_ptr` that points to a copy of `*this`` 41 1 : virtual std::unique_ptr<SpanInterpolator> get_clone() const = 0; 42 : 43 : /// Perform the interpolation of function represented by `values` at 44 : /// `source_points` to the requested `target_point`, returning the 45 : /// interpolation result. 46 1 : virtual double interpolate(const gsl::span<const double>& source_points, 47 : const gsl::span<const double>& values, 48 : double target_point) const = 0; 49 : 50 : /// Perform the interpolation of function represented by complex `values` at 51 : /// `source_points` to the requested `target_point`, returning the 52 : /// (complex) interpolation result. 53 1 : std::complex<double> interpolate( 54 : const gsl::span<const double>& source_points, 55 : const gsl::span<const std::complex<double>>& values, 56 : double target_point) const; 57 : 58 : /// The number of domain points that should be both before and after the 59 : /// requested target point for best interpolation. For instance, for a linear 60 : /// interpolator, this function would return `1` to request that the target is 61 : /// between the two domain points passed to `source_points`. 62 1 : virtual size_t required_number_of_points_before_and_after() const = 0; 63 : }; 64 : } // namespace intrp