LinearSpanInterpolator.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 linear interpolation; this class can be chosen via the
20 /// options factory mechanism as a possible `SpanInterpolator`
22  public:
23  using options = tmpl::list<>;
24  static constexpr Options::String help = {"Linear interpolator."};
25 
26  LinearSpanInterpolator() = default;
27  LinearSpanInterpolator(const LinearSpanInterpolator&) noexcept = default;
28  LinearSpanInterpolator& operator=(const LinearSpanInterpolator&) noexcept =
29  default;
30  LinearSpanInterpolator(LinearSpanInterpolator&&) noexcept = default;
31  LinearSpanInterpolator& operator=(LinearSpanInterpolator&&) noexcept =
32  default;
33  ~LinearSpanInterpolator() noexcept override = default;
34 
35  WRAPPED_PUPable_decl_template(LinearSpanInterpolator); // NOLINT
36 
37  explicit LinearSpanInterpolator(CkMigrateMessage* /*unused*/) noexcept {}
38 
39  // clang-tidy: do not pass by non-const reference
40  void pup(PUP::er& /*p*/) noexcept override {}
41 
42  std::unique_ptr<SpanInterpolator> get_clone() const noexcept override {
43  return std::make_unique<LinearSpanInterpolator>(*this);
44  }
45 
46  double interpolate(const gsl::span<const double>& source_points,
47  const gsl::span<const double>& values,
48  double target_point) const noexcept override;
49 
51  const gsl::span<const double>& source_points,
52  const gsl::span<const std::complex<double>>& values,
53  double target_point) const noexcept;
54 
55  size_t required_number_of_points_before_and_after() const noexcept override {
56  return 1;
57  }
58 };
59 } // 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::LinearSpanInterpolator::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: LinearSpanInterpolator.cpp:23
intrp::LinearSpanInterpolator
Performs a linear interpolation; this class can be chosen via the options factory mechanism as a poss...
Definition: LinearSpanInterpolator.hpp:21
intrp::LinearSpanInterpolator::get_clone
std::unique_ptr< SpanInterpolator > get_clone() const noexcept override
Produce a std::unique_ptr that points to a copy of *this`.
Definition: LinearSpanInterpolator.hpp:42
cstddef
intrp::LinearSpanInterpolator::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: LinearSpanInterpolator.hpp:55
gsl::span
Create a span/view on a range, which is cheap to copy (one pointer).
Definition: Gsl.hpp:292
Gsl.hpp
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
complex
std::unique_ptr