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 : const std::optional<std::vector<size_t>>& blocks_to_filter() const override; 89 : 90 1 : void set_blocks_to_filter( 91 : const std::vector<std::string>& all_block_names, 92 : const std::unordered_map<std::string, std::unordered_set<std::string>>& 93 : block_groups) override; 94 : 95 1 : void apply_in_volume( 96 : gsl::not_null<Variables<TagList>*> vars, const Mesh<Dim>& mesh, 97 : const std::optional< 98 : InverseJacobian<DataVector, Dim, Frame::Grid, Frame::Inertial>>& 99 : inv_jac_grid_to_inertial, 100 : const std::optional< 101 : Jacobian<DataVector, Dim, Frame::Grid, Frame::Inertial>>& 102 : jac_grid_to_inertial) const override; 103 : 104 1 : void apply_on_boundary( 105 : gsl::not_null<Variables<TagList>*> vars, const Mesh<Dim - 1>& mesh, 106 : const std::optional< 107 : InverseJacobian<DataVector, Dim, Frame::Grid, Frame::Inertial>>& 108 : inv_jac_grid_to_inertial, 109 : const std::optional< 110 : Jacobian<DataVector, Dim, Frame::Grid, Frame::Inertial>>& 111 : jac_grid_to_inertial) const override; 112 : 113 1 : bool is_equal(const Filter<Dim, TagList>& other) const override; 114 : 115 : private: 116 : template <size_t LocalDim, typename LocalTagList> 117 : // NOLINTNEXTLINE(readability-redundant-declaration) 118 0 : friend bool operator==(const None<LocalDim, LocalTagList>& lhs, 119 : const None<LocalDim, LocalTagList>& rhs); 120 : 121 0 : std::optional<std::vector<std::string>> blocks_and_groups_to_filter_{}; 122 0 : std::optional<std::vector<size_t>> blocks_to_filter_{}; 123 : }; 124 : 125 : template <size_t Dim, typename TagList> 126 0 : bool operator==(const None<Dim, TagList>& lhs, const None<Dim, TagList>& rhs); 127 : 128 : template <size_t Dim, typename TagList> 129 0 : bool operator!=(const None<Dim, TagList>& lhs, const None<Dim, TagList>& rhs); 130 : } // namespace Filters