Element.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 Element.
6 
7 #pragma once
8 
9 #include <cstddef>
10 #include <iosfwd>
11 #include <unordered_set>
12 
13 #include "Domain/Direction.hpp" // IWYU pragma: keep
14 #include "Domain/DirectionMap.hpp"
15 #include "Domain/ElementId.hpp"
16 #include "Domain/Neighbors.hpp" // IWYU pragma: keep
17 
18 /// \cond
19 namespace PUP {
20 class er;
21 } // namespace PUP
22 /// \endcond
23 
24 /// \ingroup ComputationalDomainGroup
25 /// A spectral element with knowledge of its neighbors.
26 ///
27 /// \tparam VolumeDim the volume dimension.
28 template <size_t VolumeDim>
29 class Element {
30  public:
32 
33  /// Constructor
34  ///
35  /// \param id a unique identifier for the Element.
36  /// \param neighbors info about the Elements that share an interface
37  /// with this Element.
38  Element(ElementId<VolumeDim> id, Neighbors_t neighbors) noexcept;
39 
40  /// Default needed for serialization
41  Element() = default;
42 
43  ~Element() = default;
44  Element(const Element<VolumeDim>& /*rhs*/) = default;
45  Element(Element<VolumeDim>&& /*rhs*/) noexcept = default;
46  Element<VolumeDim>& operator=(const Element<VolumeDim>& /*rhs*/) = default;
47  Element<VolumeDim>& operator=(Element<VolumeDim>&& /*rhs*/) noexcept =
48  default;
49 
50  /// The directions of the faces of the Element that are external boundaries.
52  noexcept {
53  return external_boundaries_;
54  }
55 
56  /// A unique ID for the Element.
57  const ElementId<VolumeDim>& id() const noexcept { return id_; }
58 
59  /// Information about the neighboring Elements.
60  const Neighbors_t& neighbors() const noexcept { return neighbors_; }
61 
62  /// The number of neighbors this element has
63  size_t number_of_neighbors() const noexcept { return number_of_neighbors_; }
64 
65  // clang-tidy: google-runtime-references
66  void pup(PUP::er& p) noexcept; // NOLINT
67 
68  private:
70  Neighbors_t neighbors_{};
71  size_t number_of_neighbors_{};
72  std::unordered_set<Direction<VolumeDim>> external_boundaries_{};
73 };
74 
75 template <size_t VolumeDim>
76 std::ostream& operator<<(std::ostream& os,
77  const Element<VolumeDim>& element) noexcept;
78 
79 template <size_t VolumeDim>
80 bool operator==(const Element<VolumeDim>& lhs,
81  const Element<VolumeDim>& rhs) noexcept;
82 
83 template <size_t VolumeDim>
84 bool operator!=(const Element<VolumeDim>& lhs,
85  const Element<VolumeDim>& rhs) noexcept;
const ElementId< VolumeDim > & id() const noexcept
A unique ID for the Element.
Definition: Element.hpp:57
Defines class template Direction.
Definition: Strahlkorper.hpp:14
const std::unordered_set< Direction< VolumeDim > > & external_boundaries() const noexcept
The directions of the faces of the Element that are external boundaries.
Definition: Element.hpp:51
An ElementId uniquely labels an Element. It is constructed from the BlockId of the Block to which the...
Definition: ElementId.hpp:36
Defines class ElementId.
Defines class template Neighbors.
const Neighbors_t & neighbors() const noexcept
Information about the neighboring Elements.
Definition: Element.hpp:60
A spectral element with knowledge of its neighbors.
Definition: Element.hpp:29
size_t number_of_neighbors() const noexcept
The number of neighbors this element has.
Definition: Element.hpp:63