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