Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <iosfwd>
8 :
9 : #include "Domain/Structure/Direction.hpp"
10 : #include "Domain/Structure/ElementId.hpp"
11 :
12 : /// \cond
13 : namespace PUP {
14 : class er;
15 : } // namespace PUP
16 : /// \endcond
17 :
18 : /// \brief The ElementId of an Element in a given Direction.
19 : ///
20 : /// \details Used as the key in a DirectionalIdMap
21 : template <size_t VolumeDim>
22 1 : struct DirectionalId : private ElementId<VolumeDim> {
23 0 : DirectionalId() = default;
24 :
25 0 : DirectionalId(const Direction<VolumeDim>& direction,
26 : const ElementId<VolumeDim>& element_id)
27 : : ElementId<VolumeDim>(direction, element_id) {}
28 :
29 0 : ElementId<VolumeDim> id() const { return this->without_direction(); }
30 :
31 0 : Direction<VolumeDim> direction() const {
32 : return ElementId<VolumeDim>::direction();
33 : }
34 0 : void pup(PUP::er& p) { p | static_cast<ElementId<VolumeDim>&>(*this); }
35 : };
36 :
37 : template <size_t VolumeDim>
38 0 : size_t hash_value(const DirectionalId<VolumeDim>& id);
39 :
40 : namespace std {
41 : template <size_t VolumeDim>
42 : struct hash<DirectionalId<VolumeDim>> {
43 : size_t operator()(const DirectionalId<VolumeDim>& id) const;
44 : };
45 : } // namespace std
46 :
47 : template <size_t VolumeDim>
48 0 : bool operator==(const DirectionalId<VolumeDim>& lhs,
49 : const DirectionalId<VolumeDim>& rhs);
50 :
51 : template <size_t VolumeDim>
52 0 : bool operator!=(const DirectionalId<VolumeDim>& lhs,
53 : const DirectionalId<VolumeDim>& rhs) {
54 : return not(lhs == rhs);
55 : }
56 :
57 : template <size_t VolumeDim>
58 0 : bool operator<(const DirectionalId<VolumeDim>& lhs,
59 : const DirectionalId<VolumeDim>& rhs);
60 :
61 : /// Output operator for a DirectionalId.
62 : template <size_t VolumeDim>
63 1 : std::ostream& operator<<(std::ostream& os,
64 : const DirectionalId<VolumeDim>& direction);
65 :
66 : template <size_t VolumeDim>
67 0 : DirectionalId(Direction<VolumeDim> direction, ElementId<VolumeDim> id)
68 : -> DirectionalId<VolumeDim>;
|