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 <memory> 9 : #include <vector> 10 : 11 : #include "Domain/BoundaryConditions/BoundaryCondition.hpp" 12 : #include "Domain/BoundaryConditions/GetBoundaryConditionsBase.hpp" 13 : #include "Domain/Creators/DomainCreator.hpp" // IWYU pragma: keep 14 : #include "Domain/Domain.hpp" 15 : #include "Domain/Structure/DirectionMap.hpp" 16 : #include "Options/Context.hpp" 17 : #include "Options/String.hpp" 18 : #include "Utilities/TMPL.hpp" 19 : 20 : /// \cond 21 : namespace domain { 22 : namespace CoordinateMaps { 23 : class Affine; 24 : class Equiangular; 25 : template <typename Map1, typename Map2> 26 : class ProductOf2Maps; 27 : template <size_t Dim> 28 : class Wedge; 29 : } // namespace CoordinateMaps 30 : 31 : template <typename SourceFrame, typename TargetFrame, typename... Maps> 32 : class CoordinateMap; 33 : } // namespace domain 34 : /// \endcond 35 : 36 : namespace domain { 37 : namespace creators { 38 : /// Create a 2D Domain in the shape of a disk from a square surrounded by four 39 : /// wedges. 40 1 : class Disk : public DomainCreator<2> { 41 : public: 42 0 : using maps_list = 43 : tmpl::list<domain::CoordinateMap< 44 : Frame::BlockLogical, Frame::Inertial, 45 : CoordinateMaps::ProductOf2Maps<CoordinateMaps::Affine, 46 : CoordinateMaps::Affine>>, 47 : domain::CoordinateMap<Frame::BlockLogical, Frame::Inertial, 48 : CoordinateMaps::ProductOf2Maps< 49 : CoordinateMaps::Equiangular, 50 : CoordinateMaps::Equiangular>>, 51 : domain::CoordinateMap<Frame::BlockLogical, Frame::Inertial, 52 : CoordinateMaps::Wedge<2>>>; 53 : 54 0 : struct InnerRadius { 55 0 : using type = double; 56 0 : static constexpr Options::String help = { 57 : "Radius of the circle circumscribing the inner square."}; 58 : }; 59 : 60 0 : struct OuterRadius { 61 0 : using type = double; 62 0 : static constexpr Options::String help = {"Radius of the Disk."}; 63 : }; 64 : 65 0 : struct InitialRefinement { 66 0 : using type = size_t; 67 0 : static constexpr Options::String help = { 68 : "Initial refinement level in each dimension."}; 69 : }; 70 : 71 0 : struct InitialGridPoints { 72 0 : using type = std::array<size_t, 2>; 73 0 : static constexpr Options::String help = { 74 : "Initial number of grid points in [r,theta]."}; 75 : }; 76 : 77 0 : struct UseEquiangularMap { 78 0 : using type = bool; 79 0 : static constexpr Options::String help = { 80 : "Use equiangular instead of equidistant coordinates."}; 81 : }; 82 : 83 : template <typename BoundaryConditionsBase> 84 0 : struct BoundaryCondition { 85 0 : static std::string name() { return "BoundaryCondition"; } 86 0 : static constexpr Options::String help = 87 : "The boundary condition to impose on all sides."; 88 0 : using type = std::unique_ptr<BoundaryConditionsBase>; 89 : }; 90 : 91 0 : using basic_options = tmpl::list<InnerRadius, OuterRadius, InitialRefinement, 92 : InitialGridPoints, UseEquiangularMap>; 93 : 94 : template <typename Metavariables> 95 0 : using options = tmpl::conditional_t< 96 : domain::BoundaryConditions::has_boundary_conditions_base_v< 97 : typename Metavariables::system>, 98 : tmpl::push_back< 99 : basic_options, 100 : BoundaryCondition< 101 : domain::BoundaryConditions::get_boundary_conditions_base< 102 : typename Metavariables::system>>>, 103 : basic_options>; 104 : 105 0 : static constexpr Options::String help{ 106 : "Creates a 2D Disk with five Blocks.\n" 107 : "Only one refinement level for both dimensions is currently supported.\n" 108 : "The number of gridpoints in each dimension can be set independently.\n" 109 : "The number of gridpoints along the dimensions of the square is equal\n" 110 : "to the number of gridpoints along the angular dimension of the wedges.\n" 111 : "Equiangular coordinates give better gridpoint spacings in the angular\n" 112 : "direction, while equidistant coordinates give better gridpoint\n" 113 : "spacings in the center block."}; 114 : 115 0 : Disk(typename InnerRadius::type inner_radius, 116 : typename OuterRadius::type outer_radius, 117 : typename InitialRefinement::type initial_refinement, 118 : typename InitialGridPoints::type initial_number_of_grid_points, 119 : typename UseEquiangularMap::type use_equiangular_map, 120 : std::unique_ptr<domain::BoundaryConditions::BoundaryCondition> 121 : boundary_condition = nullptr, 122 : const Options::Context& context = {}); 123 : 124 0 : Disk() = default; 125 0 : Disk(const Disk&) = delete; 126 0 : Disk(Disk&&) = default; 127 0 : Disk& operator=(const Disk&) = delete; 128 0 : Disk& operator=(Disk&&) = default; 129 0 : ~Disk() override = default; 130 : 131 0 : Domain<2> create_domain() const override; 132 : 133 : std::vector<DirectionMap< 134 : 2, std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>>> 135 1 : external_boundary_conditions() const override; 136 : 137 1 : std::vector<std::array<size_t, 2>> initial_extents() const override; 138 : 139 1 : std::vector<std::array<size_t, 2>> initial_refinement_levels() const override; 140 : 141 : private: 142 0 : typename InnerRadius::type inner_radius_{}; 143 0 : typename OuterRadius::type outer_radius_{}; 144 0 : typename InitialRefinement::type initial_refinement_{}; 145 0 : typename InitialGridPoints::type initial_number_of_grid_points_{}; 146 0 : typename UseEquiangularMap::type use_equiangular_map_{false}; 147 : std::unique_ptr<domain::BoundaryConditions::BoundaryCondition> 148 0 : boundary_condition_; 149 : }; 150 : } // namespace creators 151 : } // namespace domain