SpECTRE Documentation Coverage Report
Current view: top level - Domain/FunctionsOfTime - FunctionOfTimeHelpers.hpp Hit Total Coverage
Commit: 9f349d3c09e1c03107f00c2135ca40e209d3b84c Lines: 4 24 16.7 %
Date: 2023-06-09 21:05:06
Legend: Lines: hit not hit

          Line data    Source code
       1           1 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : /// \file
       5             : /// \brief Helper struct and functions for FunctionsOfTime
       6             : 
       7             : #pragma once
       8             : 
       9             : #include <array>
      10             : #include <limits>
      11             : #include <ostream>
      12             : #include <pup.h>
      13             : 
      14             : #include "DataStructures/DataVector.hpp"
      15             : #include "Utilities/Gsl.hpp"
      16             : 
      17           0 : namespace domain::FunctionsOfTime::FunctionOfTimeHelpers {
      18             : /// \brief Stores info at a particlar time about a function and its derivatives
      19             : ///
      20             : /// \details `MaxDerivPlusOne` template parameter is intended to be related to
      21             : /// the maximum derivative that a FunctionOfTime is supposed to store. For a
      22             : /// generic PiecewisePolynomial this will be the MaxDeriv + 1 (because we store
      23             : /// the function as well as its derivatives).
      24             : /// `StoreCoefs` template parameter indicates that the coefficients of the
      25             : /// polynomial used for evaluation are stored instead of the polynomial itself.
      26             : /// The coefficient of \f$ x^N \f$ is the Nth deriv rescaled by 1/factorial(N)
      27             : template <size_t MaxDerivPlusOne, bool StoreCoefs = true>
      28           1 : struct StoredInfo {
      29           0 :   double time{std::numeric_limits<double>::signaling_NaN()};
      30           0 :   std::array<DataVector, MaxDerivPlusOne> stored_quantities;
      31             : 
      32           0 :   StoredInfo() = default;
      33             : 
      34           0 :   StoredInfo(double t, std::array<DataVector, MaxDerivPlusOne> init_quantities);
      35           0 :   ~StoredInfo() = default;
      36           0 :   StoredInfo(StoredInfo&&) = default;
      37           0 :   StoredInfo& operator=(StoredInfo&&) = default;
      38           0 :   StoredInfo(const StoredInfo&) = default;
      39           0 :   StoredInfo& operator=(const StoredInfo&) = default;
      40             : 
      41           0 :   void pup(PUP::er& p);
      42             : };
      43             : 
      44             : template <size_t MaxDerivPlusOne>
      45           0 : struct StoredInfo<MaxDerivPlusOne, false> {
      46           0 :   double time{std::numeric_limits<double>::signaling_NaN()};
      47           0 :   std::array<DataVector, MaxDerivPlusOne> stored_quantities;
      48             : 
      49           0 :   StoredInfo() = default;
      50             : 
      51           0 :   StoredInfo(double t, std::array<DataVector, MaxDerivPlusOne> init_quantities);
      52             : 
      53           0 :   void pup(PUP::er& p);
      54             : };
      55             : 
      56             : /// Resets the previous expiration time if the next expiration time is after,
      57             : /// otherwise throws an error
      58           1 : void reset_expiration_time(const gsl::not_null<double*> prev_expiration_time,
      59             :                            const double next_expiration_time);
      60             : 
      61             : /// Returns a StoredInfo corresponding to the closest element in the range of
      62             : /// `StoredInfo.time`s that is less than `t`. The function throws an
      63             : /// error if `t` is less than all `StoredInfo.time`s (unless `t` is just less
      64             : /// than the earliest `StoredInfo.time` by roundoff, in which case it returns
      65             : /// the earliest StoredInfo.)
      66             : template <size_t MaxDerivPlusOne, bool StoreCoefs>
      67           1 : const StoredInfo<MaxDerivPlusOne, StoreCoefs>& stored_info_from_upper_bound(
      68             :     const double t, const std::vector<StoredInfo<MaxDerivPlusOne, StoreCoefs>>&
      69             :                         all_stored_infos);
      70             : 
      71             : template <size_t MaxDerivPlusOne, bool StoreCoefs>
      72           0 : bool operator==(
      73             :     const domain::FunctionsOfTime::FunctionOfTimeHelpers::StoredInfo<
      74             :         MaxDerivPlusOne, StoreCoefs>& lhs,
      75             :     const domain::FunctionsOfTime::FunctionOfTimeHelpers::StoredInfo<
      76             :         MaxDerivPlusOne, StoreCoefs>& rhs);
      77             : 
      78             : template <size_t MaxDerivPlusOne, bool StoreCoefs>
      79           0 : bool operator!=(
      80             :     const domain::FunctionsOfTime::FunctionOfTimeHelpers::StoredInfo<
      81             :         MaxDerivPlusOne, StoreCoefs>& lhs,
      82             :     const domain::FunctionsOfTime::FunctionOfTimeHelpers::StoredInfo<
      83             :         MaxDerivPlusOne, StoreCoefs>& rhs);
      84             : 
      85             : template <size_t MaxDerivPlusOne, bool StoreCoefs>
      86           0 : std::ostream& operator<<(std::ostream& os,
      87             :                          const StoredInfo<MaxDerivPlusOne, StoreCoefs>& info);
      88             : }  // namespace domain::FunctionsOfTime::FunctionOfTimeHelpers

Generated by: LCOV version 1.14