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 )
120 const unsigned int size = refCube.size( f, 1, dim );
121 std::vector< unsigned int > k( size );
122 for(
unsigned int i = 0; i < size; ++ i )
123 k[ i ] = element[ refCube.subEntity( f, 1, i, dim ) ];
124 return DGFEntityKey< unsigned int >( k );
129 inline DGFEntityKey< unsigned int >
130 ElementFaceUtil :: generateSimplexFace
131 (
const std :: vector< unsigned int > &element,
int f )
134 const unsigned int size = refSimplex.size( f, 1, dim );
135 std :: vector< unsigned int > k( size );
136 for(
unsigned int i = 0; i < size; ++i )
137 k[ i ] = element[ refSimplex.subEntity( f, 1, i, dim ) ];
138 return DGFEntityKey< unsigned int >( k );
142 inline DGFEntityKey< unsigned int >
143 ElementFaceUtil::generateFace (
int dim,
const std::vector< unsigned int > &element,
int f )
145 if( element.size() ==
size_t(dim+1) )
151 return generateSimplexFace< 3 >( element, f );
153 return generateSimplexFace< 2 >( element, f );
155 return generateSimplexFace< 1 >( element, f );
157 DUNE_THROW( NotImplemented,
"ElementUtil::generateFace not implemented for dim = " << dim <<
"." );
166 return generateCubeFace< 3 >( element, f );
168 return generateCubeFace< 2 >( element, f );
170 return generateCubeFace< 1 >( element, f );
172 DUNE_THROW( NotImplemented,
"ElementUtil::generateFace not implemented for dim = " << dim <<
"." );
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:705
constexpr GeometryType simplex(unsigned int dim)
Returns a GeometryType representing a simplex of dimension dim.
Definition: type.hh:696
Dune namespace.
Definition: alignedallocator.hh:10