1 #ifndef DUNE_FEM_SPACE_SHAPEFUNCTIONSET_CACHING_HH 2 #define DUNE_FEM_SPACE_SHAPEFUNCTIONSET_CACHING_HH 25 template<
class ShapeFunctionSet >
48 shapeFunctionSet_( shapeFunctionSet ),
57 const ThisType&
operator= (
const ThisType& ) =
delete;
61 return shapeFunctionSet_.
order();
66 return shapeFunctionSet_.
size();
69 template<
class Po
int,
class Functor >
75 template<
class Quadrature,
class Functor >
78 const bool cacheable = std::is_convertible< Quadrature, CachingInterface >::value;
82 template<
class Po
int,
class Functor >
88 template<
class Quadrature,
class Functor >
91 const bool cacheable = std::is_convertible< Quadrature, CachingInterface >::value;
95 template<
class Po
int,
class Functor >
101 GeometryType
type ()
const {
return type_; }
103 template <
class QuadratureType >
104 const RangeVectorType&
rangeCache(
const QuadratureType& quadrature )
const 106 return ReturnCache< QuadratureType, std::is_convertible< QuadratureType, CachingInterface >::value > ::
107 ranges( *
this, quadrature, valueCaches_, *localRangeCache_ );
110 template <
class QuadratureType >
111 const JacobianRangeVectorType&
jacobianCache(
const QuadratureType& quadrature )
const 113 return ReturnCache< QuadratureType, std::is_convertible< QuadratureType, CachingInterface >::value > ::
114 jacobians( *
this, quadrature, jacobianCaches_, *localJacobianCache_ );
118 template<
class Quad,
bool cacheable >
121 static const RangeVectorType&
122 ranges(
const ThisType& shapeFunctionSet,
124 const ValueCacheVectorType&,
125 RangeVectorType& storage )
128 const unsigned int nop = quad.nop();
129 const unsigned int size = shapeFunctionSet.
size();
132 storage.resize( size * nop );
133 RangeType* data = storage.data();
135 for(
unsigned int qp = 0 ; qp < nop; ++ qp )
137 const int cacheQp = quad.cachingPoint( qp );
144 static const JacobianRangeVectorType&
145 jacobians(
const ThisType& shapeFunctionSet,
147 const JacobianCacheVectorType&,
148 JacobianRangeVectorType& storage )
151 const unsigned int nop = quad.nop();
152 const unsigned int size = shapeFunctionSet.
size();
155 storage.resize( size * nop );
156 JacobianRangeType* data = storage.data();
158 for(
unsigned int qp = 0 ; qp < nop; ++ qp )
160 const int cacheQp = quad.cachingPoint( qp );
168 template<
class Quad >
169 struct ReturnCache< Quad, true >
171 static const RangeVectorType&
172 ranges(
const ThisType& shapeFunctionSet,
174 const ValueCacheVectorType& cache,
175 const RangeVectorType& )
177 return cache[ quad.id() ];
180 static const JacobianRangeVectorType&
181 jacobians(
const ThisType& shapeFunctionSet,
183 const JacobianCacheVectorType& cache,
184 const JacobianRangeVectorType& )
186 return cache[ quad.id() ];
191 template<
class Quadrature,
class Functor >
193 std::integral_constant< bool, false > )
const 198 template<
class Quadrature,
class Functor >
200 std::integral_constant< bool, true > )
const;
202 template<
class Quadrature,
class Functor >
204 std::integral_constant< bool, false > )
const 209 template<
class Quadrature,
class Functor >
211 std::integral_constant< bool, true > )
const;
214 void cacheQuadrature( std::size_t
id, std::size_t codim, std::size_t
size );
216 template<
class Po
intVector >
217 void cachePoints ( std::size_t
id,
const PointVector &points );
221 ValueCacheVectorType valueCaches_;
222 JacobianCacheVectorType jacobianCaches_;
237 template<
class ShapeFunctionSet >
244 template<
class ShapeFunctionSet >
245 template<
class Quadrature,
class Functor >
248 std::integral_constant< bool, true > )
const 250 assert( (quadrature.
id() < valueCaches_.size()) && !valueCaches_[ quadrature.
id() ].empty() );
251 const RangeType *cache = valueCaches_[ quadrature.
id() ].data();
253 const unsigned int numShapeFunctions =
size();
254 const unsigned int cpt = quadrature.cachingPoint( pt );
255 for(
unsigned int i = 0; i < numShapeFunctions; ++i )
256 functor( i, cache[ cpt*numShapeFunctions + i ] );
260 template<
class ShapeFunctionSet >
261 template<
class Quadrature,
class Functor >
264 std::integral_constant< bool, true > )
const 266 assert( (quadrature.
id() < jacobianCaches_.size()) && !jacobianCaches_[ quadrature.
id() ].empty() );
267 const JacobianRangeType *cache = jacobianCaches_[ quadrature.
id() ].data();
269 const unsigned int numShapeFunctions =
size();
270 const unsigned int cpt = quadrature.cachingPoint( pt );
271 for(
unsigned int i = 0; i < numShapeFunctions; ++i )
272 functor( i, cache[ cpt*numShapeFunctions + i ] );
276 template<
class ShapeFunctionSet >
280 if(
id >= valueCaches_.size() )
286 assert( valueCaches_[
id ].empty() == jacobianCaches_[
id ].empty() );
288 if( valueCaches_[
id ].empty() )
303 DUNE_THROW( NotImplemented,
"Caching for codim > 1 not implemented." );
309 template<
class ShapeFunctionSet >
310 template<
class Po
intVector >
314 const unsigned int numShapeFunctions =
size();
315 const unsigned int numPoints = points.size();
317 RangeVectorType& values = valueCaches_[ id ];
318 values.resize( numShapeFunctions * numPoints );
320 JacobianRangeVectorType& jacobians = jacobianCaches_[ id ];
321 jacobians.resize( numShapeFunctions * numPoints );
323 if( values.empty() || jacobians.empty() )
324 DUNE_THROW( OutOfMemoryError,
"Unable to allocate shape function set caches." );
326 for(
unsigned int pt = 0; pt < numPoints; ++pt )
337 #endif // #ifndef DUNE_FEM_SPACE_SHAPEFUNCTIONSET_CACHING_HH FunctionSpaceType::JacobianRangeType JacobianRangeType
jacobian range type
Definition: shapefunctionset/shapefunctionset.hh:44
~CachingShapeFunctionSet()
Definition: caching.hh:238
int order() const
return order of shape functions
FunctionSpaceType::RangeType RangeType
range type
Definition: shapefunctionset/shapefunctionset.hh:42
FunctionSpaceType::HessianRangeType HessianRangeType
hessian range type
Definition: shapefunctionset/shapefunctionset.hh:46
Definition: registry.hh:29
std::size_t size() const
return number of shape functions
std::vector< JacobianRangeVectorType > JacobianCacheVectorType
Definition: caching.hh:43
const RangeVectorType & rangeCache(const QuadratureType &quadrature) const
Definition: caching.hh:104
A vector valued function space.
Definition: functionspace.hh:16
wrapper for a (Quadrature,int) pair
Definition: quadrature.hh:40
const QuadratureType & quadrature() const
Definition: quadrature.hh:65
Definition: caching.hh:26
Definition: shapefunctionset/shapefunctionset.hh:33
void jacobianEach(const QuadraturePointWrapper< Quadrature > &x, Functor functor) const
Definition: caching.hh:89
static void registerStorage(StorageInterface &storage)
Definition: registry.hh:69
dimension of domain vector space
Definition: functionspaceinterface.hh:45
void evaluateEach(const Point &x, Functor functor) const
evalute each shape function
unsigned int point() const
Definition: quadrature.hh:70
int order() const
Definition: caching.hh:59
const JacobianRangeVectorType & jacobianCache(const QuadratureType &quadrature) const
Definition: caching.hh:111
Definition: misc/functor.hh:30
VectorSpaceTraits< DomainField, RangeField, dimD, dimR >::DomainFieldType DomainFieldType
Intrinsic type used for values in the domain field (usually a double)
Definition: functionspaceinterface.hh:59
Definition: coordinate.hh:4
GeometryType type() const
Definition: caching.hh:101
std::vector< JacobianRangeType > JacobianRangeVectorType
Definition: caching.hh:40
size_t id() const
obtain the identifier of the integration point list
Definition: quadrature.hh:258
const CoordinateType & point(size_t i) const
obtain coordinates of i-th integration point
Definition: quadrature.hh:242
std::vector< RangeVectorType > ValueCacheVectorType
Definition: caching.hh:42
void hessianEach(const Point &x, Functor functor) const
evalute hessian of each shape function
ShapeFunctionSet::FunctionSpaceType FunctionSpaceType
Definition: caching.hh:32
ShapeFunctionSet::JacobianRangeType JacobianRangeType
Definition: caching.hh:36
void jacobianEach(const Point &x, Functor functor) const
Definition: caching.hh:83
void evaluateEach(const Point &x, Functor functor) const
Definition: caching.hh:70
void evaluateEach(const QuadraturePointWrapper< Quadrature > &x, Functor functor) const
Definition: caching.hh:76
FunctionSpaceType::DomainType DomainType
domain type
Definition: shapefunctionset/shapefunctionset.hh:40
void jacobianEach(const Point &x, Functor functor) const
evalute jacobian of each shape function
ShapeFunctionSet::DomainType DomainType
Definition: caching.hh:34
const ThisType & operator=(const ThisType &)=delete
static void unregisterStorage(StorageInterface &storage)
Definition: registry.hh:83
Definition: pointprovider.hh:21
ShapeFunctionSet::HessianRangeType HessianRangeType
Definition: caching.hh:37
CachingShapeFunctionSet(const GeometryType &type, const ShapeFunctionSet &shapeFunctionSet=ShapeFunctionSet())
Definition: caching.hh:45
void hessianEach(const Point &x, Functor functor) const
Definition: caching.hh:96
std::vector< RangeType > RangeVectorType
Definition: caching.hh:39
ShapeFunctionSet::RangeType RangeType
Definition: caching.hh:35
std::size_t size() const
Definition: caching.hh:64
actual interface class for quadratures
Definition: quadrature.hh:320