dune-grid
2.2.0
|
00001 #ifndef DUNE_GENERICGEOMETRY_REFERENCETOPOLOGIES_HH 00002 #define DUNE_GENERICGEOMETRY_REFERENCETOPOLOGIES_HH 00003 00004 #warning This file is deprecated, and will be removed \ 00005 after the release of dune-grid-2.2. 00006 00007 #include <dune/geometry/genericgeometry/conversion.hh> 00008 #include <dune/geometry/genericgeometry/subtopologies.hh> 00009 00010 namespace Dune 00011 { 00012 00013 namespace GenericGeometry 00014 { 00015 00016 // ReferenceTopology 00017 // ----------------- 00018 00019 template< unsigned int dim > 00020 class ReferenceTopology 00021 { 00022 typedef ReferenceTopology< dim > This; 00023 00024 class SubEntityInfo; 00025 template< class Topology > struct Initialize; 00026 00027 public: 00028 static const unsigned int dimension = dim; 00029 00030 unsigned int size ( unsigned int codim ) const 00031 { 00032 assert( codim <= dimension ); 00033 return info_[ codim ].size(); 00034 } 00035 00036 unsigned int 00037 size ( unsigned int codim, unsigned int i, unsigned int subcodim ) const 00038 { 00039 assert( (codim <= dimension) && (i < info_[ codim ].size()) ); 00040 return info_[ codim ][ i ].size( subcodim ); 00041 } 00042 00043 unsigned int subEntity ( unsigned int codim, unsigned int i, 00044 unsigned int subcodim, unsigned int j ) const 00045 { 00046 assert( (codim <= dimension) && (i < info_[ codim ].size()) ); 00047 return info_[ codim ][ i ].number( subcodim, j ); 00048 } 00049 00050 unsigned int topologyId ( unsigned int codim, unsigned int i ) const 00051 { 00052 assert( (codim <= dimension) && (i < info_[ codim ].size()) ); 00053 return info_[ codim ][ i ].topologyId(); 00054 } 00055 00056 template< class Topology > 00057 void initialize () 00058 { 00059 typedef Initialize< Topology > Init; 00060 ForLoop< Init::template Codim, 0, dimension >::apply( info_ ); 00061 } 00062 00063 private: 00064 std::vector< SubEntityInfo > info_[ dimension+1 ]; 00065 }; 00066 00067 00068 00069 // ReferenceTopology::SubEntityInfo 00070 // -------------------------------- 00071 00072 template< unsigned int dim > 00073 class ReferenceTopology< dim >::SubEntityInfo 00074 { 00075 template< class Topology, unsigned int codim > struct Initialize 00076 { 00077 template< int subcodim > struct SubCodim; 00078 }; 00079 00080 public: 00081 unsigned int size ( unsigned int subcodim ) const 00082 { 00083 return numbering_[ subcodim ].size(); 00084 } 00085 00086 unsigned int number ( unsigned int subcodim, unsigned int j ) const 00087 { 00088 return numbering_[ subcodim ][ j ]; 00089 } 00090 00091 unsigned int topologyId () const 00092 { 00093 return topologyId_; 00094 } 00095 00096 template< class Topology, unsigned int codim, unsigned int i > 00097 void initialize () 00098 { 00099 typedef Initialize< Topology, codim > Init; 00100 typedef typename GenericGeometry::SubTopology< Topology, codim, i >::type SubTopology; 00101 00102 codim_ = codim; 00103 topologyId_ = SubTopology::id; 00104 numbering_.resize( SubTopology::dimension+1 ); 00105 00106 const unsigned int iVariable = i; 00107 ForLoop< Init::template SubCodim, 0, SubTopology::dimension >::apply( iVariable, numbering_ ); 00108 } 00109 00110 private: 00111 int codim_; 00112 unsigned int topologyId_; 00113 std::vector< std::vector< unsigned int > > numbering_; 00114 }; 00115 00116 00117 template< unsigned int dim > 00118 template< class Topology, unsigned int codim > 00119 template< int subcodim > 00120 struct ReferenceTopology< dim >::SubEntityInfo::Initialize< Topology, codim >::SubCodim 00121 { 00122 typedef SubTopologySize< Topology, codim, subcodim > Size; 00123 typedef SubTopologyNumbering< Topology, codim, subcodim > Numbering; 00124 00125 static void 00126 apply ( unsigned int i, std::vector< std::vector< unsigned int > > &numbering ) 00127 { 00128 const unsigned int size = Size::size( i ); 00129 numbering[ subcodim ].resize( size ); 00130 for( unsigned int j = 0; j < size; ++j ) 00131 numbering[ subcodim ][ j ] = Numbering::number( i, j ); 00132 } 00133 }; 00134 00135 00136 // ReferenceTopology::Initialize 00137 // ----------------------------- 00138 00139 template< unsigned int dim > 00140 template< class Topology > 00141 struct ReferenceTopology< dim >::Initialize 00142 { 00143 template< int codim > 00144 struct Codim 00145 { 00146 template< int i > 00147 struct SubTopology 00148 { 00149 static void apply ( std::vector< SubEntityInfo > &info ) 00150 { 00151 info[ i ].template initialize< Topology, codim, i >(); 00152 } 00153 }; 00154 00155 static void apply ( std::vector< SubEntityInfo > (&info)[ dim+1 ] ) 00156 { 00157 const unsigned int size = Size< Topology, codim >::value; 00158 info[ codim ].resize( size ); 00159 ForLoop< SubTopology, 0, size-1 >::apply( info[ codim ] ); 00160 } 00161 }; 00162 }; 00163 00164 00165 // ReferenceTopologyContainer 00166 // -------------------------- 00167 00168 template< unsigned int dim > 00169 class ReferenceTopologies 00170 { 00171 typedef ReferenceTopologies< dim > This; 00172 00173 template< int topologyId > 00174 struct Init; 00175 00176 public: 00177 static const unsigned int dimension = dim; 00178 static const unsigned int numTopologies = (1 << dimension); 00179 00180 typedef GenericGeometry::ReferenceTopology< dimension > ReferenceTopology; 00181 00182 static const ReferenceTopology &get ( const unsigned int topologyId ) 00183 { 00184 assert( topologyId < numTopologies ); 00185 return instance().refTopology_[ topologyId ]; 00186 } 00187 00188 private: 00189 ReferenceTopologies () 00190 { 00191 ForLoop< Init, 0, numTopologies-1 >::apply( refTopology_ ); 00192 } 00193 00194 ReferenceTopologies ( const This & ); 00195 This &operator= ( const This & ); 00196 00197 static const This &instance () 00198 { 00199 static This instance; 00200 return instance; 00201 } 00202 00203 ReferenceTopology refTopology_[ numTopologies ]; 00204 }; 00205 00206 00207 template< unsigned int dim > 00208 template< int topologyId > 00209 struct ReferenceTopologies< dim >::Init 00210 { 00211 static void apply ( ReferenceTopology (&refTopology)[ numTopologies ] ) 00212 { 00213 typedef typename GenericGeometry::Topology< topologyId, dimension >::type Topology; 00214 refTopology[ topologyId ].template initialize< Topology >(); 00215 } 00216 }; 00217 00218 } 00219 00220 } 00221 00222 #endif // #ifndef DUNE_GENERICGEOMETRY_REFERENCETOPOLOGIES_HH