Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <type_traits> 7 : 8 : #include "ParallelAlgorithms/Amr/Protocols/Projector.hpp" 9 : #include "Utilities/ProtocolHelpers.hpp" 10 : #include "Utilities/TMPL.hpp" 11 : 12 1 : namespace amr::protocols { 13 : /// \brief Compile-time information for AMR projectors 14 : /// 15 : /// A class conforming to this protocol is placed in the metavariables to 16 : /// provide the following: 17 : /// - `element_array`: The array component on which AMR is performed. 18 : /// - `projectors`: A type list of AMR projectors (each of which must conform to 19 : /// amr::protocols::Projector) that will be applied by: 20 : /// - amr::Actions::InitializeChild and amr::Actions::InitializeParent in 21 : /// order to initialize data on newly created elements. 22 : /// - amr::Actions::AdjustDomain in order to update data on existing 23 : /// elements in case their Mesh or neighbors have changed. 24 : /// In these projectors you must handle _all_ mutable tags in the DataBox, 25 : /// except for a few tags that are handled by the AMR actions themselves 26 : /// (e.g. `domain::Tags::Element`, `domain::Tags::Mesh`, and 27 : /// `domain::Tags::NeighborMesh` are handled by AMR). See 28 : /// `amr::protocols::Projector` for details. 29 : /// - `p_refine_only_in_event`: A boolean indicating that only h-refinement 30 : /// criteria should be evaluated in 31 : /// `::amr::Actions::EvaluateRefinementCriteria`. Only h-refinement will be 32 : /// done in `Phase::AdjustDomain`; p-refinement will only be done via 33 : /// `::amr::Events::RefineMesh`. 34 : /// - `keep_coarse_grids`: A boolean indicating that AMR should create a 35 : /// completely new grid at each AMR step with an incremented grid index, and 36 : /// keep the old grid around. This is useful for multigrid solvers. 37 : /// If this is true, then the `element_array` must include 38 : /// `::amr::Actions::RegisterElement` in the registration phase action list 39 : /// and in `Metavariables::registration::element_registrars`. You must also 40 : /// ensure to visit `Phase::UpdateSections` in the default phase order after 41 : /// registration, and in each AMR step after 42 : /// `Phase::EvaluateRefinementCriteria` and `Phase::AdjustDomain`. 43 : /// When this is enabled, you can use `amr::Tags::ParentId` and 44 : /// `amr::Tags::ChildIds` to traverse the grid hierarchy. However, you cannot 45 : /// rely on these tags to be up-to-date in the AMR projectors, as they are 46 : /// sometime updated after the projectors are run. 47 : /// 48 : /// Here is an example for a class conforming to this protocol: 49 : /// 50 : /// \snippet Amr/Test_Protocols.cpp amr_projectors 51 1 : struct AmrMetavariables { 52 : template <typename ConformingType> 53 0 : struct test { 54 0 : using element_array = typename ConformingType::element_array; 55 0 : using projectors = typename ConformingType::projectors; 56 : static_assert( 57 : tmpl::all<projectors, 58 : tt::assert_conforms_to<tmpl::_1, Projector>>::value); 59 0 : static constexpr bool keep_coarse_grids = ConformingType::keep_coarse_grids; 60 0 : static constexpr bool p_refine_only_in_event = 61 : ConformingType::p_refine_only_in_event; 62 : }; 63 : }; 64 : } // namespace amr::protocols