SpECTRE Documentation Coverage Report
Current view: top level - Domain/FunctionsOfTime - FunctionOfTime.hpp Hit Total Coverage
Commit: 3c2e9d3ed337bca2146eee9de07432e292a38c3a Lines: 7 17 41.2 %
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 <memory>
       8             : #include <pup.h>
       9             : #include <vector>
      10             : 
      11             : #include "DataStructures/DataVector.hpp"
      12             : #include "Utilities/ErrorHandling/Error.hpp"
      13             : #include "Utilities/Serialization/CharmPupable.hpp"
      14             : 
      15             : namespace domain {
      16             : /// \ingroup ComputationalDomainGroup
      17             : /// \brief Contains functions of time to support the dual frame system.
      18             : namespace FunctionsOfTime {
      19             : /// \ingroup ComputationalDomainGroup
      20             : /// \brief Base class for FunctionsOfTime
      21             : ///
      22             : /// A FunctionOfTime is a function that will return the same value for
      23             : /// a time `t`, regardless of when that function is called during a run
      24             : /// (provided that the time `t` is in the domain of validity of the function).
      25             : /// All FunctionsOfTime have members
      26             : ///   - `func`, that returns a `std::array<DataVector, 1>`
      27             : ///   - `func_and_deriv`, that returns a `std::array<DataVector, 2>`
      28             : ///   - `func_and_2_derivs`, that returns a `std::array<DataVector, 3>`
      29             : ///
      30             : /// The DataVectors that are returned can be of any size: e.g. a scalar
      31             : /// FunctionOfTime will have DataVectors with one component and a 3-vector
      32             : /// FunctionOfTime will have DataVectors with three components.
      33             : ///
      34             : /// The domain of validity of the function is given by the `time_bounds` member
      35             : /// function.
      36             : ///
      37             : /// The function and all of its derivatives are left-continuous, that
      38             : /// is, when evaluated at a time when the function was updated, they
      39             : /// return the values just before the update, ignoring the updated
      40             : /// value.
      41           1 : class FunctionOfTime : public PUP::able {
      42             :  public:
      43           0 :   FunctionOfTime() = default;
      44           0 :   FunctionOfTime(FunctionOfTime&&) = default;
      45           0 :   FunctionOfTime& operator=(FunctionOfTime&&) = default;
      46           0 :   FunctionOfTime(const FunctionOfTime&) = default;
      47           0 :   FunctionOfTime& operator=(const FunctionOfTime&) = default;
      48           0 :   ~FunctionOfTime() override = default;
      49             : 
      50           0 :   virtual auto get_clone() const -> std::unique_ptr<FunctionOfTime> = 0;
      51             : 
      52             :   /// Returns the domain of validity of the function.
      53             :   /// For FunctionsOfTime that allow a small amount of time extrapolation,
      54             :   /// `time_bounds` tells you the bounds including the allowed extrapolation
      55             :   /// interval.
      56           1 :   virtual std::array<double, 2> time_bounds() const = 0;
      57             : 
      58             :   /// \brief The first expiration time after \p time.
      59             :   ///
      60             :   /// \details For non-updatable functions, this returns infinity. For
      61             :   /// updatable functions, the first expiration time after \p time is
      62             :   /// found by determining the update immediately before \p time. The
      63             :   /// expiration time of this update is what is returned. If \p time
      64             :   /// happens to be an update itself, then the expiration of that
      65             :   /// update is returned.
      66           1 :   virtual double expiration_after(double time) const = 0;
      67             : 
      68             :   /// Updates the maximum derivative of the FunctionOfTime at a given time while
      69             :   /// also resetting the expiration. By default, a FunctionOfTime cannot be
      70             :   /// updated.
      71           1 :   virtual void update(double /*time_of_update*/,
      72             :                       DataVector /*updated_max_deriv*/,
      73             :                       double /*next_expiration_time*/) {
      74             :     ERROR("Cannot update this FunctionOfTime.");
      75             :   }
      76             : 
      77             :   /// The DataVector can be of any size
      78           1 :   virtual std::array<DataVector, 1> func(double t) const = 0;
      79             :   /// The DataVector can be of any size
      80           1 :   virtual std::array<DataVector, 2> func_and_deriv(double t) const = 0;
      81             :   /// The DataVector can be of any size
      82           1 :   virtual std::array<DataVector, 3> func_and_2_derivs(double t) const = 0;
      83             : 
      84           0 :   WRAPPED_PUPable_abstract(FunctionOfTime);  // NOLINT
      85             : };
      86             : }  // namespace FunctionsOfTime
      87             : 
      88           0 : using FunctionsOfTimeMap = std::unordered_map<
      89             :     std::string, std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>>;
      90             : 
      91             : }  // namespace domain

Generated by: LCOV version 1.14