5#ifndef DUNE_ENTITYKEY_INLINE_HH
6#define DUNE_ENTITYKEY_INLINE_HH
9#include <dune/geometry/referenceelements.hh>
21 origKey_( key.size() ),
22 origKeySet_( setOrigKey )
24 for (
size_t i=0; i<key_.size(); i++)
29 std :: sort( key_.begin(), key_.end() );
35 int N,
int offset,
bool setOrigKey )
38 origKeySet_( setOrigKey )
40 for (
size_t i=0; i<key_.size(); i++)
42 key_[i]=key[(i+offset)%key.size()];
43 origKey_[i]=key[(i+offset)%key.size()];
45 std :: sort( key_.begin(), key_.end() );
51 : key_( k.key_.size() ),
52 origKey_( k.key_.size() ),
53 origKeySet_( k. origKeySet_ )
55 for (
size_t i=0; i<key_.size(); i++)
58 origKey_[i]=k.origKey_[i];
66 assert(key_.size()==k.key_.size());
67 for (
size_t i=0; i<key_.size(); i++) {
69 origKey_[i]=k.origKey_[i];
71 origKeySet_ = k.origKeySet_;
81 assert( (
size_t) origKey_[0] < vtx.size() );
82 std::vector<double>& p0 = vtx[origKey_[0]];
83 assert( (
size_t) origKey_[1] < vtx.size() );
84 std::vector<double>& p1 = vtx[origKey_[1]];
85 assert( (
size_t) origKey_[2] < vtx.size() );
86 std::vector<double>& p2 = vtx[origKey_[2]];
87 assert( (
size_t) base < vtx.size() );
88 std::vector<double>& q = vtx[base];
90 n[0] = (p1[1]-p0[1])*(p2[2]-p0[2])-(p2[1]-p0[1])*(p1[2]-p0[2]);
91 n[1] = (p1[2]-p0[2])*(p2[0]-p0[0])-(p2[2]-p0[2])*(p1[0]-p0[0]);
92 n[2] = (p1[0]-p0[0])*(p2[1]-p0[1])-(p2[0]-p0[0])*(p1[1]-p0[1]);
93 double test = n[0]*(q[0]-p0[0])+n[1]*(q[1]-p0[1])+n[2]*(q[2]-p0[2]);
94 bool reorient = (test>0);
97 origKey_[1]=origKey_[2];
107 for(
size_t i = 0; i < key_.size(); ++i )
108 out << key_[ i ] <<
" ";
118 ElementFaceUtil::generateCubeFace
119 (
const std::vector< unsigned int > &element,
int f )
121 auto refCube = ReferenceElements< double, dim >::cube();
122 const unsigned int size = refCube.size( f, 1, dim );
123 std::vector< unsigned int > k( size );
124 for(
unsigned int i = 0; i < size; ++ i )
125 k[ i ] = element[ refCube.subEntity( f, 1, i, dim ) ];
132 ElementFaceUtil :: generateSimplexFace
133 (
const std :: vector< unsigned int > &element,
int f )
135 auto refSimplex = 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 ) ];
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 <<
"." );
Include standard header files.
Definition: agrid.hh:60
Definition: entitykey.hh:21
DGFEntityKey< A > & operator=(const DGFEntityKey< A > &k)
Definition: entitykey_inline.hh:64
void orientation(int base, std ::vector< std ::vector< double > > &vtx)
Definition: entitykey_inline.hh:78
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
static DGFEntityKey< unsigned int > generateFace(int dim, const std::vector< unsigned int > &element, int f)
Definition: entitykey_inline.hh:145