CubicSpanInterpolator.hpp
1 // 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 "NumericalAlgorithms/Interpolation/SpanInterpolator.hpp"
13 #include "Options/Options.hpp"
15 #include "Utilities/Gsl.hpp"
16 
17 namespace intrp {
18 
19 /// \brief Performs a cubic interpolation; this class can be chosen via the
20 /// options factory mechanism as a possible `SpanInterpolator`.
21 ///
22 /// \details This interpolator is hand-coded to be identical to the SpEC
23 /// implementation used for SpEC CCE so that comparison results can be as close
24 /// as possible for diagnostics.
26  public:
27  using options = tmpl::list<>;
28  static constexpr Options::String help = {"Cubic interpolator."};
29 
30  CubicSpanInterpolator() = default;
31  CubicSpanInterpolator(const CubicSpanInterpolator&) noexcept = default;
32  CubicSpanInterpolator& operator=(const CubicSpanInterpolator&) noexcept =
33  default;
34  CubicSpanInterpolator(CubicSpanInterpolator&&) noexcept = default;
35  CubicSpanInterpolator& operator=(CubicSpanInterpolator&&) noexcept = default;
36  ~CubicSpanInterpolator() noexcept override = default;
37 
38  explicit CubicSpanInterpolator(CkMigrateMessage* /*unused*/) noexcept {}
39 
40  WRAPPED_PUPable_decl_template(CubicSpanInterpolator); // NOLINT
41 
42  // clang-tidy: do not pass by non-const reference
43  void pup(PUP::er& /*p*/) noexcept override {}
44 
45  std::unique_ptr<SpanInterpolator> get_clone() const noexcept override {
46  return std::make_unique<CubicSpanInterpolator>(*this);
47  }
48 
49  double interpolate(const gsl::span<const double>& source_points,
50  const gsl::span<const double>& values,
51  double target_point) const noexcept override;
52 
54  const gsl::span<const double>& source_points,
55  const gsl::span<const std::complex<double>>& values,
56  double target_point) const noexcept;
57 
58  size_t required_number_of_points_before_and_after() const noexcept override {
59  return 2;
60  }
61 };
62 } // namespace intrp
CharmPupable.hpp
intrp::SpanInterpolator
Base class for interpolators so that the factory options mechanism can be used.
Definition: SpanInterpolator.hpp:32
Options.hpp
intrp::CubicSpanInterpolator::interpolate
double interpolate(const gsl::span< const double > &source_points, const gsl::span< const double > &values, double target_point) const noexcept override
Perform the interpolation of function represented by values at source_points to the requested target_...
Definition: CubicSpanInterpolator.cpp:40
intrp::CubicSpanInterpolator::required_number_of_points_before_and_after
size_t required_number_of_points_before_and_after() const noexcept override
The number of domain points that should be both before and after the requested target point for best ...
Definition: CubicSpanInterpolator.hpp:58
cstddef
intrp::CubicSpanInterpolator::get_clone
std::unique_ptr< SpanInterpolator > get_clone() const noexcept override
Produce a std::unique_ptr that points to a copy of *this`.
Definition: CubicSpanInterpolator.hpp:45
gsl::span
Create a span/view on a range, which is cheap to copy (one pointer).
Definition: Gsl.hpp:292
Gsl.hpp
intrp::CubicSpanInterpolator
Performs a cubic interpolation; this class can be chosen via the options factory mechanism as a possi...
Definition: CubicSpanInterpolator.hpp:25
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
complex
std::unique_ptr