SpECTRE Documentation Coverage Report
Current view: top level - Domain/FunctionsOfTime - SettleToConstantQuaternion.hpp Hit Total Coverage
Commit: 3c2e9d3ed337bca2146eee9de07432e292a38c3a Lines: 6 24 25.0 %
Date: 2024-06-11 22:56:19
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 <pup.h>
      11             : 
      12             : #include "DataStructures/DataVector.hpp"
      13             : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp"
      14             : #include "Domain/FunctionsOfTime/SettleToConstant.hpp"
      15             : #include "Utilities/Serialization/CharmPupable.hpp"
      16             : 
      17             : namespace domain::FunctionsOfTime {
      18             : /// \ingroup ControlSystemGroup
      19             : /// \brief Given an initial function of time that is a unit quaternion,
      20             : /// transitions to a constant-in-time unit quaternion.
      21             : ///
      22             : /// Given an initial unit quaternion \f$\mathbf{f}(t)\f$ and its first two
      23             : /// derivatives at the matching time \f$t_0\f$, return a function of time
      24             : /// \f$\mathbf{g}(t)\f$ satisfies \f$\mathbf{g}(t=t_0)=\mathbf{f}f(t=t_0)\f$ and
      25             : /// approaches a constant value for \f$t > t_0\f$ on a timescale of \f$\tau\f$.
      26             : /// This is done by internally holding a `SettleToConstant` function of time
      27             : /// initialized from \f$\mathbf{f}(t)\f$ and its first two derivatives at the
      28             : /// matching time, but then ensuring that \f$\mathbf{g}(t)\f$ remains
      29             : /// a unit quaternion.
      30           1 : class SettleToConstantQuaternion : public FunctionOfTime {
      31             :  public:
      32           0 :   SettleToConstantQuaternion() = default;
      33           0 :   SettleToConstantQuaternion(
      34             :       const std::array<DataVector, 3>& initial_func_and_derivs,
      35             :       double match_time, double decay_time);
      36             : 
      37           0 :   ~SettleToConstantQuaternion() override = default;
      38           0 :   SettleToConstantQuaternion(SettleToConstantQuaternion&&) = default;
      39           0 :   SettleToConstantQuaternion& operator=(SettleToConstantQuaternion&&) = default;
      40           0 :   SettleToConstantQuaternion(const SettleToConstantQuaternion&) = default;
      41           0 :   SettleToConstantQuaternion& operator=(const SettleToConstantQuaternion&) =
      42             :       default;
      43             : 
      44             :   // NOLINTNEXTLINE(google-runtime-references)
      45           0 :   WRAPPED_PUPable_decl_template(SettleToConstantQuaternion);
      46             : 
      47           0 :   explicit SettleToConstantQuaternion(CkMigrateMessage* /*unused*/) {}
      48             : 
      49           0 :   auto get_clone() const -> std::unique_ptr<FunctionOfTime> override;
      50             : 
      51             :   /// Returns the function at an arbitrary time `t`.
      52           1 :   std::array<DataVector, 1> func(const double t) const override {
      53             :     return func_and_derivs<0>(t);
      54             :   }
      55             :   /// Returns the function and its first derivative at an arbitrary time `t`.
      56           1 :   std::array<DataVector, 2> func_and_deriv(const double t) const override {
      57             :     return func_and_derivs<1>(t);
      58             :   }
      59             :   /// Returns the function and the first two derivatives at an arbitrary time
      60             :   /// `t`.
      61           1 :   std::array<DataVector, 3> func_and_2_derivs(const double t) const override {
      62             :     return func_and_derivs<2>(t);
      63             :   }
      64             : 
      65             :   /// Returns the domain of validity of the function.
      66           1 :   std::array<double, 2> time_bounds() const override {
      67             :     return {{match_time_, std::numeric_limits<double>::infinity()}};
      68             :   }
      69             : 
      70           1 :   double expiration_after(const double /*time*/) const override {
      71             :     return std::numeric_limits<double>::infinity();
      72             :   }
      73             : 
      74             :   // NOLINTNEXTLINE(google-runtime-references)
      75           0 :   void pup(PUP::er& p) override;
      76             : 
      77             :  private:
      78           0 :   friend bool operator==(const SettleToConstantQuaternion& lhs,
      79             :                          const SettleToConstantQuaternion& rhs);
      80             : 
      81             :   template <size_t MaxDerivReturned = 2>
      82           0 :   std::array<DataVector, MaxDerivReturned + 1> func_and_derivs(double t) const;
      83             : 
      84           0 :   SettleToConstant unnormalized_function_of_time_;
      85           0 :   double match_time_{std::numeric_limits<double>::signaling_NaN()};
      86           0 :   double decay_time_{std::numeric_limits<double>::signaling_NaN()};
      87             : };
      88             : 
      89           0 : bool operator!=(const SettleToConstantQuaternion& lhs,
      90             :                 const SettleToConstantQuaternion& rhs);
      91             : }  // namespace domain::FunctionsOfTime

Generated by: LCOV version 1.14