5#ifndef DUNE_ENTITYKEY_INLINE_HH
6#define DUNE_ENTITYKEY_INLINE_HH
9#include <dune/geometry/referenceelements.hh>
10#include <dune/grid/io/file/dgfparser/entitykey.hh>
19 inline DGFEntityKey< A > :: DGFEntityKey (
const std :: vector< A > &key,
bool setOrigKey )
21 origKey_( key.
size() ),
22 origKeySet_( setOrigKey )
24 for (
size_t i=0; i<key_.size(); i++)
29 std :: sort( key_.begin(), key_.end() );
34 inline DGFEntityKey< A > :: DGFEntityKey (
const std :: vector< A > &key,
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() );
50 inline DGFEntityKey< A > :: DGFEntityKey (
const DGFEntityKey< A > &k )
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];
64 inline DGFEntityKey< A > &DGFEntityKey< A > :: operator= (
const DGFEntityKey< A > &k )
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_;
77 inline void DGFEntityKey< A >
78 :: orientation (
int base, std::vector< std :: vector< double > > &vtx )
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];
105 inline void DGFEntityKey< A > :: print ( std :: ostream &out )
const
107 for(
size_t i = 0; i < key_.size(); ++i )
108 out << key_[ i ] <<
" ";
117 inline DGFEntityKey< unsigned int >
118 ElementFaceUtil::generateCubeFace
119 (
const std::vector< unsigned int > &element,
int f )
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 ) ];
126 return DGFEntityKey< unsigned int >( k );
131 inline DGFEntityKey< unsigned int >
132 ElementFaceUtil :: generateSimplexFace
133 (
const std :: vector< unsigned int > &element,
int f )
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,...)
Definition: exceptions.hh:312
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:462
constexpr GeometryType simplex(unsigned int dim)
Returns a GeometryType representing a simplex of dimension dim.
Definition: type.hh:453
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