SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/Amr/Criteria - Criterion.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 25.0 % 8 2
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 <array>
       7              : #include <pup.h>
       8              : #include <type_traits>
       9              : 
      10              : #include "DataStructures/DataBox/MetavariablesTag.hpp"
      11              : #include "DataStructures/DataBox/ObservationBox.hpp"
      12              : #include "Domain/Amr/Flag.hpp"
      13              : #include "Domain/Structure/ElementId.hpp"
      14              : #include "Parallel/GlobalCache.hpp"
      15              : #include "ParallelAlgorithms/Amr/Criteria/Type.hpp"
      16              : #include "Utilities/CallWithDynamicType.hpp"
      17              : #include "Utilities/Serialization/CharmPupable.hpp"
      18              : #include "Utilities/TMPL.hpp"
      19              : 
      20              : namespace amr {
      21              : /// \ingroup AmrGroup
      22              : /// \brief Base class for something that determines how an adaptive mesh should
      23              : /// be changed
      24              : ///
      25              : /// \details Each class derived from this class should (see the examples below):
      26              : /// - Be option-creatable
      27              : /// - Be serializable
      28              : /// - Define a call operator that returns a std::array<amr::Flag, Dim>
      29              : ///   containing the recommended refinement choice in each logical dimension of
      30              : ///   the Element.
      31              : /// - Define the type aliases `argument_tags` and
      32              : ///   `compute_tags_for_observation_box` that are type lists of tags used in the
      33              : ///   call operator.
      34              : /// The call operator should take as arguments the values corresponding to each
      35              : /// tag in `argument_tags` (in order), followed by the Parallel::GlobalCache,
      36              : /// and the ElementId.  The tags listed in `argument_tags` should either be tags
      37              : /// in the DataBox of the array component, or listed in
      38              : /// `compute_tags_for_observation_box`.
      39              : ///
      40              : /// \example
      41              : /// \snippet Amr/Criteria/Test_Criterion.cpp criterion_examples
      42            1 : class Criterion : public PUP::able {
      43              :  protected:
      44              :   /// \cond
      45              :   Criterion() = default;
      46              :   Criterion(const Criterion&) = default;
      47              :   Criterion(Criterion&&) = default;
      48              :   Criterion& operator=(const Criterion&) = default;
      49              :   Criterion& operator=(Criterion&&) = default;
      50              :   /// \endcond
      51              : 
      52              :  public:
      53            0 :   ~Criterion() override = default;
      54            0 :   explicit Criterion(CkMigrateMessage* msg) : PUP::able(msg) {}
      55              : 
      56            0 :   WRAPPED_PUPable_abstract(Criterion);  // NOLINT
      57              : 
      58            0 :   virtual Criteria::Type type() = 0;
      59              : 
      60            0 :   virtual std::string observation_name() = 0;
      61              : 
      62              :   /// Evaluates the AMR criteria by selecting the appropriate derived class
      63              :   /// and forwarding its `argument_tags` from the ObservationBox (along with the
      64              :   /// GlobalCache and ArrayIndex) to the call operator of the derived class
      65              :   ///
      66              :   /// \note In order to be available, a derived Criterion must be listed in
      67              :   /// the entry for Criterion in
      68              :   /// Metavarialbes::factory_creation::factory_classes
      69              :   ///
      70              :   /// \note The ComputeTagsList of the ObservationBox should contain the union
      71              :   /// of the tags listed in `compute_tags_for_observation_box` for each derived
      72              :   /// Criterion listed in the `factory_classes`.
      73              :   template <typename ComputeTagsList, typename DataBoxType,
      74              :             typename Metavariables>
      75            1 :   auto evaluate(const ObservationBox<ComputeTagsList, DataBoxType>& box,
      76              :                 Parallel::GlobalCache<Metavariables>& cache,
      77              :                 const ElementId<Metavariables::volume_dim>& element_id) const {
      78              :     using factory_classes =
      79              :         typename std::decay_t<Metavariables>::factory_creation::factory_classes;
      80              :     return call_with_dynamic_type<
      81              :         std::array<amr::Flag, Metavariables::volume_dim>,
      82              :         tmpl::at<factory_classes, Criterion>>(
      83              :         this, [&box, &cache, &element_id](auto* const criterion) {
      84              :           return apply(*criterion, box, cache, element_id);
      85              :         });
      86              :   }
      87              : };
      88              : }  // namespace amr
        

Generated by: LCOV version 2.0-1