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 <vector>
9 :
10 : #include "Domain/Tags.hpp"
11 : #include "NumericalAlgorithms/LinearOperators/Filters/Tag.hpp"
12 : #include "Utilities/TMPL.hpp"
13 :
14 : /// \cond
15 : template <size_t Dim>
16 : class Element;
17 : template <size_t Dim>
18 : class Mesh;
19 : namespace gsl {
20 : template <typename T>
21 : class not_null;
22 : } // namespace gsl
23 : namespace Filters {
24 : template <size_t Dim, typename TagList>
25 : class Filter;
26 : } // namespace Filters
27 : /// \endcond
28 :
29 : namespace evolution::dg::Initialization {
30 : /*!
31 : * \brief Initialization mutator that selects the spectral filter for each
32 : * element and stores it as `Filters::Tags::SpectralFilter` in the DataBox.
33 : *
34 : * \details Used with `Initialization::Actions::InitializeItems`. For each
35 : * element, `apply` scans the GlobalCache list
36 : * `Filters::Tags::SpectralFilters<Dim, TagList>` and selects the unique filter
37 : * `f` for which `f->supports_mesh(mesh)` returns `true` AND either
38 : * `f->blocks_to_filter()` is `std::nullopt` (the filter applies to every
39 : * block) or the element's block id is contained in
40 : * `f->blocks_to_filter().value()`. The selected filter is deep-copied via
41 : * `Filters::Filter::get_clone` and stored in
42 : * `Filters::Tags::SpectralFilter<Dim, TagList>`.
43 : *
44 : * Errors if more than one filter in the list matches an element, or if no
45 : * filter matches (specify a `None` filter to disable filtering in an element).
46 : *
47 : * Uses:
48 : * - GlobalCache:
49 : * - `Filters::Tags::SpectralFilters<Dim, TagList>`
50 : * - DataBox:
51 : * - `domain::Tags::Element<Dim>`
52 : * - `domain::Tags::Mesh<Dim>`
53 : *
54 : * DataBox changes:
55 : * - Adds:
56 : * - `Filters::Tags::SpectralFilter<Dim, TagList>`
57 : * - Removes: nothing
58 : * - Modifies: nothing
59 : *
60 : * \tparam Dim Spatial dimension of the element mesh.
61 : * \tparam TagList `tmpl::list` of tensor tags in the `Variables` to filter.
62 : */
63 : template <size_t Dim, typename TagList>
64 1 : struct SpectralFilters {
65 0 : using const_global_cache_tags =
66 : tmpl::list<Filters::Tags::SpectralFilters<Dim, TagList>>;
67 0 : using mutable_global_cache_tags = tmpl::list<>;
68 0 : using simple_tags_from_options = tmpl::list<>;
69 0 : using simple_tags = tmpl::list<Filters::Tags::SpectralFilter<Dim, TagList>>;
70 0 : using compute_tags = tmpl::list<>;
71 :
72 0 : using return_tags = simple_tags;
73 0 : using argument_tags =
74 : tmpl::list<Filters::Tags::SpectralFilters<Dim, TagList>,
75 : domain::Tags::Element<Dim>, domain::Tags::Mesh<Dim>>;
76 :
77 : /// Sets `spectral_filter` to a clone of the unique filter from
78 : /// `spectral_filters` that supports `mesh` and applies to `element`'s block.
79 1 : static void apply(
80 : gsl::not_null<std::unique_ptr<Filters::Filter<Dim, TagList>>*>
81 : spectral_filter,
82 : const std::vector<std::unique_ptr<Filters::Filter<Dim, TagList>>>&
83 : spectral_filters,
84 : const Element<Dim>& element, const Mesh<Dim>& mesh);
85 : };
86 : } // namespace evolution::dg::Initialization
|