DUNE PDELab (git)

localkey.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5#ifndef DUNE_LOCALKEY_HH
6#define DUNE_LOCALKEY_HH
7
8#include <array>
9#include <cstddef>
10#include <ostream>
11
12namespace Dune
13{
24 {
25 public:
26
28 enum {
38 };
39
41 constexpr LocalKey () noexcept
42 : values_{}
43 {}
44
50 constexpr LocalKey (unsigned int s, unsigned int c, unsigned int i) noexcept
51 : values_{s,c,i}
52 {}
53
55 [[nodiscard]]
56 constexpr unsigned int subEntity () const noexcept
57 {
58 return values_[0];
59 }
60
62 [[nodiscard]]
63 constexpr unsigned int codim () const noexcept
64 {
65 return values_[1];
66 }
67
69 [[nodiscard]]
70 constexpr unsigned int index () const noexcept
71 {
72 return values_[2];
73 }
74
76 constexpr void index (unsigned int i) noexcept
77 {
78 values_[2] = i;
79 }
80
82 [[nodiscard]]
83 bool operator< (const LocalKey& other) const noexcept
84 {
85 return values_ < other.values_;
86 }
87
89 friend std::ostream& operator<< (std::ostream& s, const LocalKey& localKey)
90 {
91 return s << "[ subEntity: " << localKey.subEntity()
92 << ", codim: " << localKey.codim()
93 << ", index: " << localKey.index() << " ]";
94 }
95
96 private:
97
98 // We use an array to store the values in order to be able to use the array::operator< implementation
99 std::array<unsigned int,3> values_;
100
101 };
102
103}
104#endif
Describe position of one degree of freedom.
Definition: localkey.hh:24
bool operator<(const LocalKey &other) const noexcept
Less-than operator so we can use this class as a key type in stl containers.
Definition: localkey.hh:83
constexpr void index(unsigned int i) noexcept
Set index component.
Definition: localkey.hh:76
constexpr unsigned int index() const noexcept
Return offset within subentity.
Definition: localkey.hh:70
constexpr LocalKey(unsigned int s, unsigned int c, unsigned int i) noexcept
Initialize all components.
Definition: localkey.hh:50
constexpr unsigned int codim() const noexcept
Return codim of associated entity.
Definition: localkey.hh:63
@ intersectionCodim
Codimension returned by LocalKey::codim() for degrees of freedom attached to an intersection.
Definition: localkey.hh:37
friend std::ostream & operator<<(std::ostream &s, const LocalKey &localKey)
Write LocalKey object to output stream.
Definition: localkey.hh:89
constexpr LocalKey() noexcept
Standard constructor for uninitialized local index.
Definition: localkey.hh:41
constexpr unsigned int subEntity() const noexcept
Return number of associated subentity.
Definition: localkey.hh:56
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)