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 <utility>
12 : #include <vector>
13 :
14 : #include "Domain/Creators/OptionTags.hpp"
15 : #include "Domain/Structure/Direction.hpp"
16 : #include "Evolution/DiscontinuousGalerkin/OptionTags.hpp"
17 : #include "Utilities/TMPL.hpp"
18 :
19 : /// \cond
20 : template <size_t VolumeDim>
21 : class DomainCreator;
22 : template <size_t VolumeDim>
23 : class ElementId;
24 : namespace PUP {
25 : class er;
26 : } // namespace PUP
27 : /// \endcond
28 :
29 : namespace evolution::dg::subcell {
30 : /// Combined equal-rate region generator for subcell evolution with
31 : /// nonconforming block boundaries.
32 : ///
33 : /// When using local time stepping (LTS) with both subcell evolution and
34 : /// nonconforming block boundaries, the two separate region generators
35 : /// `NonconformingEqualRateRegions` and `SubcellEqualRateRegion`
36 : /// cannot be combined without conflicts in their regions. This class merges
37 : /// the two generators into one, treating subcell-adjacent nonconforming
38 : /// interfaces as part of the "Subcell" region rather than as separate
39 : /// "NonconformingN" regions.
40 : ///
41 : /// **Subcell region (region 0)**: Contains all subcell-capable elements (those
42 : /// not in `OnlyDgBlocksAndGroups`) **plus** the elements of DG-only
43 : /// blocks that lie directly on a nonconforming face bordering a subcell-capable
44 : /// block.
45 : ///
46 : /// **NonconformingN[+/-] regions (regions 1…N)**: Created only for
47 : /// nonconforming interfaces where every block on both sides is DG-only (no
48 : /// subcell capability on either side). These behave identically to the
49 : /// regions produced by `NonconformingEqualRateRegions`.
50 : ///
51 : /// \note If your domain has no nonconforming block boundaries, use
52 : /// `SubcellEqualRateRegion` instead: it is simpler and has no overhead.
53 : template <size_t Dim>
54 1 : class SubcellAndNonconformingEqualRateRegions {
55 : public:
56 0 : SubcellAndNonconformingEqualRateRegions() = default;
57 :
58 0 : using creation_tags =
59 : tmpl::list<evolution::dg::OptionTags::OnlyDgBlocksAndGroups,
60 : domain::OptionTags::DomainCreator<Dim>>;
61 :
62 0 : SubcellAndNonconformingEqualRateRegions(
63 : const std::optional<std::vector<std::string>>&
64 : only_dg_block_and_group_names,
65 : const std::unique_ptr<DomainCreator<Dim>>& domain_creator);
66 :
67 0 : std::unordered_map<std::string, size_t> regions() const;
68 :
69 0 : bool is_in_region(size_t region, const ElementId<Dim>& element_id) const;
70 :
71 0 : void pup(PUP::er& p);
72 :
73 : private:
74 : // DG-only block IDs: non-hypercube topology blocks (detected automatically)
75 : // plus user-specified OnlyDgBlocksAndGroups blocks. Subcell-capable blocks
76 : // (those NOT in this list) are always in region 0 ("Subcell")
77 0 : std::vector<size_t> only_dg_block_ids_{};
78 : // (block_id, direction) pairs identifying the faces of DG-only blocks that
79 : // touch a nonconforming boundary with at least one subcell-capable neighbor.
80 : // The elements on these faces are included in region 0 ("Subcell").
81 0 : std::vector<std::pair<size_t, Direction<Dim>>> subcell_adjacent_dg_faces_{};
82 : // Names and face-membership data for purely DG nonconforming regions
83 : // (region index i here corresponds to region i+1 overall, since region 0
84 : // is "Subcell").
85 0 : std::vector<std::string> nonconforming_region_names_{};
86 : std::vector<std::vector<std::pair<size_t, Direction<Dim>>>>
87 0 : nonconforming_regions_{};
88 : };
89 : } // namespace evolution::dg::subcell
|