dune-grid
2.2.0
|
00001 #ifndef DUNE_DGFEnTITYKEY_HH 00002 #define DUNE_DGFEnTITYKEY_HH 00003 00004 #include <iostream> 00005 #include <vector> 00006 00007 #include <dune/grid/alugrid/3d/topology.hh> 00008 #include <dune/grid/io/file/dgfparser/dgfexception.hh> 00009 00010 namespace Dune 00011 { 00012 00013 // DGFEntityKey 00014 // ------------ 00015 00016 template< class A > 00017 struct DGFEntityKey 00018 { 00019 DGFEntityKey ( const std :: vector< A > &key, bool setOrigKey = true ); 00020 DGFEntityKey ( const std::vector< A > &key, 00021 int N, int offset, bool setOrigKey = true ); 00022 DGFEntityKey ( const DGFEntityKey< A > &k ); 00023 00024 DGFEntityKey< A > &operator= ( const DGFEntityKey< A > &k ); 00025 00026 inline const A &operator[] ( int i ) const; 00027 inline bool operator < ( const DGFEntityKey< A > &k ) const; 00028 00029 void orientation ( int base, std :: vector< std :: vector< double > > &vtx ); 00030 void print( std :: ostream &out = std :: cerr ) const; 00031 00032 inline bool origKeySet () const; 00033 inline const A &origKey ( int i ) const; 00034 inline int size () const; 00035 00036 private: 00037 std :: vector< A > key_, origKey_; 00038 bool origKeySet_; 00039 }; 00040 00041 00042 template< class A > 00043 inline const A &DGFEntityKey< A > :: operator[] ( int i ) const 00044 { 00045 return key_[ i ]; 00046 } 00047 00048 00049 template< class A > 00050 inline bool DGFEntityKey< A > :: operator< ( const DGFEntityKey< A > &k ) const 00051 { 00052 // assert(k.key_.size()==key_.size()); 00053 return key_ < k.key_; 00054 } 00055 00056 00057 template< class A > 00058 inline bool DGFEntityKey< A > :: origKeySet () const 00059 { 00060 return origKeySet_; 00061 } 00062 00063 00064 template< class A > 00065 inline const A &DGFEntityKey< A > :: origKey ( int i ) const 00066 { 00067 return origKey_[ i ]; 00068 } 00069 00070 00071 template< class A > 00072 inline int DGFEntityKey< A > :: size () const 00073 { 00074 return key_.size(); 00075 } 00076 00077 00078 00079 // ElementFaceUtil 00080 // --------------- 00081 00082 struct ElementFaceUtil 00083 { 00084 inline static int nofFaces ( int dim, std::vector< unsigned int > &element ); 00085 inline static int faceSize ( int dim, bool simpl ); 00086 00087 static DGFEntityKey< unsigned int > 00088 generateFace ( int dim, const std::vector< unsigned int > &element, int f ); 00089 00090 private: 00091 template< int dim > 00092 static DGFEntityKey< unsigned int > 00093 generateCubeFace( const std::vector< unsigned int > &element, int f ); 00094 00095 template< int dim > 00096 static DGFEntityKey< unsigned int > 00097 generateSimplexFace ( const std::vector< unsigned int > &element, int f ); 00098 }; 00099 00100 00101 inline int ElementFaceUtil::nofFaces ( int dim, std::vector< unsigned int > &element ) 00102 { 00103 switch( dim ) 00104 { 00105 case 1: 00106 return 2; 00107 case 2: 00108 switch( element.size() ) 00109 { 00110 case 3: 00111 return 3; 00112 case 4: 00113 return 4; 00114 default: 00115 return -1; 00116 } 00117 case 3: 00118 switch( element.size() ) 00119 { 00120 case 4: 00121 return 4; 00122 case 8: 00123 return 6; 00124 default: 00125 return -1; 00126 } 00127 default: 00128 return -1; 00129 } 00130 } 00131 00132 00133 inline int ElementFaceUtil::faceSize( int dim, bool simpl ) 00134 { 00135 switch( dim ) 00136 { 00137 case 1: 00138 return 1; 00139 case 2: 00140 return 2; 00141 case 3: 00142 return (simpl ? 3 : 4); 00143 default: 00144 return -1; 00145 } 00146 } 00147 00148 } //end namespace Dune 00149 00150 // inlcude inline implementation 00151 #include "entitykey_inline.hh" 00152 #endif