1 #ifndef DUNE_FEM_SPACE_COMMON_CAPABILITIES_HH 2 #define DUNE_FEM_SPACE_COMMON_CAPABILITIES_HH 3 4 #include <type_traits> 5 6 #include <dune/fem/quadrature/defaultquadratures.hh> 7 8 namespace Dune 9 { 10 11 namespace Fem 12 { 13 14 namespace Capabilities 15 { 16 17 /** \class hasFixedPolynomialOrder 18 * 19 * \brief specialize with \b true if polynomial order does 20 * not depend on the grid (part) entity 21 */ 22 template< class DiscreteFunctionSpace > 23 struct hasFixedPolynomialOrder 24 { 25 static const bool v = false; 26 }; 27 28 29 30 /** \class hasStaticPolynomialOrder 31 * 32 * \brief specialize with \b true if polynomial order fixed 33 * and compile time static 34 */ 35 template< class DiscreteFunctionSpace > 36 struct hasStaticPolynomialOrder 37 { 38 static const bool v = false; 39 static const int order = -1; 40 }; 41 42 43 44 /** \class isContinuous 45 * 46 * \brief specialize with \b true if space is always continuous 47 */ 48 template< class DiscreteFunctionSpace > 49 struct isContinuous 50 { 51 static const bool v = false; 52 }; 53 54 55 56 /** \class isLocalized 57 * 58 * \brief specialize with \b true if the space is localized, * 59 * i.e., the basis function set is based on a shape function set. 60 * 61 * We require, that a localized space has a method 62 \code 63 ShapeFunctionSetType shapeFunctionSet ( const EntityType &entity ); 64 \endcode 65 */ 66 template< class DiscreteFunctionSpace > 67 struct isLocalized 68 { 69 static const bool v = false; 70 }; 71 72 73 74 /** \class isAdaptive 75 * 76 * \brief specialize with \b true if space can be used with 77 * AdaptiveDiscreteFunction 78 */ 79 template< class DiscreteFunctionSpace > 80 struct isAdaptive 81 { 82 static const bool v = false; 83 }; 84 85 86 87 /** \class threadSafe 88 * 89 * \brief specialize with \b true if the space implementation 90 * is thread safe 91 */ 92 template< class DiscreteFunctionSpace > 93 struct threadSafe 94 { 95 static const bool v = false; 96 }; 97 98 99 100 /** \class viewThreadSafe 101 * 102 * \brief specialize with \b true if the space implementation is 103 * thread safe, while it is not modified 104 * 105 */ 106 template< class DiscreteFunctionSpace > 107 struct viewThreadSafe 108 { 109 static const bool v = false; 110 }; 111 112 113 /** \class isHierarchic 114 * 115 * \brief specialize with \b true if for a space the basis functions are 116 * sorted by the polynomial order, starting with the lowest order 117 */ 118 template< class DiscreteFunctionSpace > 119 struct isHierarchic 120 { 121 static const bool v = false; 122 }; 123 124 125 /** \class DefaultQuadrature 126 * 127 * \brief specialize when quadrature other than the standard quadrature 128 * should be used for volume and surface integral compution. 129 */ 130 template< class DiscreteFunctionSpace > 131 struct DefaultQuadrature 132 { 133 // traits specifying the quadrature points used for CachingQuadrature or ElementQuadrature. 134 template <class F, int d> 135 using DefaultQuadratureTraits = Dune::Fem::DefaultQuadratureTraits< F, d >; 136 137 //! return quadrature order for volume quadratures for given polynomial order k volumeOrderDune::Fem::Capabilities::DefaultQuadrature138 static int volumeOrder( const int k ) { return 2 * k; } 139 //! return quadrature order for surface quadratures (i.e. over intersections) for given polynomial order k surfaceOrderDune::Fem::Capabilities::DefaultQuadrature140 static int surfaceOrder( const int k ) { return 2 * k + 1; } 141 }; 142 143 144 namespace Impl 145 { 146 147 template< class DFS > 148 std::true_type hasInterpolation ( const DFS &, decltype( std::declval< const DFS & >().interpolation() ) * = nullptr ); 149 150 std::false_type hasInterpolation ( ... ); 151 152 } // namespace Impl 153 154 155 /** 156 * \class hasInterpolation 157 * 158 * \brief determine whether a discrete function space provides a (local) 159 * interpolation 160 * 161 * \note This capability is generated automatically by SFINAE. 162 */ 163 template< class DiscreteFunctionSpace > 164 struct hasInterpolation 165 { 166 static const bool v = decltype( Impl::hasInterpolation( std::declval< const DiscreteFunctionSpace & >() ) )::value; 167 }; 168 169 170 171 // const specialization 172 // -------------------- 173 174 template< class DiscreteFunctionSpace > 175 struct hasFixedPolynomialOrder< const DiscreteFunctionSpace > 176 { 177 static const bool v = hasFixedPolynomialOrder< DiscreteFunctionSpace >::v; 178 }; 179 180 template< class DiscreteFunctionSpace > 181 struct hasStaticPolynomialOrder< const DiscreteFunctionSpace > 182 { 183 static const bool v = hasStaticPolynomialOrder< DiscreteFunctionSpace >::v; 184 static const int order = hasStaticPolynomialOrder< DiscreteFunctionSpace >::order; 185 }; 186 187 template< class DiscreteFunctionSpace > 188 struct isContinuous < const DiscreteFunctionSpace > 189 { 190 static const bool v = isContinuous< DiscreteFunctionSpace >::v; 191 }; 192 193 template< class DiscreteFunctionSpace > 194 struct isLocalized< const DiscreteFunctionSpace > 195 { 196 static const bool v = isLocalized< DiscreteFunctionSpace >::v; 197 }; 198 199 template< class DiscreteFunctionSpace > 200 struct isAdaptive< const DiscreteFunctionSpace > 201 { 202 static const bool v = isAdaptive< DiscreteFunctionSpace >::v; 203 }; 204 205 template< class DiscreteFunctionSpace > 206 struct threadSafe< const DiscreteFunctionSpace > 207 { 208 static const bool v = threadSafe< DiscreteFunctionSpace >::v; 209 }; 210 211 template< class DiscreteFunctionSpace > 212 struct viewThreadSafe< const DiscreteFunctionSpace > 213 { 214 static const bool v = viewThreadSafe< DiscreteFunctionSpace >::v; 215 }; 216 217 template< class DiscreteFunctionSpace > 218 struct isHierarchic< const DiscreteFunctionSpace > 219 { 220 static const bool v = isHierarchic< DiscreteFunctionSpace >::v; 221 }; 222 223 template< class DiscreteFunctionSpace > 224 struct hasInterpolation< const DiscreteFunctionSpace > 225 { 226 static const bool v = hasInterpolation< DiscreteFunctionSpace >::v; 227 }; 228 229 template< class DiscreteFunctionSpace > 230 struct DefaultQuadrature< const DiscreteFunctionSpace > 231 : public DefaultQuadrature< DiscreteFunctionSpace > 232 {}; 233 234 } // namespace Capabilities 235 236 } // namespace Fem 237 238 } // namespace Dune 239 240 #endif // #ifndef DUNE_FEM_SPACE_COMMON_CAPABILITIES_HH 241