dune-grid 2.9.0
entitykey.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_DGFEnTITYKEY_HH
6#define DUNE_DGFEnTITYKEY_HH
7
8#include <iostream>
9#include <vector>
10
12
13namespace Dune
14{
15
16 // DGFEntityKey
17 // ------------
18
19 template< class A >
21 {
22 DGFEntityKey ( const std :: vector< A > &key, bool setOrigKey = true );
23 DGFEntityKey ( const std::vector< A > &key,
24 int N, int offset, bool setOrigKey = true );
26
28
29 inline const A &operator[] ( int i ) const;
30 inline bool operator < ( const DGFEntityKey< A > &k ) const;
31
32 void orientation ( int base, std :: vector< std :: vector< double > > &vtx );
33 void print( std :: ostream &out = std :: cerr ) const;
34
35 inline bool origKeySet () const;
36 inline const A &origKey ( int i ) const;
37 inline int size () const;
38
39 private:
40 std :: vector< A > key_, origKey_;
41 bool origKeySet_;
42 };
43
44
45 template< class A >
46 inline const A &DGFEntityKey< A > :: operator[] ( int i ) const
47 {
48 return key_[ i ];
49 }
50
51
52 template< class A >
54 {
55 // assert(k.key_.size()==key_.size());
56 return key_ < k.key_;
57 }
58
59
60 template< class A >
62 {
63 return origKeySet_;
64 }
65
66
67 template< class A >
68 inline const A &DGFEntityKey< A > :: origKey ( int i ) const
69 {
70 return origKey_[ i ];
71 }
72
73
74 template< class A >
75 inline int DGFEntityKey< A > :: size () const
76 {
77 return key_.size();
78 }
79
80
81
82 // ElementFaceUtil
83 // ---------------
84
86 {
87 inline static int nofFaces ( int dim, const std::vector< unsigned int > &element );
88 inline static int faceSize ( int dim, bool simpl );
89
91 generateFace ( int dim, const std::vector< unsigned int > &element, int f );
92
93 private:
94 template< int dim >
96 generateCubeFace( const std::vector< unsigned int > &element, int f );
97
98 template< int dim >
100 generateSimplexFace ( const std::vector< unsigned int > &element, int f );
101 };
102
103
104 inline int ElementFaceUtil::nofFaces ( int dim, const std::vector< unsigned int > &element )
105 {
106 switch( dim )
107 {
108 case 1 :
109 return 2;
110 case 2 :
111 switch( element.size() )
112 {
113 case 3 :
114 return 3;
115 case 4 :
116 return 4;
117 default :
118 return -1;
119 }
120 case 3 :
121 switch( element.size() )
122 {
123 case 4 :
124 return 4;
125 case 8 :
126 return 6;
127 default :
128 return -1;
129 }
130 default :
131 return -1;
132 }
133 }
134
135
136 inline int ElementFaceUtil::faceSize( int dim, bool simpl )
137 {
138 switch( dim )
139 {
140 case 1 :
141 return 1;
142 case 2 :
143 return 2;
144 case 3 :
145 return (simpl ? 3 : 4);
146 default :
147 return -1;
148 }
149 }
150
151} //end namespace Dune
152
153// inlcude inline implementation
154#include "entitykey_inline.hh"
155#endif
Include standard header files.
Definition: agrid.hh:60
Definition: entitykey.hh:21
bool operator<(const DGFEntityKey< A > &k) const
Definition: entitykey.hh:53
DGFEntityKey< A > & operator=(const DGFEntityKey< A > &k)
Definition: entitykey_inline.hh:64
bool origKeySet() const
Definition: entitykey.hh:61
int size() const
Definition: entitykey.hh:75
void orientation(int base, std ::vector< std ::vector< double > > &vtx)
Definition: entitykey_inline.hh:78
const A & origKey(int i) const
Definition: entitykey.hh:68
DGFEntityKey(const std::vector< A > &key, int N, int offset, bool setOrigKey=true)
void print(std ::ostream &out=std ::cerr) const
Definition: entitykey_inline.hh:105
DGFEntityKey(const std ::vector< A > &key, bool setOrigKey=true)
Definition: entitykey_inline.hh:19
const A & operator[](int i) const
Definition: entitykey.hh:46
Definition: entitykey.hh:86
static DGFEntityKey< unsigned int > generateFace(int dim, const std::vector< unsigned int > &element, int f)
Definition: entitykey_inline.hh:145
static int faceSize(int dim, bool simpl)
Definition: entitykey.hh:136
static int nofFaces(int dim, const std::vector< unsigned int > &element)
Definition: entitykey.hh:104