SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/Amr/Policies - Limits.hpp Hit Total Coverage
Commit: bfafc0de0035281135f593d1e5ba9395bc8cb41b Lines: 4 29 13.8 %
Date: 2025-06-18 15:00:46
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 <array>
       7             : #include <cstddef>
       8             : #include <optional>
       9             : 
      10             : #include "Options/Auto.hpp"
      11             : #include "Options/Context.hpp"
      12             : #include "Options/String.hpp"
      13             : #include "Utilities/TMPL.hpp"
      14             : 
      15             : /// \cond
      16             : namespace PUP {
      17             : class er;
      18             : }  // namespace PUP
      19             : /// \endcond
      20             : 
      21             : namespace amr {
      22             : /// \brief The limits on refinement level and resolution for AMR
      23             : ///
      24             : /// \details
      25             : /// - For a default constructed Limits, the refinement level is
      26             : ///   bounded between 0 and ElementId<Dim>::max_refinement_level, and the
      27             : ///   resolution is bounded between 1 and
      28             : ///   Spectral::maximum_number_of_points<Spectral::Basis::Legendre>
      29             : ///   which are limits based on the implementation details of ElementId and
      30             : ///   Mesh. There is no error for attempting to go beyond the limits.
      31             : /// - If you specify the limits on the refinement levels and resolutions, they
      32             : ///   must respect the above limits.
      33             : /// - Depending upon which Spectral::Basis is chosen, the actual minimum
      34             : ///   resolution may be higher (usually 2), but this is automatically enforced
      35             : ///   by EnforcePolicies.
      36           1 : class Limits {
      37             :  public:
      38             :   /// Inclusive bounds on the refinement level
      39           1 :   struct RefinementLevel {
      40           0 :     using type = Options::Auto<std::array<size_t, 2>>;
      41           0 :     static constexpr Options::String help = {
      42             :         "Inclusive bounds on the refinement level for AMR."};
      43             :   };
      44             : 
      45             :   /// Inclusive bounds on the number of grid points per dimension
      46           1 :   struct NumGridPoints {
      47           0 :     using type = Options::Auto<std::array<size_t, 2>>;
      48           0 :     static constexpr Options::String help = {
      49             :         "Inclusive bounds on the number of grid points per dimension for AMR."};
      50             :   };
      51             : 
      52             :   /// \brief Whether the code should error if EnforcePolicies has to prevent
      53             :   /// refinement from going beyond the given limits.
      54             :   ///
      55             :   /// \details The Limits class is just a holder for this value, the actual
      56             :   /// error happens in `amr::Actions::EvaluateRefinementCriteria` or
      57             :   /// `amr::Events::RefineMesh`
      58           1 :   struct ErrorBeyondLimits {
      59           0 :     using type = bool;
      60           0 :     static constexpr Options::String help = {
      61             :         "If adaptive mesh refinement tries to go beyond the RefinementLevel or "
      62             :         "NumGridPoints limit, error"};
      63             :   };
      64             : 
      65           0 :   using options = tmpl::list<RefinementLevel, NumGridPoints, ErrorBeyondLimits>;
      66             : 
      67           0 :   static constexpr Options::String help = {
      68             :       "Limits on refinement level and resolution for adaptive mesh "
      69             :       "refinement."};
      70             : 
      71           0 :   Limits();
      72             : 
      73           0 :   Limits(const std::optional<std::array<size_t, 2>>& refinement_level_bounds,
      74             :          const std::optional<std::array<size_t, 2>>& resolution_bounds,
      75             :          bool error_beyond_limits, const Options::Context& context = {});
      76             : 
      77           0 :   Limits(size_t minimum_refinement_level, size_t maximum_refinement_level,
      78             :          size_t minimum_resolution, size_t maximum_resolution);
      79             : 
      80           0 :   size_t minimum_refinement_level() const { return minimum_refinement_level_; }
      81           0 :   size_t maximum_refinement_level() const { return maximum_refinement_level_; }
      82           0 :   size_t minimum_resolution() const { return minimum_resolution_; }
      83           0 :   size_t maximum_resolution() const { return maximum_resolution_; }
      84           0 :   bool error_beyond_limits() const { return error_beyond_limits_; }
      85             : 
      86           0 :   void pup(PUP::er& p);
      87             : 
      88             :  private:
      89           0 :   size_t minimum_refinement_level_{0};
      90           0 :   size_t maximum_refinement_level_{16};
      91           0 :   size_t minimum_resolution_{1};
      92           0 :   size_t maximum_resolution_{20};
      93           0 :   bool error_beyond_limits_{false};
      94             : };
      95             : 
      96           0 : bool operator==(const Limits& lhs, const Limits& rhs);
      97             : 
      98           0 : bool operator!=(const Limits& lhs, const Limits& rhs);
      99             : }  // namespace amr

Generated by: LCOV version 1.14