RotatedIntervals.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 /// \file
5 /// Defines class RotatedIntervals.
6 
7 #pragma once
8 
9 #include <array>
10 #include <cstddef>
11 #include <limits>
12 #include <vector>
13 
14 #include "Domain/Domain.hpp"
15 #include "Options/Options.hpp"
16 #include "Utilities/TMPL.hpp"
17 
18 /// \cond
19 template <size_t Dim, typename Frame>
20 class DomainCreator; // IWYU pragma: keep
21 /// \endcond
22 
23 namespace domain {
24 namespace creators {
25 
26 /// \ingroup DomainCreatorsGroup
27 /// Create a 1D Domain consisting of two rotated Blocks.
28 /// The left block has its logical \f$\xi\f$-axis aligned with the grid x-axis.
29 /// The right block has its logical \f$\xi\f$-axis opposite to the grid x-axis.
30 /// This is useful for testing code that deals with unaligned blocks.
31 template <typename TargetFrame>
32 class RotatedIntervals : public DomainCreator<1, TargetFrame> {
33  public:
34  struct LowerBound {
36  static constexpr OptionString help = {
37  "Sequence of [x], the lower bound in the target frame."};
38  };
39 
40  struct Midpoint {
42  static constexpr OptionString help = {
43  "Sequence of [x], the midpoint in the target frame."};
44  };
45 
46  struct UpperBound {
48  static constexpr OptionString help = {
49  "Sequence of [x], the upper bound in the target frame."};
50  };
51 
52  struct IsPeriodicIn {
53  using type = std::array<bool, 1>;
54  static constexpr OptionString help = {
55  "Sequence for [x], true if periodic."};
56  static type default_value() noexcept { return {{false}}; }
57  };
60  static constexpr OptionString help = {"Initial refinement level in [x]."};
61  };
62 
65  static constexpr OptionString help = {
66  "Initial number of grid points in [[x]]."};
67  };
68 
69  using options = tmpl::list<LowerBound, Midpoint, UpperBound, IsPeriodicIn,
71 
72  static constexpr OptionString help = {
73  "A DomainCreator useful for testing purposes.\n"
74  "RotatedIntervals creates the interval [LowerX,UpperX] from two\n"
75  "rotated Blocks. The outermost index to InitialGridPoints is the\n"
76  "dimension index (of which there is only one in the case of\n"
77  "RotatedIntervals), and the innermost index is the block index\n"
78  "along that dimension."};
79 
80  RotatedIntervals(typename LowerBound::type lower_x,
81  typename Midpoint::type midpoint_x,
82  typename UpperBound::type upper_x,
83  typename IsPeriodicIn::type is_periodic_in,
84  typename InitialRefinement::type initial_refinement_level_x,
86  initial_number_of_grid_points_in_x) noexcept;
87 
88  RotatedIntervals() = default;
89  RotatedIntervals(const RotatedIntervals&) = delete;
90  RotatedIntervals(RotatedIntervals&&) noexcept = default;
91  RotatedIntervals& operator=(const RotatedIntervals&) = delete;
92  RotatedIntervals& operator=(RotatedIntervals&&) noexcept = default;
93  ~RotatedIntervals() override = default;
94 
95  Domain<1, TargetFrame> create_domain() const noexcept override;
96 
97  std::vector<std::array<size_t, 1>> initial_extents() const noexcept override;
98 
100  noexcept override;
101 
102  private:
103  typename LowerBound::type lower_x_{
105  typename Midpoint::type midpoint_x_{
107  typename UpperBound::type upper_x_{
109  typename IsPeriodicIn::type is_periodic_in_{{false}};
110  typename InitialRefinement::type initial_refinement_level_x_{
112  typename InitialGridPoints::type initial_number_of_grid_points_in_x_{
114 };
115 } // namespace creators
116 } // namespace domain
Definition: BlockId.hpp:16
T signaling_NaN(T... args)
Defines classes and functions for making classes creatable from input files.
Definition: RotatedIntervals.hpp:46
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.
std::vector< std::array< size_t, 1 > > initial_extents() const noexcept override
Obtain the initial grid extents of the block with the given index.
Definition: RotatedIntervals.cpp:53
T max(T... args)
A wrapper around a vector of Blocks that represent the computational domain.
Definition: Domain.hpp:36
Wraps the template metaprogramming library used (brigand)
Definition: RotatedIntervals.hpp:34
Definition: RotatedIntervals.hpp:52
Create a 1D Domain consisting of two rotated Blocks. The left block has its logical -axis aligned wit...
Definition: RotatedIntervals.hpp:32
Definition: RotatedIntervals.hpp:40
std::vector< std::array< size_t, 1 > > initial_refinement_levels() const noexcept override
Obtain the initial refinement levels of the blocks.
Definition: RotatedIntervals.cpp:60