Cylinder.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 3D Domain in the shape of a cylinder where the cross-section
24 /// is a square surrounded by four two-dimensional wedges (see Wedge2D).
25 ///
26 /// \image html Cylinder.png "The Cylinder Domain."
27 template <typename TargetFrame>
28 class Cylinder : public DomainCreator<3, TargetFrame> {
29  public:
30  struct InnerRadius {
31  using type = double;
32  static constexpr OptionString help = {
33  "Radius of the circle circumscribing the inner square."};
34  };
35 
36  struct OuterRadius {
37  using type = double;
38  static constexpr OptionString help = {"Radius of the cylinder."};
39  };
40 
41  struct LowerBound {
42  using type = double;
43  static constexpr OptionString help = {
44  "z-coordinate of the base of the cylinder."};
45  };
46 
47  struct UpperBound {
48  using type = double;
49  static constexpr OptionString help = {
50  "z-coordinate of the top of the cylinder."};
51  };
52 
53  struct IsPeriodicInZ {
54  using type = bool;
55  static constexpr OptionString help = {
56  "True if periodic in the cylindrical z direction."};
57  static type default_value() noexcept { return true; }
58  };
59 
61  using type = size_t;
62  static constexpr OptionString help = {
63  "Initial refinement level in each dimension."};
64  };
65 
68  static constexpr OptionString help = {
69  "Initial number of grid points in [r, theta, z]."};
70  };
71 
73  using type = bool;
74  static constexpr OptionString help = {
75  "Use equiangular instead of equidistant coordinates."};
76  static type default_value() noexcept { return false; }
77  };
78 
79  using options = tmpl::list<InnerRadius, OuterRadius, LowerBound, UpperBound,
82 
83  static constexpr OptionString help{
84  "Creates a 3D Cylinder with five Blocks.\n"
85  "Only one refinement level for all dimensions is currently supported.\n"
86  "The number of gridpoints in each dimension can be set independently.\n"
87  "The number of gridpoints along the dimensions of the square is equal\n"
88  "to the number of gridpoints along the angular dimension of the wedges.\n"
89  "Equiangular coordinates give better gridpoint spacings in the angular\n"
90  "direction, while equidistant coordinates give better gridpoint\n"
91  "spacings in the center block. This Domain uses equidistant coordinates\n"
92  "by default. The boundary conditions are set to be periodic along the\n"
93  "cylindrical z-axis by default."};
94 
95  Cylinder(typename InnerRadius::type inner_radius,
96  typename OuterRadius::type outer_radius,
97  typename LowerBound::type lower_bound,
98  typename UpperBound::type upper_bound,
99  typename IsPeriodicInZ::type is_periodic_in_z,
100  typename InitialRefinement::type initial_refinement,
101  typename InitialGridPoints::type initial_number_of_grid_points,
102  typename UseEquiangularMap::type use_equiangular_map) noexcept;
103 
104  Cylinder() = default;
105  Cylinder(const Cylinder&) = delete;
106  Cylinder(Cylinder&&) noexcept = default;
107  Cylinder& operator=(const Cylinder&) = delete;
108  Cylinder& operator=(Cylinder&&) noexcept = default;
109  ~Cylinder() noexcept override = default;
110 
111  Domain<3, TargetFrame> create_domain() const noexcept override;
112 
113  std::vector<std::array<size_t, 3>> initial_extents() const noexcept override;
114 
116  noexcept override;
117 
118  private:
119  typename InnerRadius::type inner_radius_{};
120  typename OuterRadius::type outer_radius_{};
121  typename LowerBound::type lower_bound_{};
122  typename UpperBound::type upper_bound_{};
123  typename IsPeriodicInZ::type is_periodic_in_z_{true};
124  typename InitialRefinement::type initial_refinement_{};
125  typename InitialGridPoints::type initial_number_of_grid_points_{};
126  typename UseEquiangularMap::type use_equiangular_map_{false};
127 };
128 } // namespace creators
129 } // namespace domain
Definition: BlockId.hpp:16
Definition: Cylinder.hpp:30
std::vector< std::array< size_t, 3 > > initial_extents() const noexcept override
Obtain the initial grid extents of the block with the given index.
Definition: Cylinder.cpp:125
Definition: Cylinder.hpp:41
Defines classes and functions for making classes creatable from input files.
Base class for creating Domains from an option string.
Definition: DomainCreator.hpp:89
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:27
Defines class template Domain.
std::vector< std::array< size_t, 3 > > initial_refinement_levels() const noexcept override
Obtain the initial refinement levels of the blocks.
Definition: Cylinder.cpp:138
A wrapper around a vector of Blocks that represent the computational domain.
Definition: Domain.hpp:38
Create a 3D Domain in the shape of a cylinder where the cross-section is a square surrounded by four ...
Definition: Cylinder.hpp:28
Wraps the template metaprogramming library used (brigand)
Definition: Cylinder.hpp:36
Definition: Cylinder.hpp:47