Disk.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <array>
7 #include <cstddef>
8 #include <vector>
9 
10 #include "Domain/Domain.hpp"
11 #include "Options/Options.hpp"
12 #include "Utilities/TMPL.hpp"
13 
14 /// \cond
15 template <size_t Dim, typename Frame>
16 class DomainCreator; // IWYU pragma: keep
17 /// \endcond
18 
19 namespace domain {
20 namespace creators {
21 
22 /// \ingroup DomainCreatorsGroup
23 /// Create a 2D Domain in the shape of a disk from a square surrounded by four
24 /// wedges.
25 template <typename TargetFrame>
26 class Disk : public DomainCreator<2, TargetFrame> {
27  public:
28  struct InnerRadius {
29  using type = double;
30  static constexpr OptionString help = {
31  "Radius of the circle circumscribing the inner square."};
32  };
33 
34  struct OuterRadius {
35  using type = double;
36  static constexpr OptionString help = {"Radius of the Disk."};
37  };
38 
40  using type = size_t;
41  static constexpr OptionString help = {
42  "Initial refinement level in each dimension."};
43  };
44 
47  static constexpr OptionString help = {
48  "Initial number of grid points in [r,theta]."};
49  };
50 
52  using type = bool;
53  static constexpr OptionString help = {
54  "Use equiangular instead of equidistant coordinates."};
55  };
56 
57  using options = tmpl::list<InnerRadius, OuterRadius, InitialRefinement,
59 
60  static constexpr OptionString help{
61  "Creates a 2D Disk with five Blocks.\n"
62  "Only one refinement level for both dimensions is currently supported.\n"
63  "The number of gridpoints in each dimension can be set independently.\n"
64  "The number of gridpoints along the dimensions of the square is equal\n"
65  "to the number of gridpoints along the angular dimension of the wedges.\n"
66  "Equiangular coordinates give better gridpoint spacings in the angular\n"
67  "direction, while equidistant coordinates give better gridpoint\n"
68  "spacings in the center block."};
69 
70  Disk(typename InnerRadius::type inner_radius,
71  typename OuterRadius::type outer_radius,
72  typename InitialRefinement::type initial_refinement,
73  typename InitialGridPoints::type initial_number_of_grid_points,
74  typename UseEquiangularMap::type use_equiangular_map) noexcept;
75 
76  Disk() = default;
77  Disk(const Disk&) = delete;
78  Disk(Disk&&) noexcept = default;
79  Disk& operator=(const Disk&) = delete;
80  Disk& operator=(Disk&&) noexcept = default;
81  ~Disk() noexcept override = default;
82 
83  Domain<2, TargetFrame> create_domain() const noexcept override;
84 
85  std::vector<std::array<size_t, 2>> initial_extents() const noexcept override;
86 
88  noexcept override;
89 
90  private:
91  typename InnerRadius::type inner_radius_{};
92  typename OuterRadius::type outer_radius_{};
93  typename InitialRefinement::type initial_refinement_{};
94  typename InitialGridPoints::type initial_number_of_grid_points_{};
95  typename UseEquiangularMap::type use_equiangular_map_{false};
96 };
97 } // namespace creators
98 } // namespace domain
Definition: BlockId.hpp:16
Defines classes and functions for making classes creatable from input files.
Base class for creating Domains from an option string.
Definition: DomainCreator.hpp:87
std::vector< std::array< size_t, 2 > > initial_extents() const noexcept override
Obtain the initial grid extents of the block with the given index.
Definition: Disk.cpp:105
Create a 2D Domain in the shape of a disk from a square surrounded by four wedges.
Definition: Disk.hpp:26
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:26
std::vector< std::array< size_t, 2 > > initial_refinement_levels() const noexcept override
Obtain the initial refinement levels of the blocks.
Definition: Disk.cpp:117
Defines class template Domain.
A wrapper around a vector of Blocks that represent the computational domain.
Definition: Domain.hpp:36
Wraps the template metaprogramming library used (brigand)