Dune Core Modules (2.10.0)

entitykey.hh
1// SPDX-FileCopyrightText: Copyright © 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
11#include <dune/grid/io/file/dgfparser/dgfexception.hh>
12
13namespace Dune
14{
15
16 // DGFEntityKey
17 // ------------
18
19 template< class A >
20 struct DGFEntityKey
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 );
25 DGFEntityKey ( const DGFEntityKey< A > &k );
26
27 DGFEntityKey< A > &operator= ( const DGFEntityKey< A > &k );
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 >
53 inline bool DGFEntityKey< A > :: operator< ( const DGFEntityKey< A > &k ) const
54 {
55 // assert(k.key_.size()==key_.size());
56 return key_ < k.key_;
57 }
58
59
60 template< class A >
61 inline bool DGFEntityKey< A > :: origKeySet () const
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
85 struct ElementFaceUtil
86 {
87 inline static int nofFaces ( int dim, const std::vector< unsigned int > &element );
88 inline static int faceSize ( int dim, bool simpl );
89
90 static DGFEntityKey< unsigned int >
91 generateFace ( int dim, const std::vector< unsigned int > &element, int f );
92
93 private:
94 template< int dim >
95 static DGFEntityKey< unsigned int >
96 generateCubeFace( const std::vector< unsigned int > &element, int f );
97
98 template< int dim >
99 static DGFEntityKey< unsigned int >
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// include inline implementation
154#include "entitykey_inline.hh"
155#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:638
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 28, 23:30, 2024)