Line data Source code
1 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 <array>
10 : #include <cstddef>
11 : #include <iosfwd>
12 : #include <unordered_set>
13 :
14 : #include "Domain/Structure/Direction.hpp"
15 : #include "Domain/Structure/DirectionMap.hpp"
16 : #include "Domain/Structure/ElementId.hpp"
17 : #include "Domain/Structure/FaceType.hpp"
18 : #include "Domain/Structure/Neighbors.hpp"
19 : #include "Domain/Structure/Topology.hpp"
20 : #include "Utilities/MakeArray.hpp"
21 :
22 : /// \cond
23 : namespace PUP {
24 : class er;
25 : } // namespace PUP
26 : /// \endcond
27 :
28 : /// \ingroup ComputationalDomainGroup
29 : /// A spectral element with knowledge of its neighbors.
30 : ///
31 : /// \tparam VolumeDim the volume dimension.
32 : template <size_t VolumeDim>
33 1 : class Element {
34 : public:
35 0 : using Neighbors_t = DirectionMap<VolumeDim, Neighbors<VolumeDim>>;
36 :
37 : /// Constructor
38 : ///
39 : /// \param id a unique identifier for the Element.
40 : /// \param neighbors info about the Elements that share an interface
41 : /// with this Element.
42 : /// \param topologies domain::Topology in each dimension
43 1 : Element(ElementId<VolumeDim> id, Neighbors_t neighbors,
44 : std::array<domain::Topology, VolumeDim> topologies);
45 :
46 : /// Default needed for serialization
47 1 : Element() = default;
48 :
49 0 : ~Element() = default;
50 0 : Element(const Element<VolumeDim>& /*rhs*/) = default;
51 0 : Element(Element<VolumeDim>&& /*rhs*/) = default;
52 0 : Element<VolumeDim>& operator=(const Element<VolumeDim>& /*rhs*/) = default;
53 0 : Element<VolumeDim>& operator=(Element<VolumeDim>&& /*rhs*/) = default;
54 :
55 : /// The directions of the faces of the Element that are external boundaries.
56 1 : const std::unordered_set<Direction<VolumeDim>>& external_boundaries() const {
57 : return external_boundaries_;
58 : }
59 :
60 : /// The directions of the faces of the Element that are internal boundaries.
61 1 : const std::unordered_set<Direction<VolumeDim>>& internal_boundaries() const {
62 : return internal_boundaries_;
63 : }
64 :
65 : /// A unique ID for the Element.
66 1 : const ElementId<VolumeDim>& id() const { return id_; }
67 :
68 : /// Information about the neighboring Elements.
69 1 : const Neighbors_t& neighbors() const { return neighbors_; }
70 :
71 : /// The number of neighbors this element has
72 1 : size_t number_of_neighbors() const { return number_of_neighbors_; }
73 :
74 : /// The topology in each dimensio of this Element
75 1 : const std::array<domain::Topology, VolumeDim>& topologies() const {
76 : return topologies_;
77 : }
78 :
79 : /// The FaceType in each direction
80 1 : const DirectionMap<VolumeDim, domain::FaceType>& face_types() const {
81 : return face_types_;
82 : }
83 :
84 : // NOLINTNEXTLINE(google-runtime-references)
85 0 : void pup(PUP::er& p);
86 :
87 : private:
88 0 : ElementId<VolumeDim> id_{};
89 0 : Neighbors_t neighbors_{};
90 0 : size_t number_of_neighbors_{};
91 0 : std::unordered_set<Direction<VolumeDim>> external_boundaries_{};
92 0 : std::unordered_set<Direction<VolumeDim>> internal_boundaries_{};
93 0 : std::array<domain::Topology, VolumeDim> topologies_;
94 0 : DirectionMap<VolumeDim, domain::FaceType> face_types_{};
95 : };
96 :
97 : template <size_t VolumeDim>
98 0 : std::ostream& operator<<(std::ostream& os, const Element<VolumeDim>& element);
99 :
100 : template <size_t VolumeDim>
101 0 : bool operator==(const Element<VolumeDim>& lhs, const Element<VolumeDim>& rhs);
102 :
103 : template <size_t VolumeDim>
104 0 : bool operator!=(const Element<VolumeDim>& lhs, const Element<VolumeDim>& rhs);
|