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 : /// - `keep_coarse_grids`: A boolean indicating that AMR should create a 30 : /// completely new grid at each AMR step with an incremented grid index, and 31 : /// keep the old grid around. This is useful for multigrid solvers. 32 : /// If this is true, then the `element_array` must include 33 : /// `::amr::Actions::RegisterElement` in the registration phase action list 34 : /// and in `Metavariables::registration::element_registrars`. You must also 35 : /// ensure to visit `Phase::UpdateSections` in the default phase order after 36 : /// registration, and in each AMR step after 37 : /// `Phase::EvaluateRefinementCriteria` and `Phase::AdjustDomain`. 38 : /// When this is enabled, you can use `amr::Tags::ParentId` and 39 : /// `amr::Tags::ChildIds` to traverse the grid hierarchy. However, you cannot 40 : /// rely on these tags to be up-to-date in the AMR projectors, as they are 41 : /// sometime updated after the projectors are run. 42 : /// 43 : /// Here is an example for a class conforming to this protocol: 44 : /// 45 : /// \snippet Amr/Test_Protocols.cpp amr_projectors 46 1 : struct AmrMetavariables { 47 : template <typename ConformingType> 48 0 : struct test { 49 0 : using element_array = typename ConformingType::element_array; 50 0 : using projectors = typename ConformingType::projectors; 51 : static_assert( 52 : tmpl::all<projectors, 53 : tt::assert_conforms_to<tmpl::_1, Projector>>::value); 54 0 : static constexpr bool keep_coarse_grids = ConformingType::keep_coarse_grids; 55 : }; 56 : }; 57 : } // namespace amr::protocols