Interval.hpp
Go to the documentation of this file.
2 // See LICENSE.txt for details.
3
4 /// \file
5 /// Defines class Interval.
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 1D Domain consisting of a single Block.
28 template <typename TargetFrame>
29 class Interval : public DomainCreator<1, TargetFrame> {
30  public:
31  struct LowerBound {
33  static constexpr OptionString help = {"Sequence of [x] for lower bounds."};
34  };
35  struct UpperBound {
37  static constexpr OptionString help = {"Sequence of [x] for upper bounds."};
38  };
39  struct IsPeriodicIn {
40  using type = std::array<bool, 1>;
41  static constexpr OptionString help = {
42  "Sequence for [x], true if periodic."};
43  static type default_value() noexcept { return make_array<1>(false); }
44  };
47  static constexpr OptionString help = {"Initial refinement level in [x]."};
48  };
51  static constexpr OptionString help = {
52  "Initial number of grid points in [x]."};
53  };
54
55  using options = tmpl::list<LowerBound, UpperBound, IsPeriodicIn,
57
58  static constexpr OptionString help = {"Creates a 1D interval."};
59
60  Interval(typename LowerBound::type lower_x, typename UpperBound::type upper_x,
61  typename IsPeriodicIn::type is_periodic_in_x,
62  typename InitialRefinement::type initial_refinement_level_x,
64  initial_number_of_grid_points_in_x) noexcept;
65
66  Interval() = default;
67  Interval(const Interval&) = delete;
68  Interval(Interval&&) noexcept = default;
69  Interval& operator=(const Interval&) = delete;
70  Interval& operator=(Interval&&) noexcept = default;
71  ~Interval() override = default;
72
73  Domain<1, TargetFrame> create_domain() const noexcept override;
74
75  std::vector<std::array<size_t, 1>> initial_extents() const noexcept override;
76
78  noexcept override;
79
80  private:
81  typename LowerBound::type lower_x_{};
82  typename UpperBound::type upper_x_{};
83  typename IsPeriodicIn::type is_periodic_in_x_{};
84  typename InitialRefinement::type initial_refinement_level_x_{};
85  typename InitialGridPoints::type initial_number_of_grid_points_in_x_{};
86 };
87 } // namespace creators
88 } // namespace domain
std::vector< std::array< size_t, 1 > > initial_refinement_levels() const noexcept override
Obtain the initial refinement levels of the blocks.
Definition: Interval.cpp:62
Definition: BlockId.hpp:16
Defines function make_array.
Definition: Interval.hpp:35
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.
Definition: Interval.hpp:39
Create a 1D Domain consisting of a single Block.
Definition: Interval.hpp:29
A wrapper around a vector of Blocks that represent the computational domain.
Definition: Domain.hpp:36
Wraps the template metaprogramming library used (brigand)
Definition: Interval.hpp:31
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: Interval.cpp:55