3#ifndef DUNE_ENTITYKEY_INLINE_HH
4#define DUNE_ENTITYKEY_INLINE_HH
7#include <dune/geometry/referenceelements.hh>
8#include <dune/grid/io/file/dgfparser/entitykey.hh>
17 inline DGFEntityKey< A > :: DGFEntityKey (
const std :: vector< A > &key,
bool setOrigKey )
19 origKey_( key.size() ),
20 origKeySet_( setOrigKey )
22 for (
size_t i=0; i<key_.size(); i++)
27 std :: sort( key_.begin(), key_.end() );
32 inline DGFEntityKey< A > :: DGFEntityKey (
const std :: vector< A > &key,
33 int N,
int offset,
bool setOrigKey )
36 origKeySet_( setOrigKey )
38 for (
size_t i=0; i<key_.size(); i++)
40 key_[i]=key[(i+offset)%key.size()];
41 origKey_[i]=key[(i+offset)%key.size()];
43 std :: sort( key_.begin(), key_.end() );
48 inline DGFEntityKey< A > :: DGFEntityKey (
const DGFEntityKey< A > &k )
49 : key_( k.key_.size() ),
50 origKey_( k.key_.size() ),
51 origKeySet_( k. origKeySet_ )
53 for (
size_t i=0; i<key_.size(); i++)
56 origKey_[i]=k.origKey_[i];
62 inline DGFEntityKey< A > &DGFEntityKey< A > :: operator= (
const DGFEntityKey< A > &k )
64 assert(key_.size()==k.key_.size());
65 for (
size_t i=0; i<key_.size(); i++) {
67 origKey_[i]=k.origKey_[i];
69 origKeySet_ = k.origKeySet_;
75 inline void DGFEntityKey< A >
76 :: orientation (
int base, std::vector< std :: vector< double > > &vtx )
79 assert( (
size_t) origKey_[0] < vtx.size() );
80 std::vector<double>& p0 = vtx[origKey_[0]];
81 assert( (
size_t) origKey_[1] < vtx.size() );
82 std::vector<double>& p1 = vtx[origKey_[1]];
83 assert( (
size_t) origKey_[2] < vtx.size() );
84 std::vector<double>& p2 = vtx[origKey_[2]];
85 assert( (
size_t) base < vtx.size() );
86 std::vector<double>& q = vtx[base];
88 n[0] = (p1[1]-p0[1])*(p2[2]-p0[2])-(p2[1]-p0[1])*(p1[2]-p0[2]);
89 n[1] = (p1[2]-p0[2])*(p2[0]-p0[0])-(p2[2]-p0[2])*(p1[0]-p0[0]);
90 n[2] = (p1[0]-p0[0])*(p2[1]-p0[1])-(p2[0]-p0[0])*(p1[1]-p0[1]);
91 double test = n[0]*(q[0]-p0[0])+n[1]*(q[1]-p0[1])+n[2]*(q[2]-p0[2]);
92 bool reorient = (test>0);
95 origKey_[1]=origKey_[2];
103 inline void DGFEntityKey< A > :: print ( std :: ostream &out )
const
105 for(
size_t i = 0; i < key_.size(); ++i )
106 out << key_[ i ] <<
" ";
115 inline DGFEntityKey< unsigned int >
116 ElementFaceUtil::generateCubeFace
117 (
const std::vector< unsigned int > &element,
int f )
119 const ReferenceElement< double, dim > &refCube
120 = ReferenceElements< double, dim >::cube();
121 const unsigned int size = refCube.size( f, 1, dim );
122 std::vector< unsigned int > k( size );
123 for(
unsigned int i = 0; i < size; ++ i )
124 k[ i ] = element[ refCube.subEntity( f, 1, i, dim ) ];
125 return DGFEntityKey< unsigned int >( k );
130 inline DGFEntityKey< unsigned int >
131 ElementFaceUtil :: generateSimplexFace
132 (
const std :: vector< unsigned int > &element,
int f )
134 const ReferenceElement< double, dim > &refSimplex
135 = ReferenceElements< double, dim >::simplex();
136 const unsigned int size = refSimplex.size( f, 1, dim );
137 std :: vector< unsigned int > k( size );
138 for(
unsigned int i = 0; i < size; ++i )
139 k[ i ] = element[ refSimplex.subEntity( f, 1, i, dim ) ];
140 return DGFEntityKey< unsigned int >( k );
144 inline DGFEntityKey< unsigned int >
145 ElementFaceUtil::generateFace (
int dim,
const std::vector< unsigned int > &element,
int f )
147 if( element.size() ==
size_t(dim+1) )
153 return generateSimplexFace< 3 >( element, f );
155 return generateSimplexFace< 2 >( element, f );
157 return generateSimplexFace< 1 >( element, f );
159 DUNE_THROW( NotImplemented,
"ElementUtil::generateFace not implemented for dim = " << dim <<
"." );
168 return generateCubeFace< 3 >( element, f );
170 return generateCubeFace< 2 >( element, f );
172 return generateCubeFace< 1 >( element, f );
174 DUNE_THROW( NotImplemented,
"ElementUtil::generateFace not implemented for dim = " << dim <<
"." );
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
Dune namespace.
Definition: alignment.hh:10