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

Generated by: LCOV version 1.14