SpECTRE Documentation Coverage Report
Current view: top level - Evolution/DiscontinuousGalerkin/EqualRateLts - EqualRateRegions.hpp Hit Total Coverage
Commit: c3e43f8d41800b0ecefb9d1393f1de1d5a280c8f Lines: 10 33 30.3 %
Date: 2026-07-24 22:09:25
Legend: Lines: hit not hit

          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 <iosfwd>
       8             : #include <map>
       9             : #include <string>
      10             : #include <tuple>
      11             : #include <unordered_map>
      12             : 
      13             : #include "Utilities/TMPL.hpp"
      14             : 
      15             : /// \cond
      16             : template <size_t VolumeDim>
      17             : class ElementId;
      18             : namespace PUP {
      19             : class er;
      20             : }  // namespace PUP
      21             : /// \endcond
      22             : 
      23             : namespace evolution::dg {
      24             : /// Unique identifier for an equal-rate region.
      25             : ///
      26             : /// \see EqualRateRegions
      27           1 : struct EqualRateRegionId {
      28           0 :   size_t type;
      29           0 :   size_t label;
      30             : 
      31           0 :   EqualRateRegionId() = default;
      32           0 :   EqualRateRegionId(const size_t type_in, const size_t label_in)
      33             :       : type(type_in), label(label_in) {}
      34             : 
      35           0 :   void pup(PUP::er& p);
      36             : 
      37           0 :   friend auto operator<=>(const EqualRateRegionId&,
      38             :                           const EqualRateRegionId&) = default;
      39           0 :   friend bool operator==(const EqualRateRegionId&,
      40             :                          const EqualRateRegionId&) = default;
      41           0 :   friend bool operator<(const EqualRateRegionId&,
      42             :                         const EqualRateRegionId&) = default;
      43             : };
      44             : 
      45           0 : std::ostream& operator<<(std::ostream& os, const EqualRateRegionId& id);
      46             : 
      47             : namespace EqualRateRegions_detail {
      48             : template <typename T>
      49             : struct creation_tags {
      50             :   using type = typename T::creation_tags;
      51             : };
      52             : }  // namespace EqualRateRegions_detail
      53             : 
      54             : /// Regions of the domain that cannot perform local time-stepping.
      55             : ///
      56             : /// The \p RegionGenerators template argument must be a `tmpl::list`
      57             : /// of classes satisfying the `equal_rate_region_generator<Dim>`
      58             : /// concept.
      59             : template <
      60             :     size_t Dim, typename RegionGenerators,
      61             :     typename CreationTags = tmpl::join<tmpl::transform<
      62             :         RegionGenerators, EqualRateRegions_detail::creation_tags<tmpl::_1>>>>
      63           1 : class EqualRateRegions;
      64             : 
      65             : /// \copydoc EqualRateRegions
      66             : template <size_t Dim>
      67           1 : class EqualRateRegionsBase {
      68             :  protected:
      69           0 :   EqualRateRegionsBase() = default;
      70           0 :   EqualRateRegionsBase(const EqualRateRegionsBase&) = default;
      71           0 :   EqualRateRegionsBase(EqualRateRegionsBase&&) = default;
      72           0 :   EqualRateRegionsBase& operator=(const EqualRateRegionsBase&) = default;
      73           0 :   EqualRateRegionsBase& operator=(EqualRateRegionsBase&&) = default;
      74           0 :   ~EqualRateRegionsBase() = default;
      75             : 
      76             :  public:
      77             :   /// Map from all region names to ids.  Inverse of `region_names()`.
      78           1 :   virtual const std::unordered_map<std::string, EqualRateRegionId>& regions()
      79             :       const = 0;
      80             : 
      81             :   /// Map from all region ids to names.  Inverse of `regions()`.
      82           1 :   virtual const std::map<EqualRateRegionId, std::string>& region_names()
      83             :       const = 0;
      84             : 
      85             :   /// Check whether a particular element is in a given region.
      86           1 :   virtual bool is_in_region(const EqualRateRegionId& region,
      87             :                             const ElementId<Dim>& element) const = 0;
      88             : };
      89             : 
      90             : /// \copydoc EqualRateRegions
      91             : template <size_t Dim, typename... RegionGenerators, typename... CreationTags>
      92           1 : class EqualRateRegions<Dim, tmpl::list<RegionGenerators...>,
      93             :                        tmpl::list<CreationTags...>>
      94             :     final : public EqualRateRegionsBase<Dim> {
      95             :  public:
      96           0 :   explicit EqualRateRegions()
      97             :     requires(sizeof...(CreationTags) > 0)
      98             :   = default;
      99             : 
     100           0 :   using creation_tags = tmpl::list<CreationTags...>;
     101             : 
     102           0 :   explicit EqualRateRegions(const typename CreationTags::type&... args);
     103             : 
     104           1 :   const std::unordered_map<std::string, EqualRateRegionId>& regions()
     105             :       const override;
     106             : 
     107           1 :   const std::map<EqualRateRegionId, std::string>& region_names() const override;
     108             : 
     109           1 :   bool is_in_region(const EqualRateRegionId& region,
     110             :                     const ElementId<Dim>& element) const override;
     111             : 
     112           0 :   void pup(PUP::er& p);
     113             : 
     114             :  private:
     115           0 :   std::tuple<RegionGenerators...> generators_{};
     116           0 :   std::unordered_map<std::string, EqualRateRegionId> regions_{};
     117           0 :   std::map<EqualRateRegionId, std::string> region_names_{};
     118             : };
     119             : }  // namespace evolution::dg

Generated by: LCOV version 1.14