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. 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 0 : using options = tmpl::list<RefinementLevel, NumGridPoints>; 53 : 54 0 : static constexpr Options::String help = { 55 : "Limits on refinement level and resolution for adaptive mesh " 56 : "refinement."}; 57 : 58 0 : Limits(); 59 : 60 0 : Limits(const std::optional<std::array<size_t, 2>>& refinement_level_bounds, 61 : const std::optional<std::array<size_t, 2>>& resolution_bounds, 62 : const Options::Context& context = {}); 63 : 64 0 : Limits(size_t minimum_refinement_level, size_t maximum_refinement_level, 65 : size_t minimum_resolution, size_t maximum_resolution); 66 : 67 0 : size_t minimum_refinement_level() const { return minimum_refinement_level_; } 68 0 : size_t maximum_refinement_level() const { return maximum_refinement_level_; } 69 0 : size_t minimum_resolution() const { return minimum_resolution_; } 70 0 : size_t maximum_resolution() const { return maximum_resolution_; } 71 : 72 0 : void pup(PUP::er& p); 73 : 74 : private: 75 0 : size_t minimum_refinement_level_{0}; 76 0 : size_t maximum_refinement_level_{16}; 77 0 : size_t minimum_resolution_{1}; 78 0 : size_t maximum_resolution_{20}; 79 : }; 80 : 81 0 : bool operator==(const Limits& lhs, const Limits& rhs); 82 : 83 0 : bool operator!=(const Limits& lhs, const Limits& rhs); 84 : } // namespace amr