SpECTRE Documentation Coverage Report
Current view: top level - Domain/FunctionsOfTime - FixedSpeedCubic.hpp Hit Total Coverage
Commit: aabde07399ba7837e5db64eedfd0a21f31f96922 Lines: 7 27 25.9 %
Date: 2024-04-26 02:38:13
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       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 <ostream>
      11             : #include <pup.h>
      12             : 
      13             : #include "DataStructures/DataVector.hpp"
      14             : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp"
      15             : #include "Utilities/Serialization/CharmPupable.hpp"
      16             : 
      17             : namespace domain {
      18           1 : namespace FunctionsOfTime {
      19             : /*!
      20             :  * \ingroup ControlSystemGroup
      21             :  * \brief Sets \f$f(t)\f$ and derivatives using cubic rational functions,
      22             :  * such that the first derivative approaches a constant and the second
      23             :  * derivative approaches zero.
      24             :  *
      25             :  * The resultant function of time is
      26             :  *
      27             :  * \f{align*}{
      28             :  *   f(t) &= f_0 + \frac{v(t-t_0)^3}{\tau^2+(t-t_0)^2},
      29             :  * \f}
      30             :  *
      31             :  * where \f$f_0\f$ is the value of the function \f$f\f$ at the initial time
      32             :  * \f$t_0\f$, and \f$v\f$ is the velocity that \f$f^\prime(t)\f$ approaches on a
      33             :  * timescale of \f$\tau\f$.
      34             :  */
      35           1 : class FixedSpeedCubic : public FunctionOfTime {
      36             :  public:
      37           0 :   FixedSpeedCubic() = default;
      38           0 :   FixedSpeedCubic(double initial_function_value, double initial_time,
      39             :                   double velocity, double decay_timescale);
      40             : 
      41           0 :   ~FixedSpeedCubic() override = default;
      42           0 :   FixedSpeedCubic(FixedSpeedCubic&&) = default;
      43           0 :   FixedSpeedCubic& operator=(FixedSpeedCubic&&) = default;
      44           0 :   FixedSpeedCubic(const FixedSpeedCubic&) = default;
      45           0 :   FixedSpeedCubic& operator=(const FixedSpeedCubic&) = default;
      46             : 
      47             :   // NOLINTNEXTLINE(google-runtime-references)
      48           0 :   WRAPPED_PUPable_decl_template(FixedSpeedCubic);
      49             : 
      50           0 :   explicit FixedSpeedCubic(CkMigrateMessage* /*unused*/) {}
      51             : 
      52           0 :   auto get_clone() const -> std::unique_ptr<FunctionOfTime> override;
      53             : 
      54             :   /// Returns the function at an arbitrary time `t`.
      55           1 :   std::array<DataVector, 1> func(const double t) const override {
      56             :     return func_and_derivs<0>(t);
      57             :   }
      58             :   /// Returns the function and its first derivative at an arbitrary time `t`.
      59           1 :   std::array<DataVector, 2> func_and_deriv(const double t) const override {
      60             :     return func_and_derivs<1>(t);
      61             :   }
      62             :   /// Returns the function and the first two derivatives at an arbitrary time
      63             :   /// `t`.
      64           1 :   std::array<DataVector, 3> func_and_2_derivs(const double t) const override {
      65             :     return func_and_derivs<2>(t);
      66             :   }
      67             : 
      68             :   /// Returns the domain of validity of the function.
      69           1 :   std::array<double, 2> time_bounds() const override {
      70             :     return {{initial_time_, std::numeric_limits<double>::infinity()}};
      71             :   }
      72             : 
      73           1 :   double expiration_after(const double /*time*/) const override {
      74             :     return std::numeric_limits<double>::infinity();
      75             :   }
      76             : 
      77             :   // NOLINTNEXTLINE(google-runtime-references)
      78           0 :   void pup(PUP::er& p) override;
      79             : 
      80             :  private:
      81           0 :   friend bool operator==(const FixedSpeedCubic& lhs,
      82             :                          const FixedSpeedCubic& rhs);
      83             : 
      84           0 :   friend std::ostream& operator<<(  // NOLINT(readability-redundant-declaration
      85             :       std::ostream& os, const FixedSpeedCubic& fixed_speed_cubic);
      86             : 
      87             :   template <size_t MaxDerivReturned = 2>
      88           0 :   std::array<DataVector, MaxDerivReturned + 1> func_and_derivs(double t) const;
      89             : 
      90           0 :   double initial_function_value_{std::numeric_limits<double>::signaling_NaN()};
      91           0 :   double initial_time_{std::numeric_limits<double>::signaling_NaN()};
      92           0 :   double velocity_{std::numeric_limits<double>::signaling_NaN()};
      93           0 :   double squared_decay_timescale_{std::numeric_limits<double>::signaling_NaN()};
      94             : };
      95             : 
      96           0 : bool operator!=(const FixedSpeedCubic& lhs, const FixedSpeedCubic& rhs);
      97             : }  // namespace FunctionsOfTime
      98             : }  // namespace domain

Generated by: LCOV version 1.14