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/GlobalCache.hpp" 8 : #include "Parallel/Local.hpp" 9 : #include "Parallel/ParallelComponentHelpers.hpp" 10 : #include "Parallel/Phase.hpp" 11 : #include "ParallelAlgorithms/Amr/Actions/AdjustDomain.hpp" 12 : #include "ParallelAlgorithms/Amr/Actions/EvaluateRefinementCriteria.hpp" 13 : #include "ParallelAlgorithms/Amr/Criteria/Tags/Criteria.hpp" 14 : #include "Utilities/TMPL.hpp" 15 : 16 : /// \ingroup AmrGroup 17 : namespace amr { 18 : /// \brief A singleton parallel component to manage adaptive mesh refinement 19 : /// 20 : /// \details This component can be used for: 21 : /// - Running actions that create new elements. This may be necessary to 22 : /// work around Charm++ bugs, and may require the singleton to be placed 23 : /// on global processor 0. 24 : /// - As a reduction target to perform sanity checks after AMR, output 25 : /// AMR diagnostics, or determine when to trigger AMR. 26 : template <class Metavariables> 27 1 : struct Component { 28 0 : using metavariables = Metavariables; 29 : 30 0 : using chare_type = Parallel::Algorithms::Singleton; 31 : 32 0 : using phase_dependent_action_list = tmpl::list< 33 : Parallel::PhaseActions<Parallel::Phase::Initialization, tmpl::list<>>>; 34 : 35 0 : using simple_tags_from_options = Parallel::get_simple_tags_from_options< 36 : Parallel::get_initialization_actions_list<phase_dependent_action_list>>; 37 : 38 0 : static void execute_next_phase( 39 : const Parallel::Phase next_phase, 40 : Parallel::CProxy_GlobalCache<Metavariables>& global_cache_proxy) { 41 : auto& local_cache = *Parallel::local_branch(global_cache_proxy); 42 : Parallel::get_parallel_component<Component>(local_cache) 43 : .start_phase(next_phase); 44 : if constexpr (tmpl::list_contains_v<typename Parallel::GlobalCache< 45 : Metavariables>::const_tags_list, 46 : amr::Criteria::Tags::Criteria>) { 47 : if (Parallel::Phase::EvaluateAmrCriteria == next_phase) { 48 : Parallel::simple_action<::amr::Actions::EvaluateRefinementCriteria>( 49 : Parallel::get_parallel_component< 50 : typename metavariables::dg_element_array>(local_cache)); 51 : } 52 : if (Parallel::Phase::AdjustDomain == next_phase) { 53 : Parallel::simple_action<::amr::Actions::AdjustDomain>( 54 : Parallel::get_parallel_component< 55 : typename metavariables::dg_element_array>(local_cache)); 56 : } 57 : } 58 : } 59 : }; 60 : } // namespace amr