SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/Interpolation/Protocols - PostInterpolationCallback.hpp Hit Total Coverage
Commit: 817e13c5144619b701c7cd870655d8dbf94ab8ce Lines: 1 3 33.3 %
Date: 2024-07-19 22:17:05
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 <type_traits>
       7             : 
       8             : #include "DataStructures/DataBox/DataBox.hpp"
       9             : #include "Utilities/Gsl.hpp"
      10             : 
      11             : /// \cond
      12             : namespace Parallel {
      13             : template <typename Metavariables>
      14             : struct GlobalCache;
      15             : }  // namespace Parallel
      16             : /// \endcond
      17             : 
      18             : namespace intrp::protocols {
      19             : namespace detail {
      20             : struct DummyMetavariables;
      21             : struct DummyTag : db::SimpleTag {
      22             :   using type = int;
      23             : };
      24             : 
      25             : template <typename T, typename = std::void_t<>>
      26             : struct has_signature_1 : std::false_type {};
      27             : 
      28             : template <typename T>
      29             : struct has_signature_1<
      30             :     T, std::void_t<decltype(T::apply(
      31             :            std::declval<const db::DataBox<DummyTag>&>(),
      32             :            std::declval<const Parallel::GlobalCache<DummyMetavariables>&>(),
      33             :            std::declval<const double&>()))>> : std::true_type {
      34             :   static_assert(
      35             :       std::is_same_v<
      36             :           void,
      37             :           decltype(T::apply(
      38             :               std::declval<const db::DataBox<DummyTag>&>(),
      39             :               std::declval<const Parallel::GlobalCache<DummyMetavariables>&>(),
      40             :               std::declval<const double&>()))>);
      41             : };
      42             : 
      43             : template <typename T, typename = std::void_t<>>
      44             : struct has_signature_2 : std::false_type {};
      45             : 
      46             : template <typename T>
      47             : struct has_signature_2<
      48             :     T, std::void_t<decltype(
      49             :            T::apply(std::declval<const db::DataBox<DummyTag>&>(),
      50             :                     std::declval<Parallel::GlobalCache<DummyMetavariables>&>(),
      51             :                     std::declval<const double&>()))>> : std::true_type {
      52             :   static_assert(
      53             :       std::is_same_v<
      54             :           void, decltype(T::apply(
      55             :                     std::declval<const db::DataBox<DummyTag>&>(),
      56             :                     std::declval<Parallel::GlobalCache<DummyMetavariables>&>(),
      57             :                     std::declval<const double&>()))>);
      58             : };
      59             : 
      60             : template <typename T, typename = std::void_t<>>
      61             : struct has_signature_3 : std::false_type {};
      62             : 
      63             : template <typename T>
      64             : struct has_signature_3<
      65             :     T, std::void_t<decltype(
      66             :            T::apply(std::declval<const gsl::not_null<db::DataBox<DummyTag>*>>(),
      67             :                     std::declval<const gsl::not_null<
      68             :                         Parallel::GlobalCache<DummyMetavariables>*>>(),
      69             :                     std::declval<const double&>()))>> : std::true_type {
      70             :   static_assert(
      71             :       std::is_same_v<
      72             :           bool, decltype(T::apply(
      73             :                     std::declval<const gsl::not_null<db::DataBox<DummyTag>*>>(),
      74             :                     std::declval<const gsl::not_null<
      75             :                         Parallel::GlobalCache<DummyMetavariables>*>>(),
      76             :                     std::declval<const double&>()))>);
      77             : };
      78             : 
      79             : }  // namespace detail
      80             : 
      81             : /*!
      82             :  * \brief A protocol for the type alias `post_interpolation_callbacks` found in
      83             :  * an InterpolationTargetTag.
      84             :  *
      85             :  * \details A struct conforming to the `PostInterpolationCallback` protocol must
      86             :  * have
      87             :  *
      88             :  * - a function `apply` with one of the 3 signatures in the example. This apply
      89             :  *   function will be called once the interpolation is complete. `DbTags`
      90             :  *   includes everything in the `vars_to_interpolate_to_target` alias and the
      91             :  *   `compute_items_on_target` alias of the InterpolationTargetTag. The `apply`
      92             :  *   that returns a bool should return false only if it calls another
      93             :  *   `intrp::Action` that still needs the volume data at this temporal_id (such
      94             :  *   as another iteration of the horizon finder). These functions must be able
      95             :  *   to take any type for the `TemporalId`. If a specific temporal ID type is
      96             :  *   required, it should be `static_assert`ed in the function itself.
      97             :  *
      98             :  * A struct conforming to this protocol can also have an optional `static
      99             :  * constexpr double fill_invalid_points_with`. Any points outside the Domain
     100             :  * will be filled with this value. If this variable is not defined, then the
     101             :  * `apply` function must check for invalid points, and should typically exit
     102             :  * with an error message if it finds any.
     103             :  *
     104             :  * Here is an example of a class that conforms to this protocols:
     105             :  *
     106             :  * \snippet Helpers/ParallelAlgorithms/Interpolation/Examples.hpp PostInterpolationCallback
     107             :  */
     108           1 : struct PostInterpolationCallback {
     109             :   template <typename ConformingType>
     110           0 :   struct test {
     111             :     static_assert(detail::has_signature_1<ConformingType>::value or
     112             :                   detail::has_signature_2<ConformingType>::value or
     113             :                   detail::has_signature_3<ConformingType>::value);
     114             :   };
     115             : };
     116             : }  // namespace intrp::protocols

Generated by: LCOV version 1.14