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 : /// \endcond
24 :
25 : namespace evolution::dg {
26 : /*!
27 : * \brief Returns the IDs of the `Block`s on which only the DG scheme is
28 : * allowed to run, i.e. that are not subcell-capable.
29 : *
30 : * This is the union of the blocks and groups listed in
31 : * `evolution::dg::OptionTags::OnlyDgBlocksAndGroups` and the blocks whose
32 : * topology does not support subcell (see `block_supports_subcell`).
33 : *
34 : * \note This is not inside the `DgSubcell` library so that it can be used by
35 : * code (like the element distribution) that must not depend on `DgSubcell`.
36 : */
37 : template <size_t Dim>
38 1 : std::vector<size_t> compute_only_dg_block_ids(
39 : const std::optional<std::vector<std::string>>&
40 : only_dg_block_and_group_names,
41 : const std::vector<std::string>& block_names,
42 : const std::unordered_map<std::string, std::unordered_set<std::string>>&
43 : block_groups,
44 : const std::vector<Block<Dim>>& blocks);
45 :
46 : /*!
47 : * \brief Returns the IDs of the `Block`s on which only the DG scheme is
48 : * allowed to run, i.e. that are not subcell-capable.
49 : *
50 : * Convenience overload that builds the `Domain` from the \p domain_creator.
51 : * If you already have a `Domain`, use the overload taking the blocks
52 : * directly to avoid constructing a second one.
53 : */
54 : template <size_t Dim>
55 1 : std::vector<size_t> compute_only_dg_block_ids(
56 : const std::optional<std::vector<std::string>>&
57 : only_dg_block_and_group_names,
58 : const DomainCreator<Dim>& domain_creator);
59 :
60 : namespace Tags {
61 : /// \ingroup DataBoxTagsGroup
62 : /// See `evolution::dg::compute_only_dg_block_ids`.
63 : template <size_t Dim>
64 1 : struct OnlyDgBlockIds : db::SimpleTag {
65 0 : using type = std::vector<size_t>;
66 0 : using option_tags =
67 : tmpl::list<evolution::dg::OptionTags::OnlyDgBlocksAndGroups,
68 : domain::OptionTags::DomainCreator<Dim>>;
69 :
70 0 : static constexpr bool pass_metavariables = false;
71 0 : static type create_from_options(
72 : const std::optional<std::vector<std::string>>&
73 : only_dg_block_and_group_names,
74 : const std::unique_ptr<DomainCreator<Dim>>& domain_creator) {
75 : return compute_only_dg_block_ids(only_dg_block_and_group_names,
76 : *domain_creator);
77 : }
78 : };
79 : } // namespace Tags
80 : } // namespace evolution::dg
|