Brick.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 Brick.
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 3D Domain consisting of a single Block.
28 template <typename TargetFrame>
29 class Brick : public DomainCreator<3, TargetFrame> {
30  public:
31  struct LowerBound {
33  static constexpr OptionString help = {
34  "Sequence of [x,y,z] for lower bounds."};
35  };
36 
37  struct UpperBound {
39  static constexpr OptionString help = {
40  "Sequence of [x,y,z] for upper bounds."};
41  };
42  struct IsPeriodicIn {
43  using type = std::array<bool, 3>;
44  static constexpr OptionString help = {
45  "Sequence for [x,y,z], true if periodic."};
46  static type default_value() noexcept { return make_array<3>(false); }
47  };
48 
51  static constexpr OptionString help = {
52  "Initial refinement level in [x,y,z]."};
53  };
54 
57  static constexpr OptionString help = {
58  "Initial number of grid points in [x,y,z]."};
59  };
60  using options = tmpl::list<LowerBound, UpperBound, IsPeriodicIn,
62 
63  static constexpr OptionString help{"Creates a 3D brick."};
64 
65  Brick(typename LowerBound::type lower_xyz,
66  typename UpperBound::type upper_xyz,
67  typename IsPeriodicIn::type is_periodic_in_xyz,
68  typename InitialRefinement::type initial_refinement_level_xyz,
69  typename InitialGridPoints::type initial_number_of_grid_points_in_xyz,
70  const OptionContext& context = {}) noexcept;
71 
72  Brick() = default;
73  Brick(const Brick&) = delete;
74  Brick(Brick&&) noexcept = default;
75  Brick& operator=(const Brick&) = delete;
76  Brick& operator=(Brick&&) noexcept = default;
77  ~Brick() noexcept override = default;
78 
79  Domain<3, TargetFrame> create_domain() const noexcept override;
80 
81  std::vector<std::array<size_t, 3>> initial_extents() const noexcept override;
82 
84  noexcept override;
85 
86  private:
87  typename LowerBound::type lower_xyz_{};
88  typename UpperBound::type upper_xyz_{};
89  typename IsPeriodicIn::type is_periodic_in_xyz_{};
90  typename InitialRefinement::type initial_refinement_level_xyz_{};
91  typename InitialGridPoints::type initial_number_of_grid_points_in_xyz_{};
92 };
93 } // namespace creators
94 } // namespace domain
Definition: Brick.hpp:31
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
std::vector< std::array< size_t, 3 > > initial_refinement_levels() const noexcept override
Obtain the initial refinement levels of the blocks.
Definition: Brick.cpp:77
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:26
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: Brick.cpp:70
Defines class template Domain.
Definition: Brick.hpp:37
Create a 3D Domain consisting of a single Block.
Definition: Brick.hpp:29
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)