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 <string>
10 : #include <unordered_map>
11 : #include <unordered_set>
12 : #include <vector>
13 :
14 : #include "DataStructures/DataBox/Tag.hpp"
15 : #include "Domain/Creators/OptionTags.hpp"
16 : #include "Evolution/DiscontinuousGalerkin/OptionTags.hpp"
17 :
18 : /// \cond
19 : template <size_t VolumeDim>
20 : class Block;
21 : template <size_t VolumeDim>
22 : class DomainCreator;
23 : template <size_t VolumeDim>
24 : class Element;
25 : /// \endcond
26 :
27 : namespace evolution::dg {
28 : /*!
29 : * \brief Returns the IDs of the `Block`s on which only the DG scheme is
30 : * allowed to run, i.e. that are not subcell-capable.
31 : *
32 : * This is the union of the blocks and groups listed in
33 : * `evolution::dg::OptionTags::OnlyDgBlocksAndGroups` and the blocks whose
34 : * topology does not support subcell (see `block_supports_subcell`).
35 : *
36 : * \note This is not inside the `DgSubcell` library so that it can be used by
37 : * code (like the element distribution) that must not depend on `DgSubcell`.
38 : */
39 : template <size_t Dim>
40 1 : std::vector<size_t> compute_only_dg_block_ids(
41 : const std::optional<std::vector<std::string>>&
42 : only_dg_block_and_group_names,
43 : const std::vector<std::string>& block_names,
44 : const std::unordered_map<std::string, std::unordered_set<std::string>>&
45 : block_groups,
46 : const std::vector<Block<Dim>>& blocks);
47 :
48 : /*!
49 : * \brief Returns the IDs of the `Block`s on which only the DG scheme is
50 : * allowed to run, i.e. that are not subcell-capable.
51 : *
52 : * Convenience overload that builds the `Domain` from the \p domain_creator.
53 : * If you already have a `Domain`, use the overload taking the blocks
54 : * directly to avoid constructing a second one.
55 : */
56 : template <size_t Dim>
57 1 : std::vector<size_t> compute_only_dg_block_ids(
58 : const std::optional<std::vector<std::string>>&
59 : only_dg_block_and_group_names,
60 : const DomainCreator<Dim>& domain_creator);
61 :
62 : /*!
63 : * \brief Returns whether any neighbor of the \p element is in a block in
64 : * \p only_dg_block_ids.
65 : *
66 : * Elements bordering a DG-only block are not allowed to use subcell, since
67 : * their DG-only neighbors cannot send them subcell ghost data.
68 : */
69 : template <size_t Dim>
70 1 : bool borders_only_dg_block(const Element<Dim>& element,
71 : const std::vector<size_t>& only_dg_block_ids);
72 :
73 : namespace Tags {
74 : /// \ingroup DataBoxTagsGroup
75 : /// See `evolution::dg::compute_only_dg_block_ids`.
76 : template <size_t Dim>
77 1 : struct OnlyDgBlockIds : db::SimpleTag {
78 0 : using type = std::vector<size_t>;
79 0 : using option_tags =
80 : tmpl::list<evolution::dg::OptionTags::OnlyDgBlocksAndGroups,
81 : domain::OptionTags::DomainCreator<Dim>>;
82 :
83 0 : static constexpr bool pass_metavariables = false;
84 0 : static type create_from_options(
85 : const std::optional<std::vector<std::string>>&
86 : only_dg_block_and_group_names,
87 : const std::unique_ptr<DomainCreator<Dim>>& domain_creator) {
88 : return compute_only_dg_block_ids(only_dg_block_and_group_names,
89 : *domain_creator);
90 : }
91 : };
92 : } // namespace Tags
93 : } // namespace evolution::dg
|