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 <string> 9 : #include <unordered_map> 10 : #include <utility> 11 : #include <vector> 12 : 13 : #include "Domain/Creators/OptionTags.hpp" 14 : #include "Domain/Structure/Direction.hpp" 15 : #include "Evolution/DgSubcell/Tags/SubcellOptions.hpp" 16 : #include "Utilities/TMPL.hpp" 17 : 18 : /// \cond 19 : template <size_t VolumeDim> 20 : class DomainCreator; 21 : template <size_t VolumeDim> 22 : class ElementId; 23 : namespace PUP { 24 : class er; 25 : } // namespace PUP 26 : namespace evolution::dg::subcell { 27 : class SubcellOptions; 28 : } // namespace evolution::dg::subcell 29 : /// \endcond 30 : 31 : namespace evolution::dg::subcell { 32 : /// Combined equal-rate region generator for subcell evolution with 33 : /// nonconforming block boundaries. 34 : /// 35 : /// When using local time stepping (LTS) with both subcell evolution and 36 : /// nonconforming block boundaries, the two separate region generators 37 : /// `NonconformingEqualRateRegions` and `SubcellEqualRateRegion` 38 : /// cannot be combined without conflicts in their regions. This class merges 39 : /// the two generators into one, treating subcell-adjacent nonconforming 40 : /// interfaces as part of the "Subcell" region rather than as separate 41 : /// "NonconformingN" regions. 42 : /// 43 : /// **Subcell region (region 0)**: Contains all subcell-capable elements (those 44 : /// not in `OnlyDgBlocksAndGroups`) **plus** the elements of DG-only 45 : /// blocks that lie directly on a nonconforming face bordering a subcell-capable 46 : /// block. 47 : /// 48 : /// **NonconformingN[+/-] regions (regions 1…N)**: Created only for 49 : /// nonconforming interfaces where every block on both sides is DG-only (no 50 : /// subcell capability on either side). These behave identically to the 51 : /// regions produced by `NonconformingEqualRateRegions`. 52 : /// 53 : /// \note If your domain has no nonconforming block boundaries, use 54 : /// `SubcellEqualRateRegion` instead: it is simpler and has no overhead. 55 : template <size_t Dim> 56 1 : class SubcellAndNonconformingEqualRateRegions { 57 : public: 58 0 : SubcellAndNonconformingEqualRateRegions() = default; 59 : 60 0 : using creation_tags = tmpl::list<OptionTags::SubcellOptions, 61 : domain::OptionTags::DomainCreator<Dim>>; 62 : 63 0 : SubcellAndNonconformingEqualRateRegions( 64 : const SubcellOptions& subcell_options, 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