Dune Core Modules (2.6.0)

entitykey.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_DGFEnTITYKEY_HH
4#define DUNE_DGFEnTITYKEY_HH
5
6#include <iostream>
7#include <vector>
8
9#include <dune/grid/io/file/dgfparser/dgfexception.hh>
10
11namespace Dune
12{
13
14 // DGFEntityKey
15 // ------------
16
17 template< class A >
18 struct DGFEntityKey
19 {
20 DGFEntityKey ( const std :: vector< A > &key, bool setOrigKey = true );
21 DGFEntityKey ( const std::vector< A > &key,
22 int N, int offset, bool setOrigKey = true );
23 DGFEntityKey ( const DGFEntityKey< A > &k );
24
25 DGFEntityKey< A > &operator= ( const DGFEntityKey< A > &k );
26
27 inline const A &operator[] ( int i ) const;
28 inline bool operator < ( const DGFEntityKey< A > &k ) const;
29
30 void orientation ( int base, std :: vector< std :: vector< double > > &vtx );
31 void print( std :: ostream &out = std :: cerr ) const;
32
33 inline bool origKeySet () const;
34 inline const A &origKey ( int i ) const;
35 inline int size () const;
36
37 private:
38 std :: vector< A > key_, origKey_;
39 bool origKeySet_;
40 };
41
42
43 template< class A >
44 inline const A &DGFEntityKey< A > :: operator[] ( int i ) const
45 {
46 return key_[ i ];
47 }
48
49
50 template< class A >
51 inline bool DGFEntityKey< A > :: operator< ( const DGFEntityKey< A > &k ) const
52 {
53 // assert(k.key_.size()==key_.size());
54 return key_ < k.key_;
55 }
56
57
58 template< class A >
59 inline bool DGFEntityKey< A > :: origKeySet () const
60 {
61 return origKeySet_;
62 }
63
64
65 template< class A >
66 inline const A &DGFEntityKey< A > :: origKey ( int i ) const
67 {
68 return origKey_[ i ];
69 }
70
71
72 template< class A >
73 inline int DGFEntityKey< A > :: size () const
74 {
75 return key_.size();
76 }
77
78
79
80 // ElementFaceUtil
81 // ---------------
82
83 struct ElementFaceUtil
84 {
85 inline static int nofFaces ( int dim, const std::vector< unsigned int > &element );
86 inline static int faceSize ( int dim, bool simpl );
87
88 static DGFEntityKey< unsigned int >
89 generateFace ( int dim, const std::vector< unsigned int > &element, int f );
90
91 private:
92 template< int dim >
93 static DGFEntityKey< unsigned int >
94 generateCubeFace( const std::vector< unsigned int > &element, int f );
95
96 template< int dim >
97 static DGFEntityKey< unsigned int >
98 generateSimplexFace ( const std::vector< unsigned int > &element, int f );
99 };
100
101
102 inline int ElementFaceUtil::nofFaces ( int dim, const std::vector< unsigned int > &element )
103 {
104 switch( dim )
105 {
106 case 1 :
107 return 2;
108 case 2 :
109 switch( element.size() )
110 {
111 case 3 :
112 return 3;
113 case 4 :
114 return 4;
115 default :
116 return -1;
117 }
118 case 3 :
119 switch( element.size() )
120 {
121 case 4 :
122 return 4;
123 case 8 :
124 return 6;
125 default :
126 return -1;
127 }
128 default :
129 return -1;
130 }
131 }
132
133
134 inline int ElementFaceUtil::faceSize( int dim, bool simpl )
135 {
136 switch( dim )
137 {
138 case 1 :
139 return 1;
140 case 2 :
141 return 2;
142 case 3 :
143 return (simpl ? 3 : 4);
144 default :
145 return -1;
146 }
147 }
148
149} //end namespace Dune
150
151// inlcude inline implementation
152#include "entitykey_inline.hh"
153#endif
EnableIfInterOperable< T1, T2, bool >::type operator<(const RandomAccessIteratorFacade< T1, V1, R1, D > &lhs, const RandomAccessIteratorFacade< T2, V2, R2, D > &rhs)
Comparison operator.
Definition: iteratorfacades.hh:629
Dune namespace.
Definition: alignedallocator.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)