SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/EventsAndDenseTriggers/DenseTriggers - Filter.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 4.5 % 22 1
Test Date: 2026-10-22 17:29:42
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 <memory>
       7              : #include <optional>
       8              : #include <pup.h>
       9              : #include <string>
      10              : 
      11              : #include "Options/String.hpp"
      12              : #include "ParallelAlgorithms/EventsAndDenseTriggers/DenseTrigger.hpp"
      13              : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
      14              : #include "Utilities/Gsl.hpp"
      15              : #include "Utilities/Serialization/CharmPupable.hpp"
      16              : #include "Utilities/TMPL.hpp"
      17              : 
      18              : /// \cond
      19              : namespace Parallel {
      20              : template <typename Metavariables>
      21              : class GlobalCache;
      22              : }  // namespace Parallel
      23              : namespace Tags {
      24              : struct DataBox;
      25              : }  // namespace Tags
      26              : namespace db {
      27              : template <typename TagsList>
      28              : class DataBox;
      29              : }  // namespace db
      30              : /// \endcond
      31              : 
      32              : namespace DenseTriggers {
      33              : /// \ingroup EventsAndTriggersGroup
      34              : /// %Filter activations of a dense trigger using a non-dense trigger.
      35              : ///
      36              : /// For example, to trigger every 10 starting at 100, one could use
      37              : ///
      38              : /// \snippet DenseTriggers/Test_Filter.cpp example
      39            1 : class Filter : public DenseTrigger {
      40              :  public:
      41              :   /// \cond
      42              :   Filter() = default;
      43              :   explicit Filter(CkMigrateMessage* const msg) : DenseTrigger(msg) {}
      44              :   using PUP::able::register_constructor;
      45              :   WRAPPED_PUPable_decl_template(Filter);  // NOLINT
      46              :   /// \endcond
      47              : 
      48            0 :   struct TriggerOption {
      49            0 :     static std::string name() { return "Trigger"; }
      50            0 :     using type = std::unique_ptr<DenseTrigger>;
      51            0 :     static constexpr Options::String help = "Dense trigger to filter";
      52              :   };
      53              : 
      54            0 :   struct FilterOption {
      55            0 :     static std::string name() { return "Filter"; }
      56            0 :     using type = std::unique_ptr<Trigger>;
      57            0 :     static constexpr Options::String help = "Non-dense trigger to filter with";
      58              :   };
      59              : 
      60            0 :   using options = tmpl::list<TriggerOption, FilterOption>;
      61            0 :   static constexpr Options::String help =
      62              :       "Filter activations of a dense trigger using a non-dense trigger.";
      63              : 
      64            0 :   explicit Filter(std::unique_ptr<DenseTrigger> trigger,
      65              :                   std::unique_ptr<Trigger> filter);
      66              : 
      67            0 :   using is_triggered_return_tags = tmpl::list<Tags::DataBox>;
      68            0 :   using is_triggered_argument_tags = tmpl::list<>;
      69              : 
      70              :   template <typename Metavariables, typename ArrayIndex, typename Component,
      71              :             typename DbTags>
      72            0 :   std::optional<bool> is_triggered(
      73              :       Parallel::GlobalCache<Metavariables>& cache,
      74              :       const ArrayIndex& array_index, const Component* component,
      75              :       const gsl::not_null<db::DataBox<DbTags>*> box) const {
      76              :     auto result = trigger_->is_triggered(box, cache, array_index, component);
      77              :     if (result == std::optional{true}) {
      78              :       return filter_->is_triggered(*box);
      79              :     }
      80              :     return result;
      81              :   }
      82              : 
      83            0 :   using next_check_time_return_tags = tmpl::list<Tags::DataBox>;
      84            0 :   using next_check_time_argument_tags = tmpl::list<>;
      85              : 
      86              :   template <typename Metavariables, typename ArrayIndex, typename Component,
      87              :             typename DbTags>
      88            0 :   std::optional<double> next_check_time(
      89              :       Parallel::GlobalCache<Metavariables>& cache,
      90              :       const ArrayIndex& array_index, const Component* component,
      91              :       const gsl::not_null<db::DataBox<DbTags>*> box) const {
      92              :     return trigger_->next_check_time(box, cache, array_index, component);
      93              :   }
      94              : 
      95              :   // NOLINTNEXTLINE(google-runtime-references)
      96            0 :   void pup(PUP::er& p) override;
      97              : 
      98              :  private:
      99            0 :   std::unique_ptr<DenseTrigger> trigger_{};
     100            0 :   std::unique_ptr<Trigger> filter_{};
     101              : };
     102              : }  // namespace DenseTriggers
        

Generated by: LCOV version 2.0-1