dune-grid
2.2.0
|
00001 #ifndef DUNE_GEOGRID_CAPABILITIES_HH 00002 #define DUNE_GEOGRID_CAPABILITIES_HH 00003 00004 #include <cassert> 00005 00006 #include <dune/common/forloop.hh> 00007 00008 #include <dune/grid/common/capabilities.hh> 00009 #include <dune/grid/geometrygrid/declaration.hh> 00010 00011 namespace Dune 00012 { 00013 00014 // Capabilities 00015 // ------------ 00016 00017 namespace Capabilities 00018 { 00019 00020 // Capabilities from dune-grid 00021 // --------------------------- 00022 00023 template< class HostGrid, class CoordFunction, class Allocator > 00024 struct hasSingleGeometryType< GeometryGrid< HostGrid, CoordFunction, Allocator > > 00025 { 00026 static const bool v = hasSingleGeometryType< HostGrid > :: v; 00027 static const unsigned int topologyId = hasSingleGeometryType< HostGrid > :: topologyId; 00028 }; 00029 00030 00031 template< class HostGrid, class CoordFunction, class Allocator, int codim > 00032 struct hasEntity< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim > 00033 { 00034 static const bool v = true; 00035 }; 00036 00037 00038 template< class HostGrid, class CoordFunction, class Allocator > 00039 struct isParallel< GeometryGrid< HostGrid, CoordFunction, Allocator > > 00040 { 00041 static const bool v = isParallel< HostGrid >::v; 00042 }; 00043 00044 00045 template< class HostGrid, class CoordFunction, class Allocator, int codim > 00046 struct canCommunicate< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim > 00047 { 00048 static const bool v = canCommunicate< HostGrid, codim >::v; 00049 }; 00050 00051 00052 template< class HostGrid, class CoordFunction, class Allocator > 00053 struct hasBackupRestoreFacilities< GeometryGrid< HostGrid, CoordFunction, Allocator > > 00054 { 00055 static const bool v = hasBackupRestoreFacilities< HostGrid >::v; 00056 }; 00057 00058 template< class HostGrid, class CoordFunction, class Allocator > 00059 struct isLevelwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > > 00060 { 00061 static const bool v = isLevelwiseConforming< HostGrid >::v; 00062 }; 00063 00064 template< class HostGrid, class CoordFunction, class Allocator > 00065 struct isLeafwiseConforming< GeometryGrid< HostGrid, CoordFunction, Allocator > > 00066 { 00067 static const bool v = isLeafwiseConforming< HostGrid >::v; 00068 }; 00069 00070 template< class HostGrid, class CoordFunction, class Allocator > 00071 struct threadSafe< GeometryGrid< HostGrid, CoordFunction, Allocator > > 00072 { 00073 static const bool v = false; 00074 }; 00075 00076 template< class HostGrid, class CoordFunction, class Allocator > 00077 struct viewThreadSafe< GeometryGrid< HostGrid, CoordFunction, Allocator > > 00078 { 00079 static const bool v = false; 00080 }; 00081 00082 00083 00084 00085 // hasHostEntity 00086 // ------------- 00087 00088 template< class Grid, int codim > 00089 struct hasHostEntity; 00090 00091 template< class Grid, int codim > 00092 struct hasHostEntity< const Grid, codim > 00093 { 00094 static const bool v = hasHostEntity< Grid, codim >::v; 00095 }; 00096 00097 template< class HostGrid, class CoordFunction, class Allocator, int codim > 00098 struct hasHostEntity< GeometryGrid< HostGrid, CoordFunction, Allocator >, codim > 00099 { 00100 static const bool v = hasEntity< HostGrid, codim >::v; 00101 }; 00102 00103 00104 00105 // CodimCache 00106 // ---------- 00107 00108 template< class Grid > 00109 class CodimCache 00110 { 00111 static const int dimension = Grid::dimension; 00112 00113 template< int codim > 00114 struct BuildCache; 00115 00116 bool hasHostEntity_[ Grid::dimension + 1 ]; 00117 00118 CodimCache () 00119 { 00120 Dune::ForLoop< BuildCache, 0, dimension >::apply( hasHostEntity_ ); 00121 } 00122 00123 static CodimCache &instance () 00124 { 00125 static CodimCache singleton; 00126 return singleton; 00127 } 00128 00129 public: 00130 static bool hasHostEntity ( int codim ) 00131 { 00132 assert( (codim >= 0) && (codim <= dimension) ); 00133 return instance().hasHostEntity_[ codim ]; 00134 } 00135 }; 00136 00137 template< class Grid > 00138 template< int codim > 00139 struct CodimCache< Grid >::BuildCache 00140 { 00141 static void apply ( bool (&hasHostEntity)[ dimension + 1 ] ) 00142 { 00143 hasHostEntity[ codim ] = Capabilities::hasHostEntity< Grid, codim >::v; 00144 } 00145 }; 00146 00147 } // namespace Capabilities 00148 00149 } // namespace Dune 00150 00151 #endif // #ifndef DUNE_GEOGRID_CAPABILITIES_HH