Dune Core Modules (2.9.0)

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 (C) 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{
23 {
24 public:
25
27 enum {
37 };
38
41 {}
42
48 LocalKey (unsigned int s, unsigned int c, unsigned int i)
49 {
50 values_[0] = s;
51 values_[1] = c;
52 values_[2] = i;
53 }
54
56 inline unsigned int subEntity () const
57 {
58 return values_[0];
59 }
60
62 inline unsigned int codim () const
63 {
64 return values_[1];
65 }
66
68 inline unsigned int index () const
69 {
70 return values_[2];
71 }
72
74 void index (unsigned int i)
75 {
76 values_[2] = i;
77 }
78
80 bool operator< (const LocalKey& other) const
81 {
82 return values_ < other.values_;
83 }
84
86 friend std::ostream& operator<< (std::ostream& s, const LocalKey& localKey)
87 {
88 return s << "[ subEntity: " << localKey.subEntity()
89 << ", codim: " << localKey.codim()
90 << ", index: " << localKey.index() << " ]";
91 }
92
93 private:
94
95 // We use an array to store the values in order to be able to use the array::operator< implementation
96 std::array<unsigned int,3> values_;
97
98 };
99
100}
101#endif
Describe position of one degree of freedom.
Definition: localkey.hh:23
LocalKey()
Standard constructor for uninitialized local index.
Definition: localkey.hh:40
unsigned int index() const
Return offset within subentity.
Definition: localkey.hh:68
unsigned int codim() const
Return codim of associated entity.
Definition: localkey.hh:62
unsigned int subEntity() const
Return number of associated subentity.
Definition: localkey.hh:56
LocalKey(unsigned int s, unsigned int c, unsigned int i)
Initialize all components.
Definition: localkey.hh:48
bool operator<(const LocalKey &other) const
Less-than operator so we can use this class as a key type in stl containers.
Definition: localkey.hh:80
void index(unsigned int i)
Set index component.
Definition: localkey.hh:74
friend std::ostream & operator<<(std::ostream &s, const LocalKey &localKey)
Write LocalKey object to output stream.
Definition: localkey.hh:86
@ intersectionCodim
Codimension returned by LocalKey::codim() for degrees of freedom attached to an intersection.
Definition: localkey.hh:36
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)