Block.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 template Block.
6
7 #pragma once
8
9 #include <cstddef>
10 #include <memory>
11 #include <ostream>
12 #include <unordered_set>
13
14 #include "Domain/BlockNeighbor.hpp" // IWYU pragma: keep
15 #include "Domain/CoordinateMaps/CoordinateMap.hpp" // IWYU pragma: keep
16 #include "Domain/Direction.hpp" // IWYU pragma: keep
17 #include "Domain/DirectionMap.hpp"
18
19 /// \cond
20 namespace Frame {
21 struct Logical;
22 } // namespace Frame
23 namespace PUP {
24 class er;
25 } // namespace PUP
26 /// \endcond
27
28 /// \ingroup ComputationalDomainGroup
29 /// A Block<VolumeDim> is a region of a VolumeDim-dimensional computational
30 /// domain that defines the root node of a tree which is used to construct the
31 /// Elements that cover a region of the computational domain.
32 ///
33 /// Each codimension 1 boundary of a Block<VolumeDim> is either an external
34 /// boundary or identical to a boundary of one other Block.
35 ///
36 /// A Block has logical coordinates that go from -1 to +1 in each
37 /// dimension. The global coordinates are obtained from the logical
38 /// coordinates from the Coordinatemap: CoordinateMap::operator() takes
39 /// Points in the Logical Frame (i.e., logical coordinates) and
40 /// returns Points in the Grid Frame (i.e., global coordinates).
41 template <size_t VolumeDim, typename TargetFrame>
42 class Block {
43  public:
44  /// \param map the CoordinateMap.
45  /// \param id a unique ID.
46  /// \param neighbors info about the Blocks that share a codimension 1
47  /// boundary with this Block.
50  size_t id,
51  DirectionMap<VolumeDim, BlockNeighbor<VolumeDim>> neighbors) noexcept;
52
53  Block() = default;
54  ~Block() = default;
55  Block(const Block&) = delete;
56  Block(Block&&) = default;
57  Block& operator=(const Block&) = delete;
58  Block& operator=(Block&&) = default;
59
61  coordinate_map() const noexcept {
62  return *map_;
63  }
64
65  /// A unique identifier for the Block that is in the range
66  /// [0, number_of_blocks -1] where number_of_blocks is the number
67  /// of Blocks that cover the computational domain.
68  size_t id() const noexcept { return id_; }
69
70  /// Information about the neighboring Blocks.
72  noexcept {
73  return neighbors_;
74  }
75
76  /// The directions of the faces of the Block that are external boundaries.
78  noexcept {
79  return external_boundaries_;
80  }
81
82  /// Serialization for Charm++
83  void pup(PUP::er& p) noexcept; // NOLINT
84
85  private:
87  map_;
88  size_t id_{0};
90  std::unordered_set<Direction<VolumeDim>> external_boundaries_;
91 };
92
93 template <size_t VolumeDim, typename TargetFrame>
94 std::ostream& operator<<(std::ostream& os,
95  const Block<VolumeDim, TargetFrame>& block) noexcept;
96
97 template <size_t VolumeDim, typename TargetFrame>
98 bool operator==(const Block<VolumeDim, TargetFrame>& lhs,
99  const Block<VolumeDim, TargetFrame>& rhs) noexcept;
100
101 template <size_t VolumeDim, typename TargetFrame>
102 bool operator!=(const Block<VolumeDim, TargetFrame>& lhs,
103  const Block<VolumeDim, TargetFrame>& rhs) noexcept;
Defines class template Direction.
Definition: Strahlkorper.hpp:14
Defines class template BlockNeighbor.
An optimized map with Direction keys.
Definition: DirectionMap.hpp:15
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:49
const std::unordered_set< Direction< VolumeDim > > & external_boundaries() const noexcept
The directions of the faces of the Block that are external boundaries.
Definition: Block.hpp:77
size_t id() const noexcept
A unique identifier for the Block that is in the range [0, number_of_blocks -1] where number_of_block...
Definition: Block.hpp:68
Indicates the Frame that a TensorIndexType is in.
Definition: IndexType.hpp:36
Defines class CoordinateMap.
const DirectionMap< VolumeDim, BlockNeighbor< VolumeDim > > & neighbors() const noexcept
Information about the neighboring Blocks.
Definition: Block.hpp:71
Information about the neighbor of a Block in a particular direction.
Definition: BlockNeighbor.hpp:25
A Block<VolumeDim> is a region of a VolumeDim-dimensional computational domain that defines the root ...
Definition: Block.hpp:42