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