Shell.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 "Domain/DomainHelpers.hpp"
12 #include "Options/Options.hpp"
13 #include "Utilities/TMPL.hpp"
14 
15 /// \cond
16 template <size_t, class>
17 class DomainCreator; // IWYU pragma: keep
18 /// \endcond
19 
20 namespace domain {
21 namespace creators {
22 
23 /*!
24  * \ingroup DomainCreatorsGroup
25  *
26  * \brief Creates a 3D Domain in the shape of a hollow spherical shell
27  * consisting of six wedges.
28  *
29  * \image html WedgeOrientations.png "The orientation of each wedge in Shell."
30  */
31 
32 template <typename TargetFrame>
33 class Shell : public DomainCreator<3, TargetFrame> {
34  public:
35  struct InnerRadius {
36  using type = double;
37  static constexpr OptionString help = {"Inner radius of the Shell."};
38  };
39 
40  struct OuterRadius {
41  using type = double;
42  static constexpr OptionString help = {"Outer radius of the Shell."};
43  };
44 
46  using type = size_t;
47  static constexpr OptionString help = {
48  "Initial refinement level in each dimension."};
49  };
50 
53  static constexpr OptionString help = {
54  "Initial number of grid points in [r,angular]."};
55  };
56 
58  using type = bool;
59  static constexpr OptionString help = {
60  "Use equiangular instead of equidistant coordinates."};
61  static constexpr type default_value() noexcept { return true; }
62  };
63 
64  struct AspectRatio {
65  using type = double;
66  static constexpr OptionString help = {"The equatorial compression factor."};
67  static constexpr type default_value() noexcept { return 1.0; }
68  };
69 
71  using type = bool;
72  static constexpr OptionString help = {
73  "Use a logarithmically spaced radial grid."};
74  static constexpr type default_value() noexcept { return false; }
75  };
76 
77  struct WhichWedges {
78  using type = ShellWedges;
79  static constexpr OptionString help = {
80  "Which wedges to include in the shell."};
81  static constexpr type default_value() noexcept { return ShellWedges::All; }
82  };
83 
85  using type = size_t;
86  static constexpr OptionString help = {
87  "The number of concentric layers of Blocks to have."};
88  static constexpr type default_value() noexcept { return 1; }
89  static type lower_bound() { return 1; }
90  };
91 
92  using options = tmpl::list<InnerRadius, OuterRadius, InitialRefinement,
95 
96  static constexpr OptionString help{
97  "Creates a 3D spherical shell with 6 Blocks. `UseEquiangularMap` has\n"
98  "a default value of `true` because there is no central Block in this\n"
99  "domain. Equidistant coordinates are best suited to Blocks with\n"
100  "Cartesian grids. However, the option is allowed for testing "
101  "purposes. The `aspect_ratio` moves grid points on the shell towards\n"
102  "the equator for values greater than 1.0, and towards the poles for\n"
103  "positive values less than 1.0. If `UseLogarithmicMap` is set to true,\n"
104  "the radial gridpoints will be spaced uniformly in \f$log(r)\f$. The\n"
105  "user may also choose to use only a single wedge (along the -x\n"
106  "direction), or four wedges along the x-y plane using the `WhichWedges`\n"
107  "option. Using the RadialBlockLayers option, a user may increase the\n"
108  "number of Blocks in the radial direction."};
109 
110  Shell(typename InnerRadius::type inner_radius,
111  typename OuterRadius::type outer_radius,
112  typename InitialRefinement::type initial_refinement,
113  typename InitialGridPoints::type initial_number_of_grid_points,
114  typename UseEquiangularMap::type use_equiangular_map,
115  typename AspectRatio::type aspect_ratio = 1.0,
116  typename UseLogarithmicMap::type use_logarithmic_map = false,
117  typename WhichWedges::type which_wedges = ShellWedges::All,
118  typename RadialBlockLayers::type number_of_layers = 1) noexcept;
119 
120  Shell() = default;
121  Shell(const Shell&) = delete;
122  Shell(Shell&&) noexcept = default;
123  Shell& operator=(const Shell&) = delete;
124  Shell& operator=(Shell&&) noexcept = default;
125  ~Shell() noexcept override = default;
126 
127  Domain<3, TargetFrame> create_domain() const noexcept override;
128 
129  std::vector<std::array<size_t, 3>> initial_extents() const noexcept override;
130 
132  noexcept override;
133 
134  private:
135  typename InnerRadius::type inner_radius_{};
136  typename OuterRadius::type outer_radius_{};
137  typename InitialRefinement::type initial_refinement_{};
138  typename InitialGridPoints::type initial_number_of_grid_points_{};
139  typename UseEquiangularMap::type use_equiangular_map_ = true;
140  typename AspectRatio::type aspect_ratio_ = 1.0;
141  typename UseLogarithmicMap::type use_logarithmic_map_ = false;
142  typename WhichWedges::type which_wedges_ = ShellWedges::All;
143  typename RadialBlockLayers::type number_of_layers_ = 1;
144 };
145 } // namespace creators
146 } // namespace domain
Use the entire shell.
Defines DomainHelper functions.
Definition: BlockId.hpp:16
ShellWedges
The number of wedges to include in the Shell domain.
Definition: DomainHelpers.hpp:93
Defines classes and functions for making classes creatable from input files.
Definition: Shell.hpp:35
Base class for creating Domains from an option string.
Definition: DomainCreator.hpp:89
std::vector< std::array< size_t, 3 > > initial_refinement_levels() const noexcept override
Obtain the initial refinement levels of the blocks.
Definition: Shell.cpp:84
Creates a 3D Domain in the shape of a hollow spherical shell consisting of six wedges.
Definition: Shell.hpp:33
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:27
Defines class template Domain.
Definition: Shell.hpp:77
A wrapper around a vector of Blocks that represent the computational domain.
Definition: Domain.hpp:38
Definition: Shell.hpp:64
Wraps the template metaprogramming library used (brigand)
Definition: Shell.hpp:40
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: Shell.cpp:68