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 <cstddef> 10 : #include <iosfwd> 11 : #include <unordered_set> 12 : 13 : #include "Domain/Structure/Direction.hpp" // IWYU pragma: keep 14 : #include "Domain/Structure/DirectionMap.hpp" 15 : #include "Domain/Structure/ElementId.hpp" 16 : #include "Domain/Structure/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 1 : class Element { 30 : public: 31 0 : using Neighbors_t = DirectionMap<VolumeDim, Neighbors<VolumeDim>>; 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 1 : Element(ElementId<VolumeDim> id, Neighbors_t neighbors); 39 : 40 : /// Default needed for serialization 41 1 : Element() = default; 42 : 43 0 : ~Element() = default; 44 0 : Element(const Element<VolumeDim>& /*rhs*/) = default; 45 0 : Element(Element<VolumeDim>&& /*rhs*/) = default; 46 0 : Element<VolumeDim>& operator=(const Element<VolumeDim>& /*rhs*/) = default; 47 0 : Element<VolumeDim>& operator=(Element<VolumeDim>&& /*rhs*/) = default; 48 : 49 : /// The directions of the faces of the Element that are external boundaries. 50 1 : const std::unordered_set<Direction<VolumeDim>>& external_boundaries() const { 51 : return external_boundaries_; 52 : } 53 : 54 : /// The directions of the faces of the Element that are internal boundaries. 55 1 : const std::unordered_set<Direction<VolumeDim>>& internal_boundaries() const { 56 : return internal_boundaries_; 57 : } 58 : 59 : /// A unique ID for the Element. 60 1 : const ElementId<VolumeDim>& id() const { return id_; } 61 : 62 : /// Information about the neighboring Elements. 63 1 : const Neighbors_t& neighbors() const { return neighbors_; } 64 : 65 : /// The number of neighbors this element has 66 1 : size_t number_of_neighbors() const { return number_of_neighbors_; } 67 : 68 : // NOLINTNEXTLINE(google-runtime-references) 69 0 : void pup(PUP::er& p); 70 : 71 : private: 72 0 : ElementId<VolumeDim> id_{}; 73 0 : Neighbors_t neighbors_{}; 74 0 : size_t number_of_neighbors_{}; 75 0 : std::unordered_set<Direction<VolumeDim>> external_boundaries_{}; 76 0 : std::unordered_set<Direction<VolumeDim>> internal_boundaries_{}; 77 : }; 78 : 79 : template <size_t VolumeDim> 80 0 : std::ostream& operator<<(std::ostream& os, const Element<VolumeDim>& element); 81 : 82 : template <size_t VolumeDim> 83 0 : bool operator==(const Element<VolumeDim>& lhs, const Element<VolumeDim>& rhs); 84 : 85 : template <size_t VolumeDim> 86 0 : bool operator!=(const Element<VolumeDim>& lhs, const Element<VolumeDim>& rhs);