SpECTRE Documentation Coverage Report
Current view: top level - Domain/CoordinateMaps/TimeDependent/ShapeMapTransitionFunctions - SphereTransition.hpp Hit Total Coverage
Commit: 3528f39684ab2ee5d689cee48331779e729b0a07 Lines: 7 23 30.4 %
Date: 2024-02-27 07:22:14
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 <optional>
       8             : #include <pup.h>
       9             : 
      10             : #include "DataStructures/DataVector.hpp"
      11             : #include "Domain/CoordinateMaps/TimeDependent/ShapeMapTransitionFunctions/ShapeMapTransitionFunction.hpp"
      12             : 
      13             : namespace domain::CoordinateMaps::ShapeMapTransitionFunctions {
      14             : 
      15             : /*!
      16             :  * \ingroup CoordMapsTimeDependentGroup
      17             :  * \brief A transition function that falls off as $f(r) = g(r) / r$ where $g(r)
      18             :  * = ar + b$.
      19             :  *
      20             :  * \details The coefficients $a$ and $b$ are chosen so that the function $g(r) =
      21             :  * ar + b$ falls off linearly from 1 at `r_min` to 0 at `r_max`. This means that
      22             :  * $f(r)$ falls off from $1/r_{\text{min}}$ at `r_min` to 0 at `r_max`. The
      23             :  * coefficients are
      24             :  *
      25             :  * \f{align}{
      26             :  * a &= \frac{-1}{r_{\text{max}} - r_{\text{min}}} \\
      27             :  * b &= \frac{r_{\text{max}}}{r_{\text{max}} - r_{\text{min}}} = -a
      28             :  * r_{\text{max}}
      29             :  * \f}
      30             :  */
      31           1 : class SphereTransition final : public ShapeMapTransitionFunction {
      32             :  public:
      33           0 :   explicit SphereTransition() = default;
      34           0 :   SphereTransition(double r_min, double r_max);
      35             : 
      36           1 :   double operator()(const std::array<double, 3>& source_coords) const override;
      37           1 :   DataVector operator()(
      38             :       const std::array<DataVector, 3>& source_coords) const override;
      39             : 
      40           1 :   std::optional<double> original_radius_over_radius(
      41             :       const std::array<double, 3>& target_coords,
      42             :       double distorted_radius) const override;
      43             : 
      44           1 :   std::array<double, 3> gradient(
      45             :       const std::array<double, 3>& source_coords) const override;
      46           1 :   std::array<DataVector, 3> gradient(
      47             :       const std::array<DataVector, 3>& source_coords) const override;
      48             : 
      49           0 :   WRAPPED_PUPable_decl_template(SphereTransition);
      50           0 :   explicit SphereTransition(CkMigrateMessage* const msg);
      51           0 :   void pup(PUP::er& p) override;
      52             : 
      53           1 :   std::unique_ptr<ShapeMapTransitionFunction> get_clone() const override {
      54             :     return std::make_unique<SphereTransition>(*this);
      55             :   }
      56             : 
      57           0 :   bool operator==(const ShapeMapTransitionFunction& other) const override;
      58           0 :   bool operator!=(const ShapeMapTransitionFunction& other) const override;
      59             : 
      60             :  private:
      61             :   template <typename T>
      62           0 :   T call_impl(const std::array<T, 3>& source_coords) const;
      63             : 
      64             :   template <typename T>
      65           0 :   std::array<T, 3> gradient_impl(const std::array<T, 3>& source_coords) const;
      66             : 
      67             :   // checks that the magnitudes are all between `r_min_` and `r_max_`
      68             :   template <typename T>
      69           0 :   void check_magnitudes(const T& mag) const;
      70             : 
      71           0 :   double r_min_{};
      72           0 :   double r_max_{};
      73           0 :   double a_{};
      74           0 :   double b_{};
      75           0 :   static constexpr double eps_ = std::numeric_limits<double>::epsilon() * 100;
      76             : };
      77             : }  // namespace domain::CoordinateMaps::ShapeMapTransitionFunctions

Generated by: LCOV version 1.14