Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <cstddef> 7 : #include <memory> 8 : #include <string> 9 : #include <unordered_map> 10 : #include <unordered_set> 11 : #include <vector> 12 : 13 : #include "DataStructures/DataBox/Tag.hpp" 14 : #include "Domain/Creators/DomainCreator.hpp" 15 : #include "Domain/Creators/OptionTags.hpp" 16 : #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags/OptionsGroup.hpp" 17 : #include "NumericalAlgorithms/LinearOperators/Filters/Filter.hpp" 18 : #include "Options/String.hpp" 19 : #include "Utilities/CloneUniquePtrs.hpp" 20 : #include "Utilities/TMPL.hpp" 21 : 22 0 : namespace Filters::OptionTags { 23 : /// \brief Option tag for the list of spectral filters read from the input file. 24 : /// 25 : /// Parsed under the `Filtering` key in the input file, this tag holds a 26 : /// `std::vector` of heap-allocated `Filters::Filter<Dim, TagList>` objects. 27 : /// 28 : /// \tparam Dim Spatial dimension of the element mesh. 29 : /// \tparam TagList `tmpl::list` of tensor tags in the `Variables` to filter. 30 : template <size_t Dim, typename TagList> 31 1 : struct SpectralFilters { 32 0 : using group = dg::OptionTags::DiscontinuousGalerkinGroup; 33 0 : static std::string name() { return "Filtering"; } 34 0 : static constexpr Options::String help = 35 : "A vector/list of the different filters that are applied in different " 36 : "elements."; 37 0 : using type = std::vector<std::unique_ptr<Filters::Filter<Dim, TagList>>>; 38 : }; 39 : } // namespace Filters::OptionTags 40 : 41 0 : namespace Filters::Tags { 42 : /// \brief DataBox tag for the spectral filters applied during DG time 43 : /// integration in a single element. 44 : /// 45 : /// Holds `Filters::Filter<Dim, TagList>`s that are applied in the element. 46 : /// `TagList` is the `tmpl::list` of tensor tags in the `Variables` to be 47 : /// filtered. 48 : /// 49 : /// \tparam Dim Spatial dimension of the element mesh. 50 : /// \tparam TagList `tmpl::list` of tensor tags in the `Variables` to filter. 51 : template <size_t Dim, typename TagList> 52 1 : struct SpectralFilter : db::SimpleTag { 53 0 : using type = std::unique_ptr<Filters::Filter<Dim, TagList>>; 54 : }; 55 : 56 : /// \brief DataBox tag for the ordered list of all spectral filters for 57 : /// different topologies applied during DG time integration. 58 : /// 59 : /// Each element holds a local copy of the filters that should be applied in it. 60 : /// 61 : /// \tparam Dim Spatial dimension of the element mesh. 62 : /// \tparam TagList `tmpl::list` of tensor tags in the `Variables` to filter. 63 : template <size_t Dim, typename TagList> 64 1 : struct SpectralFilters : db::SimpleTag { 65 0 : using type = std::vector<std::unique_ptr<Filters::Filter<Dim, TagList>>>; 66 0 : static constexpr bool pass_metavariables = false; 67 : 68 0 : using option_tags = 69 : tmpl::list<Filters::OptionTags::SpectralFilters<Dim, TagList>, 70 : domain::OptionTags::DomainCreator<Dim>>; 71 : 72 0 : static type create_from_options( 73 : const type& spectral_filters, 74 : const std::unique_ptr<DomainCreator<Dim>>& domain_creator) { 75 : auto filters = clone_unique_ptrs(spectral_filters); 76 : const auto& block_names = domain_creator->block_names(); 77 : const auto& block_groups = domain_creator->block_groups(); 78 : for (auto& filter : filters) { 79 : filter->set_blocks_to_filter(block_names, block_groups); 80 : } 81 : return filters; 82 : } 83 : }; 84 : } // namespace Filters::Tags