Rectangle.hpp
Go to the documentation of this file.
2 // See LICENSE.txt for details.
3
4 /// \file
5 /// Defines class Rectangle.
6
7 #pragma once
8
9 #include <array>
10 #include <cstddef>
11 #include <vector>
12
13 #include "Domain/Domain.hpp"
14 #include "Options/Options.hpp"
15 #include "Utilities/MakeArray.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 2D Domain consisting of a single Block.
28 template <typename TargetFrame>
29 class Rectangle : public DomainCreator<2, TargetFrame> {
30  public:
31  struct LowerBound {
33  static constexpr OptionString help = {
34  "Sequence of [x,y] for lower bounds."};
35  };
36
37  struct UpperBound {
39  static constexpr OptionString help = {
40  "Sequence of [x,y] for upper bounds."};
41  };
42  struct IsPeriodicIn {
43  using type = std::array<bool, 2>;
44  static constexpr OptionString help = {
45  "Sequence for [x,y], true if periodic."};
46  static type default_value() noexcept { return make_array<2>(false); }
47  };
48
51  static constexpr OptionString help = {"Initial refinement level in [x,y]."};
52  };
53
56  static constexpr OptionString help = {
57  "Initial number of grid points in [x,y]."};
58  };
59  using options = tmpl::list<LowerBound, UpperBound, IsPeriodicIn,
61
62  static constexpr OptionString help{"Creates a 2D rectangle."};
63
64  Rectangle(
65  typename LowerBound::type lower_xy, typename UpperBound::type upper_xy,
66  typename IsPeriodicIn::type is_periodic_in_xy,
67  typename InitialRefinement::type initial_refinement_level_xy,
68  typename InitialGridPoints::type initial_number_of_grid_points_in_xy,
69  const OptionContext& context = {}) noexcept;
70
71  Rectangle() = default;
72  Rectangle(const Rectangle&) = delete;
73  Rectangle(Rectangle&&) noexcept = default;
74  Rectangle& operator=(const Rectangle&) = delete;
75  Rectangle& operator=(Rectangle&&) noexcept = default;
76  ~Rectangle() noexcept override = default;
77
78  Domain<2, TargetFrame> create_domain() const noexcept override;
79
80  std::vector<std::array<size_t, 2>> initial_extents() const noexcept override;
81
83  noexcept override;
84
85  private:
86  typename LowerBound::type lower_xy_{};
87  typename UpperBound::type upper_xy_{};
88  typename IsPeriodicIn::type is_periodic_in_xy_{};
89  typename InitialRefinement::type initial_refinement_level_xy_{};
90  typename InitialGridPoints::type initial_number_of_grid_points_in_xy_{};
91 };
92 } // namespace creators
93 } // namespace domain
Definition: Rectangle.hpp:37
Definition: BlockId.hpp:16
Defines function make_array.
Defines classes and functions for making classes creatable from input files.
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, 2 > > initial_extents() const noexcept override
Obtain the initial grid extents of the block with the given index.
Definition: Rectangle.cpp:65
std::vector< std::array< size_t, 2 > > initial_refinement_levels() const noexcept override
Obtain the initial refinement levels of the blocks.
Definition: Rectangle.cpp:72
A wrapper around a vector of Blocks that represent the computational domain.
Definition: Domain.hpp:36
Information about the nested operations being performed by the parser, for use in printing errors...
Definition: Options.hpp:35
Wraps the template metaprogramming library used (brigand)
Definition: Rectangle.hpp:42
Definition: Rectangle.hpp:31
Create a 2D Domain consisting of a single Block.
Definition: Rectangle.hpp:29