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 (default value is 43 : /// domain::Topology::I1) 44 1 : Element(ElementId<VolumeDim> id, Neighbors_t neighbors, 45 : std::array<domain::Topology, VolumeDim> topologies = 46 : make_array<VolumeDim>(domain::Topology::I1)); 47 : 48 : /// Default needed for serialization 49 1 : Element() = default; 50 : 51 0 : ~Element() = default; 52 0 : Element(const Element<VolumeDim>& /*rhs*/) = default; 53 0 : Element(Element<VolumeDim>&& /*rhs*/) = default; 54 0 : Element<VolumeDim>& operator=(const Element<VolumeDim>& /*rhs*/) = default; 55 0 : Element<VolumeDim>& operator=(Element<VolumeDim>&& /*rhs*/) = default; 56 : 57 : /// The directions of the faces of the Element that are external boundaries. 58 1 : const std::unordered_set<Direction<VolumeDim>>& external_boundaries() const { 59 : return external_boundaries_; 60 : } 61 : 62 : /// The directions of the faces of the Element that are internal boundaries. 63 1 : const std::unordered_set<Direction<VolumeDim>>& internal_boundaries() const { 64 : return internal_boundaries_; 65 : } 66 : 67 : /// A unique ID for the Element. 68 1 : const ElementId<VolumeDim>& id() const { return id_; } 69 : 70 : /// Information about the neighboring Elements. 71 1 : const Neighbors_t& neighbors() const { return neighbors_; } 72 : 73 : /// The number of neighbors this element has 74 1 : size_t number_of_neighbors() const { return number_of_neighbors_; } 75 : 76 : /// The topology in each dimensio of this Element 77 1 : const std::array<domain::Topology, VolumeDim>& topologies() const { 78 : return topologies_; 79 : } 80 : 81 : /// The FaceType in each direction 82 1 : const DirectionMap<VolumeDim, domain::FaceType>& face_types() const { 83 : return face_types_; 84 : } 85 : 86 : // NOLINTNEXTLINE(google-runtime-references) 87 0 : void pup(PUP::er& p); 88 : 89 : private: 90 0 : ElementId<VolumeDim> id_{}; 91 0 : Neighbors_t neighbors_{}; 92 0 : size_t number_of_neighbors_{}; 93 0 : std::unordered_set<Direction<VolumeDim>> external_boundaries_{}; 94 0 : std::unordered_set<Direction<VolumeDim>> internal_boundaries_{}; 95 0 : std::array<domain::Topology, VolumeDim> topologies_; 96 0 : DirectionMap<VolumeDim, domain::FaceType> face_types_{}; 97 : }; 98 : 99 : template <size_t VolumeDim> 100 0 : std::ostream& operator<<(std::ostream& os, const Element<VolumeDim>& element); 101 : 102 : template <size_t VolumeDim> 103 0 : bool operator==(const Element<VolumeDim>& lhs, const Element<VolumeDim>& rhs); 104 : 105 : template <size_t VolumeDim> 106 0 : bool operator!=(const Element<VolumeDim>& lhs, const Element<VolumeDim>& rhs);