SpECTRE Documentation Coverage Report
Current view: top level - Domain/FunctionsOfTime - FunctionOfTime.hpp Hit Total Coverage
Commit: 9f349d3c09e1c03107f00c2135ca40e209d3b84c Lines: 7 16 43.8 %
Date: 2023-06-09 21:05:06
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             :   /// Updates the maximum derivative of the FunctionOfTime at a given time while
      59             :   /// also resetting the expiration. By default, a FunctionOfTime cannot be
      60             :   /// updated.
      61           1 :   virtual void update(double /*time_of_update*/,
      62             :                       DataVector /*updated_max_deriv*/,
      63             :                       double /*next_expiration_time*/) {
      64             :     ERROR("Cannot update this FunctionOfTime.");
      65             :   }
      66             : 
      67             :   /// Resets the expiration time to a new value. By default, the expiration time
      68             :   /// of a FunctionOfTime cannot be reset.
      69           1 :   virtual void reset_expiration_time(double /*next_expiration_time*/) {
      70             :     ERROR("Cannot reset expiration time of this FunctionOfTime.");
      71             :   }
      72             : 
      73             :   /// The DataVector can be of any size
      74           1 :   virtual std::array<DataVector, 1> func(double t) const = 0;
      75             :   /// The DataVector can be of any size
      76           1 :   virtual std::array<DataVector, 2> func_and_deriv(double t) const = 0;
      77             :   /// The DataVector can be of any size
      78           1 :   virtual std::array<DataVector, 3> func_and_2_derivs(double t) const = 0;
      79             : 
      80           0 :   WRAPPED_PUPable_abstract(FunctionOfTime);  // NOLINT
      81             : };
      82             : }  // namespace FunctionsOfTime
      83             : }  // namespace domain

Generated by: LCOV version 1.14