FixedSpeedCubic.hpp
2 // See LICENSE.txt for details.
3
4 #pragma once
5
6 #include <array>
7 #include <cstddef>
8 #include <limits>
9 #include <memory>
10 #include <pup.h>
11
12 #include "DataStructures/DataVector.hpp"
13 #include "Domain/FunctionsOfTime/FunctionOfTime.hpp"
15
16 namespace domain {
17 namespace FunctionsOfTime {
18 /*!
19  * \ingroup ControlSystemGroup
20  * \brief Sets \f$f(t)\f$ and derivatives using cubic rational functions,
21  * such that the first derivative approaches a constant and the second
22  * derivative approaches zero.
23  *
24  * The resultant function of time is
25  *
26  * \f{align*}{
27  * f(t) &= f_0 + \frac{v(t-t_0)^3}{\tau^2+(t-t_0)^2},
28  * \f}
29  *
30  * where \f$f_0\f$ is the value of the function \f$f\f$ at the initial time
31  * \f$t_0\f$, and \f$v\f$ is the velocity that \f$f^\prime(t)\f$ approaches on a
32  * timescale of \f$\tau\f$.
33  */
35  public:
36  FixedSpeedCubic() = default;
37  FixedSpeedCubic(double initial_function_value, double initial_time,
38  double velocity, double decay_timescale) noexcept;
39
40  ~FixedSpeedCubic() override = default;
41  FixedSpeedCubic(FixedSpeedCubic&&) noexcept = default;
42  FixedSpeedCubic& operator=(FixedSpeedCubic&&) noexcept = default;
43  FixedSpeedCubic(const FixedSpeedCubic&) = default;
44  FixedSpeedCubic& operator=(const FixedSpeedCubic&) = default;
45
47  WRAPPED_PUPable_decl_template(FixedSpeedCubic);
48
49  explicit FixedSpeedCubic(CkMigrateMessage* /*unused*/) {}
50
51  auto get_clone() const noexcept -> std::unique_ptr<FunctionOfTime> override;
52
53  /// Returns the function at an arbitrary time t.
54  std::array<DataVector, 1> func(const double t) const noexcept override {
55  return func_and_derivs<0>(t);
56  }
57  /// Returns the function and its first derivative at an arbitrary time t.
59  const double t) const noexcept override {
60  return func_and_derivs<1>(t);
61  }
62  /// Returns the function and the first two derivatives at an arbitrary time
63  /// t.
65  const double t) const noexcept override {
66  return func_and_derivs<2>(t);
67  }
68
69  /// Returns the domain of validity of the function.
70  std::array<double, 2> time_bounds() const noexcept override {
71  return {{initial_time_, std::numeric_limits<double>::max()}};
72  }
73
75  void pup(PUP::er& p) override;
76
77  private:
78  friend bool operator==(const FixedSpeedCubic& lhs,
79  const FixedSpeedCubic& rhs) noexcept;
80
81  template <size_t MaxDerivReturned = 2>
83  double t) const noexcept;
84
85  double initial_function_value_{std::numeric_limits<double>::signaling_NaN()};
86  double initial_time_{std::numeric_limits<double>::signaling_NaN()};
88  double squared_decay_timescale_{std::numeric_limits<double>::signaling_NaN()};
89 };
90
91 bool operator!=(const FixedSpeedCubic& lhs,
92  const FixedSpeedCubic& rhs) noexcept;
93 } // namespace FunctionsOfTime
94 } // namespace domain
CharmPupable.hpp
std::rel_ops::operator!=
T operator!=(T... args)
domain::FunctionsOfTime::FixedSpeedCubic
Sets and derivatives using cubic rational functions, such that the first derivative approaches a con...
Definition: FixedSpeedCubic.hpp:34
domain::FunctionsOfTime::FixedSpeedCubic::func_and_2_derivs
std::array< DataVector, 3 > func_and_2_derivs(const double t) const noexcept override
Returns the function and the first two derivatives at an arbitrary time t.
Definition: FixedSpeedCubic.hpp:64
cstddef
array
domain::FunctionsOfTime::FunctionOfTime
Base class for FunctionsOfTime.
Definition: FunctionOfTime.hpp:20
std::numeric_limits::signaling_NaN
T signaling_NaN(T... args)
memory
domain::FunctionsOfTime::FixedSpeedCubic::time_bounds
std::array< double, 2 > time_bounds() const noexcept override
Returns the domain of validity of the function.
Definition: FixedSpeedCubic.hpp:70
domain::FunctionsOfTime::FixedSpeedCubic::func_and_deriv
std::array< DataVector, 2 > func_and_deriv(const double t) const noexcept override
Returns the function and its first derivative at an arbitrary time t.
Definition: FixedSpeedCubic.hpp:58
limits
std::numeric_limits::max
T max(T... args)
domain::FunctionsOfTime::FixedSpeedCubic::func
std::array< DataVector, 1 > func(const double t) const noexcept override
Returns the function at an arbitrary time t.
Definition: FixedSpeedCubic.hpp:54
std::unique_ptr