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 <optional>
9 : #include <pup.h>
10 : #include <string>
11 : #include <unordered_map>
12 : #include <unordered_set>
13 : #include <vector>
14 :
15 : #include "DataStructures/Tensor/Tensor.hpp"
16 : #include "DataStructures/Tensor/TypeAliases.hpp"
17 : #include "DataStructures/Variables.hpp"
18 : #include "NumericalAlgorithms/LinearOperators/Filters/Filter.hpp"
19 : #include "Options/Auto.hpp"
20 : #include "Options/Context.hpp"
21 : #include "Options/String.hpp"
22 : #include "Utilities/Gsl.hpp"
23 :
24 : /// \cond
25 : template <size_t Dim>
26 : class Mesh;
27 : /// \endcond
28 :
29 : namespace Filters {
30 : /*!
31 : * \ingroup DiscontinuousGalerkinGroup
32 : * \brief A no-op filter that never modifies any data and accepts any mesh
33 : * basis or quadrature.
34 : *
35 : * See `Filters::Filter` for the general interface description.
36 : */
37 : template <size_t Dim, typename TagList>
38 1 : class None : public Filter<Dim, TagList> {
39 : public:
40 : /// \brief Which blocks the filter should be applied to.
41 1 : struct BlocksToFilter {
42 0 : using type =
43 : Options::Auto<std::vector<std::string>, Options::AutoLabel::All>;
44 0 : static constexpr Options::String help = {
45 : "List of blocks or block groups to restrict this no-op filter to. "
46 : "You can also specify 'All' to apply to every block in the domain. "
47 : "Since the filter never modifies data, this option only affects which "
48 : "blocks appear in the filter's block list."};
49 : };
50 :
51 0 : using options = tmpl::list<BlocksToFilter>;
52 :
53 0 : static constexpr Options::String help = {
54 : "A no-op filter that never modifies any data and is valid for any basis "
55 : "or quadrature."};
56 :
57 0 : None() = default;
58 :
59 0 : explicit None(const std::optional<std::vector<std::string>>& blocks_to_filter,
60 : const Options::Context& context = {});
61 :
62 0 : WRAPPED_PUPable_decl_base_template( // NOLINT
63 : SINGLE_ARG(Filter<Dim, TagList>), None);
64 0 : explicit None(CkMigrateMessage* msg) : Filter<Dim, TagList>(msg) {}
65 :
66 : // NOLINTNEXTLINE(google-runtime-references)
67 0 : void pup(PUP::er& p) override;
68 :
69 1 : std::unique_ptr<Filter<Dim, TagList>> get_clone() const override {
70 : return std::make_unique<None>(*this);
71 : }
72 :
73 1 : bool apply_volume_filter_on_substep() const override { return false; }
74 1 : bool apply_volume_filter_on_this_step(size_t /*step_number*/) const override {
75 : return false;
76 : }
77 :
78 1 : bool apply_boundary_filter_on_substep() const override { return false; }
79 1 : bool apply_boundary_filter_on_this_step(
80 : size_t /*step_number*/) const override {
81 : return false;
82 : }
83 :
84 1 : bool need_jacobians() const override { return false; }
85 :
86 1 : bool supports_mesh(const Mesh<Dim>& /*mesh*/) const override { return true; }
87 :
88 1 : std::string name() const override { return "None"; }
89 :
90 1 : const std::optional<std::vector<size_t>>& blocks_to_filter() const override;
91 :
92 1 : void set_blocks_to_filter(
93 : const std::vector<std::string>& all_block_names,
94 : const std::unordered_map<std::string, std::unordered_set<std::string>>&
95 : block_groups) override;
96 :
97 1 : void apply_in_volume(
98 : gsl::not_null<Variables<TagList>*> vars, const Mesh<Dim>& mesh,
99 : const std::optional<
100 : InverseJacobian<DataVector, Dim, Frame::Grid, Frame::Inertial>>&
101 : inv_jac_grid_to_inertial,
102 : const std::optional<
103 : Jacobian<DataVector, Dim, Frame::Grid, Frame::Inertial>>&
104 : jac_grid_to_inertial) const override;
105 :
106 1 : void apply_on_boundary(
107 : gsl::not_null<Variables<TagList>*> vars, const Mesh<Dim - 1>& mesh,
108 : const std::optional<
109 : InverseJacobian<DataVector, Dim, Frame::Grid, Frame::Inertial>>&
110 : inv_jac_grid_to_inertial,
111 : const std::optional<
112 : Jacobian<DataVector, Dim, Frame::Grid, Frame::Inertial>>&
113 : jac_grid_to_inertial) const override;
114 :
115 1 : bool is_equal(const Filter<Dim, TagList>& other) const override;
116 :
117 : private:
118 : template <size_t LocalDim, typename LocalTagList>
119 : // NOLINTNEXTLINE(readability-redundant-declaration)
120 0 : friend bool operator==(const None<LocalDim, LocalTagList>& lhs,
121 : const None<LocalDim, LocalTagList>& rhs);
122 :
123 0 : std::optional<std::vector<std::string>> blocks_and_groups_to_filter_{};
124 0 : std::optional<std::vector<size_t>> blocks_to_filter_{};
125 : };
126 :
127 : template <size_t Dim, typename TagList>
128 0 : bool operator==(const None<Dim, TagList>& lhs, const None<Dim, TagList>& rhs);
129 :
130 : template <size_t Dim, typename TagList>
131 0 : bool operator!=(const None<Dim, TagList>& lhs, const None<Dim, TagList>& rhs);
132 : } // namespace Filters
|