1#ifndef DUNE_FEM_QUADRATURE_CACHING_REGISTRY_HH
2#define DUNE_FEM_QUADRATURE_CACHING_REGISTRY_HH
13#include <dune/fem/storage/singleton.hh>
24 class QuadratureStorageRegistry
26 typedef QuadratureStorageRegistry ThisType;
29 struct StorageInterface
31 virtual ~StorageInterface () {}
32 virtual void cacheQuadrature ( std::size_t
id, std::size_t codim, std::size_t quadSize ) = 0;
37 typedef std::list< StorageInterface * > StorageListType;
47 typedef std::list< QuadratureInfo > QuadratureInfoListType;
49 static StorageListType &storageList ()
54 static QuadratureInfoListType &quadratureInfoList ()
60 static inline void assertSingleThreadMode (
const bool );
64 static void initialize ()
70 static void registerStorage ( StorageInterface &storage )
72 assertSingleThreadMode(
false );
74 storageList().push_back( &storage );
77 for( QuadratureInfoListType::iterator it = quadratureInfoList().begin(); it != quadratureInfoList().end(); ++it )
80 if( type == it->type )
81 storage.cacheQuadrature( it->id, it->codim, it->size );
85 static void unregisterStorage ( StorageInterface &storage )
87 assertSingleThreadMode(
false );
89 const StorageListType::iterator pos
90 = std::find( storageList().begin(), storageList().end(), &storage );
91 if( pos != storageList().end() )
92 storageList().erase( pos );
95 template<
class Quadrature >
96 static void registerQuadrature (
const Quadrature &quadrature )
98 registerQuadrature( quadrature, quadrature.geometryType(), Quadrature::codimension );
101 template<
class Quadrature >
102 static void registerQuadrature (
const Quadrature &quadrature,
103 const GeometryType &type, std::size_t codim )
105 assertSingleThreadMode(
true );
107 QuadratureInfo quadInfo = { quadrature.id(), codim, std::size_t( quadrature.nop() ), type };
108 quadratureInfoList().push_back( quadInfo );
110 for(
typename StorageListType::iterator it = storageList().begin(); it != storageList().end(); ++it )
113 if( (*it)->type() == type )
114 (*it)->cacheQuadrature( quadInfo.id, quadInfo.codim, quadInfo.size );
123#include <dune/fem/misc/mpimanager.hh>
129 inline void QuadratureStorageRegistry::assertSingleThreadMode(
const bool quad)
133 if( ! MPIManager::singleThreadMode() )
135 const char* text = quad ?
"registerQuadrature" :
"registerStorage";
136 DUNE_THROW(SingleThreadModeError,
"QuadratureStorageRegistry" << text <<
": only call in single thread mode!");
static DUNE_EXPORT Object & instance(Args &&... args)
return singleton instance of given Object type.
Definition: singleton.hh:123
actual interface class for quadratures
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
A unique label for each type of element that can occur in a grid.