entitykey.hh
00001 #ifndef DUNE_DGFEnTITYKEY_HH
00002 #define DUNE_DGFEnTITYKEY_HH
00003
00004 #include <iostream>
00005 #include <vector>
00006
00007 #include <dune/grid/common/referenceelements.hh>
00008 #include <dune/grid/alugrid/3d/topology.hh>
00009 #include <dune/grid/io/file/dgfparser/dgfexception.hh>
00010
00011 namespace Dune
00012 {
00013
00014
00015
00016
00017 template< class A > class DGFEntityKey
00018 {
00019 std :: vector< A > key_, origKey_;
00020 bool origKeySet_;
00021
00022 public:
00023 DGFEntityKey ( const std :: vector< A > &key, bool setOrigKey = true );
00024 DGFEntityKey ( const std::vector< A > &key,
00025 int N, int offset, bool setOrigKey = true );
00026 DGFEntityKey ( const DGFEntityKey< A > &k );
00027
00028 DGFEntityKey< A > &operator= ( const DGFEntityKey< A > &k );
00029
00030 inline const A &operator[] ( int i ) const;
00031 inline bool operator < ( const DGFEntityKey< A > &k ) const;
00032
00033 void orientation ( int base, std :: vector< std :: vector< double > > &vtx );
00034 void print( std :: ostream &out = std :: cerr ) const;
00035
00036 inline bool origKeySet () const;
00037 inline const A &origKey ( int i ) const;
00038 inline int size () const;
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
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
00080
00081
00082 class ElementFaceUtil
00083 {
00084 public:
00085 inline static int nofFaces ( int dimw, std :: vector< unsigned int > &element );
00086 inline static int faceSize ( int dimw, bool simpl );
00087
00088 static DGFEntityKey< unsigned int >
00089 generateFace ( int dimw, const std :: vector< unsigned int > &element, int f );
00090
00091 private:
00092 template< int dimworld >
00093 static DGFEntityKey< unsigned int >
00094 generateCubeFace( const std :: vector< unsigned int > &element, int f );
00095
00096 template< int dimworld >
00097 static DGFEntityKey< unsigned int >
00098 generateSimplexFace ( const std :: vector< unsigned int > &element, int f );
00099 };
00100
00101
00102 inline int ElementFaceUtil
00103 :: nofFaces( int dimw, std :: vector< unsigned int > &element )
00104 {
00105 if (dimw==1)
00106 return 2;
00107 else if (dimw==2)
00108 switch (element.size()) {
00109 case 3: return 3; break;
00110 case 4: return 4; break;
00111 }
00112 else if (dimw==3)
00113 switch (element.size()) {
00114 case 4: return 4; break;
00115 case 8: return 6; break;
00116 }
00117 return -1;
00118 }
00119
00120
00121 inline int ElementFaceUtil :: faceSize( int dimw, bool simpl )
00122 {
00123 if (dimw==1)
00124 return 1;
00125 else if (dimw==2)
00126 return 2;
00127 else if (dimw==3)
00128 return ((simpl)?3:4);
00129 return -1;
00130 }
00131
00132 }
00133
00134
00135 #include "entitykey_inline.hh"
00136 #endif