Sphere.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 // IWYU wants to include things we definitely don't need...
15 // IWYU pragma: no_include <pup.h> // Not needed
16 // IWYU pragma: no_include <memory> // Needed in cpp file
17 // IWYU pragma: no_include "DataStructures/Tensor/Tensor.hpp" // Not needed
18 
19 /// \cond
20 template <size_t Dim, typename Frame>
21 class DomainCreator; // IWYU pragma: keep
22 /// \endcond
23 
24 namespace domain {
25 namespace creators {
26 
27 /// \ingroup DomainCreatorsGroup
28 /// Create a 3D Domain in the shape of a sphere consisting of six wedges
29 /// and a central cube. For an image showing how the wedges are aligned in
30 /// this Domain, see the documentation for Shell.
31 template <typename TargetFrame>
32 class Sphere : public DomainCreator<3, TargetFrame> {
33  public:
34  struct InnerRadius {
35  using type = double;
36  static constexpr OptionString help = {
37  "Radius of the sphere circumscribing the inner cube."};
38  };
39 
40  struct OuterRadius {
41  using type = double;
42  static constexpr OptionString help = {"Radius of the Sphere."};
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  };
62  using options = tmpl::list<InnerRadius, OuterRadius, InitialRefinement,
64 
65  static constexpr OptionString help{
66  "Creates a 3D Sphere with seven Blocks.\n"
67  "Only one refinement level for all dimensions is currently supported.\n"
68  "The number of gridpoints in the radial direction can be set\n"
69  "independently of the number of gridpoints in the angular directions.\n"
70  "The number of gridpoints along the dimensions of the cube is equal\n"
71  "to the number of gridpoints along the angular dimensions of the "
72  "wedges.\n"
73  "Equiangular coordinates give better gridpoint spacings in the angular\n"
74  "directions, while equidistant coordinates give better gridpoint\n"
75  "spacings in the center block."};
76 
77  Sphere(typename InnerRadius::type inner_radius,
78  typename OuterRadius::type outer_radius,
79  typename InitialRefinement::type initial_refinement,
80  typename InitialGridPoints::type initial_number_of_grid_points,
81  typename UseEquiangularMap::type use_equiangular_map) noexcept;
82 
83  Sphere() = default;
84  Sphere(const Sphere&) = delete;
85  Sphere(Sphere&&) noexcept = default;
86  Sphere& operator=(const Sphere&) = delete;
87  Sphere& operator=(Sphere&&) noexcept = default;
88  ~Sphere() noexcept override = default;
89 
90  Domain<3, TargetFrame> create_domain() const noexcept override;
91 
92  std::vector<std::array<size_t, 3>> initial_extents() const noexcept override;
93 
95  noexcept override;
96 
97  private:
98  typename InnerRadius::type inner_radius_{};
99  typename OuterRadius::type outer_radius_{};
100  typename InitialRefinement::type initial_refinement_{};
101  typename InitialGridPoints::type initial_number_of_grid_points_{};
102  typename UseEquiangularMap::type use_equiangular_map_ = false;
103 };
104 } // namespace creators
105 } // namespace domain
Definition: BlockId.hpp:16
Definition: Sphere.hpp:34
Defines classes and functions for making classes creatable from input files.
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: Sphere.cpp:84
Base class for creating Domains from an option string.
Definition: DomainCreator.hpp:87
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:26
Defines class template Domain.
Definition: Sphere.hpp:40
A wrapper around a vector of Blocks that represent the computational domain.
Definition: Domain.hpp:36
Wraps the template metaprogramming library used (brigand)
std::vector< std::array< size_t, 3 > > initial_refinement_levels() const noexcept override
Obtain the initial refinement levels of the blocks.
Definition: Sphere.cpp:97
Create a 3D Domain in the shape of a sphere consisting of six wedges and a central cube...
Definition: Sphere.hpp:32