SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/Amr/Actions - Component.hpp Hit Total Coverage
Commit: 361cb8d8406bb752684a5f31c27320ec444a50e3 Lines: 1 11 9.1 %
Date: 2025-11-09 02:02:04
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 "Parallel/Algorithms/AlgorithmSingleton.hpp"
       7             : #include "Parallel/ArrayCollection/IsDgElementCollection.hpp"
       8             : #include "Parallel/ArrayCollection/SimpleActionOnElement.hpp"
       9             : #include "Parallel/GlobalCache.hpp"
      10             : #include "Parallel/Local.hpp"
      11             : #include "Parallel/ParallelComponentHelpers.hpp"
      12             : #include "Parallel/Phase.hpp"
      13             : #include "ParallelAlgorithms/Amr/Actions/AdjustDomain.hpp"
      14             : #include "ParallelAlgorithms/Amr/Actions/ElementsRegistration.hpp"
      15             : #include "ParallelAlgorithms/Amr/Actions/EvaluateRefinementCriteria.hpp"
      16             : #include "ParallelAlgorithms/Amr/Criteria/Tags/Criteria.hpp"
      17             : #include "ParallelAlgorithms/Amr/Policies/Tags.hpp"
      18             : #include "ParallelAlgorithms/Amr/Protocols/AmrMetavariables.hpp"
      19             : #include "Utilities/ProtocolHelpers.hpp"
      20             : #include "Utilities/TMPL.hpp"
      21             : 
      22             : /// \ingroup AmrGroup
      23             : namespace amr {
      24             : /// \brief A singleton parallel component to manage adaptive mesh refinement
      25             : ///
      26             : /// \details This component can be used for:
      27             : /// - Running actions that create new elements.  This may be necessary to
      28             : ///   work around Charm++ bugs, and may require the singleton to be placed
      29             : ///   on global processor 0.
      30             : /// - As a reduction target to perform sanity checks after AMR, output
      31             : ///   AMR diagnostics, or determine when to trigger AMR.
      32             : template <class Metavariables>
      33           1 : struct Component {
      34           0 :   using metavariables = Metavariables;
      35           0 :   static constexpr size_t volume_dim = Metavariables::volume_dim;
      36             :   static_assert(tt::assert_conforms_to_v<typename metavariables::amr,
      37             :                                          amr::protocols::AmrMetavariables>);
      38           0 :   using ElementArray = typename metavariables::amr::element_array;
      39             : 
      40           0 :   using chare_type = Parallel::Algorithms::Singleton;
      41           0 :   static constexpr bool checkpoint_data = true;
      42             : 
      43           0 :   using const_global_cache_tags =
      44             :       tmpl::list<amr::Criteria::Tags::Criteria, amr::Tags::Policies,
      45             :                  logging::Tags::Verbosity<amr::OptionTags::AmrGroup>>;
      46             : 
      47           0 :   using phase_dependent_action_list = tmpl::list<
      48             :       Parallel::PhaseActions<
      49             :           Parallel::Phase::Initialization,
      50             :           tmpl::list<amr::Actions::InitializeElementsRegistration<volume_dim>>>,
      51             :       Parallel::PhaseActions<
      52             :           Parallel::Phase::UpdateSections,
      53             :           tmpl::conditional_t<
      54             :               metavariables::amr::keep_coarse_grids,
      55             :               tmpl::list<::amr::Actions::UpdateSections<ElementArray>>,
      56             :               tmpl::list<>>>>;
      57             : 
      58           0 :   using simple_tags_from_options = Parallel::get_simple_tags_from_options<
      59             :       Parallel::get_initialization_actions_list<phase_dependent_action_list>>;
      60             : 
      61           0 :   static void execute_next_phase(
      62             :       const Parallel::Phase next_phase,
      63             :       Parallel::CProxy_GlobalCache<Metavariables>& global_cache_proxy) {
      64             :     auto& local_cache = *Parallel::local_branch(global_cache_proxy);
      65             :     Parallel::get_parallel_component<Component>(local_cache)
      66             :         .start_phase(next_phase);
      67             :     auto& element_array =
      68             :         Parallel::get_parallel_component<ElementArray>(local_cache);
      69             :     if (Parallel::Phase::EvaluateAmrCriteria == next_phase) {
      70             :       if constexpr (Parallel::is_dg_element_collection_v<ElementArray>) {
      71             :         Parallel::threaded_action<Parallel::Actions::SimpleActionOnElement<
      72             :             ::amr::Actions::EvaluateRefinementCriteria, true>>(element_array);
      73             :       } else {
      74             :         Parallel::simple_action<::amr::Actions::EvaluateRefinementCriteria>(
      75             :             element_array);
      76             :       }
      77             :     }
      78             :     if (Parallel::Phase::AdjustDomain == next_phase) {
      79             :       if constexpr (Parallel::is_dg_element_collection_v<ElementArray>) {
      80             :         Parallel::threaded_action<Parallel::Actions::SimpleActionOnElement<
      81             :             ::amr::Actions::AdjustDomain, true>>(element_array);
      82             :       } else {
      83             :         Parallel::simple_action<::amr::Actions::AdjustDomain>(element_array);
      84             :       }
      85             :     }
      86             :   }
      87             : };
      88             : }  // namespace amr

Generated by: LCOV version 1.14